idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
33,300 | private Long [ ] asIntegers ( List < Object > values ) { ValueFactory < Long > factory = valueFactories . getLongFactory ( ) ; Long [ ] res = new Long [ values . size ( ) ] ; for ( int i = 0 ; i < res . length ; i ++ ) { res [ i ] = factory . create ( values . get ( i ) ) ; } return res ; } | Converts CMIS value of integer type into JCR value of boolean type . | 86 | 16 |
33,301 | private BigDecimal [ ] asDecimals ( List < Object > values ) { ValueFactory < BigDecimal > factory = valueFactories . getDecimalFactory ( ) ; BigDecimal [ ] res = new BigDecimal [ values . size ( ) ] ; for ( int i = 0 ; i < res . length ; i ++ ) { res [ i ] = factory . create ( values . get ( i ) ) ; } return res ; } | Converts CMIS value of decimal type into JCR value of boolean type . | 96 | 16 |
33,302 | private URI [ ] asURI ( List < Object > values ) { ValueFactory < URI > factory = valueFactories . getUriFactory ( ) ; URI [ ] res = new URI [ values . size ( ) ] ; for ( int i = 0 ; i < res . length ; i ++ ) { res [ i ] = factory . create ( ( ( GregorianCalendar ) values . get ( i ) ) . getTime ( ) ) ; } return res ; } | Converts CMIS value of URI type into JCR value of URI type . | 99 | 16 |
33,303 | private String [ ] asIDs ( List < Object > values ) { ValueFactory < String > factory = valueFactories . getStringFactory ( ) ; String [ ] res = new String [ values . size ( ) ] ; for ( int i = 0 ; i < res . length ; i ++ ) { res [ i ] = factory . create ( values . get ( i ) ) ; } return res ; } | Converts CMIS value of ID type into JCR value of String type . | 85 | 16 |
33,304 | protected void workspaceAdded ( String workspaceName ) { String workspaceKey = NodeKey . keyForWorkspaceName ( workspaceName ) ; if ( systemWorkspaceKey . equals ( workspaceKey ) ) { // No sequencers for the system workspace! return ; } Collection < SequencingConfiguration > configs = new LinkedList < SequencingConfiguration > ( ) ; // Go through the sequencers to see which apply to this workspace ... for ( Sequencer sequencer : sequencersById . values ( ) ) { boolean updated = false ; for ( SequencerPathExpression expression : pathExpressionsBySequencerId . get ( sequencer . getUniqueId ( ) ) ) { if ( expression . appliesToWorkspace ( workspaceName ) ) { updated = true ; configs . add ( new SequencingConfiguration ( expression , sequencer ) ) ; } } if ( DEBUG && updated ) { LOGGER . debug ( "Updated sequencer '{0}' (id={1}) configuration due to new workspace '{2}' in repository '{3}'" , sequencer . getName ( ) , sequencer . getUniqueId ( ) , workspaceName , repository . name ( ) ) ; } } if ( configs . isEmpty ( ) ) return ; // Otherwise, update the configs by workspace key ... try { configChangeLock . lock ( ) ; // Make a copy of the existing map ... Map < String , Collection < SequencingConfiguration > > configByWorkspaceName = new HashMap < String , Collection < SequencingConfiguration > > ( this . configByWorkspaceName ) ; // Insert the new information ... configByWorkspaceName . put ( workspaceName , configs ) ; // Replace the exisiting map (which is used without a lock) ... this . configByWorkspaceName = configByWorkspaceName ; } finally { configChangeLock . unlock ( ) ; } } | Signal that a new workspace was added . | 395 | 9 |
33,305 | protected void workspaceRemoved ( String workspaceName ) { // Otherwise, update the configs by workspace key ... try { configChangeLock . lock ( ) ; // Make a copy of the existing map ... Map < String , Collection < SequencingConfiguration > > configByWorkspaceName = new HashMap < String , Collection < SequencingConfiguration > > ( this . configByWorkspaceName ) ; // Insert the new information ... if ( configByWorkspaceName . remove ( workspaceName ) != null ) { // Replace the exisiting map (which is used without a lock) ... this . configByWorkspaceName = configByWorkspaceName ; } } finally { configChangeLock . unlock ( ) ; } } | Signal that a new workspace was removed . | 147 | 9 |
33,306 | public static void register ( String name , Object obj ) { register ( name , obj , null , null , null , null ) ; } | A convenience method that registers the supplied object with the supplied name . | 28 | 13 |
33,307 | public Set < Name > getMixinTypes ( ) { if ( types . length == 1 ) { return Collections . emptySet ( ) ; } return new HashSet < Name > ( Arrays . asList ( Arrays . copyOfRange ( types , 1 , types . length ) ) ) ; } | Returns the mixins for this node . | 63 | 8 |
33,308 | private boolean hasModifierNamed ( String modifierName ) { for ( ModifierMetadata modifier : modifiers ) { if ( modifierName . equalsIgnoreCase ( modifier . getName ( ) ) ) { return true ; } } return false ; } | Checks if a modifier with the given name is found among this method s identifiers . | 52 | 17 |
33,309 | public double getMedianValue ( ) { Lock lock = this . getLock ( ) . writeLock ( ) ; try { lock . lock ( ) ; int count = this . values . size ( ) ; if ( count == 0 ) { return 0.0d ; } if ( this . medianValue == null ) { // Sort the values in numerical order.. Comparator < T > comparator = this . math . getComparator ( ) ; Collections . sort ( this . values , comparator ) ; this . medianValue = 0.0d ; // If there is only one value, then the median is that value ... if ( count == 1 ) { this . medianValue = this . values . get ( 0 ) . doubleValue ( ) ; } // If there is an odd number of values, find value that is in the middle .. else if ( count % 2 != 0 ) { this . medianValue = this . values . get ( ( ( count + 1 ) / 2 ) - 1 ) . doubleValue ( ) ; } // Otherwise, there is an even number of values, so find the average of the middle two values ... else { int upperMiddleValueIndex = count / 2 ; int lowerMiddleValueIndex = upperMiddleValueIndex - 1 ; double lowerValue = this . values . get ( lowerMiddleValueIndex ) . doubleValue ( ) ; double upperValue = this . values . get ( upperMiddleValueIndex ) . doubleValue ( ) ; this . medianValue = ( lowerValue + upperValue ) / 2.0d ; } this . median = this . math . create ( this . medianValue ) ; this . histogram = null ; } } finally { lock . unlock ( ) ; } return this . medianValue ; } | Return the median value . | 363 | 5 |
33,310 | public double getStandardDeviation ( ) { Lock lock = this . getLock ( ) . readLock ( ) ; lock . lock ( ) ; try { return this . sigma ; } finally { lock . unlock ( ) ; } } | Return the standard deviation . The standard deviation is a measure of the variation in a series of values . Values with a lower standard deviation has less variance in the values than a series of values with a higher standard deviation . | 49 | 43 |
33,311 | public org . modeshape . jcr . api . Problems backupRepository ( File backupDirectory , BackupOptions options ) throws RepositoryException { // Create the activity ... final BackupActivity backupActivity = createBackupActivity ( backupDirectory , options ) ; //suspend any existing transactions try { if ( runningState . suspendExistingUserTransaction ( ) ) { LOGGER . debug ( "Suspended existing active user transaction before the backup operation starts" ) ; } try { // Run the backup and return the problems ... return new JcrProblems ( backupActivity . execute ( ) ) ; } finally { runningState . resumeExistingUserTransaction ( ) ; } } catch ( SystemException e ) { throw new RuntimeException ( e ) ; } } | Start backing up the repository . | 155 | 6 |
33,312 | public org . modeshape . jcr . api . Problems restoreRepository ( final JcrRepository repository , final File backupDirectory , final RestoreOptions options ) throws RepositoryException { final String backupLocString = backupDirectory . getAbsolutePath ( ) ; LOGGER . debug ( "Beginning restore of '{0}' repository from {1} with options {2}" , repository . getName ( ) , backupLocString , options ) ; // Put the repository into the 'restoring' state ... repository . prepareToRestore ( ) ; // Create the activity ... final RestoreActivity restoreActivity = createRestoreActivity ( backupDirectory , options ) ; org . modeshape . jcr . api . Problems problems = null ; try { if ( runningState . suspendExistingUserTransaction ( ) ) { LOGGER . debug ( "Suspended existing active user transaction before the restore operation starts" ) ; } problems = new JcrProblems ( restoreActivity . execute ( ) ) ; if ( ! problems . hasProblems ( ) ) { // restart the repository ... try { repository . completeRestore ( options ) ; } catch ( Throwable t ) { restoreActivity . problems . addError ( t , JcrI18n . repositoryCannotBeRestartedAfterRestore , repository . getName ( ) , t . getMessage ( ) ) ; } finally { runningState . resumeExistingUserTransaction ( ) ; } } } catch ( SystemException e ) { throw new RuntimeException ( e ) ; } LOGGER . debug ( "Completed restore of '{0}' repository from {1}" , repository . getName ( ) , backupLocString ) ; return problems ; } | Start asynchronously backing up the repository . | 353 | 9 |
33,313 | protected final Metadata prepareMetadata ( final Binary binary , final Context context ) throws IOException , RepositoryException { Metadata metadata = new Metadata ( ) ; String mimeType = binary . getMimeType ( ) ; if ( StringUtil . isBlank ( mimeType ) ) { // Call the detector (we don't know the name) ... mimeType = context . mimeTypeOf ( null , binary ) ; } if ( ! StringUtil . isBlank ( mimeType ) ) { metadata . set ( Metadata . CONTENT_TYPE , mimeType ) ; } return metadata ; } | Creates a new tika metadata object used by the parser . This will contain the mime - type of the content being parsed if this is available to the underlying context . If not Tika s autodetection mechanism is used to try and get the mime - type . | 133 | 57 |
33,314 | private List < ServerAddress > convertToServerAddresses ( Set < String > addresses ) { return addresses . stream ( ) . map ( this :: stringToServerAddress ) . filter ( Objects :: nonNull ) . collect ( Collectors . toList ( ) ) ; } | Converts list of addresses specified in text format to mongodb specific address . | 56 | 17 |
33,315 | private void setAttribute ( DBCollection content , String fieldName , Object value ) { DBObject header = content . findOne ( HEADER_QUERY ) ; BasicDBObject newHeader = new BasicDBObject ( ) ; // clone header newHeader . put ( FIELD_CHUNK_TYPE , header . get ( FIELD_CHUNK_TYPE ) ) ; newHeader . put ( FIELD_MIME_TYPE , header . get ( FIELD_MIME_TYPE ) ) ; newHeader . put ( FIELD_EXTRACTED_TEXT , header . get ( FIELD_EXTRACTED_TEXT ) ) ; newHeader . put ( FIELD_UNUSED , header . get ( FIELD_UNUSED ) ) ; newHeader . put ( FIELD_UNUSED_SINCE , header . get ( FIELD_UNUSED_SINCE ) ) ; // modify specified field and update record newHeader . put ( fieldName , value ) ; content . update ( HEADER_QUERY , newHeader ) ; } | Modifies content header . | 227 | 5 |
33,316 | private Object getAttribute ( DBCollection content , String fieldName ) { return content . findOne ( HEADER_QUERY ) . get ( fieldName ) ; } | Gets attribute s value . | 36 | 6 |
33,317 | private boolean isExpired ( DBCollection content , long deadline ) { Long unusedSince = ( Long ) getAttribute ( content , FIELD_UNUSED_SINCE ) ; return unusedSince != null && unusedSince < deadline ; } | Checks status of unused content . | 52 | 7 |
33,318 | protected boolean pushDownJoinCriteria ( PlanNode criteriaNode , PlanNode joinNode ) { JoinType joinType = ( JoinType ) joinNode . getProperty ( Property . JOIN_TYPE ) ; switch ( joinType ) { case CROSS : joinNode . setProperty ( Property . JOIN_TYPE , JoinType . INNER ) ; moveCriteriaIntoOnClause ( criteriaNode , joinNode ) ; break ; case INNER : moveCriteriaIntoOnClause ( criteriaNode , joinNode ) ; break ; default : // This is where we could attempt to optimize the join type ... // if (optimizeJoinType(criteriaNode, joinNode) == JoinType.INNER) { // // The join type has changed ... // moveCriteriaIntoOnClause(criteriaNode, joinNode); // return true; // since the join type has changed ... // } } return false ; } | Attempt to push down criteria that applies to the JOIN as additional constraints on the JOIN itself . | 194 | 20 |
33,319 | private void moveCriteriaIntoOnClause ( PlanNode criteriaNode , PlanNode joinNode ) { List < Constraint > constraints = joinNode . getPropertyAsList ( Property . JOIN_CONSTRAINTS , Constraint . class ) ; Constraint criteria = criteriaNode . getProperty ( Property . SELECT_CRITERIA , Constraint . class ) ; // since the parser uses EMPTY_LIST, check for size 0 also if ( constraints == null || constraints . isEmpty ( ) ) { constraints = new LinkedList < Constraint > ( ) ; joinNode . setProperty ( Property . JOIN_CONSTRAINTS , constraints ) ; } if ( ! constraints . contains ( criteria ) ) { constraints . add ( criteria ) ; if ( criteriaNode . hasBooleanProperty ( Property . IS_DEPENDENT ) ) { joinNode . setProperty ( Property . IS_DEPENDENT , Boolean . TRUE ) ; } } criteriaNode . extractFromParent ( ) ; } | Move the criteria that applies to the join to be included in the actual join criteria . | 216 | 17 |
33,320 | protected void moveExtraProperties ( String oldNodeId , String newNodeId ) { ExtraPropertiesStore extraPropertiesStore = extraPropertiesStore ( ) ; if ( extraPropertiesStore == null || ! extraPropertiesStore . contains ( oldNodeId ) ) { return ; } Map < Name , Property > existingExtraProps = extraPropertiesStore . getProperties ( oldNodeId ) ; extraPropertiesStore . removeProperties ( oldNodeId ) ; extraPropertiesStore . storeProperties ( newNodeId , existingExtraProps ) ; } | Moves a set of extra properties from an old to a new node after their IDs have changed . | 119 | 20 |
33,321 | protected void checkFieldNotNull ( Object fieldValue , String fieldName ) throws RepositoryException { if ( fieldValue == null ) { throw new RepositoryException ( JcrI18n . requiredFieldNotSetInConnector . text ( getSourceName ( ) , getClass ( ) , fieldName ) ) ; } } | Utility method that checks whether the field with the supplied name is set . | 67 | 15 |
33,322 | protected void populateRuleStack ( LinkedList < OptimizerRule > ruleStack , PlanHints hints ) { ruleStack . addFirst ( ReorderSortAndRemoveDuplicates . INSTANCE ) ; ruleStack . addFirst ( RewritePathAndNameCriteria . INSTANCE ) ; if ( hints . hasSubqueries ) { ruleStack . addFirst ( RaiseVariableName . INSTANCE ) ; } ruleStack . addFirst ( RewriteAsRangeCriteria . INSTANCE ) ; if ( hints . hasJoin ) { ruleStack . addFirst ( AddJoinConditionColumnsToSources . INSTANCE ) ; ruleStack . addFirst ( ChooseJoinAlgorithm . USE_ONLY_NESTED_JOIN_ALGORITHM ) ; ruleStack . addFirst ( RewriteIdentityJoins . INSTANCE ) ; } ruleStack . addFirst ( AddOrderingColumnsToSources . INSTANCE ) ; ruleStack . addFirst ( PushProjects . INSTANCE ) ; ruleStack . addFirst ( PushSelectCriteria . INSTANCE ) ; ruleStack . addFirst ( AddAccessNodes . INSTANCE ) ; ruleStack . addFirst ( JoinOrder . INSTANCE ) ; ruleStack . addFirst ( RightOuterToLeftOuterJoins . INSTANCE ) ; ruleStack . addFirst ( CopyCriteria . INSTANCE ) ; if ( hints . hasView ) { ruleStack . addFirst ( ReplaceViews . INSTANCE ) ; } ruleStack . addFirst ( RewritePseudoColumns . INSTANCE ) ; // Add indexes determination last ... populateIndexingRules ( ruleStack , hints ) ; ruleStack . addLast ( OrderIndexesByCost . INSTANCE ) ; } | Method that is used to create the initial rule stack . This method can be overridden by subclasses | 360 | 20 |
33,323 | public Schemata getSchemataForSession ( JcrSession session ) { assert session != null ; // If the session does not override any namespace mappings used in this schemata ... if ( ! overridesNamespaceMappings ( session ) ) { // Then we can just use this schemata instance ... return this ; } // Otherwise, the session has some custom namespace mappings, so we need to return a session-specific instance... return new SessionSchemata ( session ) ; } | Get a schemata instance that works with the supplied session and that uses the session - specific namespace mappings . Note that the resulting instance does not change as the session s namespace mappings are changed so when that happens the JcrSession must call this method again to obtain a new schemata . | 104 | 61 |
33,324 | private boolean overridesNamespaceMappings ( JcrSession session ) { NamespaceRegistry registry = session . context ( ) . getNamespaceRegistry ( ) ; if ( registry instanceof LocalNamespaceRegistry ) { Set < Namespace > localNamespaces = ( ( LocalNamespaceRegistry ) registry ) . getLocalNamespaces ( ) ; if ( localNamespaces . isEmpty ( ) ) { // There are no local mappings ... return false ; } for ( Namespace namespace : localNamespaces ) { if ( prefixesByUris . containsKey ( namespace . getNamespaceUri ( ) ) ) return true ; } // None of the local namespace mappings overrode any namespaces used by this schemata ... return false ; } // We can't find the local mappings, so brute-force it ... for ( Namespace namespace : registry . getNamespaces ( ) ) { String expectedPrefix = prefixesByUris . get ( namespace . getNamespaceUri ( ) ) ; if ( expectedPrefix == null ) { // This namespace is not used by this schemata ... continue ; } if ( ! namespace . getPrefix ( ) . equals ( expectedPrefix ) ) return true ; } return false ; } | Determine if the session overrides any namespace mappings used by this schemata . | 265 | 19 |
33,325 | private List < Entry > removeValues ( Collection < ? > values , boolean ifMatch ) { LinkedList < Entry > results = null ; // Record the list of entries that are removed, but start at the end of the values (so the indexes are correct) ListIterator < ? > iter = this . values . listIterator ( size ( ) ) ; while ( iter . hasPrevious ( ) ) { int index = iter . previousIndex ( ) ; Object value = iter . previous ( ) ; if ( ifMatch == values . contains ( value ) ) { iter . remove ( ) ; if ( results == null ) { results = new LinkedList <> ( ) ; } results . addFirst ( new BasicEntry ( index , value ) ) ; } } return results != null ? results : Collections . < Entry > emptyList ( ) ; } | Remove some of the values in this array . | 175 | 9 |
33,326 | private boolean isExistCmisObject ( String path ) { try { session . getObjectByPath ( path ) ; return true ; } catch ( CmisObjectNotFoundException e ) { return false ; } } | Utility method for checking if CMIS object exists at defined path | 45 | 13 |
33,327 | private void rename ( CmisObject object , String name ) { Map < String , Object > newName = new HashMap < String , Object > ( ) ; newName . put ( "cmis:name" , name ) ; object . updateProperties ( newName ) ; } | Utility method for renaming CMIS object | 59 | 9 |
33,328 | private Document cmisObject ( String id ) { CmisObject cmisObject ; try { cmisObject = session . getObject ( id ) ; } catch ( CmisObjectNotFoundException e ) { return null ; } // object does not exist? return null if ( cmisObject == null ) { return null ; } // converting CMIS object to JCR node switch ( cmisObject . getBaseTypeId ( ) ) { case CMIS_FOLDER : return cmisFolder ( cmisObject ) ; case CMIS_DOCUMENT : return cmisDocument ( cmisObject ) ; case CMIS_POLICY : case CMIS_RELATIONSHIP : case CMIS_SECONDARY : case CMIS_ITEM : } // unexpected object type return null ; } | Converts CMIS object to JCR node . | 167 | 10 |
33,329 | private Document cmisFolder ( CmisObject cmisObject ) { Folder folder = ( Folder ) cmisObject ; DocumentWriter writer = newDocument ( ObjectId . toString ( ObjectId . Type . OBJECT , folder . getId ( ) ) ) ; ObjectType objectType = cmisObject . getType ( ) ; if ( objectType . isBaseType ( ) ) { writer . setPrimaryType ( NodeType . NT_FOLDER ) ; } else { writer . setPrimaryType ( objectType . getId ( ) ) ; } writer . setParent ( folder . getParentId ( ) ) ; writer . addMixinType ( NodeType . MIX_REFERENCEABLE ) ; writer . addMixinType ( NodeType . MIX_LAST_MODIFIED ) ; cmisProperties ( folder , writer ) ; cmisChildren ( folder , writer ) ; writer . addMixinType ( "mode:accessControllable" ) ; writer . addChild ( ObjectId . toString ( ObjectId . Type . ACL , folder . getId ( ) ) , "mode:acl" ) ; // append repository information to the root node if ( folder . isRootFolder ( ) ) { writer . addChild ( ObjectId . toString ( ObjectId . Type . REPOSITORY_INFO , "" ) , REPOSITORY_INFO_NODE_NAME ) ; } return writer . document ( ) ; } | Translates CMIS folder object to JCR node | 304 | 11 |
33,330 | public Document cmisDocument ( CmisObject cmisObject ) { org . apache . chemistry . opencmis . client . api . Document doc = ( org . apache . chemistry . opencmis . client . api . Document ) cmisObject ; DocumentWriter writer = newDocument ( ObjectId . toString ( ObjectId . Type . OBJECT , doc . getId ( ) ) ) ; ObjectType objectType = cmisObject . getType ( ) ; if ( objectType . isBaseType ( ) ) { writer . setPrimaryType ( NodeType . NT_FILE ) ; } else { writer . setPrimaryType ( objectType . getId ( ) ) ; } List < Folder > parents = doc . getParents ( ) ; ArrayList < String > parentIds = new ArrayList < String > ( ) ; for ( Folder f : parents ) { parentIds . add ( ObjectId . toString ( ObjectId . Type . OBJECT , f . getId ( ) ) ) ; } writer . setParents ( parentIds ) ; writer . addMixinType ( NodeType . MIX_REFERENCEABLE ) ; writer . addMixinType ( NodeType . MIX_LAST_MODIFIED ) ; // document specific property conversation cmisProperties ( doc , writer ) ; writer . addChild ( ObjectId . toString ( ObjectId . Type . CONTENT , doc . getId ( ) ) , JcrConstants . JCR_CONTENT ) ; writer . addMixinType ( "mode:accessControllable" ) ; writer . addChild ( ObjectId . toString ( ObjectId . Type . ACL , cmisObject . getId ( ) ) , "mode:acl" ) ; return writer . document ( ) ; } | Translates cmis document object to JCR node . | 375 | 12 |
33,331 | private Document cmisContent ( String id ) { DocumentWriter writer = newDocument ( ObjectId . toString ( ObjectId . Type . CONTENT , id ) ) ; org . apache . chemistry . opencmis . client . api . Document doc = ( org . apache . chemistry . opencmis . client . api . Document ) session . getObject ( id ) ; writer . setPrimaryType ( NodeType . NT_RESOURCE ) ; writer . setParent ( id ) ; ContentStream contentStream = doc . getContentStream ( ) ; if ( contentStream != null ) { BinaryValue content = new CmisConnectorBinary ( contentStream , getSourceName ( ) , id , getMimeTypeDetector ( ) ) ; writer . addProperty ( JcrConstants . JCR_DATA , content ) ; writer . addProperty ( JcrConstants . JCR_MIME_TYPE , contentStream . getMimeType ( ) ) ; } Property < Object > lastModified = doc . getProperty ( PropertyIds . LAST_MODIFICATION_DATE ) ; Property < Object > lastModifiedBy = doc . getProperty ( PropertyIds . LAST_MODIFIED_BY ) ; writer . addProperty ( JcrLexicon . LAST_MODIFIED , properties . jcrValues ( lastModified ) ) ; writer . addProperty ( JcrLexicon . LAST_MODIFIED_BY , properties . jcrValues ( lastModifiedBy ) ) ; return writer . document ( ) ; } | Converts binary content into JCR node . | 321 | 9 |
33,332 | private void cmisProperties ( CmisObject object , DocumentWriter writer ) { // convert properties List < Property < ? > > list = object . getProperties ( ) ; for ( Property < ? > property : list ) { String pname = properties . findJcrName ( property . getId ( ) ) ; if ( pname != null ) { writer . addProperty ( pname , properties . jcrValues ( property ) ) ; } } } | Converts CMIS object s properties to JCR node properties . | 96 | 13 |
33,333 | private void cmisChildren ( Folder folder , DocumentWriter writer ) { ItemIterable < CmisObject > it = folder . getChildren ( ) ; for ( CmisObject obj : it ) { writer . addChild ( obj . getId ( ) , obj . getName ( ) ) ; } } | Converts CMIS folder children to JCR node children | 63 | 11 |
33,334 | private Document cmisRepository ( ) { RepositoryInfo info = session . getRepositoryInfo ( ) ; DocumentWriter writer = newDocument ( ObjectId . toString ( ObjectId . Type . REPOSITORY_INFO , "" ) ) ; writer . setPrimaryType ( CmisLexicon . REPOSITORY ) ; writer . setId ( REPOSITORY_INFO_ID ) ; // product name/vendor/version writer . addProperty ( CmisLexicon . VENDOR_NAME , info . getVendorName ( ) ) ; writer . addProperty ( CmisLexicon . PRODUCT_NAME , info . getProductName ( ) ) ; writer . addProperty ( CmisLexicon . PRODUCT_VERSION , info . getProductVersion ( ) ) ; return writer . document ( ) ; } | Translates CMIS repository information into Node . | 172 | 10 |
33,335 | private ContentStream jcrBinaryContent ( Document document ) { // pickup node properties Document props = document . getDocument ( "properties" ) . getDocument ( JcrLexicon . Namespace . URI ) ; // extract binary value and content Binary value = props . getBinary ( "data" ) ; if ( value == null ) { return null ; } byte [ ] content = value . getBytes ( ) ; String fileName = props . getString ( "fileName" ) ; String mimeType = props . getString ( "mimeType" ) ; // wrap with input stream ByteArrayInputStream bin = new ByteArrayInputStream ( content ) ; bin . reset ( ) ; // create content stream return new ContentStreamImpl ( fileName , BigInteger . valueOf ( content . length ) , mimeType , bin ) ; } | Creates content stream using JCR node . | 177 | 9 |
33,336 | private void importTypes ( List < Tree < ObjectType > > types , NodeTypeManager typeManager , NamespaceRegistry registry ) throws RepositoryException { for ( Tree < ObjectType > tree : types ) { importType ( tree . getItem ( ) , typeManager , registry ) ; importTypes ( tree . getChildren ( ) , typeManager , registry ) ; } } | Import CMIS types to JCR repository . | 78 | 9 |
33,337 | @ SuppressWarnings ( "unchecked" ) public void importType ( ObjectType cmisType , NodeTypeManager typeManager , NamespaceRegistry registry ) throws RepositoryException { // TODO: get namespace information and register // registry.registerNamespace(cmisType.getLocalNamespace(), cmisType.getLocalNamespace()); // create node type template NodeTypeTemplate type = typeManager . createNodeTypeTemplate ( ) ; // convert CMIS type's attributes to node type template we have just created type . setName ( cmisType . getId ( ) ) ; type . setAbstract ( false ) ; type . setMixin ( false ) ; type . setOrderableChildNodes ( true ) ; type . setQueryable ( true ) ; if ( ! cmisType . isBaseType ( ) ) { type . setDeclaredSuperTypeNames ( superTypes ( cmisType ) ) ; } Map < String , PropertyDefinition < ? > > props = cmisType . getPropertyDefinitions ( ) ; Set < String > names = props . keySet ( ) ; // properties for ( String name : names ) { PropertyDefinition < ? > pd = props . get ( name ) ; PropertyDefinitionTemplate pt = typeManager . createPropertyDefinitionTemplate ( ) ; pt . setRequiredType ( properties . getJcrType ( pd . getPropertyType ( ) ) ) ; pt . setAutoCreated ( false ) ; pt . setAvailableQueryOperators ( new String [ ] { } ) ; pt . setName ( name ) ; pt . setMandatory ( pd . isRequired ( ) ) ; type . getPropertyDefinitionTemplates ( ) . add ( pt ) ; } // register type NodeTypeDefinition [ ] nodeDefs = new NodeTypeDefinition [ ] { type } ; typeManager . registerNodeTypes ( nodeDefs , true ) ; } | Import given CMIS type to the JCR repository . | 395 | 11 |
33,338 | private String [ ] superTypes ( ObjectType cmisType ) { if ( cmisType . getBaseTypeId ( ) == BaseTypeId . CMIS_FOLDER ) { return new String [ ] { JcrConstants . NT_FOLDER } ; } if ( cmisType . getBaseTypeId ( ) == BaseTypeId . CMIS_DOCUMENT ) { return new String [ ] { JcrConstants . NT_FILE } ; } return new String [ ] { cmisType . getParentType ( ) . getId ( ) } ; } | Determines supertypes for the given CMIS type in terms of JCR . | 121 | 17 |
33,339 | @ SuppressWarnings ( "unchecked" ) private void registerRepositoryInfoType ( NodeTypeManager typeManager ) throws RepositoryException { // create node type template NodeTypeTemplate type = typeManager . createNodeTypeTemplate ( ) ; // convert CMIS type's attributes to node type template we have just created type . setName ( "cmis:repository" ) ; type . setAbstract ( false ) ; type . setMixin ( false ) ; type . setOrderableChildNodes ( true ) ; type . setQueryable ( true ) ; type . setDeclaredSuperTypeNames ( new String [ ] { JcrConstants . NT_FOLDER } ) ; PropertyDefinitionTemplate vendorName = typeManager . createPropertyDefinitionTemplate ( ) ; vendorName . setAutoCreated ( false ) ; vendorName . setName ( "cmis:vendorName" ) ; vendorName . setMandatory ( false ) ; type . getPropertyDefinitionTemplates ( ) . add ( vendorName ) ; PropertyDefinitionTemplate productName = typeManager . createPropertyDefinitionTemplate ( ) ; productName . setAutoCreated ( false ) ; productName . setName ( "cmis:productName" ) ; productName . setMandatory ( false ) ; type . getPropertyDefinitionTemplates ( ) . add ( productName ) ; PropertyDefinitionTemplate productVersion = typeManager . createPropertyDefinitionTemplate ( ) ; productVersion . setAutoCreated ( false ) ; productVersion . setName ( "cmis:productVersion" ) ; productVersion . setMandatory ( false ) ; type . getPropertyDefinitionTemplates ( ) . add ( productVersion ) ; // register type NodeTypeDefinition [ ] nodeDefs = new NodeTypeDefinition [ ] { type } ; typeManager . registerNodeTypes ( nodeDefs , true ) ; } | Defines node type for the repository info . | 384 | 9 |
33,340 | @ Override public QueryResult execute ( String query , String language ) throws RepositoryException { logger . trace ( "Executing query: {0}" , query ) ; // Create the query ... final Query jcrQuery = getLocalSession ( ) . getSession ( ) . getWorkspace ( ) . getQueryManager ( ) . createQuery ( query , language ) ; return jcrQuery . execute ( ) ; } | This execute method is used for redirection so that the JNDI implementation can control calling execute . | 87 | 20 |
33,341 | public Repositories getRepositories ( ) { JSONRestClient . Response response = jsonRestClient . doGet ( ) ; if ( ! response . isOK ( ) ) { throw new RuntimeException ( JdbcI18n . invalidServerResponse . text ( jsonRestClient . url ( ) , response . asString ( ) ) ) ; } return new Repositories ( response . json ( ) ) ; } | Returns a list with all the available repositories . | 85 | 9 |
33,342 | public Workspaces getWorkspaces ( String repositoryName ) { String url = jsonRestClient . appendToBaseURL ( repositoryName ) ; JSONRestClient . Response response = jsonRestClient . doGet ( url ) ; if ( ! response . isOK ( ) ) { throw new RuntimeException ( JdbcI18n . invalidServerResponse . text ( url , response . asString ( ) ) ) ; } return new Workspaces ( response . json ( ) ) ; } | Returns all the workspaces for the named repository . | 99 | 10 |
33,343 | public String queryPlan ( String query , String queryLanguage ) { String url = jsonRestClient . appendToURL ( QUERY_PLAN_METHOD ) ; String contentType = contentTypeForQueryLanguage ( queryLanguage ) ; JSONRestClient . Response response = jsonRestClient . postStreamTextPlain ( new ByteArrayInputStream ( query . getBytes ( ) ) , url , contentType ) ; if ( ! response . isOK ( ) ) { throw new RuntimeException ( JdbcI18n . invalidServerResponse . text ( url , response . asString ( ) ) ) ; } return response . asString ( ) ; } | Returns a string representation of a query plan in a given language . | 134 | 13 |
33,344 | public long getCardinality ( ) { if ( pos > 0 ) { return totalHits ; } try { EsResponse res = client . search ( index , type , query ) ; Document hits = ( Document ) res . get ( "hits" ) ; totalHits = hits . getInteger ( "total" ) ; return totalHits ; } catch ( Exception e ) { throw new EsIndexException ( e ) ; } } | Gets cardinality for this search request . | 92 | 9 |
33,345 | public static List < Class < ? > > convertArgumentClassesToPrimitives ( Class < ? > ... arguments ) { if ( arguments == null || arguments . length == 0 ) return Collections . emptyList ( ) ; List < Class < ? > > result = new ArrayList < Class < ? > > ( arguments . length ) ; for ( Class < ? > clazz : arguments ) { if ( clazz == Boolean . class ) clazz = Boolean . TYPE ; else if ( clazz == Character . class ) clazz = Character . TYPE ; else if ( clazz == Byte . class ) clazz = Byte . TYPE ; else if ( clazz == Short . class ) clazz = Short . TYPE ; else if ( clazz == Integer . class ) clazz = Integer . TYPE ; else if ( clazz == Long . class ) clazz = Long . TYPE ; else if ( clazz == Float . class ) clazz = Float . TYPE ; else if ( clazz == Double . class ) clazz = Double . TYPE ; else if ( clazz == Void . class ) clazz = Void . TYPE ; result . add ( clazz ) ; } return result ; } | Convert any argument classes to primitives . | 247 | 9 |
33,346 | public static String getClassName ( final Class < ? > clazz ) { final String fullName = clazz . getName ( ) ; final int fullNameLength = fullName . length ( ) ; // Check for array ('[') or the class/interface marker ('L') ... int numArrayDimensions = 0 ; while ( numArrayDimensions < fullNameLength ) { final char c = fullName . charAt ( numArrayDimensions ) ; if ( c != ' ' ) { String name = null ; // Not an array, so it must be one of the other markers ... switch ( c ) { case ' ' : { name = fullName . subSequence ( numArrayDimensions + 1 , fullNameLength ) . toString ( ) ; break ; } case ' ' : { name = "byte" ; break ; } case ' ' : { name = "char" ; break ; } case ' ' : { name = "double" ; break ; } case ' ' : { name = "float" ; break ; } case ' ' : { name = "int" ; break ; } case ' ' : { name = "long" ; break ; } case ' ' : { name = "short" ; break ; } case ' ' : { name = "boolean" ; break ; } case ' ' : { name = "void" ; break ; } default : { name = fullName . subSequence ( numArrayDimensions , fullNameLength ) . toString ( ) ; } } if ( numArrayDimensions == 0 ) { // No array markers, so just return the name ... return name ; } // Otherwise, add the array markers and the name ... if ( numArrayDimensions < BRACKETS_PAIR . length ) { name = name + BRACKETS_PAIR [ numArrayDimensions ] ; } else { for ( int i = 0 ; i < numArrayDimensions ; i ++ ) { name = name + BRACKETS_PAIR [ 1 ] ; } } return name ; } ++ numArrayDimensions ; } return fullName ; } | Returns the name of the class . The result will be the fully - qualified class name or the readable form for arrays and primitive types . | 441 | 27 |
33,347 | public static void setValue ( Object instance , String fieldName , Object value ) { try { Field f = findFieldRecursively ( instance . getClass ( ) , fieldName ) ; if ( f == null ) throw new NoSuchMethodException ( "Cannot find field " + fieldName + " on " + instance . getClass ( ) + " or superclasses" ) ; f . setAccessible ( true ) ; f . set ( instance , value ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } } | Sets the value of a field of an object instance via reflection | 115 | 13 |
33,348 | public static Method findMethod ( Class < ? > type , String methodName ) { try { return type . getDeclaredMethod ( methodName ) ; } catch ( NoSuchMethodException e ) { if ( type . equals ( Object . class ) || type . isInterface ( ) ) { throw new RuntimeException ( e ) ; } return findMethod ( type . getSuperclass ( ) , methodName ) ; } } | Searches for a method with a given name in a class . | 87 | 14 |
33,349 | public Method [ ] findMethods ( Pattern methodNamePattern ) { final Method [ ] allMethods = this . targetClass . getMethods ( ) ; final List < Method > result = new ArrayList < Method > ( ) ; for ( int i = 0 ; i < allMethods . length ; i ++ ) { final Method m = allMethods [ i ] ; if ( methodNamePattern . matcher ( m . getName ( ) ) . matches ( ) ) { result . add ( m ) ; } } return result . toArray ( new Method [ result . size ( ) ] ) ; } | Find the methods on the target class that matches the supplied method name . | 123 | 14 |
33,350 | public Object invokeGetterMethodOnTarget ( String javaPropertyName , Object target ) throws NoSuchMethodException , SecurityException , IllegalArgumentException , IllegalAccessException , InvocationTargetException { String [ ] methodNamesArray = findMethodNames ( "get" + javaPropertyName ) ; if ( methodNamesArray . length <= 0 ) { // Try 'is' getter ... methodNamesArray = findMethodNames ( "is" + javaPropertyName ) ; } if ( methodNamesArray . length <= 0 ) { // Try 'are' getter ... methodNamesArray = findMethodNames ( "are" + javaPropertyName ) ; } return invokeBestMethodOnTarget ( methodNamesArray , target ) ; } | Find and execute the getter method on the target class for the supplied property name . If no such method is found a NoSuchMethodException is thrown . | 149 | 31 |
33,351 | public void setProperty ( Object target , Property property , Object value ) throws SecurityException , IllegalArgumentException , NoSuchMethodException , IllegalAccessException , InvocationTargetException { CheckArg . isNotNull ( target , "target" ) ; CheckArg . isNotNull ( property , "property" ) ; CheckArg . isNotNull ( property . getName ( ) , "property.getName()" ) ; invokeSetterMethodOnTarget ( property . getName ( ) , target , value ) ; } | Set the property on the supplied target object to the specified value . | 108 | 13 |
33,352 | public Object getProperty ( Object target , Property property ) throws SecurityException , IllegalArgumentException , NoSuchMethodException , IllegalAccessException , InvocationTargetException { CheckArg . isNotNull ( target , "target" ) ; CheckArg . isNotNull ( property , "property" ) ; CheckArg . isNotNull ( property . getName ( ) , "property.getName()" ) ; return invokeGetterMethodOnTarget ( property . getName ( ) , target ) ; } | Get current value for the property on the supplied target object . | 104 | 12 |
33,353 | public String getPropertyAsString ( Object target , Property property ) throws SecurityException , IllegalArgumentException , NoSuchMethodException , IllegalAccessException , InvocationTargetException { Object value = getProperty ( target , property ) ; StringBuilder sb = new StringBuilder ( ) ; writeObjectAsString ( value , sb , false ) ; return sb . toString ( ) ; } | Get current value represented as a string for the property on the supplied target object . | 81 | 16 |
33,354 | public String getSourceKey ( ) { if ( sourceKey == null ) { // Value is idempotent, so it's okay to do this without synchronizing ... sourceKey = key . substring ( SOURCE_START_INDEX , SOURCE_END_INDEX ) ; } return sourceKey ; } | Get the multi - character key uniquely identifying the repository s storage source in which this node appears . | 67 | 19 |
33,355 | public String getWorkspaceKey ( ) { if ( workspaceKey == null ) { // Value is idempotent, so it's okay to do this without synchronizing ... workspaceKey = key . substring ( WORKSPACE_START_INDEX , WORKSPACE_END_INDEX ) ; } return workspaceKey ; } | Get the multi - character key uniquely identifying the workspace in which the node appears . | 70 | 16 |
33,356 | public QueryBuilder union ( ) { this . firstQuery = query ( ) ; this . firstQuerySetOperation = Operation . UNION ; this . firstQueryAll = false ; clear ( false ) ; return this ; } | Perform a UNION between the query as defined prior to this method and the query that will be defined following this method . | 45 | 25 |
33,357 | public QueryBuilder unionAll ( ) { this . firstQuery = query ( ) ; this . firstQuerySetOperation = Operation . UNION ; this . firstQueryAll = true ; clear ( false ) ; return this ; } | Perform a UNION ALL between the query as defined prior to this method and the query that will be defined following this method . | 46 | 26 |
33,358 | public QueryBuilder intersect ( ) { this . firstQuery = query ( ) ; this . firstQuerySetOperation = Operation . INTERSECT ; this . firstQueryAll = false ; clear ( false ) ; return this ; } | Perform an INTERSECT between the query as defined prior to this method and the query that will be defined following this method . | 46 | 26 |
33,359 | public QueryBuilder intersectAll ( ) { this . firstQuery = query ( ) ; this . firstQuerySetOperation = Operation . INTERSECT ; this . firstQueryAll = true ; clear ( false ) ; return this ; } | Perform an INTERSECT ALL between the query as defined prior to this method and the query that will be defined following this method . | 47 | 27 |
33,360 | public QueryBuilder except ( ) { this . firstQuery = query ( ) ; this . firstQuerySetOperation = Operation . EXCEPT ; this . firstQueryAll = false ; clear ( false ) ; return this ; } | Perform an EXCEPT between the query as defined prior to this method and the query that will be defined following this method . | 45 | 25 |
33,361 | public QueryBuilder exceptAll ( ) { this . firstQuery = query ( ) ; this . firstQuerySetOperation = Operation . EXCEPT ; this . firstQueryAll = true ; clear ( false ) ; return this ; } | Perform an EXCEPT ALL between the query as defined prior to this method and the query that will be defined following this method . | 46 | 26 |
33,362 | public static IndexChangeAdapter forMultipleColumns ( ExecutionContext context , NodeTypePredicate matcher , String workspaceName , ProvidedIndex < ? > index , Iterable < IndexChangeAdapter > adapters ) { return new MultiColumnChangeAdapter ( context , workspaceName , matcher , index , adapters ) ; } | Creates a composite change adapter which handles the case when an index has multiple columns . | 63 | 17 |
33,363 | private boolean checkSupportedAudio ( ) { AudioHeader header = audioFile . getAudioHeader ( ) ; bitrate = header . getBitRateAsNumber ( ) ; sampleRate = header . getSampleRateAsNumber ( ) ; channels = header . getChannels ( ) ; if ( header . getChannels ( ) . toLowerCase ( ) . contains ( "stereo" ) ) { channels = "2" ; } if ( header instanceof MP3AudioHeader ) { duration = ( ( MP3AudioHeader ) header ) . getPreciseTrackLength ( ) ; } else if ( header instanceof Mp4AudioHeader ) { duration = ( double ) ( ( Mp4AudioHeader ) header ) . getPreciseLength ( ) ; } else { duration = ( double ) header . getTrackLength ( ) ; } // generic frames Tag tag = audioFile . getTag ( ) ; artist = tag . getFirst ( FieldKey . ARTIST ) ; album = tag . getFirst ( FieldKey . ALBUM ) ; title = tag . getFirst ( FieldKey . TITLE ) ; comment = tag . getFirst ( FieldKey . COMMENT ) ; year = tag . getFirst ( FieldKey . YEAR ) ; track = tag . getFirst ( FieldKey . TRACK ) ; genre = tag . getFirst ( FieldKey . GENRE ) ; artwork = new ArrayList <> ( ) ; for ( Artwork a : tag . getArtworkList ( ) ) { AudioMetadataArtwork ama = new AudioMetadataArtwork ( ) ; ama . setMimeType ( a . getMimeType ( ) ) ; if ( a . getPictureType ( ) >= 0 ) { ama . setType ( a . getPictureType ( ) ) ; } ama . setData ( a . getBinaryData ( ) ) ; artwork . add ( ama ) ; } return true ; } | Parse tags common for all audio files . | 405 | 9 |
33,364 | static < T > LocalUniqueIndex < T > create ( String name , String workspaceName , DB db , Converter < T > converter , BTreeKeySerializer < T > valueSerializer , Serializer < T > rawSerializer ) { return new LocalUniqueIndex <> ( name , workspaceName , db , converter , valueSerializer , rawSerializer ) ; } | Create a new index that allows only a single value for each unique key . | 78 | 15 |
33,365 | protected Object columnValue ( Object value ) { switch ( type ) { case PATH : case NAME : case STRING : case REFERENCE : case SIMPLEREFERENCE : case WEAKREFERENCE : case URI : return valueFactories . getStringFactory ( ) . create ( value ) ; case DATE : return ( ( DateTime ) value ) . getMilliseconds ( ) ; default : return value ; } } | Converts representation of the given value using type conversation rules between JCR type of this column and Elasticsearch core type of this column . | 89 | 27 |
33,366 | protected Object cast ( Object value ) { switch ( type ) { case STRING : return valueFactories . getStringFactory ( ) . create ( value ) ; case LONG : return valueFactories . getLongFactory ( ) . create ( value ) ; case NAME : return valueFactories . getNameFactory ( ) . create ( value ) ; case PATH : return valueFactories . getPathFactory ( ) . create ( value ) ; case DATE : return valueFactories . getDateFactory ( ) . create ( value ) ; case BOOLEAN : return valueFactories . getBooleanFactory ( ) . create ( value ) ; case URI : return valueFactories . getUriFactory ( ) . create ( value ) ; case REFERENCE : return valueFactories . getReferenceFactory ( ) . create ( value ) ; case SIMPLEREFERENCE : return valueFactories . getSimpleReferenceFactory ( ) . create ( value ) ; case WEAKREFERENCE : return valueFactories . getWeakReferenceFactory ( ) . create ( value ) ; default : return value ; } } | Converts given value to the value of JCR type of this column . | 229 | 15 |
33,367 | public boolean indexExists ( String name ) throws IOException { CloseableHttpClient client = HttpClients . createDefault ( ) ; HttpHead head = new HttpHead ( String . format ( "http://%s:%d/%s" , host , port , name ) ) ; try { CloseableHttpResponse response = client . execute ( head ) ; return response . getStatusLine ( ) . getStatusCode ( ) == HttpStatus . SC_OK ; } finally { head . releaseConnection ( ) ; } } | Tests for the index existence with specified name . | 114 | 10 |
33,368 | public boolean createIndex ( String name , String type , EsRequest mappings ) throws IOException { if ( indexExists ( name ) ) { return true ; } CloseableHttpClient client = HttpClients . createDefault ( ) ; HttpPost method = new HttpPost ( String . format ( "http://%s:%d/%s" , host , port , name ) ) ; try { StringEntity requestEntity = new StringEntity ( mappings . toString ( ) , ContentType . APPLICATION_JSON ) ; method . setEntity ( requestEntity ) ; CloseableHttpResponse resp = client . execute ( method ) ; return resp . getStatusLine ( ) . getStatusCode ( ) == HttpStatus . SC_OK ; } finally { method . releaseConnection ( ) ; } } | Creates new index . | 170 | 5 |
33,369 | public boolean deleteIndex ( String name ) throws IOException { CloseableHttpClient client = HttpClients . createDefault ( ) ; HttpDelete delete = new HttpDelete ( String . format ( "http://%s:%d/%s" , host , port , name ) ) ; try { CloseableHttpResponse resp = client . execute ( delete ) ; return resp . getStatusLine ( ) . getStatusCode ( ) == HttpStatus . SC_OK ; } finally { delete . releaseConnection ( ) ; } } | Deletes index . | 113 | 4 |
33,370 | public boolean storeDocument ( String name , String type , String id , EsRequest doc ) throws IOException { CloseableHttpClient client = HttpClients . createDefault ( ) ; HttpPost method = new HttpPost ( String . format ( "http://%s:%d/%s/%s/%s" , host , port , name , type , id ) ) ; try { StringEntity requestEntity = new StringEntity ( doc . toString ( ) , ContentType . APPLICATION_JSON ) ; method . setEntity ( requestEntity ) ; CloseableHttpResponse resp = client . execute ( method ) ; int statusCode = resp . getStatusLine ( ) . getStatusCode ( ) ; return statusCode == HttpStatus . SC_CREATED || statusCode == HttpStatus . SC_OK ; } finally { method . releaseConnection ( ) ; } } | Indexes document . | 186 | 4 |
33,371 | public EsRequest getDocument ( String name , String type , String id ) throws IOException { CloseableHttpClient client = HttpClients . createDefault ( ) ; HttpGet method = new HttpGet ( String . format ( "http://%s:%d/%s/%s/%s" , host , port , name , type , id ) ) ; try { CloseableHttpResponse resp = client . execute ( method ) ; int status = resp . getStatusLine ( ) . getStatusCode ( ) ; switch ( status ) { case HttpStatus . SC_OK : EsResponse doc = EsResponse . read ( resp . getEntity ( ) . getContent ( ) ) ; return new EsRequest ( ( Document ) doc . get ( "_source" ) ) ; case HttpStatus . SC_NOT_ACCEPTABLE : case HttpStatus . SC_NOT_FOUND : return null ; default : throw new IOException ( resp . getStatusLine ( ) . getReasonPhrase ( ) ) ; } } finally { method . releaseConnection ( ) ; } } | Searches indexed document . | 231 | 6 |
33,372 | public boolean deleteDocument ( String name , String type , String id ) throws IOException { CloseableHttpClient client = HttpClients . createDefault ( ) ; HttpDelete delete = new HttpDelete ( String . format ( "http://%s:%d/%s/%s/%s" , host , port , name , type , id ) ) ; try { return client . execute ( delete ) . getStatusLine ( ) . getStatusCode ( ) == HttpStatus . SC_OK ; } finally { delete . releaseConnection ( ) ; } } | Deletes document . | 121 | 4 |
33,373 | public void deleteAll ( String name , String type ) throws IOException { CloseableHttpClient client = HttpClients . createDefault ( ) ; HttpPost method = new HttpPost ( String . format ( "http://%s:%d/%s/%s" , host , port , name , type ) ) ; try { EsRequest query = new EsRequest ( ) ; query . put ( "query" , new MatchAllQuery ( ) . build ( ) ) ; StringEntity requestEntity = new StringEntity ( query . toString ( ) , ContentType . APPLICATION_JSON ) ; method . setEntity ( requestEntity ) ; method . setHeader ( " X-HTTP-Method-Override" , "DELETE" ) ; CloseableHttpResponse resp = client . execute ( method ) ; int status = resp . getStatusLine ( ) . getStatusCode ( ) ; if ( status != HttpStatus . SC_OK ) { throw new IOException ( resp . getStatusLine ( ) . getReasonPhrase ( ) ) ; } } finally { method . releaseConnection ( ) ; } } | Deletes all documents . | 236 | 5 |
33,374 | public void flush ( String name ) throws IOException { CloseableHttpClient client = HttpClients . createDefault ( ) ; HttpPost method = new HttpPost ( String . format ( "http://%s:%d/%s/_flush" , host , port , name ) ) ; try { CloseableHttpResponse resp = client . execute ( method ) ; int status = resp . getStatusLine ( ) . getStatusCode ( ) ; if ( status != HttpStatus . SC_OK ) { throw new IOException ( resp . getStatusLine ( ) . getReasonPhrase ( ) ) ; } } finally { method . releaseConnection ( ) ; } } | Flushes index data . | 143 | 5 |
33,375 | public EsResponse search ( String name , String type , EsRequest query ) throws IOException { CloseableHttpClient client = HttpClients . createDefault ( ) ; HttpPost method = new HttpPost ( String . format ( "http://%s:%d/%s/%s/_search" , host , port , name , type ) ) ; try { StringEntity requestEntity = new StringEntity ( query . toString ( ) , ContentType . APPLICATION_JSON ) ; method . setEntity ( requestEntity ) ; CloseableHttpResponse resp = client . execute ( method ) ; int status = resp . getStatusLine ( ) . getStatusCode ( ) ; if ( status != HttpStatus . SC_OK ) { throw new IOException ( resp . getStatusLine ( ) . getReasonPhrase ( ) ) ; } return EsResponse . read ( resp . getEntity ( ) . getContent ( ) ) ; } finally { method . releaseConnection ( ) ; } } | Executes query . | 209 | 4 |
33,376 | protected String doGetString ( NamespaceRegistry namespaceRegistry , TextEncoder encoder , TextEncoder delimiterEncoder ) { if ( encoder == null ) encoder = DEFAULT_ENCODER ; final String delimiter = delimiterEncoder != null ? delimiterEncoder . encode ( DELIMITER_STR ) : DELIMITER_STR ; // Since the segments are immutable, this code need not be synchronized because concurrent threads // may just compute the same value (with no harm done) StringBuilder sb = new StringBuilder ( ) ; if ( this . isAbsolute ( ) ) sb . append ( delimiter ) ; boolean first = true ; for ( Segment segment : this ) { if ( first ) { first = false ; } else { sb . append ( delimiter ) ; } assert segment != null ; sb . append ( segment . getString ( namespaceRegistry , encoder , delimiterEncoder ) ) ; } String result = sb . toString ( ) ; // Save the result to the internal string if this the default encoder is used. // This is not synchronized, but it's okay return result ; } | Method that creates the string representation . This method works two different ways depending upon whether the namespace registry is provided . | 247 | 22 |
33,377 | public Lock lock ( AbstractJcrNode node , boolean isDeep , boolean isSessionScoped , long timeoutHint , String ownerInfo ) throws LockException , AccessDeniedException , InvalidItemStateException , RepositoryException { if ( ! node . isLockable ( ) ) { throw new LockException ( JcrI18n . nodeNotLockable . text ( node . location ( ) ) ) ; } if ( node . isLocked ( ) ) { throw new LockException ( JcrI18n . alreadyLocked . text ( node . location ( ) ) ) ; } if ( node . isNew ( ) || node . isModified ( ) ) { throw new InvalidItemStateException ( JcrI18n . changedNodeCannotBeLocked . text ( node . location ( ) ) ) ; } // Try to obtain the lock ... ModeShapeLock lock = lockManager . lock ( session , node . node ( ) , isDeep , isSessionScoped , timeoutHint , ownerInfo ) ; String token = lock . getLockToken ( ) ; lockTokens . add ( token ) ; return lock . lockFor ( session ) ; } | Attempt to obtain a lock on the supplied node . | 243 | 10 |
33,378 | protected String removeQuotes ( String text ) { assert text != null ; if ( text . length ( ) > 2 ) { char first = text . charAt ( 0 ) ; // Need to remove these only if they are paired ... if ( first == ' ' || first == ' ' ) { int indexOfLast = text . length ( ) - 1 ; char last = text . charAt ( indexOfLast ) ; if ( last == first ) { text = text . substring ( 1 , indexOfLast ) ; } } } return text ; } | Remove any leading and trailing single - quotes or double - quotes from the supplied text . | 114 | 17 |
33,379 | public void write ( Document document ) { assert document != null ; ++ count ; ++ totalCount ; if ( count > maxDocumentsPerFile ) { // Close the stream (we'll open a new one later in the method) ... close ( ) ; count = 1 ; } try { if ( stream == null ) { // Open the stream to the next file ... ++ fileCount ; String suffix = StringUtil . justifyRight ( Long . toString ( fileCount ) , BackupService . NUM_CHARS_IN_FILENAME_SUFFIX , ' ' ) ; String filename = filenamePrefix + "_" + suffix + DOCUMENTS_EXTENSION ; if ( compress ) filename = filename + GZIP_EXTENSION ; currentFile = new File ( parentDirectory , filename ) ; OutputStream fileStream = new FileOutputStream ( currentFile ) ; if ( compress ) fileStream = new GZIPOutputStream ( fileStream ) ; stream = new BufferedOutputStream ( fileStream ) ; } Json . write ( document , stream ) ; // Need to append a non-consumable character so that we can read multiple JSON documents per file stream . write ( ( byte ) ' ' ) ; } catch ( IOException e ) { problems . addError ( JcrI18n . problemsWritingDocumentToBackup , currentFile . getAbsolutePath ( ) , e . getMessage ( ) ) ; } } | Append the supplied document to the files . | 300 | 9 |
33,380 | public Query constrainedBy ( Constraint constraint ) { return new Query ( source , constraint , orderings ( ) , columns , getLimits ( ) , distinct ) ; } | Create a copy of this query but one that uses the supplied constraint . | 36 | 14 |
33,381 | public Query orderedBy ( List < Ordering > orderings ) { return new Query ( source , constraint , orderings , columns , getLimits ( ) , distinct ) ; } | Create a copy of this query but one whose results should be ordered by the supplied orderings . | 37 | 19 |
33,382 | public Query returning ( List < Column > columns ) { return new Query ( source , constraint , orderings ( ) , columns , getLimits ( ) , distinct ) ; } | Create a copy of this query but that returns results with the supplied columns . | 36 | 15 |
33,383 | public Query adding ( Column ... columns ) { List < Column > newColumns = null ; if ( this . columns != null ) { newColumns = new ArrayList < Column > ( this . columns ) ; for ( Column column : columns ) { newColumns . add ( column ) ; } } else { newColumns = Arrays . asList ( columns ) ; } return new Query ( source , constraint , orderings ( ) , newColumns , getLimits ( ) , distinct ) ; } | Create a copy of this query but that returns results that include the columns specified by this query as well as the supplied columns . | 106 | 25 |
33,384 | private void getCredentials ( ) { jcrService . getUserName ( new BaseCallback < String > ( ) { @ Override public void onSuccess ( String name ) { showMainForm ( name ) ; } } ) ; } | Checks user s credentials . | 50 | 6 |
33,385 | public void loadNodeSpecifiedByURL ( ) { repositoriesList . select ( jcrURL . getRepository ( ) , jcrURL . getWorkspace ( ) , jcrURL . getPath ( ) , true ) ; } | Reconstructs URL and points browser to the requested node path . | 49 | 14 |
33,386 | public void showMainForm ( String userName ) { align ( ) ; changeUserName ( userName ) ; mainForm . addMember ( header ) ; mainForm . addMember ( repositoryHeader ) ; mainForm . addMember ( viewPort ) ; mainForm . addMember ( strut ( 30 ) ) ; mainForm . addMember ( footer ) ; setLayoutWidth ( LAYOUT_WIDTH ) ; loadData ( ) ; //init HTML history htmlHistory . addValueChangeHandler ( this ) ; mainForm . draw ( ) ; } | Shows main page for the logged in user . | 115 | 10 |
33,387 | public void changeRepositoryInURL ( String name , boolean changeHistory ) { jcrURL . setRepository ( name ) ; if ( changeHistory ) { htmlHistory . newItem ( jcrURL . toString ( ) , false ) ; } } | Changes repository name in URL displayed by browser . | 53 | 9 |
33,388 | public void changeWorkspaceInURL ( String name , boolean changeHistory ) { jcrURL . setWorkspace ( name ) ; if ( changeHistory ) { htmlHistory . newItem ( jcrURL . toString ( ) , false ) ; } } | Changes workspace in the URL displayed by browser . | 53 | 9 |
33,389 | public void changePathInURL ( String path , boolean changeHistory ) { jcrURL . setPath ( path ) ; if ( changeHistory ) { htmlHistory . newItem ( jcrURL . toString ( ) , false ) ; } } | Changes node path in the URL displayed by browser . | 51 | 10 |
33,390 | public void showRepositories ( Collection < RepositoryName > names ) { repositoriesList . show ( names ) ; display ( repositoriesList ) ; this . hideRepository ( ) ; } | Displays list of availables repositories . | 38 | 8 |
33,391 | public void displayContent ( String repository , String workspace , String path , boolean changeHistory ) { contents . show ( repository , workspace , path , changeHistory ) ; displayRepository ( repository ) ; display ( contents ) ; changeRepositoryInURL ( repository , changeHistory ) ; } | Displays node for the given repository workspace and path . | 58 | 11 |
33,392 | public int removeAllChildren ( Node node ) throws RepositoryException { isNotNull ( node , "node" ) ; int childrenRemoved = 0 ; NodeIterator iter = node . getNodes ( ) ; while ( iter . hasNext ( ) ) { Node child = iter . nextNode ( ) ; child . remove ( ) ; ++ childrenRemoved ; } return childrenRemoved ; } | Remove all children from the specified node | 79 | 7 |
33,393 | public Node getNode ( Node node , String relativePath , boolean required ) throws RepositoryException { isNotNull ( node , "node" ) ; isNotNull ( relativePath , "relativePath" ) ; Node result = null ; try { result = node . getNode ( relativePath ) ; } catch ( PathNotFoundException e ) { if ( required ) { throw e ; } } return result ; } | Get the node under a specified node at a location defined by the specified relative path . If node is required then a problem is created and added to the Problems list . | 86 | 33 |
33,394 | public String getReadable ( Node node ) { if ( node == null ) return "" ; try { return node . getPath ( ) ; } catch ( RepositoryException err ) { return node . toString ( ) ; } } | Get the readable string form for a specified node . | 48 | 10 |
33,395 | public Node findOrCreateNode ( Session session , String path , String nodeType ) throws RepositoryException { return findOrCreateNode ( session , path , nodeType , nodeType ) ; } | Get or create a node at the specified path and node type . | 40 | 13 |
33,396 | public Node findOrCreateChild ( Node parent , String name ) throws RepositoryException { return findOrCreateChild ( parent , name , null ) ; } | Get or create a node with the specified node under the specified parent node . | 32 | 15 |
33,397 | public Node findOrCreateChild ( Node parent , String name , String nodeType ) throws RepositoryException { return findOrCreateNode ( parent , name , nodeType , nodeType ) ; } | Get or create a node with the specified node and node type under the specified parent node . | 40 | 18 |
33,398 | public void onEachNode ( Session session , boolean includeSystemNodes , NodeOperation operation ) throws Exception { Node node = session . getRootNode ( ) ; operation . run ( node ) ; NodeIterator iter = node . getNodes ( ) ; while ( iter . hasNext ( ) ) { Node child = iter . nextNode ( ) ; if ( ! includeSystemNodes && child . getName ( ) . equals ( "jcr:system" ) ) continue ; operation . run ( child ) ; onEachNodeBelow ( child , operation ) ; } } | Execute the supplied operation on each node in the workspace accessible by the supplied session . | 118 | 17 |
33,399 | public List < AstNode > getChildrenForType ( AstNode astNode , String nodeType ) { CheckArg . isNotNull ( astNode , "astNode" ) ; CheckArg . isNotNull ( nodeType , "nodeType" ) ; List < AstNode > childrenOfType = new ArrayList < AstNode > ( ) ; for ( AstNode child : astNode . getChildren ( ) ) { if ( hasMixinType ( child , nodeType ) ) { childrenOfType . add ( child ) ; } List < AstNode > subChildrenOfType = getChildrenForType ( child , nodeType ) ; childrenOfType . addAll ( subChildrenOfType ) ; } return childrenOfType ; } | Utility method to obtain the children of a given node that match the given type | 152 | 16 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.