protected final boolean isInTheSameProcessAs( String otherProcessId ) { return session().context().getProcessId().equalsIgnoreCase(otherProcessId); }
protected final boolean isInTheSameProcessAs( String otherProcessId ) { return session().context().getProcessId().equalsIgnoreCase(otherProcessId); }
protected JcrValueFactory( ExecutionContext context ) { this.valueFactories = context.getValueFactories(); this.namespaces = context.getNamespaceRegistry(); this.executionContextProcessId = context.getProcessId(); }
protected JcrValueFactory( ExecutionContext context ) { this.valueFactories = context.getValueFactories(); this.namespaces = context.getNamespaceRegistry(); this.executionContextProcessId = context.getProcessId(); }
RepositoryLockManager with( JcrRepository.RunningState repository, RepositoryConfiguration.GarbageCollection gcConfig ) { assert this.systemWorkspaceName == repository.repositoryCache().getSystemWorkspaceName(); assert this.processId == repository.context().getProcessId(); PathFactory pathFactory = repository.context().getValueFactories().getPathFactory(); Path locksPath = pathFactory.create(pathFactory.createRootPath(), JcrLexicon.SYSTEM, ModeShapeLexicon.LOCKS); assert this.locksPath.equals(locksPath); return new RepositoryLockManager(repository, gcConfig); }
final JcrValue valueFrom( javax.jcr.Node value ) throws RepositoryException { if (!(value instanceof AbstractJcrNode)) { throw new IllegalArgumentException("Invalid node type (expected a ModeShape node): " + value.getClass().toString()); } AbstractJcrNode node = (AbstractJcrNode)value; if (!this.isInTheSameProcessAs(node.session().context().getProcessId())) { throw new RepositoryException(JcrI18n.nodeNotInTheSameSession.text(node.path())); } NodeKey key = ((AbstractJcrNode)value).key(); Reference ref = session.context().getValueFactories().getReferenceFactory() .create(key, ((AbstractJcrNode)value).isForeign()); return valueFrom(PropertyType.REFERENCE, ref); }
RepositoryLockManager( JcrRepository.RunningState repository, RepositoryConfiguration.GarbageCollection gcConfig ) { this.repository = repository; this.systemWorkspaceName = repository.repositoryCache().getSystemWorkspaceName(); this.processId = repository.context().getProcessId(); this.locksByNodeKey = new ConcurrentHashMap<NodeKey, ModeShapeLock>(); PathFactory pathFactory = repository.context().getValueFactories().getPathFactory(); this.locksPath = pathFactory.create(pathFactory.createRootPath(), JcrLexicon.SYSTEM, ModeShapeLexicon.LOCKS); this.logger = Logger.getLogger(getClass()); long lockGCIntervalMillis = gcConfig.getIntervalInMillis(); assert lockGCIntervalMillis > 0; /* * Each time the garbage collection process runs, session-scoped locks that are still used by active sessions will have their * expiry times extended by this amount of time. Each repository instance in the ModeShape cluster will run its own cleanup * process, which will extend the expiry times of its own locks. As soon as a repository is no longer running the cleanup * process, we know that there can be no active sessions. * * The default GC interval is expressed in hours, so we make the extension slightly larger to avoid any lock being expired * prematurely. */ this.lockExtensionIntervalMillis = lockGCIntervalMillis + TimeUnit.MILLISECONDS.convert(10, TimeUnit.MINUTES); /* * The amount of time that a lock may be active before considered expired. The sweep process will extend the locks for active * sessions, so only unused locks will have an unmodified expiry time. * * The default GC interval is expressed in hours, so we make the default age slightly less to avoid stale lock. */ this.defaultLockAgeMillis = lockGCIntervalMillis - TimeUnit.MILLISECONDS.convert(10, TimeUnit.MINUTES); }
RepositoryLockManager( JcrRepository.RunningState repository, RepositoryConfiguration.GarbageCollection gcConfig ) { this.repository = repository; this.systemWorkspaceName = repository.repositoryCache().getSystemWorkspaceName(); this.processId = repository.context().getProcessId(); this.locksByNodeKey = new ConcurrentHashMap<NodeKey, ModeShapeLock>(); PathFactory pathFactory = repository.context().getValueFactories().getPathFactory(); this.locksPath = pathFactory.create(pathFactory.createRootPath(), JcrLexicon.SYSTEM, ModeShapeLexicon.LOCKS); this.logger = Logger.getLogger(getClass()); long lockGCIntervalMillis = gcConfig.getIntervalInMillis(); assert lockGCIntervalMillis > 0; /* * Each time the garbage collection process runs, session-scoped locks that are still used by active sessions will have their * expiry times extended by this amount of time. Each repository instance in the ModeShape cluster will run its own cleanup * process, which will extend the expiry times of its own locks. As soon as a repository is no longer running the cleanup * process, we know that there can be no active sessions. * * The default GC interval is expressed in hours, so we make the extension slightly larger to avoid any lock being expired * prematurely. */ this.lockExtensionIntervalMillis = lockGCIntervalMillis + TimeUnit.MILLISECONDS.convert(10, TimeUnit.MINUTES); /* * The amount of time that a lock may be active before considered expired. The sweep process will extend the locks for active * sessions, so only unused locks will have an unmodified expiry time. * * The default GC interval is expressed in hours, so we make the default age slightly less to avoid stale lock. */ this.defaultLockAgeMillis = lockGCIntervalMillis - TimeUnit.MILLISECONDS.convert(10, TimeUnit.MINUTES); }
final JcrValue valueFrom( javax.jcr.Node value ) throws RepositoryException { if (!(value instanceof AbstractJcrNode)) { throw new IllegalArgumentException("Invalid node type (expected a ModeShape node): " + value.getClass().toString()); } AbstractJcrNode node = (AbstractJcrNode)value; if (!this.isInTheSameProcessAs(node.session().context().getProcessId())) { throw new RepositoryException(JcrI18n.nodeNotInTheSameSession.text(node.path())); } NodeKey key = ((AbstractJcrNode)value).key(); Reference ref = session.context().getValueFactories().getReferenceFactory() .create(key, ((AbstractJcrNode)value).isForeign()); return valueFrom(PropertyType.REFERENCE, ref); }
RepositoryLockManager with( JcrRepository.RunningState repository, RepositoryConfiguration.GarbageCollection gcConfig ) { assert this.systemWorkspaceName == repository.repositoryCache().getSystemWorkspaceName(); assert this.processId == repository.context().getProcessId(); PathFactory pathFactory = repository.context().getValueFactories().getPathFactory(); Path locksPath = pathFactory.create(pathFactory.createRootPath(), JcrLexicon.SYSTEM, ModeShapeLexicon.LOCKS); assert this.locksPath.equals(locksPath); return new RepositoryLockManager(repository, gcConfig); }
public final void setAccessControlEnabled( boolean enabled ) { if (this.accessControlEnabled.compareAndSet(!enabled, enabled)) { refreshRepositoryMetadata(true); // And notify the others ... String userId = context.getSecurityContext().getUserName(); Map<String, String> userData = context.getData(); DateTime timestamp = context.getValueFactories().getDateFactory().create(); RecordingChanges changes = new RecordingChanges(context.getId(), context.getProcessId(), this.getKey(), null, repositoryEnvironment.journalId()); changes.repositoryMetadataChanged(); changes.freeze(userId, userData, timestamp); this.changeBus.notify(changes); } }
public final void setAccessControlEnabled( boolean enabled ) { if (this.accessControlEnabled.compareAndSet(!enabled, enabled)) { refreshRepositoryMetadata(true); // And notify the others ... String userId = context.getSecurityContext().getUserName(); Map<String, String> userData = context.getData(); DateTime timestamp = context.getValueFactories().getDateFactory().create(); RecordingChanges changes = new RecordingChanges(context.getId(), context.getProcessId(), this.getKey(), null, repositoryEnvironment.journalId()); changes.repositoryMetadataChanged(); changes.freeze(userId, userData, timestamp); this.changeBus.notify(changes); } }
private ConnectorChangeSetFactory createConnectorChangedSetFactory( final Connector c ) { return () -> { PathMappings mappings = getPathMappings(c); RunningState repository1 = repository(); final ExecutionContext context = repository1.context(); return new ConnectorChangeSetImpl(Connectors.this, mappings, context.getId(), context.getProcessId(), repository1.repositoryKey(), repository1.changeBus(), context.getValueFactories().getDateFactory(), repository().journalId()); }; }
private ConnectorChangeSetFactory createConnectorChangedSetFactory( final Connector c ) { return () -> { PathMappings mappings = getPathMappings(c); RunningState repository1 = repository(); final ExecutionContext context = repository1.context(); return new ConnectorChangeSetImpl(Connectors.this, mappings, context.getId(), context.getProcessId(), repository1.repositoryKey(), repository1.changeBus(), context.getValueFactories().getDateFactory(), repository().journalId()); }; }
private void fireSequencingFailureEvent( AbstractJcrNode sequencedNode, JcrSession inputSession, Throwable cause, String sequencerName ) throws RepositoryException { assert sequencedNode != null; assert inputSession != null; Name primaryType = sequencedNode.getPrimaryTypeName(); Set<Name> mixinTypes = sequencedNode.getMixinTypeNames(); final ExecutionContext context = inputSession.context(); RecordingChanges sequencingChanges = new RecordingChanges(inputSession.sessionId(), context.getProcessId(), inputSession.getRepository().repositoryKey(), inputSession.workspaceName(), inputSession.getRepository() .journalId()); sequencingChanges.nodeSequencingFailure(sequencedNode.key(), sequencedNode.path(), primaryType, mixinTypes, work.getOutputPath(), work.getUserId(), work.getSelectedPath(), sequencerName, cause); repository.changeBus().notify(sequencingChanges); }
private void fireSequencingFailureEvent( AbstractJcrNode sequencedNode, JcrSession inputSession, Throwable cause, String sequencerName ) throws RepositoryException { assert sequencedNode != null; assert inputSession != null; Name primaryType = sequencedNode.getPrimaryTypeName(); Set<Name> mixinTypes = sequencedNode.getMixinTypeNames(); final ExecutionContext context = inputSession.context(); RecordingChanges sequencingChanges = new RecordingChanges(inputSession.sessionId(), context.getProcessId(), inputSession.getRepository().repositoryKey(), inputSession.workspaceName(), inputSession.getRepository() .journalId()); sequencingChanges.nodeSequencingFailure(sequencedNode.key(), sequencedNode.path(), primaryType, mixinTypes, work.getOutputPath(), work.getUserId(), work.getSelectedPath(), sequencerName, cause); repository.changeBus().notify(sequencingChanges); }
@Override public void setValue( Node value ) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException { if (value == null) { this.remove(); return; } checkSession(); checkForLock(); checkForCheckedOut(); checkModifyPermission(); if (!value.isNodeType(JcrMixLexicon.REFERENCEABLE.getString(this.context().getNamespaceRegistry()))) { throw new ValueFormatException(JcrI18n.nodeNotReferenceable.text()); } AbstractJcrNode jcrNode = session.getNodeByIdentifier(value.getIdentifier()); if (!jcrNode.isInTheSameProcessAs(session.context().getProcessId())) { throw new RepositoryException(JcrI18n.nodeNotInTheSameSession.text(jcrNode.path())); } JcrValue referenceValue = session().valueFactory().createValue(jcrNode); internalSetValue(referenceValue.asType(this.getType())); }
private void fireSequencingEvent( AbstractJcrNode sequencedNode, List<AbstractJcrNode> outputNodes, JcrSession outputSession, String sequencerName ) throws RepositoryException { final ExecutionContext context = outputSession.context(); RecordingChanges sequencingChanges = new RecordingChanges(outputSession.sessionId(), context.getProcessId(), outputSession.getRepository().repositoryKey(), outputSession.workspaceName(), outputSession.getRepository() .journalId()); Name primaryType = sequencedNode.getPrimaryTypeName(); Set<Name> mixinTypes = sequencedNode.getMixinTypeNames(); for (AbstractJcrNode outputNode : outputNodes) { sequencingChanges.nodeSequenced(sequencedNode.key(), sequencedNode.path(), primaryType, mixinTypes, outputNode.key(), outputNode.path(), work.getOutputPath(), work.getUserId(), work.getSelectedPath(), sequencerName); } sequencingChanges.freeze(outputSession.getUserID(), null, context.getValueFactories().getDateFactory().create()); repository.changeBus().notify(sequencingChanges); }
private void fireSequencingEvent( AbstractJcrNode sequencedNode, List<AbstractJcrNode> outputNodes, JcrSession outputSession, String sequencerName ) throws RepositoryException { final ExecutionContext context = outputSession.context(); RecordingChanges sequencingChanges = new RecordingChanges(outputSession.sessionId(), context.getProcessId(), outputSession.getRepository().repositoryKey(), outputSession.workspaceName(), outputSession.getRepository() .journalId()); Name primaryType = sequencedNode.getPrimaryTypeName(); Set<Name> mixinTypes = sequencedNode.getMixinTypeNames(); for (AbstractJcrNode outputNode : outputNodes) { sequencingChanges.nodeSequenced(sequencedNode.key(), sequencedNode.path(), primaryType, mixinTypes, outputNode.key(), outputNode.path(), work.getOutputPath(), work.getUserId(), work.getSelectedPath(), sequencerName); } sequencingChanges.freeze(outputSession.getUserID(), null, context.getValueFactories().getDateFactory().create()); repository.changeBus().notify(sequencingChanges); }
@Override public void setValue( Node value ) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException { if (value == null) { this.remove(); return; } checkSession(); checkForLock(); checkForCheckedOut(); checkModifyPermission(); if (!value.isNodeType(JcrMixLexicon.REFERENCEABLE.getString(this.context().getNamespaceRegistry()))) { throw new ValueFormatException(JcrI18n.nodeNotReferenceable.text()); } AbstractJcrNode jcrNode = session.getNodeByIdentifier(value.getIdentifier()); if (!jcrNode.isInTheSameProcessAs(session.context().getProcessId())) { throw new RepositoryException(JcrI18n.nodeNotInTheSameSession.text(jcrNode.path())); } JcrValue referenceValue = session().valueFactory().createValue(jcrNode); internalSetValue(referenceValue.asType(this.getType())); }