idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
15,800 | boolean migrationRequired ( ) throws RepositoryException { Session session = service . getStorageSession ( ) ; try { if ( session . itemExists ( storagePathOld ) ) { return true ; } try { Node node = ( Node ) session . getItem ( service . getStoragePath ( ) ) ; return node . isNodeType ( JOS_ORGANIZATION_NODETYPE_OLD ) ; } catch ( PathNotFoundException e ) { return false ; } } finally { session . logout ( ) ; } } | Method to know if migration is need . | 114 | 8 |
15,801 | private void moveOldStructure ( ) throws Exception { ExtendedSession session = ( ExtendedSession ) service . getStorageSession ( ) ; try { if ( session . itemExists ( storagePathOld ) ) { return ; } else { session . move ( service . getStoragePath ( ) , storagePathOld , false ) ; session . save ( ) ; } } finally { session . logout ( ) ; } } | Method for moving old storage into temporary location . | 86 | 9 |
15,802 | private void removeOldStructure ( ) throws RepositoryException { ExtendedSession session = ( ExtendedSession ) service . getStorageSession ( ) ; try { if ( session . itemExists ( storagePathOld ) ) { NodeIterator usersIter = ( ( ExtendedNode ) session . getItem ( usersStorageOld ) ) . getNodesLazily ( ) ; while ( usersIter . hasNext ( ) ) { Node currentUser = usersIter . nextNode ( ) ; currentUser . remove ( ) ; session . save ( ) ; } NodeIterator groupsIter = ( ( ExtendedNode ) session . getItem ( groupsStorageOld ) ) . getNodesLazily ( ) ; while ( groupsIter . hasNext ( ) ) { Node currentGroup = groupsIter . nextNode ( ) ; currentGroup . remove ( ) ; session . save ( ) ; } NodeIterator membershipTypesIter = ( ( ExtendedNode ) session . getItem ( membershipTypesStorageOld ) ) . getNodesLazily ( ) ; while ( membershipTypesIter . hasNext ( ) ) { Node currentMembershipType = membershipTypesIter . nextNode ( ) ; currentMembershipType . remove ( ) ; session . save ( ) ; } session . getItem ( storagePathOld ) . remove ( ) ; session . save ( ) ; } } finally { session . logout ( ) ; } } | Method for removing old storage from temporary location . | 287 | 9 |
15,803 | private void migrateUsers ( ) throws Exception { Session session = service . getStorageSession ( ) ; try { if ( session . itemExists ( usersStorageOld ) ) { NodeIterator iterator = ( ( ExtendedNode ) session . getItem ( usersStorageOld ) ) . getNodesLazily ( ) ; UserHandlerImpl uh = ( ( UserHandlerImpl ) service . getUserHandler ( ) ) ; while ( iterator . hasNext ( ) ) { uh . migrateUser ( iterator . nextNode ( ) ) ; } } } finally { session . logout ( ) ; } } | Method for users migration . | 122 | 5 |
15,804 | private void migrateGroups ( ) throws Exception { Session session = service . getStorageSession ( ) ; try { if ( session . itemExists ( groupsStorageOld ) ) { NodeIterator iterator = ( ( ExtendedNode ) session . getItem ( groupsStorageOld ) ) . getNodesLazily ( ) ; GroupHandlerImpl gh = ( ( GroupHandlerImpl ) service . getGroupHandler ( ) ) ; while ( iterator . hasNext ( ) ) { Node oldGroupNode = iterator . nextNode ( ) ; gh . migrateGroup ( oldGroupNode ) ; migrateGroups ( oldGroupNode ) ; } } } finally { session . logout ( ) ; } } | Method for groups migration . Must be run after users and membershipTypes migration . | 141 | 15 |
15,805 | private void migrateGroups ( Node startNode ) throws Exception { NodeIterator iterator = ( ( ExtendedNode ) startNode ) . getNodesLazily ( ) ; GroupHandlerImpl gh = ( ( GroupHandlerImpl ) service . getGroupHandler ( ) ) ; while ( iterator . hasNext ( ) ) { Node oldGroupNode = iterator . nextNode ( ) ; gh . migrateGroup ( oldGroupNode ) ; migrateGroups ( oldGroupNode ) ; } } | Method for groups migration . | 98 | 5 |
15,806 | private void migrateMembershipTypes ( ) throws Exception { Session session = service . getStorageSession ( ) ; try { if ( session . itemExists ( membershipTypesStorageOld ) ) { NodeIterator iterator = ( ( ExtendedNode ) session . getItem ( membershipTypesStorageOld ) ) . getNodesLazily ( ) ; MembershipTypeHandlerImpl mth = ( ( MembershipTypeHandlerImpl ) service . getMembershipTypeHandler ( ) ) ; while ( iterator . hasNext ( ) ) { Node oldTypeNode = iterator . nextNode ( ) ; mth . migrateMembershipType ( oldTypeNode ) ; } } } finally { session . logout ( ) ; } } | Method for membershipTypes migration . | 143 | 6 |
15,807 | private void migrateProfiles ( ) throws Exception { Session session = service . getStorageSession ( ) ; try { if ( session . itemExists ( usersStorageOld ) ) { NodeIterator iterator = ( ( ExtendedNode ) session . getItem ( usersStorageOld ) ) . getNodesLazily ( ) ; UserProfileHandlerImpl uph = ( ( UserProfileHandlerImpl ) service . getUserProfileHandler ( ) ) ; while ( iterator . hasNext ( ) ) { Node oldUserNode = iterator . nextNode ( ) ; uph . migrateProfile ( oldUserNode ) ; } } } finally { session . logout ( ) ; } } | Method for profiles migration . | 137 | 5 |
15,808 | private void migrateMemberships ( ) throws Exception { Session session = service . getStorageSession ( ) ; try { if ( session . itemExists ( usersStorageOld ) ) { NodeIterator iterator = ( ( ExtendedNode ) session . getItem ( usersStorageOld ) ) . getNodesLazily ( ) ; MembershipHandlerImpl mh = ( ( MembershipHandlerImpl ) service . getMembershipHandler ( ) ) ; while ( iterator . hasNext ( ) ) { Node oldUserNode = iterator . nextNode ( ) ; mh . migrateMemberships ( oldUserNode ) ; oldUserNode . remove ( ) ; session . save ( ) ; } } } finally { session . logout ( ) ; } } | Method for memberships migration . | 150 | 6 |
15,809 | protected void addBooleanValue ( Document doc , String fieldName , Object internalValue ) { doc . add ( createFieldWithoutNorms ( fieldName , internalValue . toString ( ) , PropertyType . BOOLEAN ) ) ; } | Adds the string representation of the boolean value to the document as the named field . | 51 | 16 |
15,810 | protected void addReferenceValue ( Document doc , String fieldName , Object internalValue ) { String uuid = internalValue . toString ( ) ; doc . add ( createFieldWithoutNorms ( fieldName , uuid , PropertyType . REFERENCE ) ) ; doc . add ( new Field ( FieldNames . PROPERTIES , FieldNames . createNamedValue ( fieldName , uuid ) , Field . Store . YES , Field . Index . NO , Field . TermVector . NO ) ) ; } | Adds the reference value to the document as the named field . The value s string representation is added as the reference data . Additionally the reference data is stored in the index . | 107 | 34 |
15,811 | protected void addPathValue ( Document doc , String fieldName , Object pathString ) { doc . add ( createFieldWithoutNorms ( fieldName , pathString . toString ( ) , PropertyType . PATH ) ) ; } | Adds the path value to the document as the named field . The path value is converted to an indexable string value using the name space mappings with which this class has been created . | 47 | 37 |
15,812 | protected void addNameValue ( Document doc , String fieldName , Object internalValue ) { doc . add ( createFieldWithoutNorms ( fieldName , internalValue . toString ( ) , PropertyType . NAME ) ) ; } | Adds the name value to the document as the named field . The name value is converted to an indexable string treating the internal value as a qualified name and mapping the name space using the name space mappings with which this class has been created . | 47 | 49 |
15,813 | protected float getPropertyBoost ( InternalQName propertyName ) { if ( indexingConfig == null ) { return DEFAULT_BOOST ; } else { return indexingConfig . getPropertyBoost ( node , propertyName ) ; } } | Returns the boost value for the given property name . | 50 | 10 |
15,814 | protected void addNodeName ( Document doc , String namespaceURI , String localName ) throws RepositoryException { String name = mappings . getNamespacePrefixByURI ( namespaceURI ) + ":" + localName ; doc . add ( new Field ( FieldNames . LABEL , name , Field . Store . NO , Field . Index . NOT_ANALYZED_NO_NORMS ) ) ; // as of version 3, also index combination of namespace URI and local name if ( indexFormatVersion . getVersion ( ) >= IndexFormatVersion . V3 . getVersion ( ) ) { doc . add ( new Field ( FieldNames . NAMESPACE_URI , namespaceURI , Field . Store . NO , Field . Index . NOT_ANALYZED_NO_NORMS ) ) ; doc . add ( new Field ( FieldNames . LOCAL_NAME , localName , Field . Store . NO , Field . Index . NOT_ANALYZED_NO_NORMS ) ) ; } } | Depending on the index format version adds one or two fields to the document for the node name . | 216 | 19 |
15,815 | protected long writeValue ( File file , ValueData value ) throws IOException { if ( value . isByteArray ( ) ) { return writeByteArrayValue ( file , value ) ; } else { return writeStreamedValue ( file , value ) ; } } | Write value to a file . | 54 | 6 |
15,816 | protected long writeByteArrayValue ( File file , ValueData value ) throws IOException { OutputStream out = new FileOutputStream ( file ) ; try { byte [ ] data = value . getAsByteArray ( ) ; out . write ( data ) ; return data . length ; } finally { out . close ( ) ; } } | Write value array of bytes to a file . | 69 | 9 |
15,817 | protected long writeStreamedValue ( File file , ValueData value ) throws IOException { long size ; // stream Value if ( value instanceof StreamPersistedValueData ) { StreamPersistedValueData streamed = ( StreamPersistedValueData ) value ; if ( streamed . isPersisted ( ) ) { // already persisted in another Value, copy it to this Value size = copyClose ( streamed . getAsStream ( ) , new FileOutputStream ( file ) ) ; } else { // the Value not yet persisted, i.e. or in client stream or spooled to a temp file File tempFile ; if ( ( tempFile = streamed . getTempFile ( ) ) != null ) { // it's spooled Value, try move its file to VS if ( ! tempFile . renameTo ( file ) ) { // not succeeded - copy bytes, temp file will be deleted by transient ValueData if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "Value spool file move (rename) to Values Storage is not succeeded. " + "Trying bytes copy. Spool file: " + tempFile . getAbsolutePath ( ) + ". Destination: " + file . getAbsolutePath ( ) ) ; } size = copyClose ( new FileInputStream ( tempFile ) , new FileOutputStream ( file ) ) ; } else { size = file . length ( ) ; } } else { // not spooled, use client InputStream size = copyClose ( streamed . getStream ( ) , new FileOutputStream ( file ) ) ; } // link this Value to file in VS streamed . setPersistedFile ( file ) ; } } else { // copy from Value stream to the file, e.g. from FilePersistedValueData to this Value size = copyClose ( value . getAsStream ( ) , new FileOutputStream ( file ) ) ; } return size ; } | Write streamed value to a file . | 401 | 7 |
15,818 | protected long writeOutput ( OutputStream out , ValueData value ) throws IOException { if ( value . isByteArray ( ) ) { byte [ ] buff = value . getAsByteArray ( ) ; out . write ( buff ) ; return buff . length ; } else { InputStream in ; if ( value instanceof StreamPersistedValueData ) { StreamPersistedValueData streamed = ( StreamPersistedValueData ) value ; if ( streamed . isPersisted ( ) ) { // already persisted in another Value, copy it to this Value in = streamed . getAsStream ( ) ; } else { in = streamed . getStream ( ) ; if ( in == null ) { in = new FileInputStream ( streamed . getTempFile ( ) ) ; } } } else { in = value . getAsStream ( ) ; } try { return copy ( in , out ) ; } finally { in . close ( ) ; } } } | Stream value data to the output . | 195 | 7 |
15,819 | protected long copy ( InputStream in , OutputStream out ) throws IOException { // compare classes as in Java6 Channels.newChannel(), Java5 has a bug in newChannel(). boolean inFile = in instanceof FileInputStream && FileInputStream . class . equals ( in . getClass ( ) ) ; boolean outFile = out instanceof FileOutputStream && FileOutputStream . class . equals ( out . getClass ( ) ) ; if ( inFile && outFile ) { // it's user file FileChannel infch = ( ( FileInputStream ) in ) . getChannel ( ) ; FileChannel outfch = ( ( FileOutputStream ) out ) . getChannel ( ) ; long size = 0 ; long r = 0 ; do { r = outfch . transferFrom ( infch , r , infch . size ( ) ) ; size += r ; } while ( r < infch . size ( ) ) ; return size ; } else { // it's user stream (not a file) ReadableByteChannel inch = inFile ? ( ( FileInputStream ) in ) . getChannel ( ) : Channels . newChannel ( in ) ; WritableByteChannel outch = outFile ? ( ( FileOutputStream ) out ) . getChannel ( ) : Channels . newChannel ( out ) ; long size = 0 ; int r = 0 ; ByteBuffer buff = ByteBuffer . allocate ( IOBUFFER_SIZE ) ; buff . clear ( ) ; while ( ( r = inch . read ( buff ) ) >= 0 ) { buff . flip ( ) ; // copy all do { outch . write ( buff ) ; } while ( buff . hasRemaining ( ) ) ; buff . clear ( ) ; size += r ; } if ( outFile ) ( ( FileChannel ) outch ) . force ( true ) ; // force all data to FS return size ; } } | Copy input to output data using NIO . | 398 | 9 |
15,820 | protected long copyClose ( InputStream in , OutputStream out ) throws IOException { try { try { return copy ( in , out ) ; } finally { in . close ( ) ; } } finally { out . close ( ) ; } } | Copy input to output data using NIO . Input and output streams will be closed after the operation . | 50 | 20 |
15,821 | public Response report ( Session session , String path , HierarchicalProperty body , Depth depth , String baseURI ) { try { Node node = ( Node ) session . getItem ( path ) ; WebDavNamespaceContext nsContext = new WebDavNamespaceContext ( session ) ; String strUri = baseURI + node . getPath ( ) ; URI uri = new URI ( TextUtil . escape ( strUri , ' ' , true ) ) ; if ( ! ResourceUtil . isVersioned ( node ) ) { return Response . status ( HTTPStatus . PRECON_FAILED ) . build ( ) ; } VersionedResource resource ; if ( ResourceUtil . isFile ( node ) ) { resource = new VersionedFileResource ( uri , node , nsContext ) ; } else { resource = new VersionedCollectionResource ( uri , node , nsContext ) ; } Set < QName > properties = getProperties ( body ) ; VersionTreeResponseEntity response = new VersionTreeResponseEntity ( nsContext , resource , properties ) ; return Response . status ( HTTPStatus . MULTISTATUS ) . entity ( response ) . build ( ) ; } catch ( PathNotFoundException exc ) { return Response . status ( HTTPStatus . NOT_FOUND ) . entity ( exc . getMessage ( ) ) . build ( ) ; } catch ( RepositoryException exc ) { LOG . error ( exc . getMessage ( ) , exc ) ; return Response . serverError ( ) . entity ( exc . getMessage ( ) ) . build ( ) ; } catch ( Exception exc ) { LOG . error ( exc . getMessage ( ) , exc ) ; return Response . serverError ( ) . entity ( exc . getMessage ( ) ) . build ( ) ; } } | Webdav Report method implementation . | 377 | 7 |
15,822 | protected Set < QName > getProperties ( HierarchicalProperty body ) { HashSet < QName > properties = new HashSet < QName > ( ) ; HierarchicalProperty prop = body . getChild ( new QName ( "DAV:" , "prop" ) ) ; if ( prop == null ) { return properties ; } for ( int i = 0 ; i < prop . getChildren ( ) . size ( ) ; i ++ ) { HierarchicalProperty property = prop . getChild ( i ) ; properties . add ( property . getName ( ) ) ; } return properties ; } | Returns the list of properties . | 127 | 6 |
15,823 | public void write ( List < NodeTypeData > nodeTypes , OutputStream os ) throws RepositoryException { OutputStreamWriter out = new OutputStreamWriter ( os ) ; try { for ( NodeTypeData nodeType : nodeTypes ) { printNamespaces ( nodeType , out ) ; printNodeTypeDeclaration ( nodeType , out ) ; } out . close ( ) ; } catch ( IOException e ) { throw new RepositoryException ( e . getMessage ( ) , e ) ; } } | Write given list of node types to output stream . | 104 | 10 |
15,824 | private void printNamespaces ( NodeTypeData nodeTypeData , OutputStreamWriter out ) throws RepositoryException , IOException { /** * Using set to store all prefixes found in node types to avoid * duplication */ Set < String > namespaces = new HashSet < String > ( ) ; /** Scanning nodeType definition for used namespaces */ printNameNamespace ( nodeTypeData . getName ( ) , namespaces ) ; printNameNamespace ( nodeTypeData . getPrimaryItemName ( ) , namespaces ) ; if ( nodeTypeData . getDeclaredSupertypeNames ( ) != null ) { for ( InternalQName reqType : nodeTypeData . getDeclaredSupertypeNames ( ) ) { printNameNamespace ( reqType , namespaces ) ; } } /** Scanning property definitions for used namespaces */ if ( nodeTypeData . getDeclaredPropertyDefinitions ( ) != null ) { for ( PropertyDefinitionData property : nodeTypeData . getDeclaredPropertyDefinitions ( ) ) { printNameNamespace ( property . getName ( ) , namespaces ) ; } } /** Scanning child definitions for used namespaces */ if ( nodeTypeData . getDeclaredChildNodeDefinitions ( ) != null ) { for ( NodeDefinitionData child : nodeTypeData . getDeclaredChildNodeDefinitions ( ) ) { printNameNamespace ( child . getName ( ) , namespaces ) ; printNameNamespace ( child . getDefaultPrimaryType ( ) , namespaces ) ; if ( child . getRequiredPrimaryTypes ( ) != null ) { for ( InternalQName reqType : child . getRequiredPrimaryTypes ( ) ) { printNameNamespace ( reqType , namespaces ) ; } } } } for ( String prefix : namespaces ) { String uri = namespaceRegistry . getURI ( prefix ) ; out . write ( "<" + prefix + "='" + uri + "'>\r\n" ) ; } } | Print namespaces to stream | 413 | 5 |
15,825 | private void printNodeTypeDeclaration ( NodeTypeData nodeTypeData , OutputStreamWriter out ) throws RepositoryException , IOException { /** Print name */ out . write ( "[" + qNameToString ( nodeTypeData . getName ( ) ) + "] " ) ; /** Print supertypes */ InternalQName [ ] superTypes = nodeTypeData . getDeclaredSupertypeNames ( ) ; if ( superTypes != null && superTypes . length > 0 ) { /** if there is only 1 element and it is NT_BASE then avoid printing it */ if ( superTypes . length > 1 || ! superTypes [ 0 ] . equals ( Constants . NT_BASE ) ) { out . write ( "> " + qNameToString ( superTypes [ 0 ] ) ) ; for ( int i = 1 ; i < superTypes . length ; i ++ ) { out . write ( ", " + qNameToString ( superTypes [ i ] ) ) ; } } } /** Print attributes */ StringBuilder attributes = new StringBuilder ( ) ; // if (nodeTypeData.isAbstract()) // { // attributes += "abstract "; // } if ( nodeTypeData . hasOrderableChildNodes ( ) ) { attributes . append ( "orderable " ) ; } if ( nodeTypeData . isMixin ( ) ) { attributes . append ( "mixin " ) ; } // if (!nodeTypeData.isQueryable()) // { // attributes += "noquery "; // } if ( nodeTypeData . getPrimaryItemName ( ) != null ) { attributes . append ( "primaryitem " + qNameToString ( nodeTypeData . getPrimaryItemName ( ) ) ) ; } if ( attributes . length ( ) > 0 ) { out . write ( "\r\n " ) ; out . write ( attributes . toString ( ) ) ; } /** Print all property definitions */ PropertyDefinitionData [ ] propertyDefinitions = nodeTypeData . getDeclaredPropertyDefinitions ( ) ; if ( propertyDefinitions != null ) { for ( PropertyDefinitionData propertyDefinition : propertyDefinitions ) { printPropertyDeclaration ( propertyDefinition , out ) ; } } /** Print all child definitions */ NodeDefinitionData [ ] nodeDefinitions = nodeTypeData . getDeclaredChildNodeDefinitions ( ) ; if ( nodeDefinitions != null ) { for ( NodeDefinitionData nodeDefinition : nodeDefinitions ) { printChildDeclaration ( nodeDefinition , out ) ; } } out . write ( "\r\n" ) ; } | Method recursively print to output stream node type definition in cnd format . | 536 | 16 |
15,826 | private void printPropertyDeclaration ( PropertyDefinitionData propertyDefinition , OutputStreamWriter out ) throws IOException , RepositoryException { /** Print name */ out . write ( "\r\n " ) ; out . write ( "- " + qNameToString ( propertyDefinition . getName ( ) ) ) ; out . write ( " (" + ExtendedPropertyType . nameFromValue ( propertyDefinition . getRequiredType ( ) ) . toUpperCase ( ) + ")" ) ; /** Print default values */ out . write ( listToString ( propertyDefinition . getDefaultValues ( ) , "'" , "\r\n = " , " " ) ) ; /** Print attributes */ StringBuilder attributes = new StringBuilder ( ) ; if ( propertyDefinition . isAutoCreated ( ) ) { attributes . append ( "autocreated " ) ; } if ( propertyDefinition . isMandatory ( ) ) { attributes . append ( "mandatory " ) ; } if ( propertyDefinition . isProtected ( ) ) { attributes . append ( "protected " ) ; } if ( propertyDefinition . isMultiple ( ) ) { attributes . append ( "multiple " ) ; } // if (!propertyDefinition.isFullTextSearchable()) // { // attributes += "nofulltext "; // } // if (!propertyDefinition.isQueryOrderable()) // { // attributes += "noqueryorder "; // } // /** Print operators avoiding printing all */ // String[] opArray = propertyDefinition.getAvailableQueryOperators(); // /** Using set to avoid duplication */ // Set<String> opSet = new HashSet<String>(); // for (String op : opArray) // { // opSet.add(op.toUpperCase()); // } // /** if not all elements are mentioned in list then print */ // if (opSet.size() < 7 && opSet.size() > 0) // { // String opString = opSet.toString(); // // opString="queryops '"+opString.substring(1, opString.length()-1)+"' "; // opString = listToString(opSet.toArray(new String[opSet.size()]), "", "\r\n queryops '", "' "); // attributes += opString; // } if ( propertyDefinition . getOnParentVersion ( ) != OnParentVersionAction . COPY ) { attributes . append ( "\r\n " + OnParentVersionAction . nameFromValue ( propertyDefinition . getOnParentVersion ( ) ) + " " ) ; } /** Don't print if all attributes are default */ if ( attributes . length ( ) > 0 ) { out . write ( "\r\n " ) ; out . write ( attributes . toString ( ) ) ; } out . write ( listToString ( propertyDefinition . getValueConstraints ( ) , "'" , "\r\n < " , " " ) ) ; } | Prints to output stream property definition in CND format | 615 | 11 |
15,827 | private void printChildDeclaration ( NodeDefinitionData nodeDefinition , OutputStreamWriter out ) throws IOException , RepositoryException { out . write ( "\r\n " ) ; out . write ( "+ " + qNameToString ( nodeDefinition . getName ( ) ) + " " ) ; InternalQName [ ] requiredTypes = nodeDefinition . getRequiredPrimaryTypes ( ) ; if ( requiredTypes != null && requiredTypes . length > 0 ) { /** if there is only 1 element and it is NT_BASE then avoid printing it */ if ( requiredTypes . length > 1 || ! requiredTypes [ 0 ] . equals ( Constants . NT_BASE ) ) { out . write ( "(" + qNameToString ( requiredTypes [ 0 ] ) ) ; for ( int i = 1 ; i < requiredTypes . length ; i ++ ) { out . write ( ", " + qNameToString ( requiredTypes [ i ] ) ) ; } out . write ( ")" ) ; } } if ( nodeDefinition . getDefaultPrimaryType ( ) != null ) { out . write ( "\r\n = " + qNameToString ( nodeDefinition . getDefaultPrimaryType ( ) ) ) ; } StringBuilder attributes = new StringBuilder ( ) ; if ( nodeDefinition . isAutoCreated ( ) ) { attributes . append ( "autocreated " ) ; } if ( nodeDefinition . isMandatory ( ) ) { attributes . append ( "mandatory " ) ; } if ( nodeDefinition . isProtected ( ) ) { attributes . append ( "protected " ) ; } if ( nodeDefinition . isAllowsSameNameSiblings ( ) ) { attributes . append ( "sns " ) ; } if ( nodeDefinition . getOnParentVersion ( ) != OnParentVersionAction . COPY ) { attributes . append ( "\r\n " + OnParentVersionAction . nameFromValue ( nodeDefinition . getOnParentVersion ( ) ) + " " ) ; } if ( attributes . length ( ) > 0 ) { out . write ( "\r\n " ) ; out . write ( attributes . toString ( ) ) ; } } | Print to output stream child node definition in CND format | 452 | 11 |
15,828 | public float getNodeBoost ( NodeData state ) { IndexingRule rule = getApplicableIndexingRule ( state ) ; if ( rule != null ) { return rule . getNodeBoost ( ) ; } return DEFAULT_BOOST ; } | Returns the boost for the node scope fulltext index field . | 52 | 12 |
15,829 | private PathExpression getCondition ( Node config ) throws IllegalNameException , RepositoryException { Node conditionAttr = config . getAttributes ( ) . getNamedItem ( "condition" ) ; if ( conditionAttr == null ) { return null ; } String conditionString = conditionAttr . getNodeValue ( ) ; int idx ; int axis ; InternalQName elementTest = null ; InternalQName nameTest = null ; InternalQName propertyName ; String propertyValue ; // parse axis if ( conditionString . startsWith ( "ancestor::" ) ) { axis = PathExpression . ANCESTOR ; idx = "ancestor::" . length ( ) ; } else if ( conditionString . startsWith ( "parent::" ) ) { axis = PathExpression . PARENT ; idx = "parent::" . length ( ) ; } else if ( conditionString . startsWith ( "@" ) ) { axis = PathExpression . SELF ; idx = "@" . length ( ) ; } else { axis = PathExpression . CHILD ; idx = 0 ; } try { if ( conditionString . startsWith ( "element(" , idx ) ) { int colon = conditionString . indexOf ( ' ' , idx + "element(" . length ( ) ) ; String name = conditionString . substring ( idx + "element(" . length ( ) , colon ) . trim ( ) ; if ( ! name . equals ( "*" ) ) { nameTest = resolver . parseJCRName ( ISO9075 . decode ( name ) ) . getInternalName ( ) ; } idx = conditionString . indexOf ( ")/@" , colon ) ; String type = conditionString . substring ( colon + 1 , idx ) . trim ( ) ; elementTest = resolver . parseJCRName ( ISO9075 . decode ( type ) ) . getInternalName ( ) ; idx += ")/@" . length ( ) ; } else { if ( axis == PathExpression . ANCESTOR || axis == PathExpression . CHILD || axis == PathExpression . PARENT ) { // simple name test String name = conditionString . substring ( idx , conditionString . indexOf ( ' ' , idx ) ) ; if ( ! name . equals ( "*" ) ) { nameTest = resolver . parseJCRName ( ISO9075 . decode ( name ) ) . getInternalName ( ) ; } idx += name . length ( ) + "/@" . length ( ) ; } } // parse property name int eq = conditionString . indexOf ( ' ' , idx ) ; String name = conditionString . substring ( idx , eq ) . trim ( ) ; propertyName = resolver . parseJCRName ( ISO9075 . decode ( name ) ) . getInternalName ( ) ; // parse string value int quote = conditionString . indexOf ( ' ' , eq ) + 1 ; propertyValue = conditionString . substring ( quote , conditionString . indexOf ( ' ' , quote ) ) ; } catch ( IndexOutOfBoundsException e ) { throw new RepositoryException ( conditionString ) ; } return new PathExpression ( axis , elementTest , nameTest , propertyName , propertyValue ) ; } | Gets the condition expression from the configuration . | 703 | 9 |
15,830 | public void remove ( ) throws IOException { if ( ( fileBuffer != null ) && PrivilegedFileHelper . exists ( fileBuffer ) ) { if ( ! PrivilegedFileHelper . delete ( fileBuffer ) ) { throw new IOException ( "Cannot remove file " + PrivilegedFileHelper . getAbsolutePath ( fileBuffer ) + " Close all streams." ) ; } } } | Remove buffer . | 81 | 3 |
15,831 | private void swapBuffers ( ) throws IOException { byte [ ] data = ( ( ByteArrayOutputStream ) out ) . toByteArray ( ) ; fileBuffer = PrivilegedFileHelper . createTempFile ( "decoderBuffer" , ".tmp" ) ; PrivilegedFileHelper . deleteOnExit ( fileBuffer ) ; out = new BufferedOutputStream ( PrivilegedFileHelper . fileOutputStream ( fileBuffer ) , bufferSize ) ; out . write ( data ) ; } | Swap in - memory buffer with file . | 101 | 9 |
15,832 | public void logComment ( String message ) throws IOException { if ( reportContext . get ( ) != null ) { reportContext . get ( ) . addComment ( message ) ; } else { writeMessage ( message ) ; } } | Adds comment to log . | 48 | 5 |
15,833 | public void logDescription ( String description ) throws IOException { // The ThreadLocal has been initialized so we know that we are in multithreaded mode. if ( reportContext . get ( ) != null ) { reportContext . get ( ) . addComment ( description ) ; } else { writeMessage ( description ) ; } } | Adds description to log . | 68 | 5 |
15,834 | public void logBrokenObjectAndSetInconsistency ( String brokenObject ) throws IOException { setInconsistency ( ) ; // The ThreadLocal has been initialized so we know that we are in multithreaded mode. if ( reportContext . get ( ) != null ) { reportContext . get ( ) . addBrokenObject ( brokenObject ) ; } else { writeBrokenObject ( brokenObject ) ; } } | Adds detailed event to log . | 91 | 6 |
15,835 | public void logExceptionAndSetInconsistency ( String message , Throwable e ) throws IOException { setInconsistency ( ) ; // The ThreadLocal has been initialized so we know that we are in multithreaded mode. if ( reportContext . get ( ) != null ) { reportContext . get ( ) . addLogException ( message , e ) ; } else { writeException ( message , e ) ; } } | Adds exception with full stack trace . | 91 | 7 |
15,836 | private String getIdColumn ( ) throws SQLException { try { return lockManagerEntry . getParameterValue ( ISPNCacheableLockManagerImpl . INFINISPAN_JDBC_CL_ID_COLUMN_NAME ) ; } catch ( RepositoryConfigurationException e ) { throw new SQLException ( e ) ; } } | Returns the column name which contain node identifier . | 74 | 9 |
15,837 | protected String getTableName ( ) throws SQLException { try { String dialect = getDialect ( ) ; String quote = "\"" ; if ( dialect . startsWith ( DBConstants . DB_DIALECT_MYSQL ) ) quote = "`" ; return quote + lockManagerEntry . getParameterValue ( ISPNCacheableLockManagerImpl . INFINISPAN_JDBC_TABLE_NAME ) + "_" + "L" + workspaceEntry . getUniqueName ( ) . replace ( "_" , "" ) . replace ( "-" , "_" ) + quote ; } catch ( RepositoryConfigurationException e ) { throw new SQLException ( e ) ; } } | Returns the name of LOCK table . | 151 | 8 |
15,838 | public File getNextFile ( ) { File nextFile = null ; try { String sNextName = generateName ( ) ; nextFile = new File ( backupSetDir . getAbsoluteFile ( ) + File . separator + sNextName ) ; if ( isFullBackup && isDirectoryForFullBackup ) { if ( ! PrivilegedFileHelper . exists ( nextFile ) ) { PrivilegedFileHelper . mkdirs ( nextFile ) ; } } else { PrivilegedFileHelper . createNewFile ( nextFile ) ; } } catch ( IOException e ) { LOG . error ( "Can nit get next file : " + e . getLocalizedMessage ( ) , e ) ; } return nextFile ; } | Get next file in backup set . | 153 | 7 |
15,839 | private String getStrDate ( Calendar c ) { int m = c . get ( Calendar . MONTH ) + 1 ; int d = c . get ( Calendar . DATE ) ; return "" + c . get ( Calendar . YEAR ) + ( m < 10 ? "0" + m : m ) + ( d < 10 ? "0" + d : d ) ; } | Returns date as String in format YYYYMMDD . | 79 | 12 |
15,840 | private String getStrTime ( Calendar c ) { int h = c . get ( Calendar . HOUR ) ; int m = c . get ( Calendar . MINUTE ) ; int s = c . get ( Calendar . SECOND ) ; return "" + ( h < 10 ? "0" + h : h ) + ( m < 10 ? "0" + m : m ) + ( s < 10 ? "0" + s : s ) ; } | Returns time as String in format HHMMSS . | 95 | 10 |
15,841 | void createStructure ( ) throws RepositoryException { Session session = getStorageSession ( ) ; try { Node storage = session . getRootNode ( ) . addNode ( storagePath . substring ( 1 ) , STORAGE_NODETYPE ) ; storage . addNode ( STORAGE_JOS_USERS , STORAGE_JOS_USERS_NODETYPE ) ; storage . addNode ( STORAGE_JOS_GROUPS , STORAGE_JOS_GROUPS_NODETYPE ) ; Node storageTypesNode = storage . addNode ( STORAGE_JOS_MEMBERSHIP_TYPES , STORAGE_JOS_MEMBERSHIP_TYPES_NODETYPE ) ; Node anyNode = storageTypesNode . addNode ( JOS_MEMBERSHIP_TYPE_ANY ) ; anyNode . setProperty ( MembershipTypeHandlerImpl . MembershipTypeProperties . JOS_DESCRIPTION , JOS_DESCRIPTION_TYPE_ANY ) ; session . save ( ) ; // storage done configure } finally { session . logout ( ) ; } } | Creates storage structure . | 249 | 5 |
15,842 | Session getStorageSession ( ) throws RepositoryException { try { ManageableRepository repository = getWorkingRepository ( ) ; String workspaceName = storageWorkspace ; if ( workspaceName == null ) { workspaceName = repository . getConfiguration ( ) . getDefaultWorkspaceName ( ) ; } return repository . getSystemSession ( workspaceName ) ; } catch ( RepositoryConfigurationException e ) { throw new RepositoryException ( "Can not get system session" , e ) ; } } | Return system Session to org - service storage workspace . For internal use only . | 102 | 15 |
15,843 | protected ManageableRepository getWorkingRepository ( ) throws RepositoryException , RepositoryConfigurationException { return repositoryName != null ? repositoryService . getRepository ( repositoryName ) : repositoryService . getCurrentRepository ( ) ; } | Returns working repository . If repository name is configured then it will be returned otherwise the current repository is used . | 50 | 21 |
15,844 | public JCRPath createJCRPath ( JCRPath parentLoc , String relPath ) throws RepositoryException { JCRPath addPath = parseNames ( relPath , false ) ; return parentLoc . add ( addPath ) ; } | Creates JCRPath from parent path and relPath | 50 | 11 |
15,845 | private boolean isNonspace ( String str , char ch ) throws RepositoryException { if ( ch == ' ' ) { throw new RepositoryException ( "Illegal absPath: \"" + str + "\": The path entry contains an illegal char: \"" + ch + "\"" ) ; } return ! ( ( ch == ' ' ) || ( ch == ' ' ) || ( ch == ' ' ) || ( ch == ' ' ) || ( ch == ' ' ) || ( ch == ' ' ) || ( ch == ' ' ) || ( ch == ' ' ) || ( ch == ' ' ) || ( ch == ' ' ) ) ; } | Some functions for JCRPath Validation | 139 | 8 |
15,846 | public boolean isAbsolute ( ) { if ( names [ 0 ] . getIndex ( ) == 1 && names [ 0 ] . getName ( ) . length ( ) == 0 && names [ 0 ] . getNamespace ( ) . length ( ) == 0 ) return true ; else return false ; } | Tell if the path is absolute . | 63 | 7 |
15,847 | public QPathEntry [ ] getRelPath ( int relativeDegree ) throws IllegalPathException { int len = getLength ( ) - relativeDegree ; if ( len < 0 ) throw new IllegalPathException ( "Relative degree " + relativeDegree + " is more than depth for " + getAsString ( ) ) ; QPathEntry [ ] relPath = new QPathEntry [ relativeDegree ] ; System . arraycopy ( names , len , relPath , 0 , relPath . length ) ; return relPath ; } | Get relative path with degree . | 116 | 6 |
15,848 | public static QPath getCommonAncestorPath ( QPath firstPath , QPath secondPath ) throws PathNotFoundException { if ( ! firstPath . getEntries ( ) [ 0 ] . equals ( secondPath . getEntries ( ) [ 0 ] ) ) { throw new PathNotFoundException ( "For the given ways there is no common ancestor." ) ; } List < QPathEntry > caEntries = new ArrayList < QPathEntry > ( ) ; for ( int i = 0 ; i < firstPath . getEntries ( ) . length ; i ++ ) { if ( firstPath . getEntries ( ) [ i ] . equals ( secondPath . getEntries ( ) [ i ] ) ) { caEntries . add ( firstPath . getEntries ( ) [ i ] ) ; } else { break ; } } return new QPath ( caEntries . toArray ( new QPathEntry [ caEntries . size ( ) ] ) ) ; } | Get common ancestor path . | 209 | 5 |
15,849 | public String getAsString ( ) { if ( stringName == null ) { StringBuilder str = new StringBuilder ( ) ; for ( int i = 0 ; i < getLength ( ) ; i ++ ) { str . append ( names [ i ] . getAsString ( true ) ) ; } stringName = str . toString ( ) ; } return stringName ; } | Get String representation . | 78 | 4 |
15,850 | public static QPath parse ( String qPath ) throws IllegalPathException { if ( qPath == null ) throw new IllegalPathException ( "Bad internal path '" + qPath + "'" ) ; if ( qPath . length ( ) < 2 || ! qPath . startsWith ( "[]" ) ) throw new IllegalPathException ( "Bad internal path '" + qPath + "'" ) ; int uriStart = 0 ; List < QPathEntry > entries = new ArrayList < QPathEntry > ( ) ; while ( uriStart >= 0 ) { uriStart = qPath . indexOf ( "[" , uriStart ) ; int uriFinish = qPath . indexOf ( "]" , uriStart ) ; String uri = qPath . substring ( uriStart + 1 , uriFinish ) ; int tmp = qPath . indexOf ( "[" , uriFinish ) ; // next token if ( tmp == - 1 ) { tmp = qPath . length ( ) ; uriStart = - 1 ; } else uriStart = tmp ; String localName = qPath . substring ( uriFinish + 1 , tmp ) ; int index = 0 ; int ind = localName . indexOf ( PREFIX_DELIMITER ) ; if ( ind != - 1 ) { // has index index = Integer . parseInt ( localName . substring ( ind + 1 ) ) ; localName = localName . substring ( 0 , ind ) ; } else { if ( uriStart > - 1 ) throw new IllegalPathException ( "Bad internal path '" + qPath + "' each intermediate name should have index" ) ; } entries . add ( new QPathEntry ( uri , localName , index ) ) ; } return new QPath ( entries . toArray ( new QPathEntry [ entries . size ( ) ] ) ) ; } | Parses string and make internal path from it . | 400 | 11 |
15,851 | void repair ( boolean ignoreFailure ) throws IOException { if ( errors . size ( ) == 0 ) { log . info ( "No errors found." ) ; return ; } int notRepairable = 0 ; for ( Iterator < ConsistencyCheckError > it = errors . iterator ( ) ; it . hasNext ( ) ; ) { final ConsistencyCheckError error = it . next ( ) ; try { if ( error . repairable ( ) ) { // running in privileged mode error . repair ( ) ; } else { log . warn ( "Not repairable: " + error ) ; notRepairable ++ ; } } catch ( IOException e ) { if ( ignoreFailure ) { log . warn ( "Exception while reparing: " + e ) ; } else { throw e ; } } catch ( Exception e ) { if ( ignoreFailure ) { log . warn ( "Exception while reparing: " + e ) ; } else { throw new IOException ( e . getMessage ( ) , e ) ; } } } log . info ( "Repaired " + ( errors . size ( ) - notRepairable ) + " errors." ) ; if ( notRepairable > 0 ) { log . warn ( "" + notRepairable + " error(s) not repairable." ) ; } } | Repairs detected errors during the consistency check . | 279 | 9 |
15,852 | private void run ( ) throws IOException , RepositoryException { // UUIDs of multiple nodes in the index Set < String > multipleEntries = new HashSet < String > ( ) ; // collect all documents UUIDs documentUUIDs = new HashSet < String > ( ) ; CachingMultiIndexReader reader = index . getIndexReader ( ) ; try { for ( int i = 0 ; i < reader . maxDoc ( ) ; i ++ ) { if ( i > 10 && i % ( reader . maxDoc ( ) / 5 ) == 0 ) { long progress = Math . round ( ( 100.0 * i ) / ( reader . maxDoc ( ) * 2f ) ) ; log . info ( "progress: " + progress + "%" ) ; } if ( reader . isDeleted ( i ) ) { continue ; } final int currentIndex = i ; Document d = reader . document ( currentIndex , FieldSelectors . UUID ) ; String uuid = d . get ( FieldNames . UUID ) ; if ( stateMgr . getItemData ( uuid ) != null ) { if ( ! documentUUIDs . add ( uuid ) ) { multipleEntries . add ( uuid ) ; } } else { errors . add ( new NodeDeleted ( uuid ) ) ; } } } finally { reader . release ( ) ; } // create multiple entries errors for ( Iterator < String > it = multipleEntries . iterator ( ) ; it . hasNext ( ) ; ) { errors . add ( new MultipleEntries ( it . next ( ) ) ) ; } reader = index . getIndexReader ( ) ; try { // run through documents again and check parent for ( int i = 0 ; i < reader . maxDoc ( ) ; i ++ ) { if ( i > 10 && i % ( reader . maxDoc ( ) / 5 ) == 0 ) { long progress = Math . round ( ( 100.0 * i ) / ( reader . maxDoc ( ) * 2f ) ) ; log . info ( "progress: " + ( progress + 50 ) + "%" ) ; } if ( reader . isDeleted ( i ) ) { continue ; } final int currentIndex = i ; Document d = reader . document ( currentIndex , FieldSelectors . UUID_AND_PARENT ) ; String uuid = d . get ( FieldNames . UUID ) ; String parentUUIDString = d . get ( FieldNames . PARENT ) ; if ( parentUUIDString == null || documentUUIDs . contains ( parentUUIDString ) ) { continue ; } // parent is missing //NodeId parentId = new NodeId(parentUUID); if ( stateMgr . getItemData ( parentUUIDString ) != null ) { errors . add ( new MissingAncestor ( uuid , parentUUIDString ) ) ; } else { errors . add ( new UnknownParent ( uuid , parentUUIDString ) ) ; } } } finally { reader . release ( ) ; } } | Runs the consistency check . | 644 | 6 |
15,853 | public WorkspaceContainer getWorkspaceContainer ( String workspaceName ) { Object comp = getComponentInstance ( workspaceName ) ; return comp != null && comp instanceof WorkspaceContainer ? ( WorkspaceContainer ) comp : null ; } | Get workspace Container by name . | 47 | 6 |
15,854 | public WorkspaceEntry getWorkspaceEntry ( String wsName ) { for ( WorkspaceEntry entry : config . getWorkspaceEntries ( ) ) { if ( entry . getName ( ) . equals ( wsName ) ) return entry ; } return null ; } | Get workspace configuration entry by name . | 57 | 7 |
15,855 | private void load ( ) throws RepositoryException { //Namespaces first NamespaceDataPersister namespacePersister = ( NamespaceDataPersister ) this . getComponentInstanceOfType ( NamespaceDataPersister . class ) ; NamespaceRegistryImpl nsRegistry = ( NamespaceRegistryImpl ) getNamespaceRegistry ( ) ; namespacePersister . start ( ) ; nsRegistry . start ( ) ; //Node types now. JCRNodeTypeDataPersister nodeTypePersister = ( JCRNodeTypeDataPersister ) this . getComponentInstanceOfType ( JCRNodeTypeDataPersister . class ) ; NodeTypeDataManagerImpl ntManager = ( NodeTypeDataManagerImpl ) this . getComponentInstanceOfType ( NodeTypeDataManagerImpl . class ) ; nodeTypePersister . start ( ) ; ntManager . start ( ) ; } | Load namespaces and nodetypes from persistent repository . | 183 | 11 |
15,856 | protected InternalQName [ ] getSelectProperties ( ) throws RepositoryException { // get select properties List < InternalQName > selectProps = new ArrayList < InternalQName > ( ) ; selectProps . addAll ( Arrays . asList ( root . getSelectProperties ( ) ) ) ; if ( selectProps . size ( ) == 0 ) { // use node type constraint LocationStepQueryNode [ ] steps = root . getLocationNode ( ) . getPathSteps ( ) ; final InternalQName [ ] ntName = new InternalQName [ 1 ] ; steps [ steps . length - 1 ] . acceptOperands ( new DefaultQueryNodeVisitor ( ) { public Object visit ( AndQueryNode node , Object data ) throws RepositoryException { return node . acceptOperands ( this , data ) ; } public Object visit ( NodeTypeQueryNode node , Object data ) { ntName [ 0 ] = node . getValue ( ) ; return data ; } } , null ) ; if ( ntName [ 0 ] == null ) { ntName [ 0 ] = Constants . NT_BASE ; } NodeTypeData nt = session . getWorkspace ( ) . getNodeTypesHolder ( ) . getNodeType ( ntName [ 0 ] ) ; PropertyDefinitionData [ ] propDefs = nt . getDeclaredPropertyDefinitions ( ) ; for ( int i = 0 ; i < propDefs . length ; i ++ ) { PropertyDefinitionData propDef = propDefs [ i ] ; if ( ! propDef . isResidualSet ( ) && ! propDef . isMultiple ( ) ) { selectProps . add ( propDef . getName ( ) ) ; } } } // add jcr:path and jcr:score if not selected already if ( ! selectProps . contains ( Constants . JCR_PATH ) ) { selectProps . add ( Constants . JCR_PATH ) ; } if ( ! selectProps . contains ( Constants . JCR_SCORE ) ) { selectProps . add ( Constants . JCR_SCORE ) ; } return ( InternalQName [ ] ) selectProps . toArray ( new InternalQName [ selectProps . size ( ) ] ) ; } | Returns the select properties for this query . | 489 | 8 |
15,857 | protected Session session ( String repoName , String wsName , List < String > lockTokens ) throws Exception , NoSuchWorkspaceException { // To be cloud compliant we need now to ignore the provided repository name (more details in JCR-2138) ManageableRepository repo = repositoryService . getCurrentRepository ( ) ; if ( PropertyManager . isDevelopping ( ) && log . isWarnEnabled ( ) ) { String currentRepositoryName = repo . getConfiguration ( ) . getName ( ) ; if ( ! currentRepositoryName . equals ( repoName ) ) { log . warn ( "The expected repository was '" + repoName + "' but we will use the current repository instead which is '" + currentRepositoryName + "'" ) ; } } SessionProvider sp = sessionProviderService . getSessionProvider ( null ) ; if ( sp == null ) throw new RepositoryException ( "SessionProvider is not properly set. Make the application calls" + "SessionProviderService.setSessionProvider(..) somewhere before (" + "for instance in Servlet Filter for WEB application)" ) ; Session session = sp . getSession ( wsName , repo ) ; if ( lockTokens != null ) { String [ ] presentLockTokens = session . getLockTokens ( ) ; ArrayList < String > presentLockTokensList = new ArrayList < String > ( ) ; for ( int i = 0 ; i < presentLockTokens . length ; i ++ ) { presentLockTokensList . add ( presentLockTokens [ i ] ) ; } for ( int i = 0 ; i < lockTokens . size ( ) ; i ++ ) { String lockToken = lockTokens . get ( i ) ; if ( ! presentLockTokensList . contains ( lockToken ) ) { session . addLockToken ( lockToken ) ; } } } return session ; } | Gives access to the current session . | 391 | 8 |
15,858 | protected String getRepositoryName ( String repoName ) throws RepositoryException { // To be cloud compliant we need now to ignore the provided repository name (more details in JCR-2138) ManageableRepository repo = repositoryService . getCurrentRepository ( ) ; String currentRepositoryName = repo . getConfiguration ( ) . getName ( ) ; if ( PropertyManager . isDevelopping ( ) && log . isWarnEnabled ( ) ) { if ( ! currentRepositoryName . equals ( repoName ) ) { log . warn ( "The expected repository was '" + repoName + "' but we will use the current repository instead which is '" + currentRepositoryName + "'" ) ; } } return currentRepositoryName ; } | Gives the name of the repository to access . | 159 | 10 |
15,859 | protected String normalizePath ( String repoPath ) { if ( repoPath . length ( ) > 0 && repoPath . endsWith ( "/" ) ) { return repoPath . substring ( 0 , repoPath . length ( ) - 1 ) ; } return repoPath ; } | Normalizes path . | 58 | 4 |
15,860 | protected String path ( String repoPath , boolean withIndex ) { String path = repoPath . substring ( workspaceName ( repoPath ) . length ( ) ) ; if ( path . length ( ) > 0 ) { if ( ! withIndex ) { return TextUtil . removeIndexFromPath ( path ) ; } return path ; } return "/" ; } | Extracts path from repository path . | 75 | 8 |
15,861 | protected List < String > lockTokens ( String lockTokenHeader , String ifHeader ) { ArrayList < String > lockTokens = new ArrayList < String > ( ) ; if ( lockTokenHeader != null ) { if ( lockTokenHeader . startsWith ( "<" ) ) { lockTokenHeader = lockTokenHeader . substring ( 1 , lockTokenHeader . length ( ) - 1 ) ; } if ( lockTokenHeader . contains ( WebDavConst . Lock . OPAQUE_LOCK_TOKEN ) ) { lockTokenHeader = lockTokenHeader . split ( ":" ) [ 1 ] ; } lockTokens . add ( lockTokenHeader ) ; } if ( ifHeader != null ) { String headerLockToken = ifHeader . substring ( ifHeader . indexOf ( "(" ) ) ; headerLockToken = headerLockToken . substring ( 2 , headerLockToken . length ( ) - 2 ) ; if ( headerLockToken . contains ( WebDavConst . Lock . OPAQUE_LOCK_TOKEN ) ) { headerLockToken = headerLockToken . split ( ":" ) [ 1 ] ; } lockTokens . add ( headerLockToken ) ; } return lockTokens ; } | Creates the list of Lock tokens from Lock - Token and If headers . | 254 | 15 |
15,862 | private URI buildURI ( String path ) throws URISyntaxException { try { return new URI ( path ) ; } catch ( URISyntaxException e ) { return new URI ( TextUtil . escape ( path , ' ' , true ) ) ; } } | Build URI from string . | 56 | 5 |
15,863 | private boolean isAllowedPath ( String workspaceName , String path ) { if ( pattern == null ) return true ; Matcher matcher = pattern . matcher ( workspaceName + ":" + path ) ; if ( ! matcher . find ( ) ) { log . warn ( "Access not allowed to webdav resource {}" , path ) ; return false ; } return true ; } | Check resource access allowed | 81 | 4 |
15,864 | protected void createRepositoryInternally ( String backupId , RepositoryEntry rEntry , String rToken , DBCreationProperties creationProps ) throws RepositoryConfigurationException , RepositoryCreationException { if ( rpcService != null ) { String stringRepositoryEntry = null ; try { JsonGeneratorImpl generatorImpl = new JsonGeneratorImpl ( ) ; JsonValue json = generatorImpl . createJsonObject ( rEntry ) ; stringRepositoryEntry = json . toString ( ) ; } catch ( JsonException e ) { throw new RepositoryCreationException ( "Can not serialize repository entry: " + e . getMessage ( ) , e ) ; } // notify coordinator node to create repository try { Object result = rpcService . executeCommandOnCoordinator ( createRepository , true , backupId , stringRepositoryEntry , rToken , creationProps ) ; if ( result != null ) { if ( result instanceof Throwable ) { throw new RepositoryCreationException ( "Can't create repository " + rEntry . getName ( ) , ( Throwable ) result ) ; } else { throw new RepositoryCreationException ( "createRepository command returned uknown result type." ) ; } } } catch ( RPCException e ) { Throwable cause = ( e ) . getCause ( ) ; if ( cause instanceof RepositoryCreationException ) { throw ( RepositoryCreationException ) cause ; } else if ( cause instanceof RepositoryConfigurationException ) { throw ( RepositoryConfigurationException ) cause ; } else { throw new RepositoryCreationException ( e . getMessage ( ) , e ) ; } } // execute startRepository at all cluster nodes (coordinator will ignore this command) try { List < Object > results = rpcService . executeCommandOnAllNodes ( startRepository , true , stringRepositoryEntry , creationProps ) ; for ( Object result : results ) { if ( result != null ) { if ( result instanceof Throwable ) { throw new RepositoryCreationException ( "Repository " + rEntry . getName ( ) + " created on coordinator, but can not be started at other cluster nodes" , ( ( Throwable ) result ) ) ; } else { throw new RepositoryCreationException ( "startRepository command returns uknown result type" ) ; } } } } catch ( RPCException e ) { throw new RepositoryCreationException ( "Repository " + rEntry . getName ( ) + " created on coordinator, can not be started at other cluster node: " + e . getMessage ( ) , e ) ; } } else { try { createRepositoryLocally ( backupId , rEntry , rToken , creationProps ) ; } finally { pendingRepositories . remove ( rToken ) ; } } } | Create repository internally . serverUrl and connProps contain specific properties for db creation . | 598 | 17 |
15,865 | protected void removeRepositoryLocally ( String repositoryName , boolean forceRemove ) throws RepositoryCreationException { try { // extract list of all datasources ManageableRepository repositorty = repositoryService . getRepository ( repositoryName ) ; Set < String > datasources = extractDataSourceNames ( repositorty . getConfiguration ( ) , false ) ; // close all opened sessions for ( String workspaceName : repositorty . getWorkspaceNames ( ) ) { WorkspaceContainerFacade wc = repositorty . getWorkspaceContainer ( workspaceName ) ; SessionRegistry sessionRegistry = ( SessionRegistry ) wc . getComponent ( SessionRegistry . class ) ; sessionRegistry . closeSessions ( workspaceName ) ; } // remove repository from configuration repositoryService . removeRepository ( repositoryName , forceRemove ) ; repositoryService . getConfig ( ) . retain ( ) ; // unbind datasource and close connections for ( String dsName : datasources ) { try { // we suppose that lookup() method returns the same instance of datasource by the same name DataSource ds = ( DataSource ) initialContextInitializer . getInitialContext ( ) . lookup ( dsName ) ; initialContextInitializer . getInitialContextBinder ( ) . unbind ( dsName ) ; // close datasource if ( ds instanceof CloseableDataSource ) { ( ( CloseableDataSource ) ds ) . close ( ) ; } } catch ( NamingException e ) { LOG . error ( "Can't unbind datasource " + dsName , e ) ; } catch ( FileNotFoundException e ) { LOG . error ( "Can't unbind datasource " + dsName , e ) ; } catch ( XMLStreamException e ) { LOG . error ( "Can't unbind datasource " + dsName , e ) ; } } } catch ( RepositoryException e ) { throw new RepositoryCreationException ( "Can't remove repository" , e ) ; } catch ( RepositoryConfigurationException e ) { throw new RepositoryCreationException ( "Can't remove repository" , e ) ; } } | Remove repository locally . | 459 | 4 |
15,866 | private void traverseResources ( Resource resource , int counter ) throws XMLStreamException , RepositoryException , IllegalResourceTypeException , URISyntaxException , UnsupportedEncodingException { xmlStreamWriter . writeStartElement ( "DAV:" , "response" ) ; xmlStreamWriter . writeStartElement ( "DAV:" , "href" ) ; String href = resource . getIdentifier ( ) . toASCIIString ( ) ; if ( resource . isCollection ( ) ) { xmlStreamWriter . writeCharacters ( href + "/" ) ; } else { xmlStreamWriter . writeCharacters ( href ) ; } xmlStreamWriter . writeEndElement ( ) ; PropstatGroupedRepresentation propstat = new PropstatGroupedRepresentation ( resource , propertyNames , propertyNamesOnly , session ) ; PropertyWriteUtil . writePropStats ( xmlStreamWriter , propstat . getPropStats ( ) ) ; xmlStreamWriter . writeEndElement ( ) ; int d = depth ; if ( resource . isCollection ( ) ) { if ( counter < d ) { CollectionResource collection = ( CollectionResource ) resource ; for ( Resource child : collection . getResources ( ) ) { traverseResources ( child , counter + 1 ) ; } } } } | Traverses resources and collects the vales of required properties . | 259 | 13 |
15,867 | private void calculateWorkspaceDataSize ( ) { long dataSize ; try { dataSize = getWorkspaceDataSizeDirectly ( ) ; } catch ( QuotaManagerException e1 ) { throw new IllegalStateException ( "Can't calculate workspace data size" , e1 ) ; } ChangesItem changesItem = new ChangesItem ( ) ; changesItem . updateWorkspaceChangedSize ( dataSize ) ; Runnable task = new ApplyPersistedChangesTask ( context , changesItem ) ; task . run ( ) ; } | Calculates and accumulates workspace data size . | 109 | 10 |
15,868 | private void printWarning ( PropertyImpl property , Exception exception ) throws RepositoryException { if ( PropertyManager . isDevelopping ( ) ) { LOG . warn ( "Binary value reader error, content by path " + property . getPath ( ) + ", property id " + property . getData ( ) . getIdentifier ( ) + " : " + exception . getMessage ( ) , exception ) ; } else { LOG . warn ( "Binary value reader error, content by path " + property . getPath ( ) + ", property id " + property . getData ( ) . getIdentifier ( ) + " : " + exception . getMessage ( ) ) ; } } | Print warning message on the console | 143 | 6 |
15,869 | private void setJCRProperties ( NodeImpl parent , Properties props ) throws Exception { if ( ! parent . isNodeType ( "dc:elementSet" ) ) { parent . addMixin ( "dc:elementSet" ) ; } ValueFactory vFactory = parent . getSession ( ) . getValueFactory ( ) ; LocationFactory lFactory = parent . getSession ( ) . getLocationFactory ( ) ; for ( Entry entry : props . entrySet ( ) ) { QName qname = ( QName ) entry . getKey ( ) ; JCRName jcrName = lFactory . createJCRName ( new InternalQName ( qname . getNamespace ( ) , qname . getName ( ) ) ) ; PropertyDefinitionData definition = parent . getSession ( ) . getWorkspace ( ) . getNodeTypesHolder ( ) . getPropertyDefinitions ( jcrName . getInternalName ( ) , ( ( NodeData ) parent . getData ( ) ) . getPrimaryTypeName ( ) , ( ( NodeData ) parent . getData ( ) ) . getMixinTypeNames ( ) ) . getAnyDefinition ( ) ; if ( definition != null ) { if ( definition . isMultiple ( ) ) { Value [ ] values = { createValue ( entry . getValue ( ) , vFactory ) } ; parent . setProperty ( jcrName . getAsString ( ) , values ) ; } else { Value value = createValue ( entry . getValue ( ) , vFactory ) ; parent . setProperty ( jcrName . getAsString ( ) , value ) ; } } } } | Sets metainfo properties as JCR properties to node . | 342 | 13 |
15,870 | private static String prepareScripts ( String initScriptPath , String itemTableSuffix , String valueTableSuffix , String refTableSuffix , boolean isolatedDB ) throws IOException { String scripts = IOUtil . getStreamContentAsString ( PrivilegedFileHelper . getResourceAsStream ( initScriptPath ) ) ; if ( isolatedDB ) { scripts = scripts . replace ( "MITEM" , itemTableSuffix ) . replace ( "MVALUE" , valueTableSuffix ) . replace ( "MREF" , refTableSuffix ) ; } return scripts ; } | Preparing SQL scripts for database initialization . | 127 | 8 |
15,871 | public static String getRootNodeInitializeScript ( String itemTableName , boolean multiDb ) { String singeDbScript = "insert into " + itemTableName + "(ID, PARENT_ID, NAME, CONTAINER_NAME, VERSION, I_CLASS, I_INDEX, " + "N_ORDER_NUM) VALUES('" + Constants . ROOT_PARENT_UUID + "', '" + Constants . ROOT_PARENT_UUID + "', '" + Constants . ROOT_PARENT_NAME + "', '" + Constants . ROOT_PARENT_CONAINER_NAME + "', 0, 0, 0, 0)" ; String multiDbScript = "insert into " + itemTableName + "(ID, PARENT_ID, NAME, VERSION, I_CLASS, I_INDEX, " + "N_ORDER_NUM) VALUES('" + Constants . ROOT_PARENT_UUID + "', '" + Constants . ROOT_PARENT_UUID + "', '" + Constants . ROOT_PARENT_NAME + "', 0, 0, 0, 0)" ; return multiDb ? multiDbScript : singeDbScript ; } | Initialization script for root node . | 275 | 7 |
15,872 | public static String getObjectScript ( String objectName , boolean multiDb , String dialect , WorkspaceEntry wsEntry ) throws RepositoryConfigurationException , IOException { String scripts = prepareScripts ( wsEntry , dialect ) ; String sql = null ; for ( String query : JDBCUtils . splitWithSQLDelimiter ( scripts ) ) { String q = JDBCUtils . cleanWhitespaces ( query ) ; if ( q . contains ( objectName ) ) { if ( sql != null ) { throw new RepositoryConfigurationException ( "Can't find unique script for object creation. Object name: " + objectName ) ; } sql = q ; } } if ( sql != null ) { return sql ; } throw new RepositoryConfigurationException ( "Script for object creation is not found. Object name: " + objectName ) ; } | Returns SQL script for create objects such as index primary of foreign key . | 178 | 14 |
15,873 | public static boolean useSequenceForOrderNumber ( WorkspaceEntry wsConfig , String dbDialect ) throws RepositoryConfigurationException { try { if ( wsConfig . getContainer ( ) . getParameterValue ( JDBCWorkspaceDataContainer . USE_SEQUENCE_FOR_ORDER_NUMBER , JDBCWorkspaceDataContainer . USE_SEQUENCE_AUTO ) . equalsIgnoreCase ( JDBCWorkspaceDataContainer . USE_SEQUENCE_AUTO ) ) { return JDBCWorkspaceDataContainer . useSequenceDefaultValue ( ) ; } else { return wsConfig . getContainer ( ) . getParameterBoolean ( JDBCWorkspaceDataContainer . USE_SEQUENCE_FOR_ORDER_NUMBER ) ; } } catch ( RepositoryConfigurationException e ) { return JDBCWorkspaceDataContainer . useSequenceDefaultValue ( ) ; } } | Use sequence for order number . | 191 | 6 |
15,874 | SessionImpl createSession ( ConversationState user ) throws RepositoryException , LoginException { if ( IdentityConstants . SYSTEM . equals ( user . getIdentity ( ) . getUserId ( ) ) ) { // Need privileges to get system session. SecurityManager security = System . getSecurityManager ( ) ; if ( security != null ) { security . checkPermission ( JCRRuntimePermissions . CREATE_SYSTEM_SESSION_PERMISSION ) ; } } else if ( DynamicIdentity . DYNAMIC . equals ( user . getIdentity ( ) . getUserId ( ) ) ) { // Need privileges to get Dynamic session. SecurityManager security = System . getSecurityManager ( ) ; if ( security != null ) { security . checkPermission ( JCRRuntimePermissions . CREATE_DYNAMIC_SESSION_PERMISSION ) ; } } if ( SessionReference . isStarted ( ) ) { return new TrackedSession ( workspaceName , user , container ) ; } else { return new SessionImpl ( workspaceName , user , container ) ; } } | Creates Session object by given Credentials | 229 | 9 |
15,875 | @ Override public synchronized void retain ( ) throws RepositoryException { try { if ( ! isRetainable ( ) ) throw new RepositoryException ( "Unsupported configuration place " + configurationService . getURL ( param . getValue ( ) ) + " If you want to save configuration, start repository from standalone file." + " Or persister-class-name not configured" ) ; OutputStream saveStream = null ; if ( configurationPersister != null ) { saveStream = new ByteArrayOutputStream ( ) ; } else { URL filePath = configurationService . getURL ( param . getValue ( ) ) ; final File sourceConfig = new File ( filePath . toURI ( ) ) ; final File backUp = new File ( sourceConfig . getAbsoluteFile ( ) + "." + indexBackupFile ++ ) ; if ( indexBackupFile > maxBackupFiles ) { indexBackupFile = 1 ; } try { SecurityHelper . doPrivilegedIOExceptionAction ( new PrivilegedExceptionAction < Void > ( ) { public Void run ( ) throws IOException { DirectoryHelper . deleteDstAndRename ( sourceConfig , backUp ) ; return null ; } } ) ; } catch ( IOException ioe ) { throw new RepositoryException ( "Can't back up configuration on path " + PrivilegedFileHelper . getAbsolutePath ( sourceConfig ) , ioe ) ; } saveStream = PrivilegedFileHelper . fileOutputStream ( sourceConfig ) ; } IBindingFactory bfact ; try { bfact = SecurityHelper . doPrivilegedExceptionAction ( new PrivilegedExceptionAction < IBindingFactory > ( ) { public IBindingFactory run ( ) throws Exception { return BindingDirectory . getFactory ( RepositoryServiceConfiguration . class ) ; } } ) ; } catch ( PrivilegedActionException pae ) { Throwable cause = pae . getCause ( ) ; if ( cause instanceof JiBXException ) { throw ( JiBXException ) cause ; } else if ( cause instanceof RuntimeException ) { throw ( RuntimeException ) cause ; } else { throw new RuntimeException ( cause ) ; } } IMarshallingContext mctx = bfact . createMarshallingContext ( ) ; mctx . marshalDocument ( this , "ISO-8859-1" , null , saveStream ) ; saveStream . close ( ) ; // writing configuration in to the persister if ( configurationPersister != null ) { configurationPersister . write ( new ByteArrayInputStream ( ( ( ByteArrayOutputStream ) saveStream ) . toByteArray ( ) ) ) ; } } catch ( JiBXException e ) { throw new RepositoryException ( e ) ; } catch ( FileNotFoundException e ) { throw new RepositoryException ( e ) ; } catch ( IOException e ) { throw new RepositoryException ( e ) ; } catch ( RepositoryConfigurationException e ) { throw new RepositoryException ( e ) ; } catch ( Exception e ) { throw new RepositoryException ( e ) ; } } | Retain configuration of JCR If configurationPersister is configured it write data in to the persister otherwise it try to save configuration in file | 637 | 28 |
15,876 | protected void doRestore ( File backupFile ) throws BackupException { if ( ! PrivilegedFileHelper . exists ( backupFile ) ) { LOG . warn ( "Nothing to restore for quotas" ) ; return ; } ZipObjectReader in = null ; try { in = new ZipObjectReader ( PrivilegedFileHelper . zipInputStream ( backupFile ) ) ; quotaPersister . restoreWorkspaceData ( rName , wsName , in ) ; } catch ( IOException e ) { throw new BackupException ( e ) ; } finally { if ( in != null ) { try { in . close ( ) ; } catch ( IOException e ) { LOG . error ( "Can't close input stream" , e ) ; } } } repairDataSize ( ) ; } | Restores content . | 161 | 4 |
15,877 | private void repairDataSize ( ) { try { long dataSize = quotaPersister . getWorkspaceDataSize ( rName , wsName ) ; ChangesItem changesItem = new ChangesItem ( ) ; changesItem . updateWorkspaceChangedSize ( dataSize ) ; quotaPersister . setWorkspaceDataSize ( rName , wsName , 0 ) ; // workaround Runnable task = new ApplyPersistedChangesTask ( wqm . getContext ( ) , changesItem ) ; task . run ( ) ; } catch ( UnknownDataSizeException e ) { if ( LOG . isTraceEnabled ( ) ) { LOG . trace ( e . getMessage ( ) , e ) ; } } } | After workspace data size being restored need also to update repository and global data size on respective value . | 148 | 19 |
15,878 | protected void doBackup ( File backupFile ) throws BackupException { ZipObjectWriter out = null ; try { out = new ZipObjectWriter ( PrivilegedFileHelper . zipOutputStream ( backupFile ) ) ; quotaPersister . backupWorkspaceData ( rName , wsName , out ) ; } catch ( IOException e ) { throw new BackupException ( e ) ; } finally { if ( out != null ) { try { out . close ( ) ; } catch ( IOException e ) { LOG . error ( "Can't close output stream" , e ) ; } } } } | Backups data to define file . | 124 | 7 |
15,879 | private void importResource ( Node parentNode , InputStream file_in , String resourceType , ArtifactDescriptor artifact ) throws RepositoryException { // Note that artifactBean been initialized within constructor // resourceType can be jar, pom, metadata String filename ; if ( resourceType . equals ( "metadata" ) ) { filename = "maven-metadata.xml" ; } else { filename = String . format ( "%s-%s.%s" , artifact . getArtifactId ( ) , artifact . getVersionId ( ) , resourceType ) ; } OutputStream fout = null ; File tmp_file = null ; try { String tmpFilename = getUniqueFilename ( filename ) ; tmp_file = File . createTempFile ( tmpFilename , null ) ; fout = new FileOutputStream ( tmp_file ) ; IOUtils . copy ( file_in , fout ) ; fout . flush ( ) ; } catch ( FileNotFoundException e ) { LOG . error ( "Cannot create .tmp file for storing artifact" , e ) ; } catch ( IOException e ) { LOG . error ( "IO exception on .tmp file for storing artifact" , e ) ; } finally { IOUtils . closeQuietly ( file_in ) ; IOUtils . closeQuietly ( fout ) ; } writePrimaryContent ( parentNode , filename , resourceType , tmp_file ) ; writeChecksum ( parentNode , filename , tmp_file , "SHA1" ) ; try { // and collect all garbage : temporary files FileUtils . forceDelete ( tmp_file ) ; } catch ( IOException e ) { LOG . error ( "Cannot delete tmp file" , e ) ; } } | this method used for writing to repo jars poms and their checksums | 370 | 14 |
15,880 | private IndexInfos createIndexInfos ( Boolean system , IndexerIoModeHandler modeHandler , QueryHandlerEntry config , QueryHandler handler ) throws RepositoryConfigurationException { try { // read RSYNC configuration RSyncConfiguration rSyncConfiguration = new RSyncConfiguration ( config ) ; // rsync configured if ( rSyncConfiguration . getRsyncEntryName ( ) != null ) { return new RsyncIndexInfos ( wsId , cache , system , modeHandler , handler . getContext ( ) . getIndexDirectory ( ) , rSyncConfiguration ) ; } else { return new ISPNIndexInfos ( wsId , cache , true , modeHandler ) ; } } catch ( RepositoryConfigurationException e ) { return new ISPNIndexInfos ( wsId , cache , true , modeHandler ) ; } } | Factory method for creating corresponding IndexInfos class . RSyncIndexInfos created if RSync configured and ISPNIndexInfos otherwise | 173 | 27 |
15,881 | @ Managed @ ManagedDescription ( "The number of active locks" ) public int getNumLocks ( ) { try { return getNumLocks . run ( ) ; } catch ( LockException e ) { if ( LOG . isTraceEnabled ( ) ) { LOG . trace ( "An exception occurred: " + e . getMessage ( ) ) ; } } return - 1 ; } | Returns the number of active locks . | 83 | 7 |
15,882 | protected boolean hasLocks ( ) { try { return hasLocks . run ( ) ; } catch ( LockException e ) { if ( LOG . isTraceEnabled ( ) ) { LOG . trace ( "An exception occurred: " + e . getMessage ( ) ) ; } } return true ; } | Indicates if some locks have already been created . | 64 | 10 |
15,883 | public boolean isLockLive ( String nodeId ) throws LockException { try { return isLockLive . run ( nodeId ) ; } catch ( LockException e ) { if ( LOG . isTraceEnabled ( ) ) { LOG . trace ( "An exception occurred: " + e . getMessage ( ) ) ; } } return false ; } | Check is LockManager contains lock . No matter it is in pending or persistent state . | 72 | 17 |
15,884 | protected LockData getLockDataById ( String nodeId ) { try { return getLockDataById . run ( nodeId ) ; } catch ( LockException e ) { if ( LOG . isTraceEnabled ( ) ) { LOG . trace ( "An exception occurred: " + e . getMessage ( ) ) ; } } return null ; } | Returns lock data by node identifier . | 72 | 7 |
15,885 | protected synchronized List < LockData > getLockList ( ) { try { return getLockList . run ( ) ; } catch ( LockException e ) { if ( LOG . isTraceEnabled ( ) ) { LOG . trace ( "An exception occurred: " + e . getMessage ( ) ) ; } } return null ; } | Returns all locks . | 69 | 4 |
15,886 | public SessionLockManager getSessionLockManager ( String sessionId , SessionDataManager transientManager ) { CacheableSessionLockManager sessionManager = new CacheableSessionLockManager ( sessionId , this , transientManager ) ; sessionLockManagers . put ( sessionId , sessionManager ) ; return sessionManager ; } | Return new instance of session lock manager . | 63 | 8 |
15,887 | public synchronized void removeExpired ( ) { final List < String > removeLockList = new ArrayList < String > ( ) ; for ( LockData lock : getLockList ( ) ) { if ( ! lock . isSessionScoped ( ) && lock . getTimeToDeath ( ) < 0 ) { removeLockList . add ( lock . getNodeIdentifier ( ) ) ; } } Collections . sort ( removeLockList ) ; for ( String rLock : removeLockList ) { removeLock ( rLock ) ; } } | Remove expired locks . Used from LockRemover . | 111 | 10 |
15,888 | protected void removeLock ( String nodeIdentifier ) { try { NodeData nData = ( NodeData ) dataManager . getItemData ( nodeIdentifier ) ; //Skip removing, because that node was removed in other node of cluster. if ( nData == null ) { return ; } PlainChangesLog changesLog = new PlainChangesLogImpl ( new ArrayList < ItemState > ( ) , IdentityConstants . SYSTEM , ExtendedEvent . UNLOCK ) ; ItemData lockOwner = copyItemData ( ( PropertyData ) dataManager . getItemData ( nData , new QPathEntry ( Constants . JCR_LOCKOWNER , 1 ) , ItemType . PROPERTY ) ) ; //Skip removing, because that lock was removed in other node of cluster. if ( lockOwner == null ) { return ; } changesLog . add ( ItemState . createDeletedState ( lockOwner ) ) ; ItemData lockIsDeep = copyItemData ( ( PropertyData ) dataManager . getItemData ( nData , new QPathEntry ( Constants . JCR_LOCKISDEEP , 1 ) , ItemType . PROPERTY ) ) ; //Skip removing, because that lock was removed in other node of cluster. if ( lockIsDeep == null ) { return ; } changesLog . add ( ItemState . createDeletedState ( lockIsDeep ) ) ; // lock probably removed by other thread if ( lockOwner == null && lockIsDeep == null ) { return ; } dataManager . save ( new TransactionChangesLog ( changesLog ) ) ; } catch ( JCRInvalidItemStateException e ) { //Skip property not found in DB, because that lock property was removed in other node of cluster. if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "The propperty was removed in other node of cluster." , e ) ; } } catch ( RepositoryException e ) { LOG . error ( "Error occur during removing lock" + e . getLocalizedMessage ( ) , e ) ; } } | Remove lock used by Lock remover . | 426 | 8 |
15,889 | protected void removeAll ( ) { List < LockData > locks = getLockList ( ) ; for ( LockData lockData : locks ) { removeLock ( lockData . getNodeIdentifier ( ) ) ; } } | Remove all locks . | 46 | 4 |
15,890 | public static byte [ ] getAsByteArray ( TransactionChangesLog dataChangesLog ) throws IOException { ByteArrayOutputStream os = new ByteArrayOutputStream ( ) ; ObjectOutputStream oos = new ObjectOutputStream ( os ) ; oos . writeObject ( dataChangesLog ) ; byte [ ] bArray = os . toByteArray ( ) ; return bArray ; } | getAsByteArray . Make the array of bytes from ChangesLog . | 79 | 14 |
15,891 | public static TransactionChangesLog getAsItemDataChangesLog ( byte [ ] byteArray ) throws IOException , ClassNotFoundException { ByteArrayInputStream is = new ByteArrayInputStream ( byteArray ) ; ObjectInputStream ois = new ObjectInputStream ( is ) ; TransactionChangesLog objRead = ( TransactionChangesLog ) ois . readObject ( ) ; return objRead ; } | getAsItemDataChangesLog . Make the ChangesLog from array of bytes . | 81 | 16 |
15,892 | public PlainChangesLog read ( ObjectReader in ) throws UnknownClassIdException , IOException { int key ; if ( ( key = in . readInt ( ) ) != SerializationConstants . PLAIN_CHANGES_LOG_IMPL ) { throw new UnknownClassIdException ( "There is unexpected class [" + key + "]" ) ; } int eventType = in . readInt ( ) ; String sessionId = in . readString ( ) ; List < ItemState > items = new ArrayList < ItemState > ( ) ; int listSize = in . readInt ( ) ; for ( int i = 0 ; i < listSize ; i ++ ) { ItemStateReader isr = new ItemStateReader ( holder , spoolConfig ) ; ItemState is = isr . read ( in ) ; items . add ( is ) ; } return new PlainChangesLogImpl ( items , sessionId , eventType ) ; } | Read and set PlainChangesLog data . | 195 | 8 |
15,893 | public void write ( ObjectWriter out , PlainChangesLog pcl ) throws IOException { // write id out . writeInt ( SerializationConstants . PLAIN_CHANGES_LOG_IMPL ) ; out . writeInt ( pcl . getEventType ( ) ) ; out . writeString ( pcl . getSessionId ( ) ) ; List < ItemState > list = pcl . getAllStates ( ) ; int listSize = list . size ( ) ; out . writeInt ( listSize ) ; ItemStateWriter wr = new ItemStateWriter ( ) ; for ( int i = 0 ; i < listSize ; i ++ ) { wr . write ( out , list . get ( i ) ) ; } } | Write PlainChangesLog data . | 153 | 6 |
15,894 | private ExtendedNode getUsersStorageNode ( ) throws RepositoryException { Session session = service . getStorageSession ( ) ; try { return ( ExtendedNode ) utils . getUsersStorageNode ( service . getStorageSession ( ) ) ; } finally { session . logout ( ) ; } } | Returns users storage node . | 61 | 5 |
15,895 | protected void closeStatements ( ) { try { if ( findItemById != null ) { findItemById . close ( ) ; } if ( findItemByPath != null ) { findItemByPath . close ( ) ; } if ( findItemByName != null ) { findItemByName . close ( ) ; } if ( findChildPropertyByPath != null ) { findChildPropertyByPath . close ( ) ; } if ( findPropertyByName != null ) { findPropertyByName . close ( ) ; } if ( findDescendantNodes != null ) { findDescendantNodes . close ( ) ; } if ( findDescendantProperties != null ) { findDescendantProperties . close ( ) ; } if ( findReferences != null ) { findReferences . close ( ) ; } if ( findValuesByPropertyId != null ) { findValuesByPropertyId . close ( ) ; } if ( findValuesDataByPropertyId != null ) { findValuesDataByPropertyId . close ( ) ; } if ( findNodesByParentId != null ) { findNodesByParentId . close ( ) ; } if ( findLastOrderNumberByParentId != null ) { findLastOrderNumberByParentId . close ( ) ; } if ( findNodesCountByParentId != null ) { findNodesCountByParentId . close ( ) ; } if ( findPropertiesByParentId != null ) { findPropertiesByParentId . close ( ) ; } if ( findMaxPropertyVersions != null ) { findMaxPropertyVersions . close ( ) ; } if ( insertNode != null ) { insertNode . close ( ) ; } if ( insertProperty != null ) { insertProperty . close ( ) ; } if ( insertReference != null ) { insertReference . close ( ) ; } if ( insertValue != null ) { insertValue . close ( ) ; } if ( updateNode != null ) { updateNode . close ( ) ; } if ( updateProperty != null ) { updateProperty . close ( ) ; } if ( deleteItem != null ) { deleteItem . close ( ) ; } if ( deleteReference != null ) { deleteReference . close ( ) ; } if ( deleteValue != null ) { deleteValue . close ( ) ; } if ( renameNode != null ) { renameNode . close ( ) ; } if ( findNodesAndProperties != null ) { findNodesAndProperties . close ( ) ; } if ( findNodesCount != null ) { findNodesCount . close ( ) ; } if ( findWorkspaceDataSize != null ) { findWorkspaceDataSize . close ( ) ; } if ( findNodeDataSize != null ) { findNodeDataSize . close ( ) ; } if ( findNodePropertiesOnValueStorage != null ) { findNodePropertiesOnValueStorage . close ( ) ; } if ( findWorkspacePropertiesOnValueStorage != null ) { findWorkspacePropertiesOnValueStorage . close ( ) ; } if ( findValueStorageDescAndSize != null ) { findValueStorageDescAndSize . close ( ) ; } } catch ( SQLException e ) { LOG . error ( "Can't close the statement: " + e . getMessage ( ) ) ; } } | Close all statements . | 693 | 4 |
15,896 | public List < NodeDataIndexing > getNodesAndProperties ( String lastNodeId , int offset , int limit ) throws RepositoryException , IllegalStateException { List < NodeDataIndexing > result = new ArrayList < NodeDataIndexing > ( ) ; checkIfOpened ( ) ; try { startTxIfNeeded ( ) ; ResultSet resultSet = findNodesAndProperties ( lastNodeId , offset , limit ) ; int processed = 0 ; try { TempNodeData tempNodeData = null ; while ( resultSet . next ( ) ) { if ( tempNodeData == null ) { tempNodeData = new TempNodeData ( resultSet ) ; processed ++ ; } else if ( ! resultSet . getString ( COLUMN_ID ) . equals ( tempNodeData . cid ) ) { if ( ! needToSkipOffsetNodes ( ) || processed > offset ) { result . add ( createNodeDataIndexing ( tempNodeData ) ) ; } tempNodeData = new TempNodeData ( resultSet ) ; processed ++ ; } if ( ! needToSkipOffsetNodes ( ) || processed > offset ) { String key = resultSet . getString ( "P_NAME" ) ; SortedSet < TempPropertyData > values = tempNodeData . properties . get ( key ) ; if ( values == null ) { values = new TreeSet < TempPropertyData > ( ) ; tempNodeData . properties . put ( key , values ) ; } values . add ( new ExtendedTempPropertyData ( resultSet ) ) ; } } if ( tempNodeData != null && ( ! needToSkipOffsetNodes ( ) || processed > offset ) ) { result . add ( createNodeDataIndexing ( tempNodeData ) ) ; } } finally { try { resultSet . close ( ) ; } catch ( SQLException e ) { LOG . error ( "Can't close the ResultSet: " + e . getMessage ( ) ) ; } } } catch ( IOException e ) { throw new RepositoryException ( e ) ; } catch ( IllegalNameException e ) { throw new RepositoryException ( e ) ; } catch ( SQLException e ) { throw new RepositoryException ( e ) ; } if ( LOG . isTraceEnabled ( ) ) { LOG . trace ( "getNodesAndProperties(%s, %s, %s) = %s elements" , lastNodeId , offset , limit , result . size ( ) ) ; } return result ; } | Returns from storage the next page of nodes and its properties . | 532 | 12 |
15,897 | public long getNodesCount ( ) throws RepositoryException { try { ResultSet countNodes = findNodesCount ( ) ; try { if ( countNodes . next ( ) ) { return countNodes . getLong ( 1 ) ; } else { throw new SQLException ( "ResultSet has't records." ) ; } } finally { JDBCUtils . freeResources ( countNodes , null , null ) ; } } catch ( SQLException e ) { throw new RepositoryException ( "Can not calculate nodes count" , e ) ; } } | Reads count of nodes in workspace . | 122 | 8 |
15,898 | public long getWorkspaceDataSize ( ) throws RepositoryException { long dataSize = 0 ; ResultSet result = null ; try { result = findWorkspaceDataSize ( ) ; try { if ( result . next ( ) ) { dataSize += result . getLong ( 1 ) ; } } finally { JDBCUtils . freeResources ( result , null , null ) ; } result = findWorkspacePropertiesOnValueStorage ( ) ; try { while ( result . next ( ) ) { String storageDesc = result . getString ( DBConstants . COLUMN_VSTORAGE_DESC ) ; String propertyId = result . getString ( DBConstants . COLUMN_VPROPERTY_ID ) ; int orderNum = result . getInt ( DBConstants . COLUMN_VORDERNUM ) ; ValueIOChannel channel = containerConfig . valueStorageProvider . getChannel ( storageDesc ) ; dataSize += channel . getValueSize ( getIdentifier ( propertyId ) , orderNum ) ; } } finally { JDBCUtils . freeResources ( result , null , null ) ; } } catch ( IOException e ) { throw new RepositoryException ( e ) ; } catch ( SQLException e ) { throw new RepositoryException ( e . getMessage ( ) , e ) ; } return dataSize ; } | Calculates workspace data size . | 293 | 7 |
15,899 | public long getNodeDataSize ( String nodeIdentifier ) throws RepositoryException { long dataSize = 0 ; ResultSet result = null ; try { result = findNodeDataSize ( getInternalId ( nodeIdentifier ) ) ; try { if ( result . next ( ) ) { dataSize += result . getLong ( 1 ) ; } } finally { JDBCUtils . freeResources ( result , null , null ) ; } result = findNodePropertiesOnValueStorage ( getInternalId ( nodeIdentifier ) ) ; try { while ( result . next ( ) ) { String storageDesc = result . getString ( DBConstants . COLUMN_VSTORAGE_DESC ) ; String propertyId = result . getString ( DBConstants . COLUMN_VPROPERTY_ID ) ; int orderNum = result . getInt ( DBConstants . COLUMN_VORDERNUM ) ; ValueIOChannel channel = containerConfig . valueStorageProvider . getChannel ( storageDesc ) ; dataSize += channel . getValueSize ( getIdentifier ( propertyId ) , orderNum ) ; } } finally { JDBCUtils . freeResources ( result , null , null ) ; } } catch ( IOException e ) { throw new RepositoryException ( e ) ; } catch ( SQLException e ) { throw new RepositoryException ( e . getMessage ( ) , e ) ; } return dataSize ; } | Calculates node data size . | 310 | 7 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.