idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
15,600
public long getNodeChangedSize ( String nodePath ) { long nodeDelta = 0 ; Iterator < ChangesItem > changes = iterator ( ) ; while ( changes . hasNext ( ) ) { nodeDelta += changes . next ( ) . getNodeChangedSize ( nodePath ) ; } return nodeDelta ; }
Return changed size for particular node accumulated during some period .
15,601
private boolean checkValueConstraints ( int requiredType , String [ ] constraints , Value value ) { ValueConstraintsMatcher constrMatcher = new ValueConstraintsMatcher ( constraints , locationFactory , dataManager , nodeTypeDataManager ) ; try { return constrMatcher . match ( ( ( BaseValue ) value ) . getInternalData ( ) , requiredType ) ; } catch ( RepositoryException e1 ) { return false ; } }
Check value constrains .
15,602
private MembershipType createMembershipType ( Session session , MembershipTypeImpl mt , boolean broadcast ) throws Exception { Node storageTypesNode = utils . getMembershipTypeStorageNode ( session ) ; Node typeNode = storageTypesNode . addNode ( mt . getName ( ) . equals ( MembershipTypeHandler . ANY_MEMBERSHIP_TYPE ) ? JCROrganizationServiceImpl . JOS_MEMBERSHIP_TYPE_ANY : mt . getName ( ) ) ; mt . setInternalId ( typeNode . getUUID ( ) ) ; if ( broadcast ) { preSave ( mt , true ) ; } writeMembershipType ( mt , typeNode ) ; session . save ( ) ; putInCache ( mt ) ; if ( broadcast ) { postSave ( mt , true ) ; } return mt ; }
Persists new membership type object .
15,603
private MembershipType findMembershipType ( Session session , String name ) throws Exception { Node membershipTypeNode ; try { membershipTypeNode = utils . getMembershipTypeNode ( session , name ) ; } catch ( PathNotFoundException e ) { return null ; } MembershipType mt = readMembershipType ( membershipTypeNode ) ; putInCache ( mt ) ; return mt ; }
Find membership type .
15,604
private MembershipType removeMembershipType ( Session session , String name , boolean broadcast ) throws RepositoryException , Exception { Node membershipTypeNode = utils . getMembershipTypeNode ( session , name ) ; MembershipType type = readMembershipType ( membershipTypeNode ) ; if ( broadcast ) { preDelete ( type ) ; } removeMemberships ( membershipTypeNode ) ; membershipTypeNode . remove ( ) ; session . save ( ) ; removeFromCache ( name ) ; removeAllRelatedFromCache ( name ) ; if ( broadcast ) { postDelete ( type ) ; } return type ; }
Removing membership type and related membership entities .
15,605
private void removeMemberships ( Node membershipTypeNode ) throws Exception { PropertyIterator refTypes = membershipTypeNode . getReferences ( ) ; while ( refTypes . hasNext ( ) ) { Property refTypeProp = refTypes . nextProperty ( ) ; Node refTypeNode = refTypeProp . getParent ( ) ; Node refUserNode = refTypeNode . getParent ( ) ; membershipHandler . removeMembership ( refUserNode , refTypeNode ) ; } }
Removes related membership entity .
15,606
void migrateMembershipType ( Node oldMembershipTypeNode ) throws Exception { MembershipType membershipType = readMembershipType ( oldMembershipTypeNode ) ; if ( findMembershipType ( membershipType . getName ( ) ) != null ) { removeMembershipType ( membershipType . getName ( ) , false ) ; } createMembershipType ( membershipType , false ) ; }
Method for membership type migration .
15,607
private MembershipType saveMembershipType ( Session session , MembershipTypeImpl mType , boolean broadcast ) throws Exception { Node mtNode = getOrCreateMembershipTypeNode ( session , mType ) ; boolean isNew = mtNode . isNew ( ) ; if ( broadcast ) { preSave ( mType , isNew ) ; } String oldType = mtNode . getName ( ) . equals ( JCROrganizationServiceImpl . JOS_MEMBERSHIP_TYPE_ANY ) ? ANY_MEMBERSHIP_TYPE : mtNode . getName ( ) ; String newType = mType . getName ( ) ; if ( ! oldType . equals ( newType ) ) { String oldPath = mtNode . getPath ( ) ; String newPath = utils . getMembershipTypeNodePath ( newType ) ; session . move ( oldPath , newPath ) ; moveMembershipsInCache ( oldType , newType ) ; removeFromCache ( oldType ) ; } writeMembershipType ( mType , mtNode ) ; session . save ( ) ; putInCache ( mType ) ; if ( broadcast ) { postSave ( mType , isNew ) ; } return mType ; }
Persists new membership type entity .
15,608
private Node getOrCreateMembershipTypeNode ( Session session , MembershipTypeImpl mType ) throws Exception { try { return mType . getInternalId ( ) != null ? session . getNodeByUUID ( mType . getInternalId ( ) ) : utils . getMembershipTypeNode ( session , mType . getName ( ) ) ; } catch ( ItemNotFoundException e ) { return createNewMembershipTypeNode ( session , mType ) ; } catch ( PathNotFoundException e ) { return createNewMembershipTypeNode ( session , mType ) ; } }
Creates and returns membership type node . If node already exists it will be returned otherwise the new one will be created .
15,609
private Node createNewMembershipTypeNode ( Session session , MembershipTypeImpl mType ) throws Exception { Node storageTypesNode = utils . getMembershipTypeStorageNode ( session ) ; return storageTypesNode . addNode ( mType . getName ( ) ) ; }
Creates and returns new membership type node .
15,610
private MembershipType readMembershipType ( Node node ) throws Exception { MembershipTypeImpl mt = new MembershipTypeImpl ( ) ; mt . setName ( node . getName ( ) . equals ( JCROrganizationServiceImpl . JOS_MEMBERSHIP_TYPE_ANY ) ? ANY_MEMBERSHIP_TYPE : node . getName ( ) ) ; mt . setInternalId ( node . getUUID ( ) ) ; mt . setDescription ( utils . readString ( node , MembershipTypeProperties . JOS_DESCRIPTION ) ) ; mt . setCreatedDate ( utils . readDate ( node , MembershipTypeProperties . EXO_DATE_CREATED ) ) ; mt . setModifiedDate ( utils . readDate ( node , MembershipTypeProperties . EXO_DATE_MODIFIED ) ) ; return mt ; }
Reads membership type from the node .
15,611
private void writeMembershipType ( MembershipType membershipType , Node mtNode ) throws Exception { if ( ! mtNode . isNodeType ( "exo:datetime" ) ) { mtNode . addMixin ( "exo:datetime" ) ; } mtNode . setProperty ( MembershipTypeProperties . JOS_DESCRIPTION , membershipType . getDescription ( ) ) ; }
Writes membership type properties to the node .
15,612
private MembershipType getFromCache ( String name ) { return ( MembershipType ) cache . get ( name , CacheType . MEMBERSHIPTYPE ) ; }
Gets membership type from cache .
15,613
private void removeAllRelatedFromCache ( String name ) { cache . remove ( CacheHandler . MEMBERSHIPTYPE_PREFIX + name , CacheType . MEMBERSHIP ) ; }
Removes all related memberships from cache .
15,614
private void moveMembershipsInCache ( String oldType , String newType ) { cache . move ( CacheHandler . MEMBERSHIPTYPE_PREFIX + oldType , CacheHandler . MEMBERSHIPTYPE_PREFIX + newType , CacheType . MEMBERSHIP ) ; }
Moves memberships in cache from old key to new one .
15,615
private void putInCache ( MembershipType mt ) { cache . put ( mt . getName ( ) , mt , CacheType . MEMBERSHIPTYPE ) ; }
Puts membership type in cache .
15,616
private void preSave ( MembershipType type , boolean isNew ) throws Exception { for ( MembershipTypeEventListener listener : listeners ) { listener . preSave ( type , isNew ) ; } }
Notifying listeners before membership type creation .
15,617
private void postSave ( MembershipType type , boolean isNew ) throws Exception { for ( MembershipTypeEventListener listener : listeners ) { listener . postSave ( type , isNew ) ; } }
Notifying listeners after membership type creation .
15,618
private void preDelete ( MembershipType type ) throws Exception { for ( MembershipTypeEventListener listener : listeners ) { listener . preDelete ( type ) ; } }
Notifying listeners before membership type deletion .
15,619
private void postDelete ( MembershipType type ) throws Exception { for ( MembershipTypeEventListener listener : listeners ) { listener . postDelete ( type ) ; } }
Notifying listeners after membership type deletion .
15,620
public void write ( ObjectWriter out , AccessControlList acl ) throws IOException { out . writeInt ( SerializationConstants . ACCESS_CONTROL_LIST ) ; String owner = acl . getOwner ( ) ; if ( owner != null ) { out . writeByte ( SerializationConstants . NOT_NULL_DATA ) ; out . writeString ( owner ) ; } else { out . writeByte ( SerializationConstants . NULL_DATA ) ; } List < AccessControlEntry > accessList = acl . getPermissionEntries ( ) ; out . writeInt ( accessList . size ( ) ) ; for ( AccessControlEntry entry : accessList ) { out . writeString ( entry . getIdentity ( ) ) ; out . writeString ( entry . getPermission ( ) ) ; } }
Write AccessControlList data .
15,621
private boolean validateRange ( Range range , long contentLength ) { long start = range . getStart ( ) ; long end = range . getEnd ( ) ; if ( start < 0 && end == - 1 ) { if ( ( - 1 * start ) >= contentLength ) { start = 0 ; end = contentLength - 1 ; } else { start = contentLength + start ; end = contentLength - 1 ; } } if ( start >= 0 && end == - 1 ) end = contentLength - 1 ; if ( end >= contentLength ) end = contentLength - 1 ; if ( start >= 0 && end >= 0 && start <= end ) { range . setStart ( start ) ; range . setEnd ( end ) ; return true ; } return false ; }
Checks is the range is valid .
15,622
private String generateCacheControl ( Map < MediaType , String > cacheControlMap , String contentType ) { ArrayList < MediaType > mediaTypesList = new ArrayList < MediaType > ( cacheControlMap . keySet ( ) ) ; Collections . sort ( mediaTypesList , MediaTypeHelper . MEDIA_TYPE_COMPARATOR ) ; String cacheControlValue = "no-cache" ; if ( contentType == null || contentType . equals ( "" ) ) { return cacheControlValue ; } for ( MediaType mediaType : mediaTypesList ) { if ( contentType . equals ( MediaType . WILDCARD ) ) { cacheControlValue = cacheControlMap . get ( MediaType . WILDCARD_TYPE ) ; break ; } else if ( mediaType . isCompatible ( new MediaType ( contentType . split ( "/" ) [ 0 ] , contentType . split ( "/" ) [ 1 ] ) ) ) { cacheControlValue = cacheControlMap . get ( mediaType ) ; break ; } } return cacheControlValue ; }
Generates the value of Cache - Control header according to the content type .
15,623
public void internalRemoveWorkspace ( final String workspaceName ) throws RepositoryException { SecurityHelper . validateSecurityPermission ( JCRRuntimePermissions . MANAGE_REPOSITORY_PERMISSION ) ; final WorkspaceContainer workspaceContainer = repositoryContainer . getWorkspaceContainer ( workspaceName ) ; try { SecurityHelper . doPrivilegedAction ( new PrivilegedAction < Void > ( ) { public Void run ( ) { workspaceContainer . stop ( ) ; return null ; } } ) ; } catch ( Exception e ) { throw new RepositoryException ( e ) ; } SecurityHelper . doPrivilegedAction ( new PrivilegedAction < Void > ( ) { public Void run ( ) { repositoryContainer . unregisterComponent ( workspaceName ) ; return null ; } } ) ; config . getWorkspaceEntries ( ) . remove ( repositoryContainer . getWorkspaceEntry ( workspaceName ) ) ; for ( WorkspaceManagingListener listener : workspaceListeners ) { listener . onWorkspaceRemove ( workspaceName ) ; } }
Internal Remove Workspace .
15,624
SessionImpl internalLogin ( ConversationState state , String workspaceName ) throws LoginException , NoSuchWorkspaceException , RepositoryException { if ( workspaceName == null ) { workspaceName = config . getDefaultWorkspaceName ( ) ; if ( workspaceName == null ) { throw new NoSuchWorkspaceException ( "Both workspace and default-workspace name are null! " ) ; } } if ( ! isWorkspaceInitialized ( workspaceName ) ) { throw new NoSuchWorkspaceException ( "Workspace '" + workspaceName + "' not found. " + "Probably is not initialized. If so either Initialize it manually or turn on the RepositoryInitializer" ) ; } SessionFactory sessionFactory = repositoryContainer . getWorkspaceContainer ( workspaceName ) . getSessionFactory ( ) ; return sessionFactory . createSession ( state ) ; }
Internal login .
15,625
public void write ( ObjectWriter out , ItemState itemState ) throws IOException { out . writeInt ( SerializationConstants . ITEM_STATE ) ; out . writeInt ( itemState . getState ( ) ) ; out . writeBoolean ( itemState . isPersisted ( ) ) ; out . writeBoolean ( itemState . isEventFire ( ) ) ; if ( itemState . getOldPath ( ) == null ) { out . writeInt ( SerializationConstants . NULL_DATA ) ; } else { out . writeInt ( SerializationConstants . NOT_NULL_DATA ) ; byte [ ] buf = itemState . getOldPath ( ) . getAsString ( ) . getBytes ( Constants . DEFAULT_ENCODING ) ; out . writeInt ( buf . length ) ; out . write ( buf ) ; } ItemData data = itemState . getData ( ) ; boolean isNodeData = ( data instanceof PersistedNodeData ) ; out . writeBoolean ( isNodeData ) ; if ( isNodeData ) { PersistedNodeDataWriter wr = new PersistedNodeDataWriter ( ) ; wr . write ( out , ( PersistedNodeData ) data ) ; } else { PersistedPropertyDataWriter wr = new PersistedPropertyDataWriter ( ) ; wr . write ( out , ( PersistedPropertyData ) data ) ; } }
Write item state into file .
15,626
public String getAsString ( boolean showIndex ) { if ( showIndex ) { if ( cachedToStringShowIndex != null ) { return cachedToStringShowIndex ; } } else { if ( cachedToString != null ) { return cachedToString ; } } String res ; if ( showIndex ) { res = super . getAsString ( ) + QPath . PREFIX_DELIMITER + getIndex ( ) ; } else { res = super . getAsString ( ) ; } if ( showIndex ) { cachedToStringShowIndex = res ; } else { cachedToString = res ; } return res ; }
Return entry textual representation .
15,627
private List < NodeTypeData > registerListOfNodeTypes ( final List < NodeTypeData > nodeTypes , final int alreadyExistsBehaviour ) throws RepositoryException { nodeTypeDataValidator . validateNodeType ( nodeTypes ) ; nodeTypeRepository . registerNodeType ( nodeTypes , this , accessControlPolicy , alreadyExistsBehaviour ) ; for ( NodeTypeData nodeType : nodeTypes ) { for ( NodeTypeManagerListener listener : listeners . values ( ) ) { listener . nodeTypeRegistered ( nodeType . getName ( ) ) ; } } if ( started && rpcService != null && repository != null && repository . getState ( ) == ManageableRepository . ONLINE ) { try { String [ ] names = new String [ nodeTypes . size ( ) ] ; for ( int i = 0 ; i < names . length ; i ++ ) { names [ i ] = nodeTypes . get ( i ) . getName ( ) . getAsString ( ) ; } rpcService . executeCommandOnAllNodes ( registerNodeTypes , false , id , names ) ; } catch ( Exception e ) { LOG . warn ( "Could not register the node types on other cluster nodes" , e ) ; } } return nodeTypes ; }
Registers the provided node types
15,628
public Query rewrite ( IndexReader reader ) throws IOException { if ( transform == TRANSFORM_NONE ) { Query stdRangeQueryImpl = new TermRangeQuery ( lowerTerm . field ( ) , lowerTerm . text ( ) , upperTerm . text ( ) , inclusive , inclusive ) ; try { stdRangeQuery = stdRangeQueryImpl . rewrite ( reader ) ; return stdRangeQuery ; } catch ( BooleanQuery . TooManyClauses e ) { return this ; } } else { return this ; } }
Tries to rewrite this query into a standard lucene RangeQuery . This rewrite might fail with a TooManyClauses exception . If that happens we use our own implementation .
15,629
public static void start ( final Cache < Serializable , Object > cache ) { PrivilegedAction < Object > action = new PrivilegedAction < Object > ( ) { public Object run ( ) { cache . start ( ) ; return null ; } } ; SecurityHelper . doPrivilegedAction ( action ) ; }
Start Infinispan cache in privileged mode .
15,630
public static Object put ( final Cache < Serializable , Object > cache , final Serializable key , final Object value , final long lifespan , final TimeUnit unit ) { PrivilegedAction < Object > action = new PrivilegedAction < Object > ( ) { public Object run ( ) { return cache . put ( key , value , lifespan , unit ) ; } } ; return SecurityHelper . doPrivilegedAction ( action ) ; }
Put in Infinispan cache in privileged mode .
15,631
public Response lock ( Session session , String path , HierarchicalProperty body , Depth depth , String timeout ) { boolean bodyIsEmpty = ( body == null ) ; String lockToken ; if ( isReadOnly ( session , path ) ) { return Response . status ( HTTPStatus . METHOD_NOT_ALLOWED ) . entity ( "Permission denied" ) . build ( ) ; } try { WebDavNamespaceContext nsContext = new WebDavNamespaceContext ( session ) ; try { Node node = ( Node ) session . getItem ( path ) ; if ( ! node . isNodeType ( "mix:lockable" ) ) { if ( node . canAddMixin ( "mix:lockable" ) ) { node . addMixin ( "mix:lockable" ) ; session . save ( ) ; } } Lock lock ; if ( bodyIsEmpty ) { lock = node . getLock ( ) ; lock . refresh ( ) ; body = new HierarchicalProperty ( new QName ( "DAV" , "activelock" , "D" ) ) ; HierarchicalProperty owner = new HierarchicalProperty ( PropertyConstants . OWNER ) ; HierarchicalProperty href = new HierarchicalProperty ( new QName ( "D" , "href" ) , lock . getLockOwner ( ) ) ; body . addChild ( owner ) . addChild ( href ) ; } else { lock = node . lock ( ( depth . getIntValue ( ) != 1 ) , false ) ; } lockToken = lock . getLockToken ( ) ; } catch ( PathNotFoundException pexc ) { lockToken = nullResourceLocks . addLock ( session , path ) ; } LockRequestEntity requestEntity = new LockRequestEntity ( body ) ; lockToken = WebDavConst . Lock . OPAQUE_LOCK_TOKEN + ":" + lockToken ; if ( bodyIsEmpty ) { return Response . ok ( body ( nsContext , requestEntity , depth , lockToken , requestEntity . getOwner ( ) , timeout ) , "text/xml" ) . build ( ) ; } else { return Response . ok ( body ( nsContext , requestEntity , depth , lockToken , requestEntity . getOwner ( ) , timeout ) , "text/xml" ) . header ( "Lock-Token" , "<" + lockToken + ">" ) . build ( ) ; } } catch ( LockException exc ) { return Response . status ( HTTPStatus . LOCKED ) . entity ( exc . getMessage ( ) ) . build ( ) ; } catch ( AccessDeniedException exc ) { return Response . status ( HTTPStatus . FORBIDDEN ) . entity ( exc . getMessage ( ) ) . build ( ) ; } catch ( Exception exc ) { LOG . error ( exc . getMessage ( ) , exc ) ; return Response . serverError ( ) . entity ( exc . getMessage ( ) ) . build ( ) ; } }
Webdav Lock comand implementation .
15,632
private StreamingOutput body ( WebDavNamespaceContext nsContext , LockRequestEntity input , Depth depth , String lockToken , String lockOwner , String timeout ) { return new LockResultResponseEntity ( nsContext , lockToken , lockOwner , timeout ) ; }
Writes response body into the stream .
15,633
private boolean isReadOnly ( Session session , String path ) { try { session . checkPermission ( path , PermissionType . SET_PROPERTY ) ; return false ; } catch ( AccessControlException e ) { return true ; } catch ( RepositoryException e ) { return false ; } }
Check node permission
15,634
public String dump ( ) throws RepositoryException { StringBuilder tmp = new StringBuilder ( ) ; QueryTreeDump . dump ( this , tmp ) ; return tmp . toString ( ) ; }
Dumps this QueryNode and its child nodes to a String .
15,635
public Query createQuery ( SessionImpl session , SessionDataManager sessionDataManager , Node node ) throws InvalidQueryException , RepositoryException { AbstractQueryImpl query = createQueryInstance ( ) ; query . init ( session , sessionDataManager , handler , node ) ; return query ; }
Creates a query object from a node that can be executed on the workspace .
15,636
public Query createQuery ( SessionImpl session , SessionDataManager sessionDataManager , String statement , String language ) throws InvalidQueryException , RepositoryException { AbstractQueryImpl query = createQueryInstance ( ) ; query . init ( session , sessionDataManager , handler , statement , language ) ; return query ; }
Creates a query object that can be executed on the workspace .
15,637
public void checkIndex ( final InspectionReport report , final boolean isSystem ) throws RepositoryException , IOException { if ( isSuspended . get ( ) ) { try { SecurityHelper . doPrivilegedExceptionAction ( new PrivilegedExceptionAction < Object > ( ) { public Object run ( ) throws RepositoryException , IOException { try { if ( isSystem && parentSearchManager != null && parentSearchManager . isSuspended . get ( ) ) { parentSearchManager . resume ( ) ; } resume ( ) ; handler . checkIndex ( itemMgr , isSystem , report ) ; return null ; } catch ( ResumeException e ) { throw new RepositoryException ( "Can not resume SearchManager for inspection purposes." , e ) ; } finally { try { suspend ( ) ; if ( isSystem && parentSearchManager != null && ! parentSearchManager . isSuspended . get ( ) ) { parentSearchManager . suspend ( ) ; } } catch ( SuspendException e ) { LOG . error ( e . getMessage ( ) , e ) ; } } } } ) ; } catch ( PrivilegedActionException e ) { Throwable ex = e . getCause ( ) ; if ( ex instanceof RepositoryException ) { throw ( RepositoryException ) ex ; } else if ( ex instanceof IOException ) { throw ( IOException ) ex ; } else { throw new RepositoryException ( ex . getMessage ( ) , ex ) ; } } } else { handler . checkIndex ( itemMgr , isSystem , report ) ; } }
Check index consistency . Iterator goes through index documents and check does each document have according jcr - node . If index is suspended then it will be temporary resumed while check is running and suspended afterwards .
15,638
public Set < String > getNodesByUri ( final String uri ) throws RepositoryException { Set < String > result ; final int defaultClauseCount = BooleanQuery . getMaxClauseCount ( ) ; try { final ValueFactoryImpl valueFactory = new ValueFactoryImpl ( new LocationFactory ( nsReg ) , cleanerHolder ) ; BooleanQuery . setMaxClauseCount ( Integer . MAX_VALUE ) ; BooleanQuery query = new BooleanQuery ( ) ; final String prefix = nsReg . getNamespacePrefixByURI ( uri ) ; query . add ( new WildcardQuery ( new Term ( FieldNames . LABEL , prefix + ":*" ) ) , Occur . SHOULD ) ; query . add ( new WildcardQuery ( new Term ( FieldNames . PROPERTIES_SET , prefix + ":*" ) ) , Occur . SHOULD ) ; result = getNodes ( query ) ; try { final Set < String > props = getFieldNames ( ) ; query = new BooleanQuery ( ) ; for ( final String fieldName : props ) { if ( ! FieldNames . PROPERTIES_SET . equals ( fieldName ) ) { query . add ( new WildcardQuery ( new Term ( fieldName , "*" + prefix + ":*" ) ) , Occur . SHOULD ) ; } } } catch ( final IndexException e ) { throw new RepositoryException ( e . getLocalizedMessage ( ) , e ) ; } final Set < String > propSet = getNodes ( query ) ; for ( final String uuid : propSet ) { if ( isPrefixMatch ( valueFactory , uuid , prefix ) ) { result . add ( uuid ) ; } } } finally { BooleanQuery . setMaxClauseCount ( defaultClauseCount ) ; } return result ; }
Return set of uuid of nodes . Contains in names prefixes maped to the given uri
15,639
protected String getIndexDirParam ( ) throws RepositoryConfigurationException { String dir = config . getParameterValue ( QueryHandlerParams . PARAM_INDEX_DIR , null ) ; if ( dir == null ) { LOG . warn ( QueryHandlerParams . PARAM_INDEX_DIR + " parameter not found. Using outdated parameter name " + QueryHandlerParams . OLD_PARAM_INDEX_DIR ) ; dir = config . getParameterValue ( QueryHandlerParams . OLD_PARAM_INDEX_DIR ) ; } return dir ; }
^ Returns index - dir parameter from configuration .
15,640
@ SuppressWarnings ( "unchecked" ) protected IndexerChangesFilter initializeChangesFilter ( ) throws RepositoryException , RepositoryConfigurationException { IndexerChangesFilter newChangesFilter = null ; Class < ? extends IndexerChangesFilter > changesFilterClass = DefaultChangesFilter . class ; String changesFilterClassName = config . getParameterValue ( QueryHandlerParams . PARAM_CHANGES_FILTER_CLASS , null ) ; try { if ( changesFilterClassName != null ) { changesFilterClass = ( Class < ? extends IndexerChangesFilter > ) ClassLoading . forName ( changesFilterClassName , this ) ; } Constructor < ? extends IndexerChangesFilter > constuctor = changesFilterClass . getConstructor ( SearchManager . class , SearchManager . class , QueryHandlerEntry . class , IndexingTree . class , IndexingTree . class , QueryHandler . class , QueryHandler . class , ConfigurationManager . class ) ; if ( parentSearchManager != null ) { newChangesFilter = constuctor . newInstance ( this , parentSearchManager , config , indexingTree , parentSearchManager . getIndexingTree ( ) , handler , parentSearchManager . getHandler ( ) , cfm ) ; } } catch ( SecurityException e ) { throw new RepositoryException ( e . getMessage ( ) , e ) ; } catch ( IllegalArgumentException e ) { throw new RepositoryException ( e . getMessage ( ) , e ) ; } catch ( ClassNotFoundException e ) { throw new RepositoryException ( e . getMessage ( ) , e ) ; } catch ( NoSuchMethodException e ) { throw new RepositoryException ( e . getMessage ( ) , e ) ; } catch ( InstantiationException e ) { throw new RepositoryException ( e . getMessage ( ) , e ) ; } catch ( IllegalAccessException e ) { throw new RepositoryException ( e . getMessage ( ) , e ) ; } catch ( InvocationTargetException e ) { throw new RepositoryException ( e . getMessage ( ) , e ) ; } return newChangesFilter ; }
Initialize changes filter .
15,641
protected void initializeQueryHandler ( ) throws RepositoryException , RepositoryConfigurationException { String className = config . getType ( ) ; if ( className == null ) { throw new RepositoryConfigurationException ( "Content hanler configuration fail" ) ; } try { Class < ? > qHandlerClass = ClassLoading . forName ( className , this ) ; try { Constructor < ? > constuctor = qHandlerClass . getConstructor ( String . class , QueryHandlerEntry . class , ConfigurationManager . class ) ; handler = ( QueryHandler ) constuctor . newInstance ( wsContainerId , config , cfm ) ; } catch ( NoSuchMethodException e ) { Constructor < ? > constuctor = qHandlerClass . getConstructor ( QueryHandlerEntry . class , ConfigurationManager . class ) ; handler = ( QueryHandler ) constuctor . newInstance ( config , cfm ) ; } QueryHandler parentHandler = ( this . parentSearchManager != null ) ? parentSearchManager . getHandler ( ) : null ; QueryHandlerContext context = createQueryHandlerContext ( parentHandler ) ; handler . setContext ( context ) ; if ( parentSearchManager != null ) { changesFilter = initializeChangesFilter ( ) ; parentSearchManager . setChangesFilter ( changesFilter ) ; } } catch ( SecurityException e ) { throw new RepositoryException ( e . getMessage ( ) , e ) ; } catch ( IllegalArgumentException e ) { throw new RepositoryException ( e . getMessage ( ) , e ) ; } catch ( ClassNotFoundException e ) { throw new RepositoryException ( e . getMessage ( ) , e ) ; } catch ( NoSuchMethodException e ) { throw new RepositoryException ( e . getMessage ( ) , e ) ; } catch ( InstantiationException e ) { throw new RepositoryException ( e . getMessage ( ) , e ) ; } catch ( IllegalAccessException e ) { throw new RepositoryException ( e . getMessage ( ) , e ) ; } catch ( InvocationTargetException e ) { throw new RepositoryException ( e . getMessage ( ) , e ) ; } }
Initializes the query handler .
15,642
public void setOnline ( boolean isOnline , boolean allowQuery , boolean dropStaleIndexes ) throws IOException { handler . setOnline ( isOnline , allowQuery , dropStaleIndexes ) ; }
Switches index into corresponding ONLINE or OFFLINE mode . Offline mode means that new indexing data is collected but index is guaranteed to be unmodified during offline state . Passing the allowQuery flag can allow or deny performing queries on index during offline mode . AllowQuery is not used when setting index back online . When dropStaleIndexes is set indexes present on the moment of switching index offline will be marked as stale and removed on switching it back online .
15,643
public CompletableFuture < Boolean > reindexWorkspace ( final boolean dropExisting , int nThreads ) throws IllegalStateException { if ( handler == null || handler . getIndexerIoModeHandler ( ) == null || changesFilter == null ) { throw new IllegalStateException ( "Index might have not been initialized yet." ) ; } if ( handler . getIndexerIoModeHandler ( ) . getMode ( ) != IndexerIoMode . READ_WRITE ) { throw new IllegalStateException ( "Index is not in READ_WRITE mode and reindexing can't be launched. Please start reindexing on coordinator node." ) ; } if ( isSuspended . get ( ) || ! handler . isOnline ( ) ) { throw new IllegalStateException ( "Can't start reindexing while index is " + ( ( isSuspended . get ( ) ) ? "SUSPENDED." : "already OFFLINE (it means that reindexing is in progress)." ) + "." ) ; } LOG . info ( "Starting hot reindexing on the " + handler . getContext ( ) . getRepositoryName ( ) + "/" + handler . getContext ( ) . getContainer ( ) . getWorkspaceName ( ) + ", with" + ( dropExisting ? "" : "out" ) + " dropping the existing indexes." ) ; ExecutorService executorService = Executors . newSingleThreadExecutor ( runnable -> new Thread ( runnable , "HotReindexing-" + handler . getContext ( ) . getRepositoryName ( ) + "-" + handler . getContext ( ) . getContainer ( ) . getWorkspaceName ( ) ) ) ; CompletableFuture < Boolean > reindexFuture = CompletableFuture . supplyAsync ( ( ) -> doReindexing ( dropExisting , nThreads ) , executorService ) ; reindexFuture . thenRun ( ( ) -> executorService . shutdown ( ) ) ; return reindexFuture ; }
Perform hot reindexing of the workspace
15,644
private void cleanIndexDirectory ( String path ) throws IOException { SecurityHelper . doPrivilegedIOExceptionAction ( ( PrivilegedExceptionAction < Void > ) ( ) -> { File newIndexFolder = new File ( path ) ; if ( newIndexFolder . exists ( ) ) { DirectoryHelper . removeDirectory ( newIndexFolder ) ; } return null ; } ) ; }
remove index directory if exist
15,645
protected void postInit ( Connection connection ) throws SQLException { String select = "select * from " + DBInitializerHelper . getItemTableName ( containerConfig ) + " where ID='" + Constants . ROOT_PARENT_UUID + "' and PARENT_ID='" + Constants . ROOT_PARENT_UUID + "'" ; if ( ! connection . createStatement ( ) . executeQuery ( select ) . next ( ) ) { String insert = DBInitializerHelper . getRootNodeInitializeScript ( containerConfig ) ; connection . createStatement ( ) . executeUpdate ( insert ) ; } }
Init root node parent record .
15,646
private static Field . Index getIndexParameter ( int flags ) { if ( ( flags & INDEXED_FLAG ) == 0 ) { return Field . Index . NO ; } else if ( ( flags & TOKENIZED_FLAG ) > 0 ) { return Field . Index . ANALYZED ; } else { return Field . Index . NOT_ANALYZED ; } }
Returns the index parameter extracted from the flags .
15,647
private static Field . Store getStoreParameter ( int flags ) { if ( ( flags & STORED_FLAG ) > 0 ) { return Field . Store . YES ; } else { return Field . Store . NO ; } }
Returns the store parameter extracted from the flags .
15,648
private static Field . TermVector getTermVectorParameter ( int flags ) { if ( ( ( flags & STORE_POSITION_WITH_TERM_VECTOR_FLAG ) > 0 ) && ( ( flags & STORE_OFFSET_WITH_TERM_VECTOR_FLAG ) > 0 ) ) { return Field . TermVector . WITH_POSITIONS_OFFSETS ; } else if ( ( flags & STORE_POSITION_WITH_TERM_VECTOR_FLAG ) > 0 ) { return Field . TermVector . WITH_POSITIONS ; } else if ( ( flags & STORE_OFFSET_WITH_TERM_VECTOR_FLAG ) > 0 ) { return Field . TermVector . WITH_OFFSETS ; } else if ( ( flags & STORE_TERM_VECTOR_FLAG ) > 0 ) { return Field . TermVector . YES ; } else { return Field . TermVector . NO ; } }
Returns the term vector parameter extracted from the flags .
15,649
private void addNamespace ( String prefix , String uri ) { prefixToURI . put ( prefix , uri ) ; uriToPrefix . put ( uri , prefix ) ; }
Adds the given namespace declaration to this resolver .
15,650
public Response versionControl ( Session session , String path ) { try { Node node = ( Node ) session . getItem ( path ) ; if ( ! node . isNodeType ( "mix:versionable" ) ) { node . addMixin ( "mix:versionable" ) ; session . save ( ) ; } return Response . ok ( ) . build ( ) ; } catch ( LockException exc ) { return Response . status ( HTTPStatus . LOCKED ) . entity ( exc . getMessage ( ) ) . build ( ) ; } catch ( PathNotFoundException exc ) { return Response . status ( HTTPStatus . NOT_FOUND ) . entity ( exc . getMessage ( ) ) . build ( ) ; } catch ( Exception exc ) { log . error ( exc . getMessage ( ) , exc ) ; return Response . serverError ( ) . entity ( exc . getMessage ( ) ) . build ( ) ; } }
Webdav Version - Control method implementation .
15,651
public byte [ ] generateLinkContent ( ) throws IOException { ByteArrayOutputStream outStream = new ByteArrayOutputStream ( ) ; for ( int i = 0 ; i < linkHeader . length ; i ++ ) { byte curByteValue = ( byte ) linkHeader [ i ] ; outStream . write ( curByteValue ) ; } byte [ ] linkContent = getLinkContent ( ) ; writeInt ( linkContent . length + 2 , outStream ) ; outStream . write ( linkContent ) ; for ( int i = 0 ; i < 6 ; i ++ ) { outStream . write ( 0 ) ; } return outStream . toByteArray ( ) ; }
Generates the content of link .
15,652
private byte [ ] getLinkContent ( ) throws IOException { ByteArrayOutputStream outStream = new ByteArrayOutputStream ( ) ; byte [ ] firstItem = getFirstItem ( ) ; writeInt ( firstItem . length + 2 , outStream ) ; writeBytes ( firstItem , outStream ) ; byte [ ] lastItem = getLastItem ( ) ; writeInt ( lastItem . length + 2 , outStream ) ; writeBytes ( lastItem , outStream ) ; String [ ] pathes = servletPath . split ( "/" ) ; String root = pathes [ pathes . length - 1 ] ; byte [ ] rootItem = getRootItem ( root , servletPath ) ; writeInt ( rootItem . length + 2 , outStream ) ; writeBytes ( rootItem , outStream ) ; pathes = targetPath . split ( "/" ) ; StringBuilder curHref = new StringBuilder ( servletPath ) ; for ( int i = 0 ; i < pathes . length ; i ++ ) { if ( "" . equals ( pathes [ i ] ) ) { continue ; } String curName = pathes [ i ] ; curHref . append ( "/" ) . append ( curName ) ; if ( i < pathes . length - 1 ) { byte [ ] linkItem = getHreffedFolder ( curName , curHref . toString ( ) ) ; writeInt ( linkItem . length + 2 , outStream ) ; writeBytes ( linkItem , outStream ) ; } else { byte [ ] linkFile = getHreffedFile ( curName , curHref . toString ( ) ) ; writeInt ( linkFile . length + 2 , outStream ) ; writeBytes ( linkFile , outStream ) ; } } return outStream . toByteArray ( ) ; }
Gets the content of the link .
15,653
private byte [ ] getFirstItem ( ) throws IOException { ByteArrayOutputStream outStream = new ByteArrayOutputStream ( ) ; int [ ] firstItem = { 0x1F , 0x50 , 0xE0 , 0x4F , 0xD0 , 0x20 , 0xEA , 0x3A , 0x69 , 0x10 , 0xA2 , 0xD8 , 0x08 , 0x00 , 0x2B , 0x30 , 0x30 , 0x9D , } ; writeInts ( firstItem , outStream ) ; return outStream . toByteArray ( ) ; }
Returns the first item .
15,654
private byte [ ] getLastItem ( ) throws IOException { ByteArrayOutputStream outStream = new ByteArrayOutputStream ( ) ; int [ ] lastItem = { 0x2E , 0x80 , 0x00 , 0xDF , 0xEA , 0xBD , 0x65 , 0xC2 , 0xD0 , 0x11 , 0xBC , 0xED , 0x00 , 0xA0 , 0xC9 , 0x0A , 0xB5 , 0x0F } ; writeInts ( lastItem , outStream ) ; return outStream . toByteArray ( ) ; }
Returns the last item .
15,655
private byte [ ] getRootValue ( String rootName ) throws IOException { ByteArrayOutputStream outStream = new ByteArrayOutputStream ( ) ; simpleWriteString ( rootName , outStream ) ; int [ ] rootVal = { 0x20 , 0x00 , 0x3D , 0x04 , 0x30 , 0x04 , 0x20 , 0x00 } ; writeInts ( rootVal , outStream ) ; simpleWriteString ( hostName , outStream ) ; return outStream . toByteArray ( ) ; }
Returns the root value .
15,656
private void writeZeroString ( String outString , OutputStream outStream ) throws IOException { simpleWriteString ( outString , outStream ) ; outStream . write ( 0 ) ; outStream . write ( 0 ) ; }
Writes zero - string into stream .
15,657
private void writeInt ( int intValue , OutputStream outStream ) throws IOException { outStream . write ( intValue & 0xFF ) ; outStream . write ( ( intValue >> 8 ) & 0xFF ) ; }
Writes int into stream .
15,658
private void writeInts ( int [ ] bytes , OutputStream outStream ) throws IOException { for ( int i = 0 ; i < bytes . length ; i ++ ) { byte curByte = ( byte ) bytes [ i ] ; outStream . write ( curByte ) ; } }
Writes int array into stream .
15,659
private void commitPending ( ) throws IOException { if ( pending . isEmpty ( ) ) { return ; } super . addDocuments ( ( Document [ ] ) pending . values ( ) . toArray ( new Document [ pending . size ( ) ] ) ) ; pending . clear ( ) ; aggregateIndexes . clear ( ) ; }
Commits pending documents to the index .
15,660
public Query rewrite ( IndexReader reader ) throws IOException { @ SuppressWarnings ( "serial" ) Query stdWildcardQuery = new MultiTermQuery ( ) { protected FilteredTermEnum getEnum ( IndexReader reader ) throws IOException { return new WildcardTermEnum ( reader , field , propName , pattern , transform ) ; } public String toString ( String field ) { StringBuilder buffer = new StringBuilder ( ) ; buffer . append ( field ) ; buffer . append ( ':' ) ; buffer . append ( ToStringUtils . boost ( getBoost ( ) ) ) ; return buffer . toString ( ) ; } } ; try { multiTermQuery = stdWildcardQuery . rewrite ( reader ) ; return multiTermQuery ; } catch ( BooleanQuery . TooManyClauses e ) { log . debug ( "Too many terms to enumerate, using custom WildcardQuery." ) ; return this ; } }
Either rewrites this query to a lucene MultiTermQuery or in case of a TooManyClauses exception to a custom jackrabbit query implementation that uses a BitSet to collect all hits .
15,661
public BaseXmlExporter getExportVisitor ( XmlMapping type , OutputStream stream , boolean skipBinary , boolean noRecurse , boolean exportChildVersionHistory , ItemDataConsumer dataManager , NamespaceRegistry namespaceRegistry , ValueFactoryImpl systemValueFactory ) throws NamespaceException , RepositoryException , IOException { XMLOutputFactory outputFactory = XMLOutputFactory . newInstance ( ) ; XMLStreamWriter streamWriter ; try { streamWriter = outputFactory . createXMLStreamWriter ( stream , Constants . DEFAULT_ENCODING ) ; } catch ( XMLStreamException e ) { throw new IOException ( e . getLocalizedMessage ( ) , e ) ; } if ( type == XmlMapping . SYSVIEW ) { return new SystemViewStreamExporter ( streamWriter , dataManager , namespaceRegistry , systemValueFactory , skipBinary , noRecurse , exportChildVersionHistory ) ; } else if ( type == XmlMapping . DOCVIEW ) { return new DocumentViewStreamExporter ( streamWriter , dataManager , namespaceRegistry , systemValueFactory , skipBinary , noRecurse ) ; } else if ( type == XmlMapping . BACKUP ) { return new WorkspaceSystemViewStreamExporter ( streamWriter , dataManager , namespaceRegistry , systemValueFactory , skipBinary , noRecurse ) ; } return null ; }
Create export visitor for given type of view . \
15,662
protected JCRPathMatcher parsePathMatcher ( LocationFactory locFactory , String path ) throws RepositoryException { JCRPath knownPath = null ; boolean forDescendants = false ; boolean forAncestors = false ; if ( path . equals ( "*" ) || path . equals ( ".*" ) ) { forDescendants = true ; forAncestors = true ; } else if ( path . endsWith ( "*" ) && path . startsWith ( "*" ) ) { forDescendants = true ; forAncestors = true ; knownPath = parsePath ( path . substring ( 1 , path . length ( ) - 1 ) , locFactory ) ; } else if ( path . endsWith ( "*" ) ) { forDescendants = true ; knownPath = parsePath ( path . substring ( 0 , path . length ( ) - 1 ) , locFactory ) ; } else if ( path . startsWith ( "*" ) ) { forAncestors = true ; knownPath = parsePath ( path . substring ( 1 ) , locFactory ) ; } else { knownPath = parsePath ( path , locFactory ) ; } return new JCRPathMatcher ( knownPath == null ? null : knownPath . getInternalPath ( ) , forDescendants , forAncestors ) ; }
Parses JCR path matcher from string .
15,663
public boolean checkedOut ( ) throws UnsupportedRepositoryOperationException , RepositoryException { NodeData vancestor = getVersionableAncestor ( ) ; if ( vancestor != null ) { PropertyData isCheckedOut = ( PropertyData ) dataManager . getItemData ( vancestor , new QPathEntry ( Constants . JCR_ISCHECKEDOUT , 1 ) , ItemType . PROPERTY ) ; return ValueDataUtil . getBoolean ( isCheckedOut . getValues ( ) . get ( 0 ) ) ; } return true ; }
Tell if this node or its nearest versionable ancestor is checked - out .
15,664
private void doAddMixin ( NodeTypeData type ) throws NoSuchNodeTypeException , ConstraintViolationException , VersionException , LockException , RepositoryException { InternalQName [ ] mixinTypes = nodeData ( ) . getMixinTypeNames ( ) ; List < InternalQName > newMixin = new ArrayList < InternalQName > ( mixinTypes . length + 1 ) ; List < ValueData > values = new ArrayList < ValueData > ( mixinTypes . length + 1 ) ; for ( int i = 0 ; i < mixinTypes . length ; i ++ ) { InternalQName cn = mixinTypes [ i ] ; newMixin . add ( cn ) ; values . add ( new TransientValueData ( cn ) ) ; } newMixin . add ( type . getName ( ) ) ; values . add ( new TransientValueData ( type . getName ( ) ) ) ; PropertyData prop = ( PropertyData ) dataManager . getItemData ( ( ( NodeData ) getData ( ) ) , new QPathEntry ( Constants . JCR_MIXINTYPES , 0 ) , ItemType . PROPERTY , false ) ; ItemState state ; if ( prop != null ) { prop = new TransientPropertyData ( prop . getQPath ( ) , prop . getIdentifier ( ) , prop . getPersistedVersion ( ) , prop . getType ( ) , prop . getParentIdentifier ( ) , prop . isMultiValued ( ) , values ) ; state = ItemState . createUpdatedState ( prop ) ; } else { prop = TransientPropertyData . createPropertyData ( this . nodeData ( ) , Constants . JCR_MIXINTYPES , PropertyType . NAME , true , values ) ; state = ItemState . createAddedState ( prop ) ; } NodeTypeDataManager ntmanager = session . getWorkspace ( ) . getNodeTypesHolder ( ) ; for ( PropertyDefinitionData def : ntmanager . getAllPropertyDefinitions ( type . getName ( ) ) ) { if ( ntmanager . isNodeType ( Constants . EXO_OWNEABLE , new InternalQName [ ] { type . getName ( ) } ) && def . getName ( ) . equals ( Constants . EXO_OWNER ) ) { AccessControlList acl = new AccessControlList ( session . getUserID ( ) , ( ( NodeData ) data ) . getACL ( ) . getPermissionEntries ( ) ) ; setACL ( acl ) ; } } updateMixin ( newMixin ) ; dataManager . update ( state , false ) ; ItemAutocreator itemAutocreator = new ItemAutocreator ( ntmanager , valueFactory , dataManager , false ) ; PlainChangesLog changes = itemAutocreator . makeAutoCreatedItems ( nodeData ( ) , type . getName ( ) , dataManager , session . getUserID ( ) ) ; for ( ItemState autoCreatedState : changes . getAllStates ( ) ) { dataManager . update ( autoCreatedState , false ) ; } session . getActionHandler ( ) . postAddMixin ( this , type . getName ( ) ) ; if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "Node.addMixin Property " + prop . getQPath ( ) . getAsString ( ) + " values " + mixinTypes . length ) ; } }
Internal method to add mixin Nodetype to the Node .
15,665
protected NodeData getCorrespondingNodeData ( SessionImpl corrSession ) throws ItemNotFoundException , AccessDeniedException , RepositoryException { final QPath myPath = nodeData ( ) . getQPath ( ) ; final SessionDataManager corrDataManager = corrSession . getTransientNodesManager ( ) ; if ( this . isNodeType ( Constants . MIX_REFERENCEABLE ) ) { NodeData corrNode = ( NodeData ) corrDataManager . getItemData ( getUUID ( ) ) ; if ( corrNode != null ) { return corrNode ; } } else { NodeData ancestor = ( NodeData ) dataManager . getItemData ( Constants . ROOT_UUID ) ; for ( int i = 1 ; i < myPath . getDepth ( ) ; i ++ ) { ancestor = ( NodeData ) dataManager . getItemData ( ancestor , myPath . getEntries ( ) [ i ] , ItemType . NODE ) ; if ( corrSession . getWorkspace ( ) . getNodeTypesHolder ( ) . isNodeType ( Constants . MIX_REFERENCEABLE , ancestor . getPrimaryTypeName ( ) , ancestor . getMixinTypeNames ( ) ) ) { NodeData corrAncestor = ( NodeData ) corrDataManager . getItemData ( ancestor . getIdentifier ( ) ) ; if ( corrAncestor == null ) { throw new ItemNotFoundException ( "No corresponding path for ancestor " + ancestor . getQPath ( ) . getAsString ( ) + " in " + corrSession . getWorkspace ( ) . getName ( ) ) ; } NodeData corrNode = ( NodeData ) corrDataManager . getItemData ( corrAncestor , myPath . getRelPath ( myPath . getDepth ( ) - i ) , ItemType . NODE ) ; if ( corrNode != null ) { return corrNode ; } } } } NodeData corrNode = ( NodeData ) corrDataManager . getItemData ( myPath ) ; if ( corrNode != null ) { return corrNode ; } throw new ItemNotFoundException ( "No corresponding path for " + getPath ( ) + " in " + corrSession . getWorkspace ( ) . getName ( ) ) ; }
Return Node corresponding to this Node .
15,666
public String [ ] getMixinTypeNames ( ) throws RepositoryException { NodeType [ ] mixinTypes = getMixinNodeTypes ( ) ; String [ ] mtNames = new String [ mixinTypes . length ] ; for ( int i = 0 ; i < mtNames . length ; i ++ ) { mtNames [ i ] = mixinTypes [ i ] . getName ( ) ; } return mtNames ; }
Return mixin Nodetype names .
15,667
private void initDefinition ( NodeData parent ) throws RepositoryException , ConstraintViolationException { if ( this . isRoot ( ) ) { this . definition = new NodeDefinitionData ( null , null , true , true , OnParentVersionAction . ABORT , true , new InternalQName [ ] { Constants . NT_BASE } , null , false ) ; return ; } if ( parent == null ) { parent = ( NodeData ) dataManager . getItemData ( getParentIdentifier ( ) ) ; } this . definition = session . getWorkspace ( ) . getNodeTypesHolder ( ) . getChildNodeDefinition ( getInternalName ( ) , nodeData ( ) . getPrimaryTypeName ( ) , parent . getPrimaryTypeName ( ) , parent . getMixinTypeNames ( ) ) ; if ( definition == null ) { throw new ConstraintViolationException ( "Node definition not found for " + getPath ( ) ) ; } }
Init NodeDefinition .
15,668
public VersionHistoryImpl versionHistory ( boolean pool ) throws UnsupportedRepositoryOperationException , RepositoryException { if ( ! this . isNodeType ( Constants . MIX_VERSIONABLE ) ) { throw new UnsupportedRepositoryOperationException ( "Node is not mix:versionable " + getPath ( ) ) ; } PropertyData vhProp = ( PropertyData ) dataManager . getItemData ( nodeData ( ) , new QPathEntry ( Constants . JCR_VERSIONHISTORY , 1 ) , ItemType . PROPERTY ) ; if ( vhProp == null ) { throw new UnsupportedRepositoryOperationException ( "Node does not have jcr:versionHistory " + getPath ( ) ) ; } return ( VersionHistoryImpl ) dataManager . getItemByIdentifier ( ValueDataUtil . getString ( vhProp . getValues ( ) . get ( 0 ) ) , pool , false ) ; }
For internal use . Doesn t check the InvalidItemStateException and may return unpooled VersionHistory object .
15,669
private List < PropertyData > childPropertiesData ( ) throws RepositoryException , AccessDeniedException { List < PropertyData > storedProps = new ArrayList < PropertyData > ( dataManager . getChildPropertiesData ( nodeData ( ) ) ) ; Collections . sort ( storedProps , new PropertiesDataOrderComparator < PropertyData > ( ) ) ; return storedProps ; }
Return child Properties list .
15,670
private List < NodeData > childNodesData ( ) throws RepositoryException , AccessDeniedException { List < NodeData > storedNodes = new ArrayList < NodeData > ( dataManager . getChildNodesData ( nodeData ( ) ) ) ; Collections . sort ( storedNodes , new NodeDataOrderComparator ( ) ) ; return storedNodes ; }
Return child Nodes list .
15,671
private int getNextChildIndex ( InternalQName nameToAdd , InternalQName primaryTypeName , NodeData parentNode , NodeDefinitionData def ) throws RepositoryException , ItemExistsException { boolean allowSns = def . isAllowsSameNameSiblings ( ) ; int ind = 1 ; boolean hasSibling = dataManager . hasItemData ( parentNode , new QPathEntry ( nameToAdd , ind ) , ItemType . NODE ) ; while ( hasSibling ) { if ( allowSns ) { ind ++ ; hasSibling = dataManager . hasItemData ( parentNode , new QPathEntry ( nameToAdd , ind ) , ItemType . NODE ) ; } else { throw new ItemExistsException ( "The node " + nameToAdd + " already exists in " + getPath ( ) + " and same name sibling is not allowed " ) ; } } ; return ind ; }
Calculates next child node index . Is used existed node definition if no - get one based on node name and node type .
15,672
protected boolean accept ( Node node ) { try { return status == UserStatus . ANY || status . matches ( node . canAddMixin ( JCROrganizationServiceImpl . JOS_DISABLED ) ) ; } catch ( RepositoryException e ) { if ( LOG . isDebugEnabled ( ) ) { String path = "unknown" ; try { path = node . getPath ( ) ; } catch ( RepositoryException e1 ) { LOG . debug ( "Could not get the node of the node: " + node , e1 ) ; } LOG . debug ( "Could not know if the mixin type " + JCROrganizationServiceImpl . JOS_DISABLED + " has been added to the node " + path , e ) ; } return true ; } }
Tests whether or not the specified node should be included in the node list .
15,673
public String getPositionSegment ( ) { HierarchicalProperty position = member . getChild ( new QName ( "DAV:" , "position" ) ) ; return position . getChild ( 0 ) . getChild ( new QName ( "DAV:" , "segment" ) ) . getValue ( ) ; }
Position segment getter .
15,674
public Response copy ( Session destSession , String sourcePath , String destPath ) { try { Workspace workspace = destSession . getWorkspace ( ) ; workspace . copy ( sourcePath , destPath ) ; if ( itemExisted ) { return Response . noContent ( ) . build ( ) ; } else { if ( uriBuilder != null ) { return Response . created ( uriBuilder . path ( workspace . getName ( ) ) . path ( destPath ) . build ( ) ) . build ( ) ; } return Response . status ( HTTPStatus . CREATED ) . build ( ) ; } } catch ( ItemExistsException e ) { return Response . status ( HTTPStatus . METHOD_NOT_ALLOWED ) . entity ( e . getMessage ( ) ) . build ( ) ; } catch ( PathNotFoundException e ) { return Response . status ( HTTPStatus . CONFLICT ) . entity ( e . getMessage ( ) ) . build ( ) ; } catch ( AccessDeniedException e ) { return Response . status ( HTTPStatus . FORBIDDEN ) . entity ( e . getMessage ( ) ) . build ( ) ; } catch ( LockException e ) { return Response . status ( HTTPStatus . LOCKED ) . entity ( e . getMessage ( ) ) . build ( ) ; } catch ( RepositoryException e ) { log . error ( e . getMessage ( ) , e ) ; return Response . serverError ( ) . entity ( e . getMessage ( ) ) . build ( ) ; } }
Webdav COPY method implementation for the same workspace .
15,675
public void execute ( ) throws IOException { Runtime run = Runtime . getRuntime ( ) ; try { String command ; if ( excludeDir != null && ! excludeDir . isEmpty ( ) ) { command = "rsync -rv --delete --exclude " + excludeDir + " " + src + " " + dst ; } else { command = "rsync -rv --delete " + src + " " + dst ; } if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "Rsync job started: " + command ) ; } if ( userName != null && password != null ) { String [ ] envProperties = new String [ ] { RSYNC_USER_SYSTEM_PROPERTY + "=" + userName , RSYNC_PASSWORD_SYSTEM_PROPERTY + "=" + password } ; process = run . exec ( command , envProperties ) ; } else { process = run . exec ( command ) ; } InputStream stderr = process . getErrorStream ( ) ; InputStreamReader isrErr = new InputStreamReader ( stderr ) ; BufferedReader brErr = new BufferedReader ( isrErr ) ; InputStream stdout = process . getInputStream ( ) ; InputStreamReader isrStd = new InputStreamReader ( stdout ) ; BufferedReader brStd = new BufferedReader ( isrStd ) ; String val = null ; StringBuilder stringBuilderErr = new StringBuilder ( ) ; StringBuilder stringBuilderStd = new StringBuilder ( ) ; while ( ( val = brStd . readLine ( ) ) != null ) { stringBuilderStd . append ( val ) ; stringBuilderStd . append ( '\n' ) ; } while ( ( val = brErr . readLine ( ) ) != null ) { stringBuilderErr . append ( val ) ; stringBuilderErr . append ( '\n' ) ; } Integer returnCode = null ; while ( returnCode == null ) { try { returnCode = process . waitFor ( ) ; } catch ( InterruptedException e ) { } } if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "Rsync job finished: " + returnCode + ". Error stream output \n" + stringBuilderErr . toString ( ) + " Standard stream output \n" + stringBuilderStd . toString ( ) ) ; } if ( returnCode != 0 ) { throw new IOException ( "RSync job finished with exit code is " + returnCode + ". Error stream output: \n" + stringBuilderErr . toString ( ) ) ; } } finally { process = null ; } }
Executes RSYNC synchronization job
15,676
private List < ValueData > parseValues ( ) throws RepositoryException { List < ValueData > values = new ArrayList < ValueData > ( propertyInfo . getValuesSize ( ) ) ; List < String > stringValues = new ArrayList < String > ( ) ; for ( int k = 0 ; k < propertyInfo . getValuesSize ( ) ; k ++ ) { if ( propertyInfo . getType ( ) == PropertyType . BINARY ) { try { InputStream vStream = propertyInfo . getValues ( ) . get ( k ) . getInputStream ( ) ; TransientValueData binaryValue = new TransientValueData ( k , vStream , null , valueFactory . getSpoolConfig ( ) ) ; binaryValue . getAsStream ( ) . close ( ) ; vStream . close ( ) ; propertyInfo . getValues ( ) . get ( k ) . remove ( ) ; values . add ( binaryValue ) ; } catch ( IOException e ) { throw new RepositoryException ( e ) ; } } else { String val = new String ( propertyInfo . getValues ( ) . get ( k ) . toString ( ) ) ; stringValues . add ( val ) ; values . add ( ( ( BaseValue ) valueFactory . createValue ( val , propertyInfo . getType ( ) ) ) . getInternalData ( ) ) ; } } if ( propertyInfo . getType ( ) == ExtendedPropertyType . PERMISSION ) { ImportNodeData currentNodeInfo = ( ImportNodeData ) getParent ( ) ; currentNodeInfo . setExoPrivileges ( stringValues ) ; } else if ( Constants . EXO_OWNER . equals ( propertyInfo . getName ( ) ) ) { ImportNodeData currentNodeInfo = ( ImportNodeData ) getParent ( ) ; currentNodeInfo . setExoOwner ( stringValues . get ( 0 ) ) ; } return values ; }
Returns the list of ValueData for current property
15,677
protected String getAttribute ( Map < String , String > attributes , InternalQName name ) throws RepositoryException { JCRName jname = locationFactory . createJCRName ( name ) ; return attributes . get ( jname . getAsString ( ) ) ; }
Returns the value of the named XML attribute .
15,678
protected void suspendRepository ( ) throws RepositoryException { SecurityHelper . validateSecurityPermission ( JCRRuntimePermissions . MANAGE_REPOSITORY_PERMISSION ) ; repository . setState ( ManageableRepository . SUSPENDED ) ; }
Suspend repository which means that allow only read operations . All writing threads will wait until resume operations invoked .
15,679
protected void resumeRepository ( ) throws RepositoryException { SecurityHelper . validateSecurityPermission ( JCRRuntimePermissions . MANAGE_REPOSITORY_PERMISSION ) ; repository . setState ( ManageableRepository . ONLINE ) ; }
Resume repository . All previously suspended threads continue working .
15,680
public static long getLength ( ValueData value , int propType ) { if ( propType == PropertyType . BINARY ) { return value . getLength ( ) ; } else if ( propType == PropertyType . NAME || propType == PropertyType . PATH ) { return - 1 ; } else { return value . toString ( ) . length ( ) ; } }
Returns length of the internal value .
15,681
public void recreateEntry ( final SessionProvider sessionProvider , final String groupPath , final RegistryEntry entry ) throws RepositoryException { final String entryRelPath = EXO_REGISTRY + "/" + groupPath + "/" + entry . getName ( ) ; final String parentFullPath = "/" + EXO_REGISTRY + "/" + groupPath ; try { Session session = session ( sessionProvider , repositoryService . getCurrentRepository ( ) ) ; Node node = session . getRootNode ( ) . getNode ( entryRelPath ) ; node . remove ( ) ; session . importXML ( parentFullPath , entry . getAsInputStream ( ) , IMPORT_UUID_CREATE_NEW ) ; session . save ( ) ; } catch ( IOException ioe ) { throw new RepositoryException ( "Item " + parentFullPath + "can't be created " + ioe ) ; } catch ( TransformerException te ) { throw new RepositoryException ( "Can't get XML representation from stream " + te ) ; } }
Re - creates an entry in the group .
15,682
public void initRegistryEntry ( String groupName , String entryName ) throws RepositoryException , RepositoryConfigurationException { String relPath = EXO_REGISTRY + "/" + groupName + "/" + entryName ; for ( RepositoryEntry repConfiguration : repConfigurations ( ) ) { String repName = repConfiguration . getName ( ) ; SessionProvider sysProvider = SessionProvider . createSystemProvider ( ) ; Node root = session ( sysProvider , repositoryService . getRepository ( repName ) ) . getRootNode ( ) ; if ( ! root . hasNode ( relPath ) ) { root . addNode ( relPath , EXO_REGISTRYENTRY_NT ) ; root . save ( ) ; } else { LOG . info ( "The RegistryEntry " + relPath + "is already initialized on repository " + repName ) ; } sysProvider . close ( ) ; } }
Initializes the registry entry
15,683
public boolean getForceXMLConfigurationValue ( InitParams initParams ) { ValueParam valueParam = initParams . getValueParam ( "force-xml-configuration" ) ; return ( valueParam != null ? Boolean . valueOf ( valueParam . getValue ( ) ) : false ) ; }
Get value of force - xml - configuration param .
15,684
private void checkGroup ( final SessionProvider sessionProvider , final String groupPath ) throws RepositoryException { String [ ] groupNames = groupPath . split ( "/" ) ; String prefix = "/" + EXO_REGISTRY ; Session session = session ( sessionProvider , repositoryService . getCurrentRepository ( ) ) ; for ( String name : groupNames ) { String path = prefix + "/" + name ; try { Node group = ( Node ) session . getItem ( path ) ; if ( ! group . isNodeType ( EXO_REGISTRYGROUP_NT ) ) throw new RepositoryException ( "Node at " + path + " should be " + EXO_REGISTRYGROUP_NT + " type" ) ; } catch ( PathNotFoundException e ) { Node parent = ( Node ) session . getItem ( prefix ) ; parent . addNode ( name , EXO_REGISTRYGROUP_NT ) ; parent . save ( ) ; } prefix = path ; } }
check if group exists and creates one if necessary
15,685
private PlainChangesLog makeAutoCreatedItems ( final NodeData parent , final InternalQName nodeTypeName , final ItemDataConsumer targetDataManager , final String owner , boolean addedAutoCreatedNodes ) throws RepositoryException { final PlainChangesLogImpl changes = new PlainChangesLogImpl ( ) ; final NodeTypeData type = nodeTypeDataManager . getNodeType ( nodeTypeName ) ; changes . addAll ( makeAutoCreatedProperties ( parent , nodeTypeName , nodeTypeDataManager . getAllPropertyDefinitions ( nodeTypeName ) , targetDataManager , owner ) . getAllStates ( ) ) ; changes . addAll ( makeAutoCreatedNodes ( parent , nodeTypeName , nodeTypeDataManager . getAllChildNodeDefinitions ( nodeTypeName ) , targetDataManager , owner ) . getAllStates ( ) ) ; if ( nodeTypeDataManager . isNodeType ( Constants . MIX_VERSIONABLE , new InternalQName [ ] { type . getName ( ) } ) ) { changes . addAll ( makeMixVesionableChanges ( parent ) . getAllStates ( ) ) ; } return changes ; }
Prepares changes log
15,686
@ Produces ( MediaType . APPLICATION_JSON ) @ RolesAllowed ( "administrators" ) @ Path ( "/repository-service-configuration" ) public Response getRepositoryServiceConfiguration ( ) { RepositoryServiceConfiguration configuration = repositoryService . getConfig ( ) ; RepositoryServiceConf conf = new RepositoryServiceConf ( configuration . getRepositoryConfigurations ( ) , configuration . getDefaultRepositoryName ( ) ) ; return Response . ok ( conf , MediaType . APPLICATION_JSON_TYPE ) . cacheControl ( NO_CACHE ) . build ( ) ; }
Gives the repository service configuration which is composed of the configuration of all the repositories and workspaces
15,687
@ Produces ( MediaType . APPLICATION_JSON ) @ RolesAllowed ( "administrators" ) @ Path ( "/default-ws-config/{repositoryName}" ) public Response getDefaultWorkspaceConfig ( @ PathParam ( "repositoryName" ) String repositoryName ) { String errorMessage = new String ( ) ; Status status ; try { String defaultWorkspaceName = repositoryService . getRepository ( repositoryName ) . getConfiguration ( ) . getDefaultWorkspaceName ( ) ; for ( WorkspaceEntry wEntry : repositoryService . getRepository ( repositoryName ) . getConfiguration ( ) . getWorkspaceEntries ( ) ) { if ( defaultWorkspaceName . equals ( wEntry . getName ( ) ) ) { return Response . ok ( wEntry ) . cacheControl ( NO_CACHE ) . build ( ) ; } } return Response . status ( Response . Status . NOT_FOUND ) . entity ( "Can not get default workspace configuration." ) . type ( MediaType . TEXT_PLAIN ) . cacheControl ( NO_CACHE ) . build ( ) ; } catch ( RepositoryException e ) { if ( log . isDebugEnabled ( ) ) { log . error ( e . getMessage ( ) , e ) ; } errorMessage = e . getMessage ( ) ; status = Status . NOT_FOUND ; } catch ( Throwable e ) { if ( log . isDebugEnabled ( ) ) { log . error ( e . getMessage ( ) , e ) ; } errorMessage = e . getMessage ( ) ; status = Status . INTERNAL_SERVER_ERROR ; } return Response . status ( status ) . entity ( errorMessage ) . type ( MediaType . TEXT_PLAIN_TYPE ) . cacheControl ( NO_CACHE ) . build ( ) ; }
Gives the configuration of the default workspace of the given repository
15,688
@ Produces ( MediaType . APPLICATION_JSON ) @ RolesAllowed ( "administrators" ) @ Path ( "/repositories" ) public Response getRepositoryNames ( ) { List < String > repositories = new ArrayList < String > ( ) ; for ( RepositoryEntry rEntry : repositoryService . getConfig ( ) . getRepositoryConfigurations ( ) ) { repositories . add ( rEntry . getName ( ) ) ; } return Response . ok ( new NamesList ( repositories ) ) . cacheControl ( NO_CACHE ) . build ( ) ; }
Gives the name of all the existing repositories .
15,689
@ Produces ( MediaType . APPLICATION_JSON ) @ RolesAllowed ( "administrators" ) @ Path ( "/workspaces/{repositoryName}" ) public Response getWorkspaceNames ( @ PathParam ( "repositoryName" ) String repositoryName ) { String errorMessage = new String ( ) ; Status status ; try { List < String > workspaces = new ArrayList < String > ( ) ; for ( WorkspaceEntry wEntry : repositoryService . getRepository ( repositoryName ) . getConfiguration ( ) . getWorkspaceEntries ( ) ) { workspaces . add ( wEntry . getName ( ) ) ; } return Response . ok ( new NamesList ( workspaces ) ) . cacheControl ( NO_CACHE ) . build ( ) ; } catch ( RepositoryException e ) { if ( log . isDebugEnabled ( ) ) { log . error ( e . getMessage ( ) , e ) ; } errorMessage = e . getMessage ( ) ; status = Status . NOT_FOUND ; } catch ( Throwable e ) { if ( log . isDebugEnabled ( ) ) { log . error ( e . getMessage ( ) , e ) ; } errorMessage = e . getMessage ( ) ; status = Status . INTERNAL_SERVER_ERROR ; } return Response . status ( status ) . entity ( errorMessage ) . type ( MediaType . TEXT_PLAIN_TYPE ) . cacheControl ( NO_CACHE ) . build ( ) ; }
Gives the name of all the existing workspaces for a given repository .
15,690
@ Consumes ( MediaType . APPLICATION_JSON ) @ RolesAllowed ( "administrators" ) @ Path ( "/update-workspace-config/{repositoryName}/{workspaceName}" ) public Response updateWorkspaceConfiguration ( @ PathParam ( "repositoryName" ) String repositoryName , @ PathParam ( "workspaceName" ) String workspaceName , WorkspaceEntry workspaceEntry ) { return Response . status ( Status . OK ) . entity ( "The method /update-workspace-config not implemented." ) . type ( MediaType . TEXT_PLAIN_TYPE ) . cacheControl ( NO_CACHE ) . build ( ) ; }
Updates the configuration of a given workspace .
15,691
private String setProperty ( Node node , HierarchicalProperty property ) { String propertyName = WebDavNamespaceContext . createName ( property . getName ( ) ) ; if ( READ_ONLY_PROPS . contains ( property . getName ( ) ) ) { return WebDavConst . getStatusDescription ( HTTPStatus . CONFLICT ) ; } try { Workspace ws = node . getSession ( ) . getWorkspace ( ) ; NodeTypeDataManager nodeTypeHolder = ( ( WorkspaceImpl ) ws ) . getNodeTypesHolder ( ) ; NodeData data = ( NodeData ) ( ( NodeImpl ) node ) . getData ( ) ; InternalQName propName = ( ( SessionImpl ) node . getSession ( ) ) . getLocationFactory ( ) . parseJCRName ( propertyName ) . getInternalName ( ) ; PropertyDefinitionDatas propdefs = nodeTypeHolder . getPropertyDefinitions ( propName , data . getPrimaryTypeName ( ) , data . getMixinTypeNames ( ) ) ; if ( propdefs == null ) { throw new RepositoryException ( ) ; } PropertyDefinitionData propertyDefinitionData = propdefs . getAnyDefinition ( ) ; if ( propertyDefinitionData == null ) { throw new RepositoryException ( ) ; } boolean isMultiValued = propertyDefinitionData . isMultiple ( ) ; if ( node . isNodeType ( WebDavConst . NodeTypes . MIX_VERSIONABLE ) && ! node . isCheckedOut ( ) ) { node . checkout ( ) ; node . save ( ) ; } if ( ! isMultiValued ) { node . setProperty ( propertyName , property . getValue ( ) ) ; } else { String [ ] value = new String [ 1 ] ; value [ 0 ] = property . getValue ( ) ; node . setProperty ( propertyName , value ) ; } node . save ( ) ; return WebDavConst . getStatusDescription ( HTTPStatus . OK ) ; } catch ( AccessDeniedException e ) { return WebDavConst . getStatusDescription ( HTTPStatus . FORBIDDEN ) ; } catch ( ItemNotFoundException e ) { return WebDavConst . getStatusDescription ( HTTPStatus . NOT_FOUND ) ; } catch ( PathNotFoundException e ) { return WebDavConst . getStatusDescription ( HTTPStatus . NOT_FOUND ) ; } catch ( RepositoryException e ) { return WebDavConst . getStatusDescription ( HTTPStatus . CONFLICT ) ; } }
Sets changes the property value .
15,692
private String removeProperty ( Node node , HierarchicalProperty property ) { try { node . getProperty ( property . getStringName ( ) ) . remove ( ) ; node . save ( ) ; return WebDavConst . getStatusDescription ( HTTPStatus . OK ) ; } catch ( AccessDeniedException e ) { return WebDavConst . getStatusDescription ( HTTPStatus . FORBIDDEN ) ; } catch ( ItemNotFoundException e ) { return WebDavConst . getStatusDescription ( HTTPStatus . NOT_FOUND ) ; } catch ( PathNotFoundException e ) { return WebDavConst . getStatusDescription ( HTTPStatus . NOT_FOUND ) ; } catch ( RepositoryException e ) { return WebDavConst . getStatusDescription ( HTTPStatus . CONFLICT ) ; } }
Removes the property .
15,693
public Response head ( Session session , String path , String baseURI ) { try { Node node = ( Node ) session . getItem ( path ) ; WebDavNamespaceContext nsContext = new WebDavNamespaceContext ( session ) ; URI uri = new URI ( TextUtil . escape ( baseURI + node . getPath ( ) , '%' , true ) ) ; if ( ResourceUtil . isFile ( node ) ) { Resource resource = new FileResource ( uri , node , nsContext ) ; String lastModified = resource . getProperty ( PropertyConstants . GETLASTMODIFIED ) . getValue ( ) ; String contentType = resource . getProperty ( PropertyConstants . GETCONTENTTYPE ) . getValue ( ) ; String contentLength = resource . getProperty ( PropertyConstants . GETCONTENTLENGTH ) . getValue ( ) ; return Response . ok ( ) . header ( ExtHttpHeaders . LAST_MODIFIED , lastModified ) . header ( ExtHttpHeaders . CONTENT_TYPE , contentType ) . header ( ExtHttpHeaders . CONTENT_LENGTH , contentLength ) . build ( ) ; } return Response . ok ( ) . build ( ) ; } catch ( PathNotFoundException exc ) { return Response . status ( HTTPStatus . NOT_FOUND ) . entity ( exc . getMessage ( ) ) . build ( ) ; } catch ( Exception exc ) { LOG . error ( exc . getMessage ( ) , exc ) ; return Response . serverError ( ) . entity ( exc . getMessage ( ) ) . build ( ) ; } }
Webdav Head method implementation .
15,694
public void remove ( ItemState item ) { if ( item . isNode ( ) ) { remove ( item . getData ( ) . getQPath ( ) ) ; } else { removeProperty ( item , - 1 ) ; } }
Removes the property or node and all descendants from the log
15,695
public void remove ( QPath rootPath ) { for ( int i = items . size ( ) - 1 ; i >= 0 ; i -- ) { ItemState item = items . get ( i ) ; QPath qPath = item . getData ( ) . getQPath ( ) ; if ( qPath . isDescendantOf ( rootPath ) || item . getAncestorToSave ( ) . isDescendantOf ( rootPath ) || item . getAncestorToSave ( ) . equals ( rootPath ) || qPath . equals ( rootPath ) ) { if ( item . isNode ( ) ) { removeNode ( item , i ) ; } else { removeProperty ( item , i ) ; } } } }
Removes the item at the rootPath and all descendants from the log
15,696
private void removeNode ( ItemState item , int indexItem ) { items . remove ( indexItem ) ; index . remove ( item . getData ( ) . getIdentifier ( ) ) ; index . remove ( item . getData ( ) . getQPath ( ) ) ; index . remove ( new ParentIDQPathBasedKey ( item ) ) ; index . remove ( new IDStateBasedKey ( item . getData ( ) . getIdentifier ( ) , item . getState ( ) ) ) ; childNodesInfo . remove ( item . getData ( ) . getIdentifier ( ) ) ; lastChildNodeStates . remove ( item . getData ( ) . getIdentifier ( ) ) ; childNodeStates . remove ( item . getData ( ) . getIdentifier ( ) ) ; if ( allPathsChanged != null && item . isPathChanged ( ) ) { allPathsChanged . remove ( item ) ; if ( allPathsChanged . isEmpty ( ) ) allPathsChanged = null ; } if ( item . isPersisted ( ) ) { int childInfo [ ] = childNodesInfo . get ( item . getData ( ) . getParentIdentifier ( ) ) ; if ( childInfo != null ) { if ( item . isDeleted ( ) ) { ++ childInfo [ CHILD_NODES_COUNT ] ; } else if ( item . isAdded ( ) ) { -- childInfo [ CHILD_NODES_COUNT ] ; } childNodesInfo . put ( item . getData ( ) . getParentIdentifier ( ) , childInfo ) ; } } Map < String , ItemState > children = lastChildNodeStates . get ( item . getData ( ) . getParentIdentifier ( ) ) ; if ( children != null ) { children . remove ( item . getData ( ) . getIdentifier ( ) ) ; if ( children . isEmpty ( ) ) { lastChildNodeStates . remove ( item . getData ( ) . getParentIdentifier ( ) ) ; } } List < ItemState > listItemStates = childNodeStates . get ( item . getData ( ) . getParentIdentifier ( ) ) ; if ( listItemStates != null ) { listItemStates . remove ( item ) ; if ( listItemStates . isEmpty ( ) ) { childNodeStates . remove ( item . getData ( ) . getParentIdentifier ( ) ) ; } } if ( ( children == null || children . isEmpty ( ) ) && ( listItemStates == null || listItemStates . isEmpty ( ) ) ) { childNodesInfo . remove ( item . getData ( ) . getParentIdentifier ( ) ) ; } }
Removes the node from the log
15,697
private void removeProperty ( ItemState item , int indexItem ) { if ( indexItem == - 1 ) { items . remove ( item ) ; } else { items . remove ( indexItem ) ; } index . remove ( item . getData ( ) . getIdentifier ( ) ) ; index . remove ( item . getData ( ) . getQPath ( ) ) ; index . remove ( new ParentIDQPathBasedKey ( item ) ) ; index . remove ( new IDStateBasedKey ( item . getData ( ) . getIdentifier ( ) , item . getState ( ) ) ) ; lastChildPropertyStates . remove ( item . getData ( ) . getIdentifier ( ) ) ; childPropertyStates . remove ( item . getData ( ) . getIdentifier ( ) ) ; Map < String , ItemState > children = lastChildPropertyStates . get ( item . getData ( ) . getParentIdentifier ( ) ) ; if ( children != null ) { children . remove ( item . getData ( ) . getIdentifier ( ) ) ; if ( children . isEmpty ( ) ) { lastChildPropertyStates . remove ( item . getData ( ) . getParentIdentifier ( ) ) ; } } List < ItemState > listItemStates = childPropertyStates . get ( item . getData ( ) . getParentIdentifier ( ) ) ; if ( listItemStates != null ) { listItemStates . remove ( item ) ; if ( listItemStates . isEmpty ( ) ) { childPropertyStates . remove ( item . getData ( ) . getParentIdentifier ( ) ) ; } } }
Removes the property from the log
15,698
public Collection < ItemState > getLastChildrenStates ( ItemData rootData , boolean forNodes ) { Map < String , ItemState > children = forNodes ? lastChildNodeStates . get ( rootData . getIdentifier ( ) ) : lastChildPropertyStates . get ( rootData . getIdentifier ( ) ) ; return children == null ? new ArrayList < ItemState > ( ) : children . values ( ) ; }
Collect last in ChangesLog order item child changes .
15,699
public ItemState getLastState ( ItemData item , boolean forNode ) { Map < String , ItemState > children = forNode ? lastChildNodeStates . get ( item . getParentIdentifier ( ) ) : lastChildPropertyStates . get ( item . getParentIdentifier ( ) ) ; return children == null ? null : children . get ( item . getIdentifier ( ) ) ; }
Return the last item state from ChangesLog .