final boolean checkPermissionsWhenIteratingChildren() { // we cannot "cache" the ACL enabled/disabled state because it's dynamic return this.hasCustomAuthorizationProvider || repository.repositoryCache().isAccessControlEnabled(); }
final boolean checkPermissionsWhenIteratingChildren() { // we cannot "cache" the ACL enabled/disabled state because it's dynamic return this.hasCustomAuthorizationProvider || repository.repositoryCache().isAccessControlEnabled(); }
protected final NodeCache workspaceCache( String workspaceName ) { return repositoryCache().getWorkspaceCache(workspaceName); }
protected final boolean hasWorkspace( String workspaceName ) { return repositoryCache().getWorkspaceNames().contains(workspaceName); }
protected final boolean hasWorkspace( String workspaceName ) { return repositoryCache().getWorkspaceNames().contains(workspaceName); }
protected final NodeCache workspaceCache( String workspaceName ) { return repositoryCache().getWorkspaceCache(workspaceName); }
@Override public String[] getAccessibleWorkspaceNames() throws RepositoryException { session.checkLive(); // Make a copy, since the size may change before we iterate over it ... Set<String> names = new HashSet<String>(session.repository().repositoryCache().getWorkspaceNames()); // Remove any workspaces for which we don't have read access ... for (Iterator<String> iter = names.iterator(); iter.hasNext();) { try { session.checkWorkspacePermission(iter.next(), ModeShapePermissions.READ); } catch (AccessDeniedException ace) { iter.remove(); } } return names.toArray(new String[names.size()]); }
@Override public String[] getAccessibleWorkspaceNames() throws RepositoryException { session.checkLive(); // Make a copy, since the size may change before we iterate over it ... Set<String> names = new HashSet<String>(session.repository().repositoryCache().getWorkspaceNames()); // Remove any workspaces for which we don't have read access ... for (Iterator<String> iter = names.iterator(); iter.hasNext();) { try { session.checkWorkspacePermission(iter.next(), ModeShapePermissions.READ); } catch (AccessDeniedException ace) { iter.remove(); } } return names.toArray(new String[names.size()]); }
final SessionCache createSystemSession( ExecutionContext context, boolean readOnly ) { return repositoryCache().createSession(context, systemWorkspaceName(), readOnly); }
final SessionCache createSystemSession( ExecutionContext context, boolean readOnly ) { return repositoryCache().createSession(context, systemWorkspaceName(), readOnly); }
final SessionCache spawnSessionCache( boolean readOnly ) { SessionCache cache = repository().repositoryCache().createSession(context(), workspaceName(), readOnly); return readOnly ? cache : new SystemSessionCache(cache); }
final SessionCache spawnSessionCache( boolean readOnly ) { SessionCache cache = repository().repositoryCache().createSession(context(), workspaceName(), readOnly); return readOnly ? cache : new SystemSessionCache(cache); }
private void aclMetadataRefresh( long aclChangesCount ) { // we have a session that has added and/or removed ACLs from nodes, so we need to reflect this in the repository // metadata MutableCachedNode systemNode = systemContent.mutableSystemNode(); org.modeshape.jcr.value.Property aclCount = systemNode.getProperty(ModeShapeLexicon.ACL_COUNT, systemCache); if (aclCount == null && aclChangesCount > 0) { systemNode.setProperty(systemCache, propertyFactory().create(ModeShapeLexicon.ACL_COUNT, aclChangesCount)); repository().repositoryCache().setAccessControlEnabled(true); } else if (aclCount != null) { long newCount = Long.valueOf(aclCount.getFirstValue().toString()) + aclChangesCount; if (newCount < 0) { newCount = 0; } if (newCount == 0) { repository().repositoryCache().setAccessControlEnabled(false); } systemNode.setProperty(systemCache, propertyFactory().create(ModeShapeLexicon.ACL_COUNT, newCount)); } }
protected JcrSession( JcrSession original, boolean readOnly ) { // Most of the components can be reused from the original session ... this.repository = original.repository; this.context = original.context; this.sessionRegistry = original.sessionRegistry; this.valueFactory = original.valueFactory; this.sessionAttributes = original.sessionAttributes; this.workspace = original.workspace; this.hasCustomAuthorizationProvider = original.hasCustomAuthorizationProvider; // Create a new session cache and root node ... this.cache = repository.repositoryCache().createSession(context, this.workspace.getName(), readOnly); this.rootNode = new JcrRootNode(this, this.cache.getRootKey()); this.jcrNodes.put(this.rootNode.key(), this.rootNode); // Increment the statistics ... this.nanosCreated = System.nanoTime(); repository.statistics().increment(ValueMetric.SESSION_COUNT); acm = new AccessControlManagerImpl(this); this.mimeTypeDetectionEnabled = original.mimeTypeDetectionEnabled; }
protected JcrSession( JcrSession original, boolean readOnly ) { // Most of the components can be reused from the original session ... this.repository = original.repository; this.context = original.context; this.sessionRegistry = original.sessionRegistry; this.valueFactory = original.valueFactory; this.sessionAttributes = original.sessionAttributes; this.workspace = original.workspace; this.hasCustomAuthorizationProvider = original.hasCustomAuthorizationProvider; // Create a new session cache and root node ... this.cache = repository.repositoryCache().createSession(context, this.workspace.getName(), readOnly); this.rootNode = new JcrRootNode(this, this.cache.getRootKey()); this.jcrNodes.put(this.rootNode.key(), this.rootNode); // Increment the statistics ... this.nanosCreated = System.nanoTime(); repository.statistics().increment(ValueMetric.SESSION_COUNT); acm = new AccessControlManagerImpl(this); this.mimeTypeDetectionEnabled = original.mimeTypeDetectionEnabled; }
private void aclMetadataRefresh( long aclChangesCount ) { // we have a session that has added and/or removed ACLs from nodes, so we need to reflect this in the repository // metadata MutableCachedNode systemNode = systemContent.mutableSystemNode(); org.modeshape.jcr.value.Property aclCount = systemNode.getProperty(ModeShapeLexicon.ACL_COUNT, systemCache); if (aclCount == null && aclChangesCount > 0) { systemNode.setProperty(systemCache, propertyFactory().create(ModeShapeLexicon.ACL_COUNT, aclChangesCount)); repository().repositoryCache().setAccessControlEnabled(true); } else if (aclCount != null) { long newCount = Long.valueOf(aclCount.getFirstValue().toString()) + aclChangesCount; if (newCount < 0) { newCount = 0; } if (newCount == 0) { repository().repositoryCache().setAccessControlEnabled(false); } systemNode.setProperty(systemCache, propertyFactory().create(ModeShapeLexicon.ACL_COUNT, newCount)); } }
@Test public void shouldProvideRepositoryWorkspaceNamesDescriptor() throws ValueFormatException { Set<String> workspaceNames = repository.repositoryCache().getWorkspaceNames(); Set<String> descriptorValues = new HashSet<String>(); for (JcrValue value : repository.getDescriptorValues(org.modeshape.jcr.api.Repository.REPOSITORY_WORKSPACES)) { descriptorValues.add(value.getString()); } assertThat(descriptorValues, is(workspaceNames)); }
@Override public void createWorkspace( String name ) throws AccessDeniedException, UnsupportedRepositoryOperationException, RepositoryException { session.checkLive(); try { session.checkWorkspacePermission(name, ModeShapePermissions.CREATE_WORKSPACE); JcrRepository repository = session.repository(); if (repository.hasWorkspace(name)) { // TCK: cannot create a workspace with the same name as an already existing one String msg = GraphI18n.workspaceAlreadyExistsInRepository.text(name, getName()); throw new RepositoryException(msg); } repository.repositoryCache().createWorkspace(name); // import any initial content repository.runningState().initialContentImporter().importInitialContent(name); } catch (UnsupportedOperationException e) { throw new UnsupportedRepositoryOperationException(e.getMessage()); } }
@Override public void createWorkspace( String name ) throws AccessDeniedException, UnsupportedRepositoryOperationException, RepositoryException { session.checkLive(); try { session.checkWorkspacePermission(name, ModeShapePermissions.CREATE_WORKSPACE); JcrRepository repository = session.repository(); if (repository.hasWorkspace(name)) { // TCK: cannot create a workspace with the same name as an already existing one String msg = GraphI18n.workspaceAlreadyExistsInRepository.text(name, getName()); throw new RepositoryException(msg); } repository.repositoryCache().createWorkspace(name); // import any initial content repository.runningState().initialContentImporter().importInitialContent(name); } catch (UnsupportedOperationException e) { throw new UnsupportedRepositoryOperationException(e.getMessage()); } }
session.save(); assertTrue(repository().repositoryCache().isAccessControlEnabled()); assertTrue("ACLs should not be disabled", repository().repositoryCache().isAccessControlEnabled()); assertFalse("ACLs should be disabled", repository().repositoryCache().isAccessControlEnabled());