idx int64 0 165k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
15,400 | public QPath getRemainder ( ) { if ( matchPos + matchLength >= pathLength ) { return null ; } else { try { throw new RepositoryException ( "Not implemented" ) ; } catch ( RepositoryException e ) { throw ( IllegalStateException ) new IllegalStateException ( "Path not normalized" ) . initCause ( e ) ; } } } | Returns the remaining path after the matching part . |
15,401 | private void calculateDocFilter ( ) throws IOException { PerQueryCache cache = PerQueryCache . getInstance ( ) ; @ SuppressWarnings ( "unchecked" ) Map < String , BitSet > readerCache = ( Map < String , BitSet > ) cache . get ( MatchAllScorer . class , reader ) ; if ( readerCache == null ) { readerCache = new HashMap < String , BitSet > ( ) ; cache . put ( MatchAllScorer . class , reader , readerCache ) ; } docFilter = ( BitSet ) readerCache . get ( field ) ; if ( docFilter != null ) { return ; } docFilter = new BitSet ( reader . maxDoc ( ) ) ; String namedValue = FieldNames . createNamedValue ( field , "" ) ; TermEnum terms = reader . terms ( new Term ( FieldNames . PROPERTIES , namedValue ) ) ; try { TermDocs docs = reader . termDocs ( ) ; try { while ( terms . term ( ) != null && terms . term ( ) . field ( ) == FieldNames . PROPERTIES && terms . term ( ) . text ( ) . startsWith ( namedValue ) ) { docs . seek ( terms ) ; while ( docs . next ( ) ) { docFilter . set ( docs . doc ( ) ) ; } terms . next ( ) ; } } finally { docs . close ( ) ; } } finally { terms . close ( ) ; } readerCache . put ( field , docFilter ) ; } | Calculates a BitSet filter that includes all the nodes that have content in properties according to the field name passed in the constructor of this MatchAllScorer . |
15,402 | public String [ ] getSynonyms ( String word ) { String [ ] synonyms = table . get ( word ) ; if ( synonyms == null ) return EMPTY ; String [ ] copy = new String [ synonyms . length ] ; System . arraycopy ( synonyms , 0 , copy , 0 , synonyms . length ) ; return copy ; } | Returns the synonym set for the given word sorted ascending . |
15,403 | public static void writePropStats ( XMLStreamWriter xmlStreamWriter , Map < String , Set < HierarchicalProperty > > propStatuses ) throws XMLStreamException { for ( Map . Entry < String , Set < HierarchicalProperty > > stat : propStatuses . entrySet ( ) ) { xmlStreamWriter . writeStartElement ( "DAV:" , "propstat" ) ; xmlStreamWriter . writeStartElement ( "DAV:" , "prop" ) ; for ( HierarchicalProperty prop : propStatuses . get ( stat . getKey ( ) ) ) { writeProperty ( xmlStreamWriter , prop ) ; } xmlStreamWriter . writeEndElement ( ) ; xmlStreamWriter . writeStartElement ( "DAV:" , "status" ) ; xmlStreamWriter . writeCharacters ( stat . getKey ( ) ) ; xmlStreamWriter . writeEndElement ( ) ; xmlStreamWriter . writeEndElement ( ) ; } } | Writes the statuses of properties into XML . |
15,404 | public static void writeProperty ( XMLStreamWriter xmlStreamWriter , HierarchicalProperty prop ) throws XMLStreamException { String uri = prop . getName ( ) . getNamespaceURI ( ) ; String prefix = xmlStreamWriter . getNamespaceContext ( ) . getPrefix ( uri ) ; if ( prefix == null ) { prefix = "" ; } String local = prop . getName ( ) . getLocalPart ( ) ; if ( prop . getValue ( ) == null ) { if ( prop . getChildren ( ) . size ( ) != 0 ) { xmlStreamWriter . writeStartElement ( prefix , local , uri ) ; if ( ! uri . equalsIgnoreCase ( "DAV:" ) ) { xmlStreamWriter . writeNamespace ( prefix , uri ) ; } writeAttributes ( xmlStreamWriter , prop ) ; for ( int i = 0 ; i < prop . getChildren ( ) . size ( ) ; i ++ ) { HierarchicalProperty property = prop . getChildren ( ) . get ( i ) ; writeProperty ( xmlStreamWriter , property ) ; } xmlStreamWriter . writeEndElement ( ) ; } else { xmlStreamWriter . writeEmptyElement ( prefix , local , uri ) ; if ( ! uri . equalsIgnoreCase ( "DAV:" ) ) { xmlStreamWriter . writeNamespace ( prefix , uri ) ; } writeAttributes ( xmlStreamWriter , prop ) ; } } else { xmlStreamWriter . writeStartElement ( prefix , local , uri ) ; if ( ! uri . equalsIgnoreCase ( "DAV:" ) ) { xmlStreamWriter . writeNamespace ( prefix , uri ) ; } writeAttributes ( xmlStreamWriter , prop ) ; xmlStreamWriter . writeCharacters ( prop . getValue ( ) ) ; xmlStreamWriter . writeEndElement ( ) ; } } | Writes the statuses of property into XML . |
15,405 | public static void writeAttributes ( XMLStreamWriter xmlStreamWriter , HierarchicalProperty property ) throws XMLStreamException { Map < String , String > attributes = property . getAttributes ( ) ; Iterator < String > keyIter = attributes . keySet ( ) . iterator ( ) ; while ( keyIter . hasNext ( ) ) { String attrName = keyIter . next ( ) ; String attrValue = attributes . get ( attrName ) ; xmlStreamWriter . writeAttribute ( attrName , attrValue ) ; } } | Writes property attributes into XML . |
15,406 | private String getRealm ( String sUrl ) throws IOException , ModuleException { AuthorizationHandler ah = AuthorizationInfo . getAuthHandler ( ) ; try { URL url = new URL ( sUrl ) ; HTTPConnection connection = new HTTPConnection ( url ) ; connection . removeModule ( CookieModule . class ) ; AuthorizationInfo . setAuthHandler ( null ) ; HTTPResponse resp = connection . Get ( url . getFile ( ) ) ; String authHeader = resp . getHeader ( "WWW-Authenticate" ) ; if ( authHeader == null ) { return null ; } String realm = authHeader . split ( "=" ) [ 1 ] ; realm = realm . substring ( 1 , realm . length ( ) - 1 ) ; return realm ; } finally { AuthorizationInfo . setAuthHandler ( ah ) ; } } | Get realm by URL . |
15,407 | public static String getChecksum ( InputStream in , String algo ) throws NoSuchAlgorithmException , IOException { MessageDigest md = MessageDigest . getInstance ( algo ) ; DigestInputStream digestInputStream = new DigestInputStream ( in , md ) ; digestInputStream . on ( true ) ; while ( digestInputStream . read ( ) > - 1 ) { digestInputStream . read ( ) ; } byte [ ] bytes = digestInputStream . getMessageDigest ( ) . digest ( ) ; return generateString ( bytes ) ; } | Generates checksum for the InputStream . |
15,408 | private static String generateString ( byte [ ] bytes ) { StringBuffer sb = new StringBuffer ( ) ; for ( byte b : bytes ) { int v = b & 0xFF ; sb . append ( ( char ) HEX . charAt ( v >> 4 ) ) ; sb . append ( ( char ) HEX . charAt ( v & 0x0f ) ) ; } return sb . toString ( ) ; } | Converts the array of bytes into a HEX string . |
15,409 | public static void cleanWorkspaceData ( WorkspaceEntry wsEntry ) throws DBCleanException { SecurityHelper . validateSecurityPermission ( JCRRuntimePermissions . MANAGE_REPOSITORY_PERMISSION ) ; Connection jdbcConn = getConnection ( wsEntry ) ; String dialect = resolveDialect ( jdbcConn , wsEntry ) ; boolean autoCommit = dialect . startsWith ( DialectConstants . DB_DIALECT_SYBASE ) ; try { jdbcConn . setAutoCommit ( autoCommit ) ; DBCleanerTool dbCleaner = getWorkspaceDBCleaner ( jdbcConn , wsEntry ) ; doClean ( dbCleaner ) ; } catch ( SQLException e ) { throw new DBCleanException ( e ) ; } finally { try { jdbcConn . close ( ) ; } catch ( SQLException e ) { LOG . error ( "Can not close connection" , e ) ; } } } | Cleans workspace data from database . |
15,410 | public static void cleanRepositoryData ( RepositoryEntry rEntry ) throws DBCleanException { SecurityHelper . validateSecurityPermission ( JCRRuntimePermissions . MANAGE_REPOSITORY_PERMISSION ) ; WorkspaceEntry wsEntry = rEntry . getWorkspaceEntries ( ) . get ( 0 ) ; boolean multiDB = getMultiDbParameter ( wsEntry ) ; if ( multiDB ) { for ( WorkspaceEntry entry : rEntry . getWorkspaceEntries ( ) ) { cleanWorkspaceData ( entry ) ; } } else { Connection jdbcConn = getConnection ( wsEntry ) ; String dialect = resolveDialect ( jdbcConn , wsEntry ) ; boolean autoCommit = dialect . startsWith ( DialectConstants . DB_DIALECT_SYBASE ) ; try { jdbcConn . setAutoCommit ( autoCommit ) ; DBCleanerTool dbCleaner = getRepositoryDBCleaner ( jdbcConn , rEntry ) ; doClean ( dbCleaner ) ; } catch ( SQLException e ) { throw new DBCleanException ( e ) ; } finally { try { jdbcConn . close ( ) ; } catch ( SQLException e ) { LOG . error ( "Can not close connection" , e ) ; } } } } | Cleans repository data from database . |
15,411 | public static DBCleanerTool getRepositoryDBCleaner ( Connection jdbcConn , RepositoryEntry rEntry ) throws DBCleanException { SecurityHelper . validateSecurityPermission ( JCRRuntimePermissions . MANAGE_REPOSITORY_PERMISSION ) ; WorkspaceEntry wsEntry = rEntry . getWorkspaceEntries ( ) . get ( 0 ) ; boolean multiDb = getMultiDbParameter ( wsEntry ) ; if ( multiDb ) { throw new DBCleanException ( "It is not possible to create cleaner with common connection for multi database repository configuration" ) ; } String dialect = resolveDialect ( jdbcConn , wsEntry ) ; boolean autoCommit = dialect . startsWith ( DialectConstants . DB_DIALECT_SYBASE ) ; DBCleaningScripts scripts = DBCleaningScriptsFactory . prepareScripts ( dialect , rEntry ) ; return new DBCleanerTool ( jdbcConn , autoCommit , scripts . getCleaningScripts ( ) , scripts . getCommittingScripts ( ) , scripts . getRollbackingScripts ( ) ) ; } | Returns database cleaner for repository . |
15,412 | public static DBCleanerTool getWorkspaceDBCleaner ( Connection jdbcConn , WorkspaceEntry wsEntry ) throws DBCleanException { SecurityHelper . validateSecurityPermission ( JCRRuntimePermissions . MANAGE_REPOSITORY_PERMISSION ) ; String dialect = resolveDialect ( jdbcConn , wsEntry ) ; boolean autoCommit = dialect . startsWith ( DialectConstants . DB_DIALECT_SYBASE ) ; DBCleaningScripts scripts = DBCleaningScriptsFactory . prepareScripts ( dialect , wsEntry ) ; return new DBCleanerTool ( jdbcConn , autoCommit , scripts . getCleaningScripts ( ) , scripts . getCommittingScripts ( ) , scripts . getRollbackingScripts ( ) ) ; } | Returns database cleaner for workspace . |
15,413 | private static Connection getConnection ( WorkspaceEntry wsEntry ) throws DBCleanException { String dsName = getSourceNameParameter ( wsEntry ) ; DataSource ds ; try { ds = ( DataSource ) new InitialContext ( ) . lookup ( dsName ) ; } catch ( NamingException e ) { throw new DBCleanException ( e ) ; } if ( ds == null ) { throw new DBCleanException ( "Data source " + dsName + " not found" ) ; } final DataSource dsF = ds ; Connection jdbcConn ; try { jdbcConn = SecurityHelper . doPrivilegedSQLExceptionAction ( new PrivilegedExceptionAction < Connection > ( ) { public Connection run ( ) throws Exception { return dsF . getConnection ( ) ; } } ) ; } catch ( SQLException e ) { throw new DBCleanException ( e ) ; } return jdbcConn ; } | Opens connection to database underlying a workspace . |
15,414 | private String hash ( String dataId ) { try { MessageDigest digest = MessageDigest . getInstance ( hashAlgorithm ) ; digest . update ( dataId . getBytes ( "UTF-8" ) ) ; return new BigInteger ( 1 , digest . digest ( ) ) . toString ( 32 ) ; } catch ( NumberFormatException e ) { throw new RuntimeException ( "Could not generate the hash code of '" + dataId + "' with the algorithm '" + hashAlgorithm + "'" , e ) ; } catch ( UnsupportedEncodingException e ) { throw new RuntimeException ( "Could not generate the hash code of '" + dataId + "' with the algorithm '" + hashAlgorithm + "'" , e ) ; } catch ( NoSuchAlgorithmException e ) { throw new RuntimeException ( "Could not generate the hash code of '" + dataId + "' with the algorithm '" + hashAlgorithm + "'" , e ) ; } } | Gives the hash code of the given data id |
15,415 | private QPathEntry parsePatternQPathEntry ( String namePattern , SessionImpl session ) throws RepositoryException { int colonIndex = namePattern . indexOf ( ':' ) ; int bracketIndex = namePattern . lastIndexOf ( '[' ) ; String namespaceURI ; String localName ; int index = getDefaultIndex ( ) ; if ( bracketIndex != - 1 ) { int rbracketIndex = namePattern . lastIndexOf ( ']' ) ; if ( rbracketIndex < bracketIndex ) { throw new RepositoryException ( "Malformed pattern expression " + namePattern ) ; } index = Integer . parseInt ( namePattern . substring ( bracketIndex + 1 , rbracketIndex ) ) ; } if ( colonIndex == - 1 ) { namespaceURI = "" ; localName = ( bracketIndex == - 1 ) ? namePattern : namePattern . substring ( 0 , bracketIndex ) ; } else { String prefix = namePattern . substring ( 0 , colonIndex ) ; localName = ( bracketIndex == - 1 ) ? namePattern . substring ( colonIndex + 1 ) : namePattern . substring ( 0 , bracketIndex ) ; if ( prefix . indexOf ( "*" ) != - 1 ) { namespaceURI = "*" ; } else { namespaceURI = session . getNamespaceURI ( prefix ) ; } } return new PatternQPathEntry ( namespaceURI , localName , index ) ; } | Parse QPathEntry from string namePattern . NamePattern may contain wildcard symbols in namespace and local name . And may not contain index which means look all samename siblings . So ordinary QPathEntry parser is not acceptable . |
15,416 | protected void accumulatePersistedNodesChanges ( Map < String , Long > calculatedChangedNodesSize ) throws QuotaManagerException { for ( Entry < String , Long > entry : calculatedChangedNodesSize . entrySet ( ) ) { String nodePath = entry . getKey ( ) ; long delta = entry . getValue ( ) ; try { long dataSize = delta + quotaPersister . getNodeDataSize ( rName , wsName , nodePath ) ; quotaPersister . setNodeDataSizeIfQuotaExists ( rName , wsName , nodePath , dataSize ) ; } catch ( UnknownDataSizeException e ) { calculateNodeDataSizeTool . getAndSetNodeDataSize ( nodePath ) ; } } } | Update nodes data size . |
15,417 | protected void accumulatePersistedWorkspaceChanges ( long delta ) throws QuotaManagerException { long dataSize = 0 ; try { dataSize = quotaPersister . getWorkspaceDataSize ( rName , wsName ) ; } catch ( UnknownDataSizeException e ) { if ( LOG . isTraceEnabled ( ) ) { LOG . trace ( e . getMessage ( ) , e ) ; } } long newDataSize = Math . max ( dataSize + delta , 0 ) ; quotaPersister . setWorkspaceDataSize ( rName , wsName , newDataSize ) ; } | Update workspace data size . |
15,418 | protected void accumulatePersistedRepositoryChanges ( long delta ) { long dataSize = 0 ; try { dataSize = quotaPersister . getRepositoryDataSize ( rName ) ; } catch ( UnknownDataSizeException e ) { if ( LOG . isTraceEnabled ( ) ) { LOG . trace ( e . getMessage ( ) , e ) ; } } long newDataSize = Math . max ( dataSize + delta , 0 ) ; quotaPersister . setRepositoryDataSize ( rName , newDataSize ) ; } | Update repository data size . |
15,419 | private void accumulatePersistedGlobalChanges ( long delta ) { long dataSize = 0 ; try { dataSize = quotaPersister . getGlobalDataSize ( ) ; } catch ( UnknownDataSizeException e ) { if ( LOG . isTraceEnabled ( ) ) { LOG . trace ( e . getMessage ( ) , e ) ; } } long newDataSize = Math . max ( dataSize + delta , 0 ) ; quotaPersister . setGlobalDataSize ( newDataSize ) ; } | Update global data size . |
15,420 | protected NodeImpl parent ( final boolean pool ) throws RepositoryException { NodeImpl parent = ( NodeImpl ) dataManager . getItemByIdentifier ( getParentIdentifier ( ) , pool ) ; if ( parent == null ) { throw new ItemNotFoundException ( "FATAL: Parent is null for " + getPath ( ) + " parent UUID: " + getParentIdentifier ( ) ) ; } return parent ; } | Get parent node item . |
15,421 | public NodeData parentData ( ) throws RepositoryException { checkValid ( ) ; NodeData parent = ( NodeData ) dataManager . getItemData ( getData ( ) . getParentIdentifier ( ) ) ; if ( parent == null ) { throw new ItemNotFoundException ( "FATAL: Parent is null for " + getPath ( ) + " parent UUID: " + getData ( ) . getParentIdentifier ( ) ) ; } return parent ; } | Get and return parent node data . |
15,422 | public JCRPath getLocation ( ) throws RepositoryException { if ( this . location == null ) { this . location = session . getLocationFactory ( ) . createJCRPath ( qpath ) ; } return this . location ; } | Get item JCRPath location . |
15,423 | public String getType ( ) { if ( input == null ) { return "allprop" ; } if ( input . getChild ( PropertyConstants . DAV_ALLPROP_INCLUDE ) != null ) { return "include" ; } QName name = input . getChild ( 0 ) . getName ( ) ; if ( name . getNamespaceURI ( ) . equals ( "DAV:" ) ) return name . getLocalPart ( ) ; else return null ; } | Returns the type of request . |
15,424 | public R run ( A ... arg ) throws E { final TransactionManager tm = getTransactionManager ( ) ; Transaction tx = null ; try { if ( tm != null ) { try { tx = tm . suspend ( ) ; } catch ( SystemException e ) { LOG . warn ( "Cannot suspend the current transaction" , e ) ; } } return execute ( arg ) ; } finally { if ( tx != null ) { try { tm . resume ( tx ) ; } catch ( Exception e ) { LOG . warn ( "Cannot resume the current transaction" , e ) ; } } } } | Executes the action outside the context of the current tx |
15,425 | protected R execute ( A ... arg ) throws E { if ( arg == null || arg . length == 0 ) { return execute ( ( A ) null ) ; } return execute ( arg [ 0 ] ) ; } | Executes the action |
15,426 | public NodeRepresentation getNodeRepresentation ( Node node , String mediaTypeHint ) throws RepositoryException { NodeRepresentationFactory factory = factory ( node ) ; if ( factory != null ) return factory . createNodeRepresentation ( node , mediaTypeHint ) ; else return new DocumentViewNodeRepresentation ( node ) ; } | Get NodeRepresentation for given node . String mediaTypeHint can be used as external information for representation . By default node will be represented as doc - view . |
15,427 | public void spoolDone ( ) { final CountDownLatch sl = this . spoolLatch . get ( ) ; this . spoolLatch . set ( null ) ; sl . countDown ( ) ; } | Mark the file ready for read . |
15,428 | public ItemData getItemData ( NodeData parent , QPathEntry [ ] relPathEntries , ItemType itemType ) throws RepositoryException { ItemData item = parent ; for ( int i = 0 ; i < relPathEntries . length ; i ++ ) { if ( i == relPathEntries . length - 1 ) { item = getItemData ( parent , relPathEntries [ i ] , itemType ) ; } else { item = getItemData ( parent , relPathEntries [ i ] , ItemType . UNKNOWN ) ; } if ( item == null ) { break ; } if ( item . isNode ( ) ) { parent = ( NodeData ) item ; } else if ( i < relPathEntries . length - 1 ) { throw new IllegalPathException ( "Path can not contains a property as the intermediate element" ) ; } } return item ; } | Return item data by parent NodeDada and relPathEntries If relpath is JCRPath . THIS_RELPATH = . it return itself |
15,429 | public ItemData getItemData ( String identifier , boolean checkChangesLogOnly ) throws RepositoryException { ItemData data = null ; ItemState state = changesLog . getItemState ( identifier ) ; if ( state == null ) { data = transactionableManager . getItemData ( identifier , checkChangesLogOnly ) ; data = updatePathIfNeeded ( data ) ; } else if ( ! state . isDeleted ( ) ) { data = state . getData ( ) ; } return data ; } | Return item data by identifier in this transient storage then in workspace container . |
15,430 | public ItemImpl getItem ( NodeData parent , QPathEntry name , boolean pool , ItemType itemType ) throws RepositoryException { return getItem ( parent , name , pool , itemType , true ) ; } | Return Item by parent NodeDada and the name of searched item . |
15,431 | public ItemImpl getItem ( NodeData parent , QPathEntry name , boolean pool , ItemType itemType , boolean apiRead , boolean createNullItemData ) throws RepositoryException { long start = 0 ; if ( LOG . isDebugEnabled ( ) ) { start = System . currentTimeMillis ( ) ; LOG . debug ( "getItem(" + parent . getQPath ( ) . getAsString ( ) + " + " + name . getAsString ( ) + " ) >>>>>" ) ; } ItemImpl item = null ; try { return item = readItem ( getItemData ( parent , name , itemType , createNullItemData ) , parent , pool , apiRead ) ; } finally { if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "getItem(" + parent . getQPath ( ) . getAsString ( ) + " + " + name . getAsString ( ) + ") + ( item != null ? item . getPath ( ) : "null" ) + " <<<<< " + ( ( System . currentTimeMillis ( ) - start ) / 1000d ) + "sec" ) ; } } } | For internal use . Return Item by parent NodeDada and the name of searched item . |
15,432 | public ItemImpl getItem ( NodeData parent , QPathEntry [ ] relPath , boolean pool , ItemType itemType ) throws RepositoryException { long start = 0 ; if ( LOG . isDebugEnabled ( ) ) { start = System . currentTimeMillis ( ) ; StringBuilder debugPath = new StringBuilder ( ) ; for ( QPathEntry rp : relPath ) { debugPath . append ( rp . getAsString ( ) ) ; } LOG . debug ( "getItem(" + parent . getQPath ( ) . getAsString ( ) + " + " + debugPath + " ) >>>>>" ) ; } ItemImpl item = null ; try { return item = readItem ( getItemData ( parent , relPath , itemType ) , pool ) ; } finally { if ( LOG . isDebugEnabled ( ) ) { StringBuilder debugPath = new StringBuilder ( ) ; for ( QPathEntry rp : relPath ) { debugPath . append ( rp . getAsString ( ) ) ; } LOG . debug ( "getItem(" + parent . getQPath ( ) . getAsString ( ) + " + " + debugPath + ") + ( item != null ? item . getPath ( ) : "null" ) + " <<<<< " + ( ( System . currentTimeMillis ( ) - start ) / 1000d ) + "sec" ) ; } } } | Return Item by parent NodeDada and array of QPathEntry which represent a relative path to the searched item |
15,433 | public ItemImpl getItem ( QPath path , boolean pool ) throws RepositoryException { long start = 0 ; if ( LOG . isDebugEnabled ( ) ) { start = System . currentTimeMillis ( ) ; LOG . debug ( "getItem(" + path . getAsString ( ) + " ) >>>>>" ) ; } ItemImpl item = null ; try { return item = readItem ( getItemData ( path ) , pool ) ; } finally { if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "getItem(" + path . getAsString ( ) + ") + ( item != null ? item . getPath ( ) : "null" ) + " <<<<< " + ( ( System . currentTimeMillis ( ) - start ) / 1000d ) + "sec" ) ; } } } | Return item by absolute path in this transient storage then in workspace container . |
15,434 | protected ItemImpl readItem ( ItemData itemData , boolean pool ) throws RepositoryException { return readItem ( itemData , null , pool , true ) ; } | Read ItemImpl of given ItemData . Will call postRead Action and check permissions . |
15,435 | protected ItemImpl readItem ( ItemData itemData , NodeData parent , boolean pool , boolean apiRead ) throws RepositoryException { if ( ! apiRead ) { SecurityManager security = System . getSecurityManager ( ) ; if ( security != null ) { security . checkPermission ( JCRRuntimePermissions . INVOKE_INTERNAL_API_PERMISSION ) ; } } if ( itemData != null ) { ItemImpl item ; ItemImpl pooledItem ; if ( pool && ( pooledItem = itemsPool . get ( itemData , parent ) ) != null ) { item = pooledItem ; } else { item = itemFactory . createItem ( itemData , parent ) ; } if ( apiRead ) { if ( ! item . hasPermission ( PermissionType . READ ) ) { throw new AccessDeniedException ( "Access denied " + itemData . getQPath ( ) . getAsString ( ) + " for " + session . getUserID ( ) ) ; } session . getActionHandler ( ) . postRead ( item ) ; } return item ; } else { return null ; } } | Create or reload pooled ItemImpl with the given ItemData . |
15,436 | public ItemImpl getItemByIdentifier ( String identifier , boolean pool ) throws RepositoryException { return getItemByIdentifier ( identifier , pool , true ) ; } | Return item by identifier in this transient storage then in workspace container . |
15,437 | public ItemImpl getItemByIdentifier ( String identifier , boolean pool , boolean apiRead ) throws RepositoryException { long start = 0 ; if ( LOG . isDebugEnabled ( ) ) { start = System . currentTimeMillis ( ) ; LOG . debug ( "getItemByIdentifier(" + identifier + " ) >>>>>" ) ; } ItemImpl item = null ; try { return item = readItem ( getItemData ( identifier ) , null , pool , apiRead ) ; } finally { if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "getItemByIdentifier(" + identifier + ") + ( item != null ? item . getPath ( ) : "null" ) + " <<<<< " + ( ( System . currentTimeMillis ( ) - start ) / 1000d ) + "sec" ) ; } } } | For internal use required privileges . Return item by identifier in this transient storage then in workspace container . |
15,438 | public AccessControlList getACL ( QPath path ) throws RepositoryException { long start = 0 ; if ( LOG . isDebugEnabled ( ) ) { start = System . currentTimeMillis ( ) ; LOG . debug ( "getACL(" + path . getAsString ( ) + " ) >>>>>" ) ; } try { NodeData parent = ( NodeData ) getItemData ( Constants . ROOT_UUID ) ; if ( path . equals ( Constants . ROOT_PATH ) ) { return parent . getACL ( ) ; } ItemData item = null ; QPathEntry [ ] relPathEntries = path . getRelPath ( path . getDepth ( ) ) ; for ( int i = 0 ; i < relPathEntries . length ; i ++ ) { if ( i == relPathEntries . length - 1 ) { item = getItemData ( parent , relPathEntries [ i ] , ItemType . NODE ) ; } else { item = getItemData ( parent , relPathEntries [ i ] , ItemType . UNKNOWN ) ; } if ( item == null ) { break ; } if ( item . isNode ( ) ) { parent = ( NodeData ) item ; } else if ( i < relPathEntries . length - 1 ) { throw new IllegalPathException ( "Get ACL. Path can not contains a property as the intermediate element" ) ; } } if ( item != null && item . isNode ( ) ) { return ( ( NodeData ) item ) . getACL ( ) ; } else { return parent . getACL ( ) ; } } finally { if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "getACL(" + path . getAsString ( ) + ") <<<<< " + ( ( System . currentTimeMillis ( ) - start ) / 1000d ) + "sec" ) ; } } } | Return the ACL of the location . A session pending changes will be searched too . Item path will be traversed from the root node to a last existing item . |
15,439 | protected List < ItemState > reindexSameNameSiblings ( NodeData cause , ItemDataConsumer dataManager ) throws RepositoryException { List < ItemState > changes = new ArrayList < ItemState > ( ) ; NodeData parentNodeData = ( NodeData ) dataManager . getItemData ( cause . getParentIdentifier ( ) ) ; NodeData nextSibling = ( NodeData ) dataManager . getItemData ( parentNodeData , new QPathEntry ( cause . getQPath ( ) . getName ( ) , cause . getQPath ( ) . getIndex ( ) + 1 ) , ItemType . NODE ) ; String reindexedId = null ; while ( nextSibling != null && ! nextSibling . getIdentifier ( ) . equals ( cause . getIdentifier ( ) ) && ! nextSibling . getIdentifier ( ) . equals ( reindexedId ) ) { QPath siblingOldPath = QPath . makeChildPath ( nextSibling . getQPath ( ) . makeParentPath ( ) , nextSibling . getQPath ( ) . getName ( ) , nextSibling . getQPath ( ) . getIndex ( ) ) ; QPath siblingPath = QPath . makeChildPath ( nextSibling . getQPath ( ) . makeParentPath ( ) , nextSibling . getQPath ( ) . getName ( ) , nextSibling . getQPath ( ) . getIndex ( ) - 1 ) ; NodeData reindexed = new TransientNodeData ( siblingPath , nextSibling . getIdentifier ( ) , nextSibling . getPersistedVersion ( ) , nextSibling . getPrimaryTypeName ( ) , nextSibling . getMixinTypeNames ( ) , nextSibling . getOrderNumber ( ) , nextSibling . getParentIdentifier ( ) , nextSibling . getACL ( ) ) ; reindexedId = reindexed . getIdentifier ( ) ; ItemState reindexedState = ItemState . createUpdatedState ( reindexed ) ; changes . add ( reindexedState ) ; itemsPool . reload ( reindexed ) ; reloadDescendants ( siblingOldPath , siblingPath ) ; nextSibling = ( NodeData ) dataManager . getItemData ( parentNodeData , new QPathEntry ( nextSibling . getQPath ( ) . getName ( ) , nextSibling . getQPath ( ) . getIndex ( ) + 1 ) , ItemType . NODE ) ; } return changes ; } | Reindex same - name siblings of the node Reindex is actual for remove move only . If node is added then its index always is a last in list of childs . |
15,440 | public List < PropertyData > getReferencesData ( String identifier , boolean skipVersionStorage ) throws RepositoryException { List < PropertyData > persisted = transactionableManager . getReferencesData ( identifier , skipVersionStorage ) ; List < PropertyData > sessionTransient = new ArrayList < PropertyData > ( ) ; for ( PropertyData p : persisted ) { sessionTransient . add ( p ) ; } return sessionTransient ; } | Returns all REFERENCE properties that refer to this node . |
15,441 | private void validate ( QPath path ) throws RepositoryException , AccessDeniedException , ReferentialIntegrityException { List < ItemState > changes = changesLog . getAllStates ( ) ; for ( ItemState itemState : changes ) { if ( itemState . isInternallyCreated ( ) ) { if ( itemState . isMixinChanged ( ) ) { if ( itemState . isDescendantOf ( path ) ) { if ( ( ( NodeData ) itemState . getData ( ) ) . getACL ( ) . getPermissionsSize ( ) < 1 ) { throw new RepositoryException ( "Node " + itemState . getData ( ) . getQPath ( ) . getAsString ( ) + " has wrong formed ACL." ) ; } } validateMandatoryItem ( itemState ) ; } } else { if ( itemState . isDescendantOf ( path ) ) { validateAccessPermissions ( itemState ) ; validateMandatoryItem ( itemState ) ; } if ( path . isDescendantOf ( itemState . getAncestorToSave ( ) ) ) { throw new ConstraintViolationException ( path . getAsString ( ) + " is the same or descendant of either Session.move()'s destination or source node only " + path . getAsString ( ) ) ; } } } } | Validate all user created changes saves like access permeations mandatory items value constraint . |
15,442 | private void validateAccessPermissions ( ItemState changedItem ) throws RepositoryException , AccessDeniedException { if ( changedItem . isAddedAutoCreatedNodes ( ) ) { validateAddNodePermission ( changedItem ) ; } else if ( changedItem . isDeleted ( ) ) { validateRemoveAccessPermission ( changedItem ) ; } else if ( changedItem . isMixinChanged ( ) ) { validateMixinChangedPermission ( changedItem ) ; } else { NodeData parent = ( NodeData ) getItemData ( changedItem . getData ( ) . getParentIdentifier ( ) ) ; if ( parent != null ) { if ( changedItem . getData ( ) . isNode ( ) ) { if ( changedItem . isAdded ( ) ) { if ( ! accessManager . hasPermission ( parent . getACL ( ) , new String [ ] { PermissionType . ADD_NODE } , session . getUserState ( ) . getIdentity ( ) ) ) { throw new AccessDeniedException ( "Access denied: ADD_NODE " + changedItem . getData ( ) . getQPath ( ) . getAsString ( ) + " for: " + session . getUserID ( ) + " item owner " + parent . getACL ( ) . getOwner ( ) ) ; } } } else if ( changedItem . isAdded ( ) || changedItem . isUpdated ( ) ) { if ( ! accessManager . hasPermission ( parent . getACL ( ) , new String [ ] { PermissionType . SET_PROPERTY } , session . getUserState ( ) . getIdentity ( ) ) ) { throw new AccessDeniedException ( "Access denied: SET_PROPERTY " + changedItem . getData ( ) . getQPath ( ) . getAsString ( ) + " for: " + session . getUserID ( ) + " item owner " + parent . getACL ( ) . getOwner ( ) ) ; } } } } } | Validate ItemState for access permeations |
15,443 | private void validateMandatoryItem ( ItemState changedItem ) throws ConstraintViolationException , AccessDeniedException { if ( changedItem . getData ( ) . isNode ( ) && ( changedItem . isAdded ( ) || changedItem . isMixinChanged ( ) ) && ! changesLog . getItemState ( changedItem . getData ( ) . getQPath ( ) ) . isDeleted ( ) ) { if ( ! changesLog . getItemState ( changedItem . getData ( ) . getIdentifier ( ) ) . isDeleted ( ) ) { NodeData nData = ( NodeData ) changedItem . getData ( ) ; try { validateMandatoryChildren ( nData ) ; } catch ( ConstraintViolationException e ) { throw e ; } catch ( AccessDeniedException e ) { throw e ; } catch ( RepositoryException e ) { LOG . warn ( "Unexpected exception. Probable wrong data. Exception message:" + e . getLocalizedMessage ( ) ) ; } } } } | Validate ItemState which represents the add node for it s all mandatory items |
15,444 | void rollback ( ItemData item ) throws InvalidItemStateException , RepositoryException { PlainChangesLog slog = changesLog . pushLog ( item . getQPath ( ) ) ; SessionChangesLog changes = new SessionChangesLog ( slog . getAllStates ( ) , session ) ; for ( Iterator < ItemImpl > removedIter = invalidated . iterator ( ) ; removedIter . hasNext ( ) ; ) { ItemImpl removed = removedIter . next ( ) ; QPath removedPath = removed . getLocation ( ) . getInternalPath ( ) ; ItemState rstate = changes . getItemState ( removedPath ) ; if ( rstate != null ) { if ( rstate . isRenamed ( ) || rstate . isPathChanged ( ) ) { rstate = changes . findItemState ( rstate . getData ( ) . getIdentifier ( ) , false , new int [ ] { ItemState . DELETED } ) ; if ( rstate == null ) { continue ; } } NodeData parent = ( NodeData ) transactionableManager . getItemData ( rstate . getData ( ) . getParentIdentifier ( ) ) ; if ( parent != null ) { ItemData persisted = transactionableManager . getItemData ( parent , rstate . getData ( ) . getQPath ( ) . getEntries ( ) [ rstate . getData ( ) . getQPath ( ) . getEntries ( ) . length - 1 ] , ItemType . getItemType ( rstate . getData ( ) ) ) ; if ( persisted != null ) { removed . loadData ( persisted ) ; } } } else if ( removed . getData ( ) != null ) { ItemData persisted = transactionableManager . getItemData ( removed . getData ( ) . getIdentifier ( ) ) ; if ( persisted != null ) { removed . loadData ( persisted ) ; } } removedIter . remove ( ) ; } } | Removes all pending changes of this item |
15,445 | protected List < ? extends ItemData > mergeList ( ItemData rootData , DataManager dataManager , boolean deep , int action ) throws RepositoryException { List < ItemState > transientDescendants = new ArrayList < ItemState > ( ) ; traverseTransientDescendants ( rootData , action , transientDescendants ) ; if ( deep || ! transientDescendants . isEmpty ( ) ) { Map < String , ItemData > descendants = new LinkedHashMap < String , ItemData > ( ) ; traverseStoredDescendants ( rootData , dataManager , action , descendants , true , transientDescendants ) ; for ( ItemState state : transientDescendants ) { ItemData data = state . getData ( ) ; if ( ! state . isDeleted ( ) ) { descendants . put ( data . getIdentifier ( ) , data ) ; } else { descendants . remove ( data . getIdentifier ( ) ) ; } } Collection < ItemData > desc = descendants . values ( ) ; List < ItemData > retval ; if ( deep ) { int size = desc . size ( ) ; retval = new ArrayList < ItemData > ( size < 10 ? 10 : size ) ; for ( ItemData itemData : desc ) { retval . add ( itemData ) ; if ( deep && itemData . isNode ( ) ) { retval . addAll ( mergeList ( itemData , dataManager , true , action ) ) ; } } } else { retval = new ArrayList < ItemData > ( desc ) ; } return retval ; } else { return getStoredDescendants ( rootData , dataManager , action ) ; } } | Merge a list of nodes and properties of root data . NOTE . Properties in the list will have empty value data . I . e . for operations not changes properties content . USED FOR DELETE . |
15,446 | private void traverseStoredDescendants ( ItemData parent , DataManager dataManager , int action , Map < String , ItemData > ret , boolean listOnly , Collection < ItemState > transientDescendants ) throws RepositoryException { if ( parent . isNode ( ) && ! isNew ( parent . getIdentifier ( ) ) ) { if ( action != MERGE_PROPS ) { List < NodeData > childNodes = dataManager . getChildNodesData ( ( NodeData ) parent ) ; for ( int i = 0 , length = childNodes . size ( ) ; i < length ; i ++ ) { NodeData childNode = childNodes . get ( i ) ; ret . put ( childNode . getIdentifier ( ) , childNode ) ; } } if ( action != MERGE_NODES ) { List < PropertyData > childProps = listOnly ? dataManager . listChildPropertiesData ( ( NodeData ) parent ) : dataManager . getChildPropertiesData ( ( NodeData ) parent ) ; outer : for ( int i = 0 , length = childProps . size ( ) ; i < length ; i ++ ) { PropertyData childProp = childProps . get ( i ) ; for ( ItemState transientState : transientDescendants ) { if ( ! transientState . isNode ( ) && ! transientState . isDeleted ( ) && transientState . getData ( ) . getQPath ( ) . getDepth ( ) == childProp . getQPath ( ) . getDepth ( ) && transientState . getData ( ) . getQPath ( ) . getName ( ) . equals ( childProp . getQPath ( ) . getName ( ) ) ) { continue outer ; } } if ( ! childProp . getQPath ( ) . isDescendantOf ( parent . getQPath ( ) , true ) ) { QPath qpath = QPath . makeChildPath ( parent . getQPath ( ) , childProp . getQPath ( ) . getName ( ) ) ; childProp = new PersistedPropertyData ( childProp . getIdentifier ( ) , qpath , childProp . getParentIdentifier ( ) , childProp . getPersistedVersion ( ) , childProp . getType ( ) , childProp . isMultiValued ( ) , childProp . getValues ( ) , new SimplePersistedSize ( ( ( PersistedPropertyData ) childProp ) . getPersistedSize ( ) ) ) ; } ret . put ( childProp . getIdentifier ( ) , childProp ) ; } } } } | Calculate all stored descendants for the given parent node |
15,447 | private List < ? extends ItemData > getStoredDescendants ( ItemData parent , DataManager dataManager , int action ) throws RepositoryException { if ( parent . isNode ( ) ) { List < ItemData > childItems = null ; List < NodeData > childNodes = dataManager . getChildNodesData ( ( NodeData ) parent ) ; if ( action != MERGE_NODES ) { childItems = new ArrayList < ItemData > ( childNodes ) ; } else { return childNodes ; } List < PropertyData > childProps = dataManager . getChildPropertiesData ( ( NodeData ) parent ) ; if ( action != MERGE_PROPS ) { childItems . addAll ( childProps ) ; } else { return childProps ; } return childItems ; } return null ; } | Get all stored descendants for the given parent node |
15,448 | private void traverseTransientDescendants ( ItemData parent , int action , List < ItemState > ret ) throws RepositoryException { if ( parent . isNode ( ) ) { if ( action != MERGE_PROPS ) { Collection < ItemState > childNodes = changesLog . getLastChildrenStates ( parent , true ) ; for ( ItemState childNode : childNodes ) { ret . add ( childNode ) ; } } if ( action != MERGE_NODES ) { Collection < ItemState > childProps = changesLog . getLastChildrenStates ( parent , false ) ; for ( ItemState childProp : childProps ) { ret . add ( childProp ) ; } } } } | Calculate all transient descendants for the given parent node |
15,449 | private void reloadDescendants ( QPath parentOld , QPath parent ) throws RepositoryException { List < ItemImpl > items = itemsPool . getDescendats ( parentOld ) ; for ( ItemImpl item : items ) { ItemData oldItemData = item . getData ( ) ; ItemData newItemData = updatePath ( parentOld , parent , oldItemData ) ; ItemImpl reloadedItem = reloadItem ( newItemData ) ; if ( reloadedItem != null ) { invalidated . add ( reloadedItem ) ; } } } | Reload item s descendants in item reference pool |
15,450 | private ItemData updatePathIfNeeded ( ItemData data ) throws IllegalPathException { if ( data == null || changesLog . getAllPathsChanged ( ) == null ) return data ; List < ItemState > states = changesLog . getAllPathsChanged ( ) ; for ( int i = 0 , length = states . size ( ) ; i < length ; i ++ ) { ItemState state = states . get ( i ) ; if ( data . getQPath ( ) . isDescendantOf ( state . getOldPath ( ) ) ) { data = updatePath ( state . getOldPath ( ) , state . getData ( ) . getQPath ( ) , data ) ; } } return data ; } | Updates the path if needed and gives the updated item data if an update was needed or the provided item data otherwise |
15,451 | private ItemData updatePath ( QPath parentOld , QPath parent , ItemData oldItemData ) throws IllegalPathException { int relativeDegree = oldItemData . getQPath ( ) . getDepth ( ) - parentOld . getDepth ( ) ; QPath newQPath = QPath . makeChildPath ( parent , oldItemData . getQPath ( ) . getRelPath ( relativeDegree ) ) ; ItemData newItemData ; if ( oldItemData . isNode ( ) ) { NodeData oldNodeData = ( NodeData ) oldItemData ; newItemData = new TransientNodeData ( newQPath , oldNodeData . getIdentifier ( ) , oldNodeData . getPersistedVersion ( ) , oldNodeData . getPrimaryTypeName ( ) , oldNodeData . getMixinTypeNames ( ) , oldNodeData . getOrderNumber ( ) , oldNodeData . getParentIdentifier ( ) , oldNodeData . getACL ( ) ) ; } else { PropertyData oldPropertyData = ( PropertyData ) oldItemData ; newItemData = new TransientPropertyData ( newQPath , oldPropertyData . getIdentifier ( ) , oldPropertyData . getPersistedVersion ( ) , oldPropertyData . getType ( ) , oldPropertyData . getParentIdentifier ( ) , oldPropertyData . isMultiValued ( ) , oldPropertyData . getValues ( ) ) ; } return newItemData ; } | Updates the path of the item data and gives the updated objects |
15,452 | private static Statistics getStatistics ( Class < ? > target , String signature ) { initIfNeeded ( ) ; Statistics statistics = MAPPING . get ( signature ) ; if ( statistics == null ) { synchronized ( JCRAPIAspect . class ) { Class < ? > interfaceClass = findInterface ( target ) ; if ( interfaceClass != null ) { Map < String , Statistics > allStatistics = ALL_STATISTICS . get ( interfaceClass . getSimpleName ( ) ) ; if ( allStatistics != null ) { int index1 = signature . indexOf ( '(' ) ; int index = signature . substring ( 0 , index1 ) . lastIndexOf ( '.' ) ; String name = signature . substring ( index + 1 ) ; statistics = allStatistics . get ( name ) ; } } if ( statistics == null ) { statistics = UNKNOWN ; } Map < String , Statistics > tempMapping = new HashMap < String , Statistics > ( MAPPING ) ; tempMapping . put ( signature , statistics ) ; MAPPING = Collections . unmodifiableMap ( tempMapping ) ; } } if ( statistics == UNKNOWN ) { return null ; } return statistics ; } | Gives the corresponding statistics for the given target class and AspectJ signature |
15,453 | private static void initIfNeeded ( ) { if ( ! INITIALIZED ) { synchronized ( JCRAPIAspect . class ) { if ( ! INITIALIZED ) { ExoContainer container = ExoContainerContext . getTopContainer ( ) ; JCRAPIAspectConfig config = null ; if ( container != null ) { config = ( JCRAPIAspectConfig ) container . getComponentInstanceOfType ( JCRAPIAspectConfig . class ) ; } if ( config == null ) { TARGET_INTERFACES = new Class < ? > [ ] { } ; LOG . warn ( "No interface to monitor could be found" ) ; } else { TARGET_INTERFACES = config . getTargetInterfaces ( ) ; for ( Class < ? > c : TARGET_INTERFACES ) { Statistics global = new Statistics ( null , "global" ) ; Map < String , Statistics > statistics = new TreeMap < String , Statistics > ( ) ; Method [ ] methods = c . getMethods ( ) ; for ( Method m : methods ) { String name = getStatisticsName ( m ) ; statistics . put ( name , new Statistics ( global , name ) ) ; } JCRStatisticsManager . registerStatistics ( c . getSimpleName ( ) , global , statistics ) ; ALL_STATISTICS . put ( c . getSimpleName ( ) , statistics ) ; } } INITIALIZED = true ; } } } } | Initializes the aspect if needed |
15,454 | public static DBCleaningScripts prepareScripts ( String dialect , WorkspaceEntry wsEntry ) throws DBCleanException { if ( dialect . startsWith ( DialectConstants . DB_DIALECT_MYSQL ) ) { return new MySQLCleaningScipts ( dialect , wsEntry ) ; } else if ( dialect . startsWith ( DialectConstants . DB_DIALECT_DB2 ) ) { return new DB2CleaningScipts ( dialect , wsEntry ) ; } else if ( dialect . startsWith ( DialectConstants . DB_DIALECT_MSSQL ) ) { return new MSSQLCleaningScipts ( dialect , wsEntry ) ; } else if ( dialect . startsWith ( DialectConstants . DB_DIALECT_PGSQL ) ) { return new PgSQLCleaningScipts ( dialect , wsEntry ) ; } else if ( dialect . startsWith ( DialectConstants . DB_DIALECT_SYBASE ) ) { return new SybaseCleaningScipts ( dialect , wsEntry ) ; } else if ( dialect . startsWith ( DialectConstants . DB_DIALECT_HSQLDB ) ) { return new HSQLDBCleaningScipts ( dialect , wsEntry ) ; } else if ( dialect . startsWith ( DialectConstants . DB_DIALECT_H2 ) ) { return new H2CleaningScipts ( dialect , wsEntry ) ; } else if ( dialect . startsWith ( DialectConstants . DB_DIALECT_ORACLE ) ) { return new OracleCleaningScipts ( dialect , wsEntry ) ; } else { throw new DBCleanException ( "Unsupported dialect " + dialect ) ; } } | Prepare SQL scripts for cleaning workspace data from database . |
15,455 | private void triggerRSyncSynchronization ( ) { if ( modeHandler . getMode ( ) == IndexerIoMode . READ_ONLY ) { EmbeddedCacheManager cacheManager = cache . getCacheManager ( ) ; if ( cacheManager . getCoordinator ( ) instanceof JGroupsAddress && cacheManager . getTransport ( ) instanceof JGroupsTransport ) { JGroupsTransport transport = ( JGroupsTransport ) cacheManager . getTransport ( ) ; org . jgroups . Address jgAddress = ( ( JGroupsAddress ) cacheManager . getCoordinator ( ) ) . getJGroupsAddress ( ) ; if ( ! ( jgAddress instanceof IpAddress ) ) { Channel channel = transport . getChannel ( ) ; jgAddress = ( org . jgroups . Address ) channel . down ( new Event ( Event . GET_PHYSICAL_ADDRESS , jgAddress ) ) ; } if ( jgAddress instanceof IpAddress ) { String address = ( ( IpAddress ) jgAddress ) . getIpAddress ( ) . getHostAddress ( ) ; RSyncJob rSyncJob = new RSyncJob ( String . format ( urlFormatString , address ) , indexPath , rsyncUserName , rsyncPassword ) ; try { synchronized ( this ) { rSyncJob . execute ( ) ; } } catch ( IOException e ) { LOG . error ( "Failed to retrieve index using RSYNC" , e ) ; } } else { LOG . error ( "Error triggering RSync synchronization, skipped. Unsupported Address object : " + jgAddress . getClass ( ) . getName ( ) ) ; } } else { LOG . error ( "Error triggering RSync synchronization, skipped. Unsupported Address object : " + cacheManager . getCoordinator ( ) . getClass ( ) . getName ( ) ) ; } } } | Call to system RSync binary implementation |
15,456 | public static SessionProvider createAnonimProvider ( ) { Identity id = new Identity ( IdentityConstants . ANONIM , new HashSet < MembershipEntry > ( ) ) ; return new SessionProvider ( new ConversationState ( id ) ) ; } | Helper for creating Anonymous session provider . |
15,457 | public synchronized Session getSession ( String workspaceName , ManageableRepository repository ) throws LoginException , NoSuchWorkspaceException , RepositoryException { if ( closed ) { throw new IllegalStateException ( "Session provider already closed" ) ; } if ( workspaceName == null ) { throw new IllegalArgumentException ( "Workspace Name is null" ) ; } ExtendedSession session = cache . get ( key ( repository , workspaceName ) ) ; if ( session == null ) { if ( conversationState != null ) { session = ( ExtendedSession ) repository . getDynamicSession ( workspaceName , conversationState . getIdentity ( ) . getMemberships ( ) ) ; } else if ( ! isSystem ) { session = ( ExtendedSession ) repository . login ( workspaceName ) ; } else { session = ( ExtendedSession ) repository . getSystemSession ( workspaceName ) ; } session . registerLifecycleListener ( this ) ; cache . put ( key ( repository , workspaceName ) , session ) ; } return session ; } | Gets the session from an internal cache if a similar session has already been used or creates a new session and puts it into the internal cache . |
15,458 | private String key ( ManageableRepository repository , String workspaceName ) { String repositoryName = repository . getConfiguration ( ) . getName ( ) ; return repositoryName + workspaceName ; } | Key generator for sessions cache . |
15,459 | public static String extractCommonAncestor ( String pattern , String absPath ) { pattern = normalizePath ( pattern ) ; absPath = normalizePath ( absPath ) ; String [ ] patterEntries = pattern . split ( "/" ) ; String [ ] pathEntries = absPath . split ( "/" ) ; StringBuilder ancestor = new StringBuilder ( ) ; int count = Math . min ( pathEntries . length , patterEntries . length ) ; for ( int i = 1 ; i < count ; i ++ ) { if ( acceptName ( patterEntries [ i ] , pathEntries [ i ] ) ) { ancestor . append ( "/" ) ; ancestor . append ( pathEntries [ i ] ) ; } else { break ; } } return ancestor . length ( ) == 0 ? JCRPath . ROOT_PATH : ancestor . toString ( ) ; } | Returns common ancestor for paths represented by absolute path and pattern . |
15,460 | protected void doUpdateIndex ( Set < String > removedNodes , Set < String > addedNodes , Set < String > parentRemovedNodes , Set < String > parentAddedNodes ) { ChangesHolder changes = searchManager . getChanges ( removedNodes , addedNodes ) ; ChangesHolder parentChanges = parentSearchManager . getChanges ( parentRemovedNodes , parentAddedNodes ) ; if ( changes == null && parentChanges == null ) { return ; } try { doUpdateIndex ( new ChangesFilterListsWrapper ( changes , parentChanges ) ) ; } catch ( RuntimeException e ) { if ( isTXAware ( ) ) { throw e ; } getLogger ( ) . error ( e . getLocalizedMessage ( ) , e ) ; logErrorChanges ( handler , removedNodes , addedNodes ) ; logErrorChanges ( parentHandler , parentRemovedNodes , parentAddedNodes ) ; } } | Update index . |
15,461 | private int forceCloseSession ( String repositoryName , String workspaceName ) throws RepositoryException , RepositoryConfigurationException { ManageableRepository mr = repositoryService . getRepository ( repositoryName ) ; WorkspaceContainerFacade wc = mr . getWorkspaceContainer ( workspaceName ) ; SessionRegistry sessionRegistry = ( SessionRegistry ) wc . getComponent ( SessionRegistry . class ) ; return sessionRegistry . closeSessions ( workspaceName ) ; } | Close sessions on specific workspace . |
15,462 | public List < String > readList ( ) throws IOException { InputStream in = PrivilegedFileHelper . fileInputStream ( logFile ) ; try { List < String > list = new ArrayList < String > ( ) ; BufferedReader reader = new BufferedReader ( new InputStreamReader ( in ) ) ; String line ; while ( ( line = reader . readLine ( ) ) != null ) { if ( ! line . matches ( "\\x00++" ) ) { list . add ( line ) ; } } return list ; } finally { if ( in != null ) { try { in . close ( ) ; } catch ( IOException e ) { LOG . warn ( "Exception while closing error log: " + e . toString ( ) ) ; } } } } | Reads the log file . |
15,463 | public void addJobEntry ( BackupJob job ) { try { JobEntryInfo info = new JobEntryInfo ( ) ; info . setDate ( Calendar . getInstance ( ) ) ; info . setType ( job . getType ( ) ) ; info . setState ( job . getState ( ) ) ; info . setURL ( job . getStorageURL ( ) ) ; logWriter . write ( info , config ) ; } catch ( IOException e ) { logger . error ( "Can't add job" , e ) ; } catch ( XMLStreamException e ) { logger . error ( "Can't add job" , e ) ; } catch ( BackupOperationException e ) { logger . error ( "Can't add job" , e ) ; } } | Adding the the backup job . |
15,464 | public Collection < JobEntryInfo > getJobEntryStates ( ) { HashMap < Integer , JobEntryInfo > infos = new HashMap < Integer , JobEntryInfo > ( ) ; for ( JobEntryInfo jobEntry : jobEntries ) { infos . put ( jobEntry . getID ( ) , jobEntry ) ; } return infos . values ( ) ; } | Getting the states for jobs . |
15,465 | public Response mkCol ( Session session , String path , String nodeType , List < String > mixinTypes , List < String > tokens ) { Node node ; try { nullResourceLocks . checkLock ( session , path , tokens ) ; node = session . getRootNode ( ) . addNode ( TextUtil . relativizePath ( path ) , nodeType ) ; path = node . getPath ( ) ; if ( mixinTypes != null ) { addMixins ( node , mixinTypes ) ; } session . save ( ) ; } catch ( ItemExistsException exc ) { return Response . status ( HTTPStatus . METHOD_NOT_ALLOWED ) . entity ( exc . getMessage ( ) ) . build ( ) ; } catch ( PathNotFoundException exc ) { return Response . status ( HTTPStatus . CONFLICT ) . entity ( exc . getMessage ( ) ) . build ( ) ; } catch ( AccessDeniedException exc ) { return Response . status ( HTTPStatus . FORBIDDEN ) . entity ( exc . getMessage ( ) ) . build ( ) ; } catch ( LockException exc ) { return Response . status ( HTTPStatus . LOCKED ) . entity ( exc . getMessage ( ) ) . build ( ) ; } catch ( RepositoryException exc ) { log . error ( exc . getMessage ( ) , exc ) ; return Response . serverError ( ) . entity ( exc . getMessage ( ) ) . build ( ) ; } if ( uriBuilder != null ) { return Response . created ( uriBuilder . path ( session . getWorkspace ( ) . getName ( ) ) . path ( path ) . build ( ) ) . build ( ) ; } return Response . status ( HTTPStatus . CREATED ) . build ( ) ; } | Webdav Mkcol method implementation . |
15,466 | private void addMixins ( Node node , List < String > mixinTypes ) { for ( int i = 0 ; i < mixinTypes . size ( ) ; i ++ ) { String curMixinType = mixinTypes . get ( i ) ; try { node . addMixin ( curMixinType ) ; } catch ( Exception exc ) { log . error ( "Can't add mixin [" + curMixinType + "]" , exc ) ; } } } | Adds mixins to node . |
15,467 | public Response unLock ( Session session , String path , List < String > tokens ) { try { try { Node node = ( Node ) session . getItem ( path ) ; if ( node . isLocked ( ) ) { node . unlock ( ) ; session . save ( ) ; } return Response . status ( HTTPStatus . NO_CONTENT ) . build ( ) ; } catch ( PathNotFoundException exc ) { if ( nullResourceLocks . isLocked ( session , path ) ) { nullResourceLocks . checkLock ( session , path , tokens ) ; nullResourceLocks . removeLock ( session , path ) ; return Response . status ( HTTPStatus . NO_CONTENT ) . build ( ) ; } return Response . status ( HTTPStatus . NOT_FOUND ) . entity ( exc . getMessage ( ) ) . build ( ) ; } } catch ( LockException exc ) { return Response . status ( HTTPStatus . LOCKED ) . entity ( exc . getMessage ( ) ) . build ( ) ; } catch ( Exception exc ) { log . error ( exc . getMessage ( ) , exc ) ; return Response . serverError ( ) . entity ( exc . getMessage ( ) ) . build ( ) ; } } | Webdav Unlock method implementation . |
15,468 | public static HierarchicalProperty lockDiscovery ( String token , String lockOwner , String timeOut ) { HierarchicalProperty lockDiscovery = new HierarchicalProperty ( new QName ( "DAV:" , "lockdiscovery" ) ) ; HierarchicalProperty activeLock = lockDiscovery . addChild ( new HierarchicalProperty ( new QName ( "DAV:" , "activelock" ) ) ) ; HierarchicalProperty lockType = activeLock . addChild ( new HierarchicalProperty ( new QName ( "DAV:" , "locktype" ) ) ) ; lockType . addChild ( new HierarchicalProperty ( new QName ( "DAV:" , "write" ) ) ) ; HierarchicalProperty lockScope = activeLock . addChild ( new HierarchicalProperty ( new QName ( "DAV:" , "lockscope" ) ) ) ; lockScope . addChild ( new HierarchicalProperty ( new QName ( "DAV:" , "exclusive" ) ) ) ; HierarchicalProperty depth = activeLock . addChild ( new HierarchicalProperty ( new QName ( "DAV:" , "depth" ) ) ) ; depth . setValue ( "Infinity" ) ; if ( lockOwner != null ) { HierarchicalProperty owner = activeLock . addChild ( new HierarchicalProperty ( new QName ( "DAV:" , "owner" ) ) ) ; owner . setValue ( lockOwner ) ; } HierarchicalProperty timeout = activeLock . addChild ( new HierarchicalProperty ( new QName ( "DAV:" , "timeout" ) ) ) ; timeout . setValue ( "Second-" + timeOut ) ; if ( token != null ) { HierarchicalProperty lockToken = activeLock . addChild ( new HierarchicalProperty ( new QName ( "DAV:" , "locktoken" ) ) ) ; HierarchicalProperty lockHref = lockToken . addChild ( new HierarchicalProperty ( new QName ( "DAV:" , "href" ) ) ) ; lockHref . setValue ( token ) ; } return lockDiscovery ; } | Returns the information about lock . |
15,469 | protected HierarchicalProperty supportedLock ( ) { HierarchicalProperty supportedLock = new HierarchicalProperty ( new QName ( "DAV:" , "supportedlock" ) ) ; HierarchicalProperty lockEntry = new HierarchicalProperty ( new QName ( "DAV:" , "lockentry" ) ) ; supportedLock . addChild ( lockEntry ) ; HierarchicalProperty lockScope = new HierarchicalProperty ( new QName ( "DAV:" , "lockscope" ) ) ; lockScope . addChild ( new HierarchicalProperty ( new QName ( "DAV:" , "exclusive" ) ) ) ; lockEntry . addChild ( lockScope ) ; HierarchicalProperty lockType = new HierarchicalProperty ( new QName ( "DAV:" , "locktype" ) ) ; lockType . addChild ( new HierarchicalProperty ( new QName ( "DAV:" , "write" ) ) ) ; lockEntry . addChild ( lockType ) ; return supportedLock ; } | The information about supported locks . |
15,470 | protected HierarchicalProperty supportedMethodSet ( ) { HierarchicalProperty supportedMethodProp = new HierarchicalProperty ( SUPPORTEDMETHODSET ) ; supportedMethodProp . addChild ( new HierarchicalProperty ( new QName ( "DAV:" , "supported-method" ) ) ) . setAttribute ( "name" , "PROPFIND" ) ; supportedMethodProp . addChild ( new HierarchicalProperty ( new QName ( "DAV:" , "supported-method" ) ) ) . setAttribute ( "name" , "OPTIONS" ) ; supportedMethodProp . addChild ( new HierarchicalProperty ( new QName ( "DAV:" , "supported-method" ) ) ) . setAttribute ( "name" , "DELETE" ) ; supportedMethodProp . addChild ( new HierarchicalProperty ( new QName ( "DAV:" , "supported-method" ) ) ) . setAttribute ( "name" , "PROPPATCH" ) ; supportedMethodProp . addChild ( new HierarchicalProperty ( new QName ( "DAV:" , "supported-method" ) ) ) . setAttribute ( "name" , "CHECKIN" ) ; supportedMethodProp . addChild ( new HierarchicalProperty ( new QName ( "DAV:" , "supported-method" ) ) ) . setAttribute ( "name" , "CHECKOUT" ) ; supportedMethodProp . addChild ( new HierarchicalProperty ( new QName ( "DAV:" , "supported-method" ) ) ) . setAttribute ( "name" , "REPORT" ) ; supportedMethodProp . addChild ( new HierarchicalProperty ( new QName ( "DAV:" , "supported-method" ) ) ) . setAttribute ( "name" , "UNCHECKOUT" ) ; supportedMethodProp . addChild ( new HierarchicalProperty ( new QName ( "DAV:" , "supported-method" ) ) ) . setAttribute ( "name" , "PUT" ) ; supportedMethodProp . addChild ( new HierarchicalProperty ( new QName ( "DAV:" , "supported-method" ) ) ) . setAttribute ( "name" , "GET" ) ; supportedMethodProp . addChild ( new HierarchicalProperty ( new QName ( "DAV:" , "supported-method" ) ) ) . setAttribute ( "name" , "HEAD" ) ; supportedMethodProp . addChild ( new HierarchicalProperty ( new QName ( "DAV:" , "supported-method" ) ) ) . setAttribute ( "name" , "COPY" ) ; supportedMethodProp . addChild ( new HierarchicalProperty ( new QName ( "DAV:" , "supported-method" ) ) ) . setAttribute ( "name" , "MOVE" ) ; supportedMethodProp . addChild ( new HierarchicalProperty ( new QName ( "DAV:" , "supported-method" ) ) ) . setAttribute ( "name" , "VERSION-CONTROL" ) ; supportedMethodProp . addChild ( new HierarchicalProperty ( new QName ( "DAV:" , "supported-method" ) ) ) . setAttribute ( "name" , "LABEL" ) ; supportedMethodProp . addChild ( new HierarchicalProperty ( new QName ( "DAV:" , "supported-method" ) ) ) . setAttribute ( "name" , "LOCK" ) ; supportedMethodProp . addChild ( new HierarchicalProperty ( new QName ( "DAV:" , "supported-method" ) ) ) . setAttribute ( "name" , "UNLOCK" ) ; return supportedMethodProp ; } | The information about supported methods . |
15,471 | private void updateVersion ( Node fileNode , InputStream inputStream , String autoVersion , List < String > mixins ) throws RepositoryException { if ( ! fileNode . isCheckedOut ( ) ) { fileNode . checkout ( ) ; fileNode . getSession ( ) . save ( ) ; } if ( CHECKOUT . equals ( autoVersion ) ) { updateContent ( fileNode , inputStream , mixins ) ; } else if ( CHECKOUT_CHECKIN . equals ( autoVersion ) ) { updateContent ( fileNode , inputStream , mixins ) ; fileNode . getSession ( ) . save ( ) ; fileNode . checkin ( ) ; } fileNode . getSession ( ) . save ( ) ; } | Updates the content of the versionable file according to auto - version value . |
15,472 | void put ( String uuid , CachingIndexReader reader , int n ) { LRUMap cacheSegment = docNumbers [ getSegmentIndex ( uuid . charAt ( 0 ) ) ] ; String key = uuid ; synchronized ( cacheSegment ) { Entry e = ( Entry ) cacheSegment . get ( key ) ; if ( e != null ) { if ( reader . getCreationTick ( ) <= e . creationTick ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "Ignoring put(). New entry is not from a newer reader. " + "existing: " + e . creationTick + ", new: " + reader . getCreationTick ( ) ) ; } e = null ; } } else { e = new Entry ( reader . getCreationTick ( ) , n ) ; } if ( e != null ) { cacheSegment . put ( key , e ) ; } } } | Puts a document number into the cache using a uuid as key . An entry is only overwritten if the according reader is younger than the reader associated with the existing entry . |
15,473 | public Value createValue ( JCRName value ) throws RepositoryException { if ( value == null ) return null ; try { return new NameValue ( value . getInternalName ( ) , locationFactory ) ; } catch ( IOException e ) { throw new RepositoryException ( "Cannot create NAME Value from JCRName" , e ) ; } } | Create Value from JCRName . |
15,474 | public Value createValue ( JCRPath value ) throws RepositoryException { if ( value == null ) return null ; try { return new PathValue ( value . getInternalPath ( ) , locationFactory ) ; } catch ( IOException e ) { throw new RepositoryException ( "Cannot create PATH Value from JCRPath" , e ) ; } } | Create Value from JCRPath . |
15,475 | public Value createValue ( Identifier value ) { if ( value == null ) return null ; try { return new ReferenceValue ( value ) ; } catch ( IOException e ) { LOG . warn ( "Cannot create REFERENCE Value from Identifier " + value , e ) ; return null ; } } | Create Value from Id . |
15,476 | public Value loadValue ( ValueData data , int type ) throws RepositoryException { try { switch ( type ) { case PropertyType . STRING : return new StringValue ( data ) ; case PropertyType . BINARY : return new BinaryValue ( data , spoolConfig ) ; case PropertyType . BOOLEAN : return new BooleanValue ( data ) ; case PropertyType . LONG : return new LongValue ( data ) ; case PropertyType . DOUBLE : return new DoubleValue ( data ) ; case PropertyType . DATE : return new DateValue ( data ) ; case PropertyType . PATH : return new PathValue ( data , locationFactory ) ; case PropertyType . NAME : return new NameValue ( data , locationFactory ) ; case PropertyType . REFERENCE : return new ReferenceValue ( data , true ) ; case PropertyType . UNDEFINED : return null ; case ExtendedPropertyType . PERMISSION : return new PermissionValue ( data ) ; default : throw new ValueFormatException ( "unknown type " + type ) ; } } catch ( IOException e ) { throw new RepositoryException ( e ) ; } } | Creates new Value object using ValueData |
15,477 | protected Connection openConnection ( ) throws SQLException { return SecurityHelper . doPrivilegedSQLExceptionAction ( new PrivilegedExceptionAction < Connection > ( ) { public Connection run ( ) throws SQLException { return ds . getConnection ( ) ; } } ) ; } | Opens connection to database . |
15,478 | public String getUrlParams ( ) { StringBuffer osParams = new StringBuffer ( ) ; for ( Iterator i = this . entrySet ( ) . iterator ( ) ; i . hasNext ( ) ; ) { Map . Entry entry = ( Map . Entry ) i . next ( ) ; if ( entry . getValue ( ) != null ) osParams . append ( "&" + encodeConfig ( entry . getKey ( ) . toString ( ) ) + "=" + encodeConfig ( entry . getValue ( ) . toString ( ) ) ) ; } return osParams . toString ( ) ; } | Generate the url parameter sequence used to pass this configuration to the editor . |
15,479 | public String addLock ( Session session , String path ) throws LockException { String repoPath = session . getRepository ( ) . hashCode ( ) + "/" + session . getWorkspace ( ) . getName ( ) + "/" + path ; if ( ! nullResourceLocks . containsKey ( repoPath ) ) { String newLockToken = IdGenerator . generate ( ) ; session . addLockToken ( newLockToken ) ; nullResourceLocks . put ( repoPath , newLockToken ) ; return newLockToken ; } String currentToken = nullResourceLocks . get ( repoPath ) ; for ( String t : session . getLockTokens ( ) ) { if ( t . equals ( currentToken ) ) return t ; } throw new LockException ( "Resource already locked " + repoPath ) ; } | Locks the node . |
15,480 | public void removeLock ( Session session , String path ) { String repoPath = session . getRepository ( ) . hashCode ( ) + "/" + session . getWorkspace ( ) . getName ( ) + "/" + path ; String token = nullResourceLocks . get ( repoPath ) ; session . removeLockToken ( token ) ; nullResourceLocks . remove ( repoPath ) ; } | Removes lock from the node . |
15,481 | public boolean isLocked ( Session session , String path ) { String repoPath = session . getRepository ( ) . hashCode ( ) + "/" + session . getWorkspace ( ) . getName ( ) + "/" + path ; if ( nullResourceLocks . get ( repoPath ) != null ) { return true ; } return false ; } | Checks if the node is locked . |
15,482 | public void checkLock ( Session session , String path , List < String > tokens ) throws LockException { String repoPath = session . getRepository ( ) . hashCode ( ) + "/" + session . getWorkspace ( ) . getName ( ) + "/" + path ; String currentToken = nullResourceLocks . get ( repoPath ) ; if ( currentToken == null ) { return ; } if ( tokens != null ) { for ( String token : tokens ) { if ( token . equals ( currentToken ) ) { return ; } } } throw new LockException ( "Resource already locked " + repoPath ) ; } | Checks if the node can be unlocked using current tokens . |
15,483 | private Object getObject ( Class cl , byte [ ] data ) throws Exception { JsonHandler jsonHandler = new JsonDefaultHandler ( ) ; JsonParser jsonParser = new JsonParserImpl ( ) ; InputStream inputStream = new ByteArrayInputStream ( data ) ; jsonParser . parse ( inputStream , jsonHandler ) ; JsonValue jsonValue = jsonHandler . getJsonObject ( ) ; return new BeanBuilder ( ) . createObject ( cl , jsonValue ) ; } | Will be created the Object from JSON binary data . |
15,484 | public Response propPatch ( Session session , String path , HierarchicalProperty body , List < String > tokens , String baseURI ) { try { lockHolder . checkLock ( session , path , tokens ) ; Node node = ( Node ) session . getItem ( path ) ; WebDavNamespaceContext nsContext = new WebDavNamespaceContext ( session ) ; URI uri = new URI ( TextUtil . escape ( baseURI + node . getPath ( ) , '%' , true ) ) ; List < HierarchicalProperty > setList = Collections . emptyList ( ) ; if ( body . getChild ( new QName ( "DAV:" , "set" ) ) != null ) { setList = setList ( body ) ; } List < HierarchicalProperty > removeList = Collections . emptyList ( ) ; if ( body . getChild ( new QName ( "DAV:" , "remove" ) ) != null ) { removeList = removeList ( body ) ; } PropPatchResponseEntity entity = new PropPatchResponseEntity ( nsContext , node , uri , setList , removeList ) ; return Response . status ( HTTPStatus . MULTISTATUS ) . entity ( entity ) . type ( MediaType . TEXT_XML ) . build ( ) ; } catch ( PathNotFoundException exc ) { return Response . status ( HTTPStatus . NOT_FOUND ) . entity ( exc . getMessage ( ) ) . build ( ) ; } catch ( LockException exc ) { return Response . status ( HTTPStatus . LOCKED ) . entity ( exc . getMessage ( ) ) . build ( ) ; } catch ( Exception exc ) { log . error ( exc . getMessage ( ) , exc ) ; return Response . serverError ( ) . entity ( exc . getMessage ( ) ) . build ( ) ; } } | Webdav Proppatch method method implementation . |
15,485 | public List < HierarchicalProperty > setList ( HierarchicalProperty request ) { HierarchicalProperty set = request . getChild ( new QName ( "DAV:" , "set" ) ) ; HierarchicalProperty prop = set . getChild ( new QName ( "DAV:" , "prop" ) ) ; List < HierarchicalProperty > setList = prop . getChildren ( ) ; return setList ; } | List of properties to set . |
15,486 | public List < HierarchicalProperty > removeList ( HierarchicalProperty request ) { HierarchicalProperty remove = request . getChild ( new QName ( "DAV:" , "remove" ) ) ; HierarchicalProperty prop = remove . getChild ( new QName ( "DAV:" , "prop" ) ) ; List < HierarchicalProperty > removeList = prop . getChildren ( ) ; return removeList ; } | List of properties to remove . |
15,487 | public Response orderPatch ( Session session , String path , HierarchicalProperty body , String baseURI ) { try { Node node = ( Node ) session . getItem ( path ) ; List < OrderMember > members = getMembers ( body ) ; WebDavNamespaceContext nsContext = new WebDavNamespaceContext ( session ) ; URI uri = new URI ( TextUtil . escape ( baseURI + node . getPath ( ) , '%' , true ) ) ; if ( doOrder ( node , members ) ) { return Response . ok ( ) . build ( ) ; } OrderPatchResponseEntity orderPatchEntity = new OrderPatchResponseEntity ( nsContext , uri , node , members ) ; return Response . status ( HTTPStatus . MULTISTATUS ) . entity ( orderPatchEntity ) . build ( ) ; } catch ( PathNotFoundException exc ) { return Response . status ( HTTPStatus . NOT_FOUND ) . entity ( exc . getMessage ( ) ) . build ( ) ; } catch ( LockException exc ) { return Response . status ( HTTPStatus . LOCKED ) . entity ( exc . getMessage ( ) ) . build ( ) ; } catch ( Exception exc ) { LOG . error ( exc . getMessage ( ) , exc ) ; return Response . serverError ( ) . entity ( exc . getMessage ( ) ) . build ( ) ; } } | Webdav OrderPatch method implementation . |
15,488 | protected List < OrderMember > getMembers ( HierarchicalProperty body ) { ArrayList < OrderMember > members = new ArrayList < OrderMember > ( ) ; List < HierarchicalProperty > childs = body . getChildren ( ) ; for ( int i = 0 ; i < childs . size ( ) ; i ++ ) { OrderMember member = new OrderMember ( childs . get ( i ) ) ; members . add ( member ) ; } return members ; } | Get oder members . |
15,489 | protected boolean doOrder ( Node parentNode , List < OrderMember > members ) { boolean success = true ; for ( int i = 0 ; i < members . size ( ) ; i ++ ) { OrderMember member = members . get ( i ) ; int status = HTTPStatus . OK ; try { parentNode . getSession ( ) . refresh ( false ) ; String positionedNodeName = null ; if ( ! parentNode . hasNode ( member . getSegment ( ) ) ) { throw new PathNotFoundException ( ) ; } if ( ! new QName ( "DAV:" , "last" ) . equals ( member . getPosition ( ) ) ) { NodeIterator nodeIter = parentNode . getNodes ( ) ; boolean finded = false ; while ( nodeIter . hasNext ( ) ) { Node curNode = nodeIter . nextNode ( ) ; if ( new QName ( "DAV:" , "first" ) . equals ( member . getPosition ( ) ) ) { positionedNodeName = curNode . getName ( ) ; finded = true ; break ; } if ( new QName ( "DAV:" , "before" ) . equals ( member . getPosition ( ) ) && curNode . getName ( ) . equals ( member . getPositionSegment ( ) ) ) { positionedNodeName = curNode . getName ( ) ; finded = true ; break ; } if ( new QName ( "DAV:" , "after" ) . equals ( member . getPosition ( ) ) && curNode . getName ( ) . equals ( member . getPositionSegment ( ) ) ) { if ( nodeIter . hasNext ( ) ) { positionedNodeName = nodeIter . nextNode ( ) . getName ( ) ; } finded = true ; break ; } } if ( ! finded ) { throw new AccessDeniedException ( ) ; } } parentNode . getSession ( ) . refresh ( false ) ; parentNode . orderBefore ( member . getSegment ( ) , positionedNodeName ) ; parentNode . getSession ( ) . save ( ) ; } catch ( LockException exc ) { status = HTTPStatus . LOCKED ; } catch ( PathNotFoundException exc ) { status = HTTPStatus . FORBIDDEN ; } catch ( AccessDeniedException exc ) { status = HTTPStatus . FORBIDDEN ; } catch ( RepositoryException exc ) { LOG . error ( exc . getMessage ( ) , exc ) ; status = HTTPStatus . INTERNAL_ERROR ; } member . setStatus ( status ) ; if ( status != HTTPStatus . OK ) { success = false ; } } return success ; } | Order members . |
15,490 | private InputStream spoolInputStream ( ObjectReader in , long contentLen ) throws IOException { byte [ ] buffer = new byte [ 0 ] ; byte [ ] tmpBuff ; long readLen = 0 ; File sf = null ; OutputStream sfout = null ; try { while ( true ) { int needToRead = contentLen - readLen > 2048 ? 2048 : ( int ) ( contentLen - readLen ) ; tmpBuff = new byte [ needToRead ] ; if ( needToRead == 0 ) { break ; } in . readFully ( tmpBuff ) ; if ( sfout != null ) { sfout . write ( tmpBuff ) ; } else if ( readLen + needToRead > maxBufferSize && fileCleaner != null ) { sf = PrivilegedFileHelper . createTempFile ( "jcrvd" , null , tempDir ) ; sfout = PrivilegedFileHelper . fileOutputStream ( sf ) ; sfout . write ( buffer ) ; sfout . write ( tmpBuff ) ; buffer = null ; } else { byte [ ] newBuffer = new byte [ ( int ) ( readLen + needToRead ) ] ; System . arraycopy ( buffer , 0 , newBuffer , 0 , ( int ) readLen ) ; System . arraycopy ( tmpBuff , 0 , newBuffer , ( int ) readLen , needToRead ) ; buffer = newBuffer ; } readLen += needToRead ; } if ( buffer != null ) { return new ByteArrayInputStream ( buffer ) ; } else { return PrivilegedFileHelper . fileInputStream ( sf ) ; } } finally { if ( sfout != null ) { sfout . close ( ) ; } if ( sf != null ) { spoolFileList . add ( sf ) ; } } } | Spool input stream . |
15,491 | protected TransientItemData copyItemDataDelete ( final ItemData item ) throws RepositoryException { if ( item == null ) { return null ; } if ( item . isNode ( ) ) { final NodeData node = ( NodeData ) item ; final AccessControlList acl = node . getACL ( ) ; if ( acl == null ) { throw new RepositoryException ( "Node ACL is null. " + node . getQPath ( ) . getAsString ( ) + " " + node . getIdentifier ( ) ) ; } return new TransientNodeData ( node . getQPath ( ) , node . getIdentifier ( ) , node . getPersistedVersion ( ) , node . getPrimaryTypeName ( ) , node . getMixinTypeNames ( ) , node . getOrderNumber ( ) , node . getParentIdentifier ( ) , acl ) ; } final PropertyData prop = ( PropertyData ) item ; TransientPropertyData newData = new TransientPropertyData ( prop . getQPath ( ) , prop . getIdentifier ( ) , prop . getPersistedVersion ( ) , prop . getType ( ) , prop . getParentIdentifier ( ) , prop . isMultiValued ( ) ) ; return newData ; } | Copy ItemData for Delete operation . |
15,492 | protected List < ValueData > copyValues ( PropertyData property ) throws RepositoryException { List < ValueData > src = property . getValues ( ) ; List < ValueData > copy = new ArrayList < ValueData > ( src . size ( ) ) ; try { for ( ValueData vd : src ) { copy . add ( ValueDataUtil . createTransientCopy ( vd ) ) ; } } catch ( IOException e ) { throw new RepositoryException ( "Error of Value copy " + property . getQPath ( ) . getAsString ( ) , e ) ; } return copy ; } | Do actual copy of the property ValueDatas . |
15,493 | public NodeTypeData build ( ) { if ( nodeDefinitionDataBuilders . size ( ) > 0 ) { childNodeDefinitions = new NodeDefinitionData [ nodeDefinitionDataBuilders . size ( ) ] ; for ( int i = 0 ; i < childNodeDefinitions . length ; i ++ ) { childNodeDefinitions [ i ] = nodeDefinitionDataBuilders . get ( i ) . build ( ) ; } } if ( propertyDefinitionDataBuilders . size ( ) > 0 ) { propertyDefinitions = new PropertyDefinitionData [ propertyDefinitionDataBuilders . size ( ) ] ; for ( int i = 0 ; i < propertyDefinitions . length ; i ++ ) { propertyDefinitions [ i ] = propertyDefinitionDataBuilders . get ( i ) . build ( ) ; } } return new NodeTypeDataImpl ( name , primaryItemName , isMixin , isOrderable , supertypes , propertyDefinitions , childNodeDefinitions ) ; } | Creates instance of NodeTypeData using parameters stored in this object . |
15,494 | public static void createVersion ( Node nodeVersioning ) throws Exception { if ( ! nodeVersioning . isNodeType ( NT_FILE ) ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "Version history is not impact with non-nt:file documents, there'is not any version created." ) ; } return ; } if ( ! nodeVersioning . isNodeType ( MIX_VERSIONABLE ) ) { if ( nodeVersioning . canAddMixin ( MIX_VERSIONABLE ) ) { nodeVersioning . addMixin ( MIX_VERSIONABLE ) ; nodeVersioning . save ( ) ; } return ; } if ( ! nodeVersioning . isCheckedOut ( ) ) { nodeVersioning . checkout ( ) ; } else { nodeVersioning . checkin ( ) ; nodeVersioning . checkout ( ) ; } if ( maxAllowVersion != DOCUMENT_AUTO_DEFAULT_VERSION_MAX || maxLiveTime != DOCUMENT_AUTO_DEFAULT_VERSION_EXPIRED ) { removeRedundant ( nodeVersioning ) ; } nodeVersioning . save ( ) ; } | Create new version and clear redundant versions |
15,495 | private static void removeRedundant ( Node nodeVersioning ) throws Exception { VersionHistory versionHistory = nodeVersioning . getVersionHistory ( ) ; String baseVersion = nodeVersioning . getBaseVersion ( ) . getName ( ) ; String rootVersion = nodeVersioning . getVersionHistory ( ) . getRootVersion ( ) . getName ( ) ; VersionIterator versions = versionHistory . getAllVersions ( ) ; Date currentDate = new Date ( ) ; Map < String , String > lstVersions = new HashMap < String , String > ( ) ; List < String > lstVersionTime = new ArrayList < String > ( ) ; while ( versions . hasNext ( ) ) { Version version = versions . nextVersion ( ) ; if ( rootVersion . equals ( version . getName ( ) ) || baseVersion . equals ( version . getName ( ) ) ) continue ; if ( maxLiveTime != DOCUMENT_AUTO_DEFAULT_VERSION_EXPIRED && currentDate . getTime ( ) - version . getCreated ( ) . getTime ( ) . getTime ( ) > maxLiveTime ) { versionHistory . removeVersion ( version . getName ( ) ) ; } else { lstVersions . put ( String . valueOf ( version . getCreated ( ) . getTimeInMillis ( ) ) , version . getName ( ) ) ; lstVersionTime . add ( String . valueOf ( version . getCreated ( ) . getTimeInMillis ( ) ) ) ; } } if ( maxAllowVersion <= lstVersionTime . size ( ) && maxAllowVersion != DOCUMENT_AUTO_DEFAULT_VERSION_MAX ) { Collections . sort ( lstVersionTime ) ; String [ ] lsts = lstVersionTime . toArray ( new String [ lstVersionTime . size ( ) ] ) ; for ( int j = 0 ; j <= lsts . length - maxAllowVersion ; j ++ ) { versionHistory . removeVersion ( lstVersions . get ( lsts [ j ] ) ) ; } } } | Remove redundant version - Remove versions has been expired - Remove versions over max allow |
15,496 | protected List < PropertyData > getChildProps ( String parentId , boolean withValue ) { return getChildProps . run ( parentId , withValue ) ; } | Internal get child properties . |
15,497 | protected ItemData putItem ( ItemData item ) { if ( item . isNode ( ) ) { return putNode ( ( NodeData ) item , ModifyChildOption . MODIFY ) ; } else { return putProperty ( ( PropertyData ) item , ModifyChildOption . MODIFY ) ; } } | Internal put Item . |
15,498 | protected ItemData putNode ( NodeData node , ModifyChildOption modifyListsOfChild ) { if ( node . getParentIdentifier ( ) != null ) { if ( modifyListsOfChild == ModifyChildOption . NOT_MODIFY ) { cache . putIfAbsent ( new CacheQPath ( getOwnerId ( ) , node . getParentIdentifier ( ) , node . getQPath ( ) , ItemType . NODE ) , node . getIdentifier ( ) ) ; } else { cache . put ( new CacheQPath ( getOwnerId ( ) , node . getParentIdentifier ( ) , node . getQPath ( ) , ItemType . NODE ) , node . getIdentifier ( ) ) ; } if ( modifyListsOfChild != ModifyChildOption . NOT_MODIFY ) { cache . addToPatternList ( new CachePatternNodesId ( getOwnerId ( ) , node . getParentIdentifier ( ) ) , node ) ; cache . addToList ( new CacheNodesId ( getOwnerId ( ) , node . getParentIdentifier ( ) ) , node . getIdentifier ( ) , modifyListsOfChild == ModifyChildOption . FORCE_MODIFY ) ; cache . remove ( new CacheNodesByPageId ( getOwnerId ( ) , node . getParentIdentifier ( ) ) ) ; } } if ( modifyListsOfChild == ModifyChildOption . NOT_MODIFY ) { return ( ItemData ) cache . putIfAbsent ( new CacheId ( getOwnerId ( ) , node . getIdentifier ( ) ) , node ) ; } else { return ( ItemData ) cache . put ( new CacheId ( getOwnerId ( ) , node . getIdentifier ( ) ) , node , true ) ; } } | Internal put Node . |
15,499 | protected void putNullItem ( NullItemData item ) { boolean inTransaction = cache . isTransactionActive ( ) ; try { if ( ! inTransaction ) { cache . beginTransaction ( ) ; } cache . setLocal ( true ) ; if ( ! item . getIdentifier ( ) . equals ( NullItemData . NULL_ID ) ) { cache . putIfAbsent ( new CacheId ( getOwnerId ( ) , item . getIdentifier ( ) ) , item ) ; } else if ( item . getName ( ) != null && item . getParentIdentifier ( ) != null ) { cache . putIfAbsent ( new CacheQPath ( getOwnerId ( ) , item . getParentIdentifier ( ) , item . getName ( ) , ItemType . getItemType ( item ) ) , NullItemData . NULL_ID ) ; } } finally { cache . setLocal ( false ) ; if ( ! inTransaction ) { dedicatedTxCommit ( ) ; } } } | Internal put NullNode . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.