idx int64 0 41.2k | question stringlengths 74 4.04k | target stringlengths 7 750 |
|---|---|---|
33,000 | public Term parse ( String fullTextSearchExpression ) { CheckArg . isNotNull ( fullTextSearchExpression , "fullTextSearchExpression" ) ; Tokenizer tokenizer = new TermTokenizer ( ) ; TokenStream stream = new TokenStream ( fullTextSearchExpression , tokenizer , false ) ; return parse ( stream . start ( ) ) ; } | Parse the full - text search criteria given in the supplied string . |
33,001 | public Term parse ( TokenStream tokens ) { CheckArg . isNotNull ( tokens , "tokens" ) ; List < Term > terms = new ArrayList < Term > ( ) ; do { Term term = parseDisjunctedTerms ( tokens ) ; if ( term == null ) break ; terms . add ( term ) ; } while ( tokens . canConsume ( "OR" ) ) ; if ( terms . isEmpty ( ) ) return null ; return terms . size ( ) > 1 ? new Disjunction ( terms ) : terms . iterator ( ) . next ( ) ; } | Parse the full - text search criteria from the supplied token stream . This method is useful when the full - text search expression is included in other content . |
33,002 | protected static String requireActiveTransaction ( ) { return Optional . ofNullable ( ACTIVE_TX_ID . get ( ) ) . orElseThrow ( ( ) -> new RelationalProviderException ( RelationalProviderI18n . threadNotAssociatedWithTransaction , Thread . currentThread ( ) . getName ( ) ) ) ; } | Requires that an active transaction exists for the current calling thread . |
33,003 | public static NodeSequence emptySequence ( final int width ) { assert width >= 0 ; return new NodeSequence ( ) { public int width ( ) { return width ; } public Batch nextBatch ( ) { return null ; } public long getRowCount ( ) { return 0 ; } public boolean isEmpty ( ) { return true ; } public void close ( ) { } public String toString ( ) { return "(empty-sequence width=" + width ( ) + ")" ; } } ; } | Get an empty node sequence . |
33,004 | public static Batch emptyBatch ( final String workspaceName , final int width ) { assert width > 0 ; return new Batch ( ) { public boolean hasNext ( ) { return false ; } public String getWorkspaceName ( ) { return workspaceName ; } public int width ( ) { return width ; } public long rowCount ( ) { return 0 ; } public boolean isEmpty ( ) { return true ; } public void nextRow ( ) { throw new NoSuchElementException ( ) ; } public CachedNode getNode ( ) { throw new NoSuchElementException ( ) ; } public CachedNode getNode ( int index ) { throw new NoSuchElementException ( ) ; } public float getScore ( ) { throw new NoSuchElementException ( ) ; } public float getScore ( int index ) { throw new NoSuchElementException ( ) ; } public String toString ( ) { return "(empty-batch width=" + width ( ) + ")" ; } } ; } | Get a batch of nodes that is empty . |
33,005 | public static NodeSequence withBatch ( final Batch sequence ) { if ( sequence == null ) return emptySequence ( 1 ) ; return new NodeSequence ( ) { private boolean done = false ; public int width ( ) { return sequence . width ( ) ; } public long getRowCount ( ) { return sequence . rowCount ( ) ; } public boolean isEmpty ( ) { return sequence . isEmpty ( ) ; } public Batch nextBatch ( ) { if ( done ) return null ; done = true ; return sequence ; } public void close ( ) { } public String toString ( ) { return "(sequence-with-batch width=" + width ( ) + " " + sequence + " )" ; } } ; } | Create a sequence of nodes that returns the supplied single batch of nodes . |
33,006 | public static NodeSequence limit ( NodeSequence sequence , Limit limitAndOffset ) { if ( sequence == null ) return emptySequence ( 0 ) ; if ( limitAndOffset != null && ! limitAndOffset . isUnlimited ( ) ) { final int limit = limitAndOffset . getRowLimit ( ) ; if ( limitAndOffset . isOffset ( ) ) { sequence = skip ( sequence , limitAndOffset . getOffset ( ) ) ; } if ( limit != Integer . MAX_VALUE ) { sequence = limit ( sequence , limit ) ; } } return sequence ; } | Create a sequence of nodes that skips a specified number of nodes before returning any nodes and that limits the number of nodes returned . |
33,007 | public static NodeSequence limit ( final NodeSequence sequence , final long maxRows ) { if ( sequence == null ) return emptySequence ( 0 ) ; if ( maxRows <= 0 ) return emptySequence ( sequence . width ( ) ) ; if ( sequence . isEmpty ( ) ) return sequence ; return new NodeSequence ( ) { private LimitBatch lastLimitBatch = null ; protected long rowsRemaining = maxRows ; public long getRowCount ( ) { long count = sequence . getRowCount ( ) ; if ( count < 0L ) return - 1 ; return count < maxRows ? count : maxRows ; } public int width ( ) { return sequence . width ( ) ; } public boolean isEmpty ( ) { return false ; } public Batch nextBatch ( ) { if ( rowsRemaining <= 0 ) return null ; if ( lastLimitBatch != null ) { long rowsUsed = lastLimitBatch . rowsUsed ( ) ; if ( rowsUsed < rowsRemaining ) { rowsRemaining -= rowsUsed ; } else { return null ; } } final Batch next = sequence . nextBatch ( ) ; if ( next == null ) return null ; long size = next . rowCount ( ) ; boolean sizeKnown = false ; if ( size >= 0 ) { sizeKnown = true ; if ( size <= rowsRemaining ) { rowsRemaining -= size ; return next ; } assert size > rowsRemaining ; } long limit = rowsRemaining ; lastLimitBatch = new LimitBatch ( next , limit , sizeKnown ) ; return lastLimitBatch ; } public void close ( ) { sequence . close ( ) ; } public String toString ( ) { return "(limit " + maxRows + " " + sequence + " )" ; } } ; } | Create a sequence of nodes that returns at most the supplied number of rows . |
33,008 | public static NodeSequence skip ( final NodeSequence sequence , final int skip ) { if ( sequence == null ) return emptySequence ( 0 ) ; if ( skip <= 0 || sequence . isEmpty ( ) ) return sequence ; return new NodeSequence ( ) { private int rowsToSkip = skip ; public long getRowCount ( ) { long count = sequence . getRowCount ( ) ; if ( count < skip ) return - 1 ; return count == skip ? 0 : count - skip ; } public int width ( ) { return sequence . width ( ) ; } public boolean isEmpty ( ) { return false ; } public Batch nextBatch ( ) { Batch next = sequence . nextBatch ( ) ; while ( next != null ) { if ( rowsToSkip <= 0 ) return next ; long size = next . rowCount ( ) ; if ( size >= 0 ) { if ( size == 0 ) { next = sequence . nextBatch ( ) ; continue ; } if ( size <= rowsToSkip ) { rowsToSkip -= size ; next = sequence . nextBatch ( ) ; continue ; } for ( int i = 0 ; i != rowsToSkip ; ++ i ) { if ( ! next . hasNext ( ) ) return null ; next . nextRow ( ) ; -- size ; } rowsToSkip = 0 ; return new AlternateSizeBatch ( next , size ) ; } while ( rowsToSkip > 0 && next . hasNext ( ) ) { next . nextRow ( ) ; -- rowsToSkip ; } if ( next . hasNext ( ) ) return next ; next = sequence . nextBatch ( ) ; } return next ; } public void close ( ) { sequence . close ( ) ; } public String toString ( ) { return "(skip " + skip + " " + sequence + " )" ; } } ; } | Create a sequence of nodes that skips a specified number of rows before returning any rows . |
33,009 | public static NodeSequence filter ( final NodeSequence sequence , final RowFilter filter ) { if ( sequence == null ) return emptySequence ( 0 ) ; if ( filter == null || sequence . isEmpty ( ) ) return sequence ; return new NodeSequence ( ) { public long getRowCount ( ) { return - 1 ; } public int width ( ) { return sequence . width ( ) ; } public boolean isEmpty ( ) { return false ; } public Batch nextBatch ( ) { Batch next = sequence . nextBatch ( ) ; return batchFilteredWith ( next , filter ) ; } public void close ( ) { sequence . close ( ) ; } public String toString ( ) { return "(filtered width=" + width ( ) + " " + filter + " " + sequence + ")" ; } } ; } | Create a sequence of nodes that all satisfy the supplied filter . |
33,010 | public static NodeSequence append ( final NodeSequence first , final NodeSequence second ) { if ( first == null ) { return second != null ? second : emptySequence ( 0 ) ; } if ( second == null ) return first ; int firstWidth = first . width ( ) ; final int secondWidth = second . width ( ) ; if ( firstWidth > 0 && secondWidth > 0 && firstWidth != secondWidth ) { throw new IllegalArgumentException ( "The sequences must have the same width: " + first + " and " + second ) ; } if ( first . isEmpty ( ) ) return second ; if ( second . isEmpty ( ) ) return first ; long firstCount = first . getRowCount ( ) ; long secondCount = second . getRowCount ( ) ; final long count = firstCount < 0 ? - 1 : ( secondCount < 0 ? - 1 : firstCount + secondCount ) ; return new NodeSequence ( ) { private NodeSequence current = first ; public int width ( ) { return secondWidth ; } public long getRowCount ( ) { return count ; } public boolean isEmpty ( ) { return false ; } public Batch nextBatch ( ) { Batch batch = current . nextBatch ( ) ; while ( batch == null && current == first ) { current = second ; batch = current . nextBatch ( ) ; } return batch ; } public void close ( ) { try { first . close ( ) ; } finally { second . close ( ) ; } } public String toString ( ) { return "(append width=" + width ( ) + " " + first + "," + second + " )" ; } } ; } | Create a sequence of nodes that contains the nodes from the first sequence followed by the second sequence . |
33,011 | public static NodeSequence slice ( final NodeSequence original , Columns columns ) { final int newWidth = columns . getSelectorNames ( ) . size ( ) ; if ( original . width ( ) == newWidth ) { return original ; } final int [ ] selectorIndexes = new int [ newWidth ] ; int i = 0 ; for ( String selectorName : columns . getSelectorNames ( ) ) { selectorIndexes [ i ++ ] = columns . getSelectorIndex ( selectorName ) ; } return new NodeSequence ( ) { public int width ( ) { return 1 ; } public long getRowCount ( ) { return original . getRowCount ( ) ; } public boolean isEmpty ( ) { return original . isEmpty ( ) ; } public Batch nextBatch ( ) { return slicingBatch ( original . nextBatch ( ) , selectorIndexes ) ; } public void close ( ) { original . close ( ) ; } public String toString ( ) { return "(slice width=" + newWidth + " indexes=" + selectorIndexes + " " + original + " )" ; } } ; } | Create a sequence of nodes that include only those selectors defined by the given columns . |
33,012 | public static NodeSequence merging ( final NodeSequence first , final NodeSequence second , final int totalWidth ) { if ( first == null ) { if ( second == null ) return emptySequence ( totalWidth ) ; final int firstWidth = totalWidth - second . width ( ) ; return new NodeSequence ( ) { public int width ( ) { return totalWidth ; } public long getRowCount ( ) { return second . getRowCount ( ) ; } public boolean isEmpty ( ) { return second . isEmpty ( ) ; } public Batch nextBatch ( ) { return batchOf ( null , second . nextBatch ( ) , firstWidth , second . width ( ) ) ; } public void close ( ) { second . close ( ) ; } public String toString ( ) { return "(merge width=" + width ( ) + " (null-sequence)," + second + " )" ; } } ; } if ( second == null ) { final int secondWidth = totalWidth - first . width ( ) ; return new NodeSequence ( ) { public int width ( ) { return totalWidth ; } public long getRowCount ( ) { return first . getRowCount ( ) ; } public boolean isEmpty ( ) { return first . isEmpty ( ) ; } public Batch nextBatch ( ) { return batchOf ( first . nextBatch ( ) , null , first . width ( ) , secondWidth ) ; } public void close ( ) { first . close ( ) ; } public String toString ( ) { return "(merge width=" + width ( ) + " " + first + ",(null-sequence) )" ; } } ; } final int firstWidth = first . width ( ) ; final int secondWidth = second . width ( ) ; final long rowCount = Math . max ( - 1 , first . getRowCount ( ) + second . getRowCount ( ) ) ; return new NodeSequence ( ) { public int width ( ) { return totalWidth ; } public long getRowCount ( ) { return rowCount ; } public boolean isEmpty ( ) { return rowCount == 0 ; } public Batch nextBatch ( ) { Batch nextA = first . nextBatch ( ) ; Batch nextB = second . nextBatch ( ) ; if ( nextA == null ) { if ( nextB == null ) return null ; return batchOf ( null , nextB , firstWidth , secondWidth ) ; } return batchOf ( nextA , nextB , firstWidth , secondWidth ) ; } public void close ( ) { try { first . close ( ) ; } finally { second . close ( ) ; } } public String toString ( ) { return "(merge width=" + width ( ) + " " + first + "," + second + " )" ; } } ; } | Create a sequence of nodes that merges the two supplied sequences . |
33,013 | public synchronized final void initialize ( ) throws RepositoryException { if ( ! initialized ) { try { doInitialize ( ) ; initialized = true ; } catch ( RuntimeException e ) { throw new RepositoryException ( e ) ; } } } | Initialize the provider . This is called automatically by ModeShape once for each provider instance and should not be called by the provider itself . |
33,014 | public synchronized final void shutdown ( ) throws RepositoryException { preShutdown ( ) ; delegateWriter = NoOpQueryIndexWriter . INSTANCE ; try { for ( Map < String , AtomicIndex > byWorkspaceName : providedIndexesByWorkspaceNameByIndexName . values ( ) ) { for ( AtomicIndex provided : byWorkspaceName . values ( ) ) { provided . shutdown ( false ) ; } } } finally { providedIndexesByWorkspaceNameByIndexName . clear ( ) ; providedIndexesByIndexNameByWorkspaceName . clear ( ) ; postShutdown ( ) ; } } | Signal this provider that it is no longer needed and can release any resources that are being held . |
33,015 | public void validateDefaultColumnTypes ( ExecutionContext context , IndexDefinition defn , Problems problems ) { assert defn != null ; for ( int i = 0 ; i < defn . size ( ) ; i ++ ) { validateDefaultColumnDefinitionType ( context , defn , defn . getColumnDefinition ( i ) , problems ) ; } } | Validates that if certain default columns are present in the index definition they have a required type . |
33,016 | public final Index getIndex ( String indexName , String workspaceName ) { logger ( ) . trace ( "Looking for index '{0}' in '{1}' provider for query in workspace '{2}'" , indexName , getName ( ) , workspaceName ) ; Map < String , AtomicIndex > byWorkspaceNames = providedIndexesByWorkspaceNameByIndexName . get ( indexName ) ; return byWorkspaceNames == null ? null : byWorkspaceNames . get ( workspaceName ) ; } | Get the queryable index with the given name and applicable for the given workspace . |
33,017 | public final ManagedIndex getManagedIndex ( String indexName , String workspaceName ) { logger ( ) . trace ( "Looking for managed index '{0}' in '{1}' provider in workspace '{2}'" , indexName , getName ( ) , workspaceName ) ; Map < String , AtomicIndex > byWorkspaceNames = providedIndexesByWorkspaceNameByIndexName . get ( indexName ) ; if ( byWorkspaceNames == null ) { return null ; } AtomicIndex atomicIndex = byWorkspaceNames . get ( workspaceName ) ; return atomicIndex == null ? null : atomicIndex . managed ( ) ; } | Get the managed index with the given name and applicable for the given workspace . |
33,018 | private final void onEachIndex ( ProvidedIndexOperation op ) { for ( String workspaceName : workspaceNames ( ) ) { Collection < AtomicIndex > indexes = providedIndexesFor ( workspaceName ) ; if ( indexes != null ) { for ( AtomicIndex atomicIndex : indexes ) { assert atomicIndex . managed ( ) != null ; assert atomicIndex . indexDefinition ( ) != null ; op . apply ( workspaceName , atomicIndex ) ; } } } } | Perform the specified operation on each of the managed indexes . |
33,019 | public final void onEachIndexInWorkspace ( String workspaceName , ManagedIndexOperation op ) { assert workspaceName != null ; Collection < AtomicIndex > indexes = providedIndexesFor ( workspaceName ) ; if ( indexes != null ) { for ( AtomicIndex atomicIndex : indexes ) { assert atomicIndex . managed ( ) != null ; assert atomicIndex . indexDefinition ( ) != null ; op . apply ( workspaceName , atomicIndex . managed ( ) , atomicIndex . indexDefinition ( ) ) ; } } } | Perform the specified operation on each of the managed indexes in the named workspace . |
33,020 | protected ManagedIndex updateIndex ( IndexDefinition oldDefn , IndexDefinition updatedDefn , ManagedIndex existingIndex , String workspaceName , NodeTypes . Supplier nodeTypesSupplier , NodeTypePredicate matcher , IndexFeedback feedback ) { ManagedIndexBuilder builder = getIndexBuilder ( updatedDefn , workspaceName , nodeTypesSupplier , matcher ) ; if ( builder == null ) { throw new UnsupportedOperationException ( "Index providers should either override this method or the #getIndexBuilder method" ) ; } logger ( ) . debug ( "Index provider '{0}' is updating index in workspace '{1}': {2}" , getName ( ) , workspaceName , updatedDefn ) ; existingIndex . shutdown ( true ) ; ManagedIndex index = builder . build ( ) ; if ( index . requiresReindexing ( ) ) { scanWorkspace ( feedback , updatedDefn , workspaceName , index , nodeTypesSupplier ) ; } return index ; } | Method called when this provider needs to update an existing index given the unique pair of workspace name and index definition . An index definition can apply to multiple workspaces and when it is changed this method will be called once for each applicable workspace . |
33,021 | public List < NodeTypeDefinition > readAllNodeTypes ( ) { CachedNode nodeTypes = nodeTypesNode ( ) ; List < NodeTypeDefinition > defns = new ArrayList < NodeTypeDefinition > ( ) ; for ( ChildReference ref : nodeTypes . getChildReferences ( system ) ) { CachedNode nodeType = system . getNode ( ref ) ; defns . add ( readNodeTypeDefinition ( nodeType ) ) ; } return defns ; } | Read from system storage all of the node type definitions . |
33,022 | public Position add ( Position position ) { if ( this . getIndexInContent ( ) < 0 ) { return position . getIndexInContent ( ) < 0 ? EMPTY_CONTENT_POSITION : position ; } if ( position . getIndexInContent ( ) < 0 ) { return this ; } int index = this . getIndexInContent ( ) + position . getIndexInContent ( ) ; int line = position . getLine ( ) + this . getLine ( ) - 1 ; int column = this . getLine ( ) == 1 ? this . getColumn ( ) + position . getColumn ( ) : this . getColumn ( ) ; return new Position ( index , line , column ) ; } | Return a new position that is the addition of this position and that supplied . |
33,023 | public static ObjectId valueOf ( String uuid ) { int p = uuid . indexOf ( "/" ) ; if ( p < 0 ) { return new ObjectId ( Type . OBJECT , uuid ) ; } int p1 = p ; while ( p > 0 ) { p1 = p ; p = uuid . indexOf ( "/" , p + 1 ) ; } p = p1 ; String ident = uuid . substring ( 0 , p ) ; String type = uuid . substring ( p + 1 ) ; return new ObjectId ( Type . valueOf ( type . toUpperCase ( ) ) , ident ) ; } | Constructs instance of this class from its textual representation . |
33,024 | protected static Document replaceSystemPropertyVariables ( Document doc ) { if ( doc . isEmpty ( ) ) return doc ; Document modified = doc . withVariablesReplacedWithSystemProperties ( ) ; if ( modified == doc ) return doc ; return SCHEMA_LIBRARY . convertValues ( modified , JSON_SCHEMA_URI ) ; } | Utility method to replace all system property variables found within the specified document . |
33,025 | public static RepositoryConfiguration read ( String resourcePathOrJsonContentString ) throws ParsingException , FileNotFoundException { CheckArg . isNotNull ( resourcePathOrJsonContentString , "resourcePathOrJsonContentString" ) ; InputStream stream = ResourceLookup . read ( resourcePathOrJsonContentString , RepositoryConfiguration . class , true ) ; if ( stream != null ) { Document doc = Json . read ( stream ) ; return new RepositoryConfiguration ( doc , withoutExtension ( resourcePathOrJsonContentString ) ) ; } File file = new File ( resourcePathOrJsonContentString ) ; if ( file . exists ( ) && file . isFile ( ) ) { return read ( file ) ; } String content = resourcePathOrJsonContentString . trim ( ) ; if ( content . startsWith ( "{" ) ) { Document doc = Json . read ( content ) ; return new RepositoryConfiguration ( doc , null ) ; } throw new FileNotFoundException ( resourcePathOrJsonContentString ) ; } | Read the repository configuration given by the supplied path to a file on the file system the path a classpath resource file or a string containg the actual JSON content . |
33,026 | public List < String > getNodeTypes ( ) { List < String > result = new ArrayList < String > ( ) ; List < ? > configuredNodeTypes = doc . getArray ( FieldName . NODE_TYPES ) ; if ( configuredNodeTypes != null ) { for ( Object configuredNodeType : configuredNodeTypes ) { result . add ( configuredNodeType . toString ( ) ) ; } } return result ; } | Returns a list with the cnd files which should be loaded at startup . |
33,027 | public String getDefaultWorkspaceName ( ) { Document workspaces = doc . getDocument ( FieldName . WORKSPACES ) ; if ( workspaces != null ) { return workspaces . getString ( FieldName . DEFAULT , Default . DEFAULT ) ; } return Default . DEFAULT ; } | Get the name of the workspace that should be used for sessions where the client does not specify the name of the workspace . |
33,028 | public List < Component > getIndexProviders ( ) { Problems problems = new SimpleProblems ( ) ; List < Component > components = readComponents ( doc , FieldName . INDEX_PROVIDERS , FieldName . CLASSNAME , INDEX_PROVIDER_ALIASES , problems ) ; assert ! problems . hasErrors ( ) ; return components ; } | Get the ordered list of index providers defined in the configuration . |
33,029 | public DocumentOptimization getDocumentOptimization ( ) { Document storage = doc . getDocument ( FieldName . STORAGE ) ; if ( storage == null ) { storage = Schematic . newDocument ( ) ; } return new DocumentOptimization ( storage . getDocument ( FieldName . DOCUMENT_OPTIMIZATION ) ) ; } | Get the configuration for the document optimization for this repository . |
33,030 | public void writeTo ( WritableByteChannel channel ) throws IOException { int numberOfBytesToWrite = size ; for ( ByteBuffer buffer : buffers ) { if ( buffer == null ) { continue ; } int numBytesInBuffer = Math . min ( numberOfBytesToWrite , bufferSize ) ; buffer . position ( numBytesInBuffer ) ; buffer . flip ( ) ; channel . write ( buffer ) ; numberOfBytesToWrite -= numBytesInBuffer ; } buffers . clear ( ) ; } | Write all content to the supplied channel . |
33,031 | public final int applyUpgradesSince ( int lastId , Context resources ) { int lastUpgradeId = lastId ; for ( UpgradeOperation op : operations ) { if ( op . getId ( ) <= lastId ) continue ; LOGGER . debug ( "Upgrade {0}: starting" , op ) ; op . apply ( resources ) ; LOGGER . debug ( "Upgrade {0}: complete" , op ) ; lastUpgradeId = op . getId ( ) ; } return lastUpgradeId ; } | Apply any upgrades that are more recent than identified by the last upgraded identifier . |
33,032 | public static org . modeshape . jcr . api . Logger getLogger ( Class < ? > clazz ) { return new ExtensionLogger ( Logger . getLogger ( clazz ) ) ; } | Creates a new logger instance for the underlying class . |
33,033 | private void createIndex ( ) { try { client . createIndex ( name ( ) , workspace , columns . mappings ( workspace ) ) ; client . flush ( name ( ) ) ; } catch ( IOException e ) { throw new EsIndexException ( e ) ; } } | Executes create index action . |
33,034 | private EsRequest find ( String nodeKey ) throws IOException { return client . getDocument ( name ( ) , workspace , nodeKey ) ; } | Searches indexed node s properties by node key . |
33,035 | private EsRequest findOrCreateDoc ( String nodeKey ) throws IOException { EsRequest doc = client . getDocument ( name ( ) , workspace , nodeKey ) ; return doc != null ? doc : new EsRequest ( ) ; } | Searches indexed node s properties by node key or creates new empty list . |
33,036 | private void putValue ( EsRequest doc , EsIndexColumn column , Object value ) { Object columnValue = column . columnValue ( value ) ; String stringValue = column . stringValue ( value ) ; doc . put ( column . getName ( ) , columnValue ) ; if ( ! ( value instanceof ModeShapeDateTime || value instanceof Long || value instanceof Boolean ) ) { doc . put ( column . getLowerCaseFieldName ( ) , stringValue . toLowerCase ( ) ) ; doc . put ( column . getUpperCaseFieldName ( ) , stringValue . toUpperCase ( ) ) ; } doc . put ( column . getLengthFieldName ( ) , stringValue . length ( ) ) ; } | Appends specified value for the given column and related pseudo columns into list of properties . |
33,037 | private void putValues ( EsRequest doc , EsIndexColumn column , Object [ ] value ) { Object [ ] columnValue = column . columnValues ( value ) ; int [ ] ln = new int [ columnValue . length ] ; String [ ] lc = new String [ columnValue . length ] ; String [ ] uc = new String [ columnValue . length ] ; for ( int i = 0 ; i < columnValue . length ; i ++ ) { String stringValue = column . stringValue ( columnValue [ i ] ) ; lc [ i ] = stringValue . toLowerCase ( ) ; uc [ i ] = stringValue . toUpperCase ( ) ; ln [ i ] = stringValue . length ( ) ; } doc . put ( column . getName ( ) , columnValue ) ; doc . put ( column . getLowerCaseFieldName ( ) , lc ) ; doc . put ( column . getUpperCaseFieldName ( ) , uc ) ; doc . put ( column . getLengthFieldName ( ) , ln ) ; } | Appends specified values for the given column and related pseudo columns into list of properties . |
33,038 | protected void processIdent ( DetailAST aAST ) { final int parentType = aAST . getParent ( ) . getType ( ) ; if ( ( ( parentType != TokenTypes . DOT ) && ( parentType != TokenTypes . METHOD_DEF ) ) || ( ( parentType == TokenTypes . DOT ) && ( aAST . getNextSibling ( ) != null ) ) ) { referenced . add ( aAST . getText ( ) ) ; } } | Collects references made by IDENT . |
33,039 | private void processImport ( DetailAST aAST ) { final FullIdent name = FullIdent . createFullIdentBelow ( aAST ) ; if ( ( name != null ) && ! name . getText ( ) . endsWith ( ".*" ) ) { imports . add ( name ) ; } } | Collects the details of imports . |
33,040 | private void processStaticImport ( DetailAST aAST ) { final FullIdent name = FullIdent . createFullIdent ( aAST . getFirstChild ( ) . getNextSibling ( ) ) ; if ( ( name != null ) && ! name . getText ( ) . endsWith ( ".*" ) ) { imports . add ( name ) ; } } | Collects the details of static imports . |
33,041 | public PrivilegeImpl forName ( String name ) { if ( name . contains ( "}" ) ) { String localName = name . substring ( name . indexOf ( '}' ) + 1 ) ; return privileges . get ( localName ) ; } if ( name . contains ( ":" ) ) { String localName = name . substring ( name . indexOf ( ':' ) + 1 ) ; PrivilegeImpl p = privileges . get ( localName ) ; return p . getName ( ) . equals ( name ) ? p : null ; } return null ; } | Searches privilege object for the privilege with the given name . |
33,042 | public void setChangedNodes ( Set < NodeKey > keys ) { if ( keys != null ) { this . nodeKeys = Collections . unmodifiableSet ( new HashSet < NodeKey > ( keys ) ) ; } } | Sets the list of node keys involved in this change set . |
33,043 | public static boolean hasWildcardCharacters ( String expression ) { Objects . requireNonNull ( expression ) ; CharacterIterator iter = new StringCharacterIterator ( expression ) ; boolean skipNext = false ; for ( char c = iter . first ( ) ; c != CharacterIterator . DONE ; c = iter . next ( ) ) { if ( skipNext ) { skipNext = false ; continue ; } if ( c == '*' || c == '?' || c == '%' || c == '_' ) return true ; if ( c == '\\' ) skipNext = true ; } return false ; } | Checks if the given expression has any wildcard characters |
33,044 | public static String toRegularExpression ( String likeExpression ) { String result = likeExpression . replaceAll ( "\\\\(.)" , "$1" ) ; result = result . replaceAll ( "([$.|+()\\[\\\\^\\\\\\\\])" , "\\\\$1" ) ; result = result . replace ( "*" , ".*" ) . replace ( "?" , "." ) ; result = result . replace ( "%" , ".*" ) . replace ( "_" , "." ) ; result = result . replace ( "\\[.*]" , "\\[\\d+]" ) ; return result ; } | Convert the JCR like expression to a regular expression . The JCR like expression uses % to match 0 or more characters _ to match any single character \ x to match the x character and all other characters to match themselves . Note that if any regex metacharacters appear in the like expression they will be escaped within the resulting regular expression . |
33,045 | public String [ ] getAttributeNames ( ) { synchronized ( attributes ) { return attributes . keySet ( ) . toArray ( new String [ attributes . keySet ( ) . size ( ) ] ) ; } } | Returns the names of the attributes available to this credentials instance . This method returns an empty array if the credentials instance has no attributes available to it . |
33,046 | protected boolean appliesToPathConstraint ( List < Component > predicates ) { if ( predicates . isEmpty ( ) ) return true ; if ( predicates . size ( ) > 1 ) return false ; assert predicates . size ( ) == 1 ; Component predicate = predicates . get ( 0 ) ; if ( predicate instanceof Literal && ( ( Literal ) predicate ) . isInteger ( ) ) return true ; if ( predicate instanceof NameTest && ( ( NameTest ) predicate ) . isWildcard ( ) ) return true ; return false ; } | Determine if the predicates contain any expressions that cannot be put into a LIKE constraint on the path . |
33,047 | static BinaryStorage defaultConfig ( ) { EditableDocument binaries = Schematic . newDocument ( ) ; binaries . set ( RepositoryConfiguration . FieldName . TYPE , RepositoryConfiguration . FieldValue . BINARY_STORAGE_TYPE_TRANSIENT ) ; return new BinaryStorage ( binaries ) ; } | Creates a default storage configuration which will be used whenever no specific binary store is configured . |
33,048 | private static void localize ( final Class < ? > i18nClass , final Locale locale ) { assert i18nClass != null ; assert locale != null ; Map < Class < ? > , Set < String > > classToProblemsMap = new ConcurrentHashMap < Class < ? > , Set < String > > ( ) ; Map < Class < ? > , Set < String > > existingClassToProblemsMap = LOCALE_TO_CLASS_TO_PROBLEMS_MAP . putIfAbsent ( locale , classToProblemsMap ) ; if ( existingClassToProblemsMap != null ) { classToProblemsMap = existingClassToProblemsMap ; } if ( classToProblemsMap . get ( i18nClass ) != null ) { return ; } synchronized ( i18nClass ) { Set < String > problems = classToProblemsMap . get ( i18nClass ) ; if ( problems == null ) { problems = new CopyOnWriteArraySet < String > ( ) ; classToProblemsMap . put ( i18nClass , problems ) ; } else { return ; } final String localizationBaseName = i18nClass . getName ( ) ; URL bundleUrl = ClasspathLocalizationRepository . getLocalizationBundle ( i18nClass . getClassLoader ( ) , localizationBaseName , locale ) ; if ( bundleUrl == null && i18nClass == CommonI18n . class ) { throw new SystemFailureException ( "CommonI18n.properties file not found in classpath !" ) ; } if ( bundleUrl == null ) { LOGGER . warn ( CommonI18n . i18nBundleNotFoundInClasspath , ClasspathLocalizationRepository . getPathsToSearchForBundle ( localizationBaseName , locale ) ) ; Locale defaultLocale = Locale . getDefault ( ) ; if ( ! defaultLocale . equals ( locale ) ) { bundleUrl = ClasspathLocalizationRepository . getLocalizationBundle ( i18nClass . getClassLoader ( ) , localizationBaseName , defaultLocale ) ; } if ( bundleUrl == null ) { LOGGER . error ( CommonI18n . i18nBundleNotFoundInClasspath , ClasspathLocalizationRepository . getPathsToSearchForBundle ( localizationBaseName , defaultLocale ) ) ; LOGGER . error ( CommonI18n . i18nLocalizationFileNotFound , localizationBaseName ) ; problems . add ( CommonI18n . i18nLocalizationFileNotFound . text ( localizationBaseName ) ) ; return ; } } Properties props = prepareBundleLoading ( i18nClass , locale , bundleUrl , problems ) ; try { InputStream propStream = bundleUrl . openStream ( ) ; try { props . load ( propStream ) ; for ( Field fld : i18nClass . getDeclaredFields ( ) ) { if ( fld . getType ( ) == I18n . class ) { try { I18n i18n = ( I18n ) fld . get ( null ) ; if ( i18n . localeToTextMap . get ( locale ) == null ) { i18n . localeToProblemMap . put ( locale , CommonI18n . i18nPropertyMissing . text ( fld . getName ( ) , bundleUrl ) ) ; } } catch ( IllegalAccessException notPossible ) { problems . add ( notPossible . getMessage ( ) ) ; } } } } finally { propStream . close ( ) ; } } catch ( IOException err ) { problems . add ( err . getMessage ( ) ) ; } } } | Synchronized on the supplied internalization class . |
33,049 | public String text ( Locale locale , Object ... arguments ) { try { String rawText = rawText ( locale == null ? Locale . getDefault ( ) : locale ) ; return StringUtil . createString ( rawText , arguments ) ; } catch ( IllegalArgumentException err ) { throw new IllegalArgumentException ( CommonI18n . i18nRequiredToSuppliedParameterMismatch . text ( id , i18nClass , err . getMessage ( ) ) ) ; } catch ( SystemFailureException err ) { return '<' + err . getMessage ( ) + '>' ; } } | Get the localized text for the supplied locale replacing the parameters in the text with those supplied . |
33,050 | protected DocumentBuilder getDocumentBuilder ( ) throws ServletException { DocumentBuilder documentBuilder = null ; DocumentBuilderFactory documentBuilderFactory = null ; try { documentBuilderFactory = DocumentBuilderFactory . newInstance ( ) ; documentBuilderFactory . setNamespaceAware ( true ) ; documentBuilder = documentBuilderFactory . newDocumentBuilder ( ) ; } catch ( ParserConfigurationException e ) { throw new ServletException ( "jaxp failed" ) ; } return documentBuilder ; } | Return JAXP document builder instance . |
33,051 | public boolean indexAppliesTo ( JoinCondition condition ) { if ( condition instanceof ChildNodeJoinCondition ) { return indexAppliesTo ( ( ChildNodeJoinCondition ) condition ) ; } if ( condition instanceof DescendantNodeJoinCondition ) { return indexAppliesTo ( ( DescendantNodeJoinCondition ) condition ) ; } if ( condition instanceof EquiJoinCondition ) { return indexAppliesTo ( ( EquiJoinCondition ) condition ) ; } if ( condition instanceof SameNodeJoinCondition ) { return indexAppliesTo ( ( SameNodeJoinCondition ) condition ) ; } return false ; } | Determine if this index can be used to evaluate the given join condition . |
33,052 | public boolean indexAppliesTo ( Constraint constraint ) { if ( constraint instanceof Comparison ) { return indexAppliesTo ( ( Comparison ) constraint ) ; } if ( constraint instanceof And ) { return indexAppliesTo ( ( And ) constraint ) ; } if ( constraint instanceof Or ) { return indexAppliesTo ( ( Or ) constraint ) ; } if ( constraint instanceof Not ) { return indexAppliesTo ( ( Not ) constraint ) ; } if ( constraint instanceof Between ) { return indexAppliesTo ( ( Between ) constraint ) ; } if ( constraint instanceof SetCriteria ) { return indexAppliesTo ( ( SetCriteria ) constraint ) ; } if ( constraint instanceof Relike ) { return indexAppliesTo ( ( Relike ) constraint ) ; } if ( constraint instanceof PropertyExistence ) { return indexAppliesTo ( ( PropertyExistence ) constraint ) ; } if ( constraint instanceof FullTextSearch ) { return applies ( ( FullTextSearch ) constraint ) ; } return false ; } | Determine if this index can be used to evaluate the given constraint . |
33,053 | private void aggregate ( ArrayList < Privilege > list , Privilege p ) { list . add ( p ) ; if ( p . isAggregate ( ) ) { for ( Privilege ap : p . getDeclaredAggregatePrivileges ( ) ) { aggregate ( list , ap ) ; } } } | Recursively aggregates privileges for the given privilege . |
33,054 | public boolean contains ( Privilege p ) { if ( p . getName ( ) . equalsIgnoreCase ( this . getName ( ) ) ) { return true ; } Privilege [ ] list = getAggregatePrivileges ( ) ; for ( Privilege privilege : list ) { if ( privilege . getName ( ) . equalsIgnoreCase ( p . getName ( ) ) ) { return true ; } } return false ; } | Tests given privilege . |
33,055 | void save ( AbstractJcrNode node ) throws RepositoryException { Set < NodeKey > keysToBeSaved = null ; try { if ( node . isNew ( ) ) { throw new RepositoryException ( JcrI18n . unableToSaveNodeThatWasCreatedSincePreviousSave . text ( node . getPath ( ) , workspaceName ( ) ) ) ; } AtomicReference < Set < NodeKey > > refToKeys = new AtomicReference < Set < NodeKey > > ( ) ; if ( node . containsChangesWithExternalDependencies ( refToKeys ) ) { I18n msg = JcrI18n . unableToSaveBranchBecauseChangesDependOnChangesToNodesOutsideOfBranch ; throw new ConstraintViolationException ( msg . text ( node . path ( ) , workspaceName ( ) ) ) ; } keysToBeSaved = refToKeys . get ( ) ; } catch ( ItemNotFoundException e ) { throw new InvalidItemStateException ( e ) ; } catch ( NodeNotFoundException e ) { throw new InvalidItemStateException ( e ) ; } assert keysToBeSaved != null ; SessionCache sessionCache = cache ( ) ; if ( sessionCache . getChangedNodeKeys ( ) . size ( ) == keysToBeSaved . size ( ) ) { save ( ) ; return ; } SessionCache systemCache = createSystemCache ( false ) ; SystemContent systemContent = new SystemContent ( systemCache ) ; Map < NodeKey , NodeKey > baseVersionKeys = this . baseVersionKeys . get ( ) ; Map < NodeKey , NodeKey > originalVersionKeys = this . originalVersionKeys . get ( ) ; try { sessionCache . save ( keysToBeSaved , systemContent . cache ( ) , new JcrPreSave ( systemContent , baseVersionKeys , originalVersionKeys , aclChangesCount ( ) ) ) ; } catch ( WrappedException e ) { Throwable cause = e . getCause ( ) ; throw ( cause instanceof RepositoryException ) ? ( RepositoryException ) cause : new RepositoryException ( e . getCause ( ) ) ; } catch ( DocumentNotFoundException e ) { throw new InvalidItemStateException ( JcrI18n . nodeModifiedBySessionWasRemovedByAnotherSession . text ( e . getKey ( ) ) , e ) ; } catch ( DocumentAlreadyExistsException e ) { NodeKey key = new NodeKey ( e . getKey ( ) ) ; AbstractJcrNode problemNode = node ( key , null ) ; String path = problemNode . getPath ( ) ; throw new InvalidItemStateException ( JcrI18n . nodeCreatedBySessionUsedExistingKey . text ( path , key ) , e ) ; } catch ( org . modeshape . jcr . cache . ReferentialIntegrityException e ) { throw new ReferentialIntegrityException ( e ) ; } catch ( Throwable t ) { throw new RepositoryException ( t ) ; } try { repository ( ) . statistics ( ) . increment ( ValueMetric . SESSION_SAVES ) ; } catch ( IllegalStateException e ) { } } | Save a subset of the changes made within this session . |
33,056 | static boolean hasRole ( SecurityContext context , String roleName , String repositoryName , String workspaceName ) { if ( context . hasRole ( roleName ) ) return true ; roleName = roleName + "." + repositoryName ; if ( context . hasRole ( roleName ) ) return true ; roleName = roleName + "." + workspaceName ; return context . hasRole ( roleName ) ; } | Returns whether the authenticated user has the given role . |
33,057 | public static boolean isForeignKey ( NodeKey key , NodeKey rootKey ) { if ( key == null ) { return false ; } String nodeWorkspaceKey = key . getWorkspaceKey ( ) ; boolean sameWorkspace = rootKey . getWorkspaceKey ( ) . equals ( nodeWorkspaceKey ) ; boolean sameSource = rootKey . getSourceKey ( ) . equalsIgnoreCase ( key . getSourceKey ( ) ) ; return ! sameWorkspace || ! sameSource ; } | Checks if the node given key is foreign by comparing the source key & workspace key against the same keys from this session s root . This method is used for reference resolving . |
33,058 | public static String nodeIdentifier ( NodeKey key , NodeKey rootKey ) { return isForeignKey ( key , rootKey ) ? key . toString ( ) : key . getIdentifier ( ) ; } | Returns a string representing a node s identifier based on whether the node is foreign or not . |
33,059 | public int computeNextStatementStartKeywordCount ( ) { int result = 0 ; if ( isNextKeyWord ( ) ) { for ( String [ ] nextStmtStart : registeredStatementStartPhrases ) { if ( this . matches ( nextStmtStart ) ) { return nextStmtStart . length ; } } } return result ; } | Method to determine if next tokens match a registered statement start phrase . |
33,060 | protected void parse ( String content ) { Tokenizer tokenizer = new CndTokenizer ( false , true ) ; TokenStream tokens = new TokenStream ( content , tokenizer , false ) ; tokens . start ( ) ; while ( tokens . hasNext ( ) ) { if ( tokens . matches ( "<" , ANY_VALUE , "=" , ANY_VALUE , ">" ) ) { parseNamespaceMapping ( tokens ) ; } else if ( tokens . matches ( "[" , ANY_VALUE , "]" ) ) { parseNodeTypeDefinition ( tokens ) ; } else { Position position = tokens . previousPosition ( ) ; throw new ParsingException ( position , CndI18n . expectedNamespaceOrNodeDefinition . text ( tokens . consume ( ) , position . getLine ( ) , position . getColumn ( ) ) ) ; } } } | Parse the CND content . |
33,061 | protected void parseNamespaceMapping ( TokenStream tokens ) { tokens . consume ( '<' ) ; String prefix = removeQuotes ( tokens . consume ( ) ) ; tokens . consume ( '=' ) ; String uri = removeQuotes ( tokens . consume ( ) ) ; tokens . consume ( '>' ) ; context . getNamespaceRegistry ( ) . register ( prefix , uri ) ; } | Parse the namespace mapping statement that is next on the token stream . |
33,062 | protected void parseNodeTypeDefinition ( TokenStream tokens ) { Name name = parseNodeTypeName ( tokens ) ; JcrNodeTypeTemplate nodeType = new JcrNodeTypeTemplate ( context ) ; try { nodeType . setName ( string ( name ) ) ; } catch ( ConstraintViolationException e ) { assert false : "Names should always be syntactically valid" ; } List < Name > supertypes = parseSupertypes ( tokens ) ; try { nodeType . setDeclaredSuperTypeNames ( names ( supertypes ) ) ; parseNodeTypeOptions ( tokens , nodeType ) ; parsePropertyOrChildNodeDefinitions ( tokens , nodeType ) ; } catch ( ConstraintViolationException e ) { assert false : "Names should always be syntactically valid" ; } this . nodeTypes . add ( nodeType ) ; } | Parse the node type definition that is next on the token stream . |
33,063 | protected Name parseNodeTypeName ( TokenStream tokens ) { tokens . consume ( '[' ) ; Name name = parseName ( tokens ) ; tokens . consume ( ']' ) ; return name ; } | Parse a node type name that appears next on the token stream . |
33,064 | protected List < Name > parseSupertypes ( TokenStream tokens ) { if ( tokens . canConsume ( '>' ) ) { return parseNameList ( tokens ) ; } return Collections . emptyList ( ) ; } | Parse an optional list of supertypes if they appear next on the token stream . |
33,065 | protected List < String > parseStringList ( TokenStream tokens ) { List < String > strings = new ArrayList < String > ( ) ; if ( tokens . canConsume ( '?' ) ) { strings . add ( "?" ) ; } else { do { strings . add ( removeQuotes ( tokens . consume ( ) ) ) ; } while ( tokens . canConsume ( ',' ) ) ; } return strings ; } | Parse a list of strings separated by commas . Any quotes surrounding the strings are removed . |
33,066 | protected List < Name > parseNameList ( TokenStream tokens ) { List < Name > names = new ArrayList < Name > ( ) ; if ( ! tokens . canConsume ( '?' ) ) { do { names . add ( parseName ( tokens ) ) ; } while ( tokens . canConsume ( ',' ) ) ; } return names ; } | Parse a list of names separated by commas . Any quotes surrounding the names are removed . |
33,067 | protected void parsePropertyOrChildNodeDefinitions ( TokenStream tokens , JcrNodeTypeTemplate nodeType ) throws ConstraintViolationException { while ( true ) { if ( tokens . matches ( '-' ) ) { parsePropertyDefinition ( tokens , nodeType ) ; } else if ( tokens . matches ( '+' ) ) { parseChildNodeDefinition ( tokens , nodeType ) ; } else { break ; } } } | Parse a node type s property or child node definitions that appear next on the token stream . |
33,068 | protected void parsePropertyDefinition ( TokenStream tokens , JcrNodeTypeTemplate nodeType ) throws ConstraintViolationException { tokens . consume ( '-' ) ; Name name = parseName ( tokens ) ; JcrPropertyDefinitionTemplate propDefn = new JcrPropertyDefinitionTemplate ( context ) ; propDefn . setName ( string ( name ) ) ; parsePropertyType ( tokens , propDefn , PropertyType . STRING . getName ( ) ) ; parseDefaultValues ( tokens , propDefn ) ; parsePropertyAttributes ( tokens , propDefn , nodeType ) ; parseValueConstraints ( tokens , propDefn ) ; List < Property > properties = new LinkedList < Property > ( ) ; parseVendorExtensions ( tokens , properties ) ; applyVendorExtensions ( nodeType , properties ) ; nodeType . getPropertyDefinitionTemplates ( ) . add ( propDefn ) ; } | Parse a node type s property definition from the next tokens on the stream . |
33,069 | protected void parsePropertyType ( TokenStream tokens , JcrPropertyDefinitionTemplate propDefn , String defaultPropertyType ) { if ( tokens . canConsume ( '(' ) ) { String propertyType = defaultPropertyType ; if ( tokens . matchesAnyOf ( VALID_PROPERTY_TYPES ) ) { propertyType = tokens . consume ( ) ; if ( "*" . equals ( propertyType ) ) propertyType = "UNDEFINED" ; } tokens . consume ( ')' ) ; PropertyType type = PropertyType . valueFor ( propertyType . toLowerCase ( ) ) ; int jcrType = PropertyTypeUtil . jcrPropertyTypeFor ( type ) ; propDefn . setRequiredType ( jcrType ) ; } } | Parse the property type if a valid one appears next on the token stream . |
33,070 | protected void parseDefaultValues ( TokenStream tokens , JcrPropertyDefinitionTemplate propDefn ) { if ( tokens . canConsume ( '=' ) ) { List < String > defaultValues = parseStringList ( tokens ) ; if ( ! defaultValues . isEmpty ( ) ) { propDefn . setDefaultValues ( values ( defaultValues ) ) ; } } } | Parse the property definition s default value if they appear next on the token stream . |
33,071 | protected void parseValueConstraints ( TokenStream tokens , JcrPropertyDefinitionTemplate propDefn ) { if ( tokens . canConsume ( '<' ) ) { List < String > defaultValues = parseStringList ( tokens ) ; if ( ! defaultValues . isEmpty ( ) ) { propDefn . setValueConstraints ( strings ( defaultValues ) ) ; } } } | Parse the property definition s value constraints if they appear next on the token stream . |
33,072 | protected void parsePropertyAttributes ( TokenStream tokens , JcrPropertyDefinitionTemplate propDefn , JcrNodeTypeTemplate nodeType ) throws ConstraintViolationException { boolean autoCreated = false ; boolean mandatory = false ; boolean isProtected = false ; boolean multiple = false ; boolean isFullTextSearchable = true ; boolean isQueryOrderable = true ; String onParentVersion = "COPY" ; while ( true ) { if ( tokens . canConsumeAnyOf ( "AUTOCREATED" , "AUT" , "A" ) ) { tokens . canConsume ( '?' ) ; autoCreated = true ; } else if ( tokens . canConsumeAnyOf ( "MANDATORY" , "MAN" , "M" ) ) { tokens . canConsume ( '?' ) ; mandatory = true ; } else if ( tokens . canConsumeAnyOf ( "PROTECTED" , "PRO" , "P" ) ) { tokens . canConsume ( '?' ) ; isProtected = true ; } else if ( tokens . canConsumeAnyOf ( "MULTIPLE" , "MUL" , "*" ) ) { tokens . canConsume ( '?' ) ; multiple = true ; } else if ( tokens . matchesAnyOf ( VALID_ON_PARENT_VERSION ) ) { onParentVersion = tokens . consume ( ) ; tokens . canConsume ( '?' ) ; } else if ( tokens . matches ( "OPV" ) ) { onParentVersion = tokens . consume ( ) ; tokens . canConsume ( '?' ) ; } else if ( tokens . canConsumeAnyOf ( "NOFULLTEXT" , "NOF" ) ) { tokens . canConsume ( '?' ) ; isFullTextSearchable = false ; } else if ( tokens . canConsumeAnyOf ( "NOQUERYORDER" , "NQORD" ) ) { tokens . canConsume ( '?' ) ; isQueryOrderable = false ; } else if ( tokens . canConsumeAnyOf ( "QUERYOPS" , "QOP" ) ) { parseQueryOperators ( tokens , propDefn ) ; } else if ( tokens . canConsumeAnyOf ( "PRIMARYITEM" , "PRIMARY" , "PRI" , "!" ) ) { Position pos = tokens . previousPosition ( ) ; int line = pos . getLine ( ) ; int column = pos . getColumn ( ) ; throw new ParsingException ( tokens . previousPosition ( ) , CndI18n . primaryKeywordNotValidInJcr2CndFormat . text ( line , column ) ) ; } else if ( tokens . matches ( CndTokenizer . VENDOR_EXTENSION ) ) { List < Property > properties = new LinkedList < Property > ( ) ; parseVendorExtensions ( tokens , properties ) ; applyVendorExtensions ( propDefn , properties ) ; } else { break ; } } propDefn . setAutoCreated ( autoCreated ) ; propDefn . setMandatory ( mandatory ) ; propDefn . setProtected ( isProtected ) ; propDefn . setOnParentVersion ( OnParentVersionAction . valueFromName ( onParentVersion . toUpperCase ( Locale . ROOT ) ) ) ; propDefn . setMultiple ( multiple ) ; propDefn . setFullTextSearchable ( isFullTextSearchable ) ; propDefn . setQueryOrderable ( isQueryOrderable ) ; } | Parse the property definition s attributes if they appear next on the token stream . |
33,073 | protected void parseQueryOperators ( TokenStream tokens , JcrPropertyDefinitionTemplate propDefn ) { if ( tokens . canConsume ( '?' ) ) { return ; } List < String > operators = new ArrayList < String > ( ) ; String operatorList = removeQuotes ( tokens . consume ( ) ) ; for ( String operatorValue : operatorList . split ( "," ) ) { String operator = operatorValue . trim ( ) ; if ( ! VALID_QUERY_OPERATORS . contains ( operator ) ) { throw new ParsingException ( tokens . previousPosition ( ) , CndI18n . expectedValidQueryOperator . text ( operator ) ) ; } operators . add ( operator ) ; } if ( operators . isEmpty ( ) ) { operators . addAll ( VALID_QUERY_OPERATORS ) ; } propDefn . setAvailableQueryOperators ( strings ( operators ) ) ; } | Parse the property definition s query operators if they appear next on the token stream . |
33,074 | protected void parseChildNodeDefinition ( TokenStream tokens , JcrNodeTypeTemplate nodeType ) throws ConstraintViolationException { tokens . consume ( '+' ) ; Name name = parseName ( tokens ) ; JcrNodeDefinitionTemplate childDefn = new JcrNodeDefinitionTemplate ( context ) ; childDefn . setName ( string ( name ) ) ; parseRequiredPrimaryTypes ( tokens , childDefn ) ; parseDefaultType ( tokens , childDefn ) ; parseNodeAttributes ( tokens , childDefn , nodeType ) ; nodeType . getNodeDefinitionTemplates ( ) . add ( childDefn ) ; } | Parse a node type s child node definition from the next tokens on the stream . |
33,075 | protected void parseRequiredPrimaryTypes ( TokenStream tokens , JcrNodeDefinitionTemplate childDefn ) throws ConstraintViolationException { if ( tokens . canConsume ( '(' ) ) { List < Name > requiredTypes = parseNameList ( tokens ) ; if ( requiredTypes . isEmpty ( ) ) { requiredTypes . add ( JcrNtLexicon . BASE ) ; } childDefn . setRequiredPrimaryTypeNames ( names ( requiredTypes ) ) ; tokens . consume ( ')' ) ; } } | Parse the child node definition s list of required primary types if they appear next on the token stream . |
33,076 | protected void parseDefaultType ( TokenStream tokens , JcrNodeDefinitionTemplate childDefn ) throws ConstraintViolationException { if ( tokens . canConsume ( '=' ) ) { if ( ! tokens . canConsume ( '?' ) ) { Name defaultType = parseName ( tokens ) ; childDefn . setDefaultPrimaryTypeName ( string ( defaultType ) ) ; } } } | Parse the child node definition s default type if they appear next on the token stream . |
33,077 | protected void parseNodeAttributes ( TokenStream tokens , JcrNodeDefinitionTemplate childDefn , JcrNodeTypeTemplate nodeType ) throws ConstraintViolationException { boolean autoCreated = false ; boolean mandatory = false ; boolean isProtected = false ; boolean sns = false ; String onParentVersion = "COPY" ; while ( true ) { if ( tokens . canConsumeAnyOf ( "AUTOCREATED" , "AUT" , "A" ) ) { tokens . canConsume ( '?' ) ; autoCreated = true ; } else if ( tokens . canConsumeAnyOf ( "MANDATORY" , "MAN" , "M" ) ) { tokens . canConsume ( '?' ) ; mandatory = true ; } else if ( tokens . canConsumeAnyOf ( "PROTECTED" , "PRO" , "P" ) ) { tokens . canConsume ( '?' ) ; isProtected = true ; } else if ( tokens . canConsumeAnyOf ( "SNS" , "*" ) ) { tokens . canConsume ( '?' ) ; sns = true ; } else if ( tokens . canConsumeAnyOf ( "MULTIPLE" , "MUL" , "*" ) ) { Position pos = tokens . previousPosition ( ) ; int line = pos . getLine ( ) ; int column = pos . getColumn ( ) ; throw new ParsingException ( tokens . previousPosition ( ) , CndI18n . multipleKeywordNotValidInJcr2CndFormat . text ( line , column ) ) ; } else if ( tokens . matchesAnyOf ( VALID_ON_PARENT_VERSION ) ) { onParentVersion = tokens . consume ( ) ; tokens . canConsume ( '?' ) ; } else if ( tokens . matches ( "OPV" ) ) { onParentVersion = tokens . consume ( ) ; tokens . canConsume ( '?' ) ; } else if ( tokens . canConsumeAnyOf ( "PRIMARYITEM" , "PRIMARY" , "PRI" , "!" ) ) { Position pos = tokens . previousPosition ( ) ; int line = pos . getLine ( ) ; int column = pos . getColumn ( ) ; throw new ParsingException ( tokens . previousPosition ( ) , CndI18n . primaryKeywordNotValidInJcr2CndFormat . text ( line , column ) ) ; } else if ( tokens . matches ( CndTokenizer . VENDOR_EXTENSION ) ) { List < Property > properties = new LinkedList < Property > ( ) ; parseVendorExtensions ( tokens , properties ) ; applyVendorExtensions ( childDefn , properties ) ; } else { break ; } } childDefn . setAutoCreated ( autoCreated ) ; childDefn . setMandatory ( mandatory ) ; childDefn . setProtected ( isProtected ) ; childDefn . setOnParentVersion ( OnParentVersionAction . valueFromName ( onParentVersion . toUpperCase ( Locale . ROOT ) ) ) ; childDefn . setSameNameSiblings ( sns ) ; } | Parse the child node definition s attributes if they appear next on the token stream . |
33,078 | protected Name parseName ( TokenStream tokens ) { String value = tokens . consume ( ) ; try { return nameFactory . create ( removeQuotes ( value ) ) ; } catch ( ValueFormatException e ) { if ( e . getCause ( ) instanceof NamespaceException ) { throw ( NamespaceException ) e . getCause ( ) ; } throw new ParsingException ( tokens . previousPosition ( ) , CndI18n . expectedValidNameLiteral . text ( value ) ) ; } } | Parse the name that is expected to be next on the token stream . |
33,079 | protected final void parseVendorExtensions ( TokenStream tokens , List < Property > properties ) { while ( tokens . matches ( CndTokenizer . VENDOR_EXTENSION ) ) { Property extension = parseVendorExtension ( tokens . consume ( ) ) ; if ( extension != null ) properties . add ( extension ) ; } } | Parse the vendor extensions that may appear next on the tokenzied stream . |
33,080 | protected final Property parseVendorExtension ( String vendorExtension ) { if ( vendorExtension == null ) return null ; String extension = vendorExtension . replaceFirst ( "^[{]" , "" ) . replaceAll ( "[}]$" , "" ) ; if ( extension . trim ( ) . length ( ) == 0 ) return null ; return parseVendorExtensionContent ( extension ) ; } | Parse the vendor extension including the curly braces in the CND content . |
33,081 | protected final Property parseVendorExtensionContent ( String vendorExtension ) { Matcher matcher = VENDOR_PATTERN . matcher ( vendorExtension ) ; if ( ! matcher . find ( ) ) return null ; String vendorName = removeQuotes ( matcher . group ( 1 ) ) ; String vendorValue = removeQuotes ( matcher . group ( 3 ) ) ; assert vendorName != null ; assert vendorValue != null ; assert vendorName . length ( ) != 0 ; assert vendorValue . length ( ) != 0 ; return context . getPropertyFactory ( ) . create ( nameFactory . create ( vendorName ) , vendorValue ) ; } | Parse the content of the vendor extension excluding the curly braces in the CND content . |
33,082 | public WorkspaceCache createWorkspace ( String name ) { if ( ! workspaceNames . contains ( name ) ) { if ( ! configuration . isCreatingWorkspacesAllowed ( ) ) { throw new UnsupportedOperationException ( JcrI18n . creatingWorkspacesIsNotAllowedInRepository . text ( getName ( ) ) ) ; } this . workspaceNames . add ( name ) ; refreshRepositoryMetadata ( true ) ; SessionCache session = createSession ( context , name , false ) ; MutableCachedNode root = session . mutable ( session . getRootKey ( ) ) ; ChildReference ref = root . getChildReferences ( session ) . getChild ( JcrLexicon . SYSTEM ) ; if ( ref == null ) { root . linkChild ( session , systemKey , JcrLexicon . SYSTEM ) ; session . save ( ) ; } String userId = context . getSecurityContext ( ) . getUserName ( ) ; Map < String , String > userData = context . getData ( ) ; DateTime timestamp = context . getValueFactories ( ) . getDateFactory ( ) . create ( ) ; RecordingChanges changes = new RecordingChanges ( context . getId ( ) , context . getProcessId ( ) , this . getKey ( ) , null , repositoryEnvironment . journalId ( ) ) ; changes . workspaceAdded ( name ) ; changes . freeze ( userId , userData , timestamp ) ; this . changeBus . notify ( changes ) ; } return workspace ( name ) ; } | Create a new workspace in this repository if the repository is appropriately configured . If the repository already contains a workspace with the supplied name then this method simply returns that workspace . Otherwise this method attempts to create the named workspace and will return a cache for this newly - created workspace . |
33,083 | public WorkspaceCache createExternalWorkspace ( String name , Connectors connectors ) { String [ ] tokens = name . split ( ":" ) ; String sourceName = tokens [ 0 ] ; String workspaceName = tokens [ 1 ] ; this . workspaceNames . add ( workspaceName ) ; refreshRepositoryMetadata ( true ) ; ConcurrentMap < NodeKey , CachedNode > nodeCache = cacheForWorkspace ( ) . asMap ( ) ; ExecutionContext context = context ( ) ; String sourceKey = NodeKey . keyForSourceName ( sourceName ) ; String workspaceKey = NodeKey . keyForWorkspaceName ( workspaceName ) ; Connector connector = connectors . getConnectorForSourceName ( sourceName ) ; if ( connector == null ) { throw new IllegalArgumentException ( JcrI18n . connectorNotFound . text ( sourceName ) ) ; } FederatedDocumentStore documentStore = new FederatedDocumentStore ( connectors , this . documentStore ( ) . localStore ( ) ) ; String rootId = connector . getRootDocumentId ( ) ; NodeKey rootKey = new NodeKey ( sourceKey , workspaceKey , rootId ) ; final WorkspaceCache systemWorkspaceCache = workspaceCachesByName . get ( systemWorkspaceName ) ; WorkspaceCache workspaceCache = new WorkspaceCache ( context , getKey ( ) , workspaceName , systemWorkspaceCache , documentStore , translator , rootKey , nodeCache , changeBus , repositoryEnvironment ( ) ) ; workspaceCachesByName . put ( workspaceName , workspaceCache ) ; return workspace ( workspaceName ) ; } | Creates a new workspace in the repository coupled with external document store . |
33,084 | public SessionCache createSession ( ExecutionContext context , String workspaceName , boolean readOnly ) { WorkspaceCache workspaceCache = workspace ( workspaceName ) ; if ( readOnly ) { return new ReadOnlySessionCache ( context , workspaceCache ) ; } return new WritableSessionCache ( context , workspaceCache , txWorkspaceCaches , repositoryEnvironment ) ; } | Create a session for the workspace with the given name using the supplied ExecutionContext for the session . |
33,085 | public void setColumnStartPositions ( String commaDelimitedColumnStartPositions ) { CheckArg . isNotNull ( commaDelimitedColumnStartPositions , "commaDelimitedColumnStartPositions" ) ; String [ ] stringStartPositions = commaDelimitedColumnStartPositions . split ( "," ) ; int [ ] columnStartPositions = new int [ stringStartPositions . length ] ; for ( int i = 0 ; i < stringStartPositions . length ; i ++ ) { columnStartPositions [ i ] = Integer . valueOf ( stringStartPositions [ i ] ) ; } setColumnStartPositions ( columnStartPositions ) ; } | Set the column start positions from a list of column start positions concatenated into a single comma - delimited string . |
33,086 | private static Set < String > setFor ( String ... elements ) { Set < String > set = new HashSet < String > ( elements . length ) ; set . addAll ( Arrays . asList ( elements ) ) ; return set ; } | Returns an unmodifiable set containing the elements passed in to this method |
33,087 | public void changeField ( MappedAttributeDefinition defn , ModelNode newValue ) throws RepositoryException , OperationFailedException { ModeShapeEngine engine = getEngine ( ) ; String repositoryName = repositoryName ( ) ; RepositoryConfiguration config = engine . getRepositoryConfiguration ( repositoryName ) ; Editor editor = config . edit ( ) ; EditableDocument fieldContainer = editor ; for ( String fieldName : defn . getPathToContainerOfField ( ) ) { fieldContainer = editor . getOrCreateDocument ( fieldName ) ; } Object rawValue = defn . getTypedValue ( newValue ) ; String fieldName = defn . getFieldName ( ) ; fieldContainer . set ( fieldName , rawValue ) ; Changes changes = editor . getChanges ( ) ; engine . update ( repositoryName , changes ) ; } | Immediately change and apply the specified field in the current repository configuration to the new value . |
33,088 | public void changeIndexProviderField ( MappedAttributeDefinition defn , ModelNode newValue , String indexProviderName ) throws RepositoryException , OperationFailedException { ModeShapeEngine engine = getEngine ( ) ; String repositoryName = repositoryName ( ) ; RepositoryConfiguration config = engine . getRepositoryConfiguration ( repositoryName ) ; Editor editor = config . edit ( ) ; List < String > pathToContainer = defn . getPathToContainerOfField ( ) ; EditableDocument providers = editor . getOrCreateDocument ( pathToContainer . get ( 0 ) ) ; for ( String configuredProviderName : providers . keySet ( ) ) { if ( indexProviderName . equals ( configuredProviderName ) ) { EditableDocument provider = ( EditableDocument ) providers . get ( configuredProviderName ) ; String fieldName = defn . getFieldName ( ) ; Object rawValue = defn . getTypedValue ( newValue ) ; provider . set ( fieldName , rawValue ) ; break ; } } Changes changes = editor . getChanges ( ) ; engine . update ( repositoryName , changes ) ; } | Immediately change and apply the specified index provider field in the current repository configuration to the new value . |
33,089 | public void changeSequencerField ( MappedAttributeDefinition defn , ModelNode newValue , String sequencerName ) throws RepositoryException , OperationFailedException { ModeShapeEngine engine = getEngine ( ) ; String repositoryName = repositoryName ( ) ; RepositoryConfiguration config = engine . getRepositoryConfiguration ( repositoryName ) ; Editor editor = config . edit ( ) ; List < String > pathToContainer = defn . getPathToContainerOfField ( ) ; EditableDocument sequencing = editor . getOrCreateDocument ( pathToContainer . get ( 0 ) ) ; EditableDocument sequencers = sequencing . getOrCreateArray ( pathToContainer . get ( 1 ) ) ; for ( String configuredSequencerName : sequencers . keySet ( ) ) { if ( sequencerName . equals ( configuredSequencerName ) ) { EditableDocument sequencer = ( EditableDocument ) sequencers . get ( configuredSequencerName ) ; String fieldName = defn . getFieldName ( ) ; Object rawValue = defn . getTypedValue ( newValue ) ; sequencer . set ( fieldName , rawValue ) ; break ; } } Changes changes = editor . getChanges ( ) ; engine . update ( repositoryName , changes ) ; } | Immediately change and apply the specified sequencer field in the current repository configuration to the new value . |
33,090 | public void changePersistenceField ( MappedAttributeDefinition defn , ModelNode newValue ) throws RepositoryException , OperationFailedException { ModeShapeEngine engine = getEngine ( ) ; String repositoryName = repositoryName ( ) ; RepositoryConfiguration config = engine . getRepositoryConfiguration ( repositoryName ) ; Editor editor = config . edit ( ) ; EditableDocument persistence = editor . getOrCreateDocument ( FieldName . STORAGE ) . getOrCreateDocument ( FieldName . PERSISTENCE ) ; String fieldName = defn . getFieldName ( ) ; Object rawValue = defn . getTypedValue ( newValue ) ; persistence . set ( fieldName , rawValue ) ; Changes changes = editor . getChanges ( ) ; engine . update ( repositoryName , changes ) ; } | Immediately change and apply the specified persistence field to the repository configuration |
33,091 | public void changeSourceField ( MappedAttributeDefinition defn , ModelNode newValue , String sourceName ) throws RepositoryException , OperationFailedException { ModeShapeEngine engine = getEngine ( ) ; String repositoryName = repositoryName ( ) ; RepositoryConfiguration config = engine . getRepositoryConfiguration ( repositoryName ) ; Editor editor = config . edit ( ) ; EditableDocument externalSources = editor . getOrCreateDocument ( FieldName . EXTERNAL_SOURCES ) ; EditableDocument externalSource = externalSources . getDocument ( sourceName ) ; assert externalSource != null ; String fieldName = defn . getFieldName ( ) ; Object rawValue = defn . getTypedValue ( newValue ) ; externalSource . set ( fieldName , rawValue ) ; Changes changes = editor . getChanges ( ) ; engine . update ( repositoryName , changes ) ; } | Immediately change and apply the specified external source field in the current repository configuration to the new value . |
33,092 | public void changeTextExtractorField ( MappedAttributeDefinition defn , ModelNode newValue , String extractorName ) throws RepositoryException , OperationFailedException { ModeShapeEngine engine = getEngine ( ) ; String repositoryName = repositoryName ( ) ; RepositoryConfiguration config = engine . getRepositoryConfiguration ( repositoryName ) ; Editor editor = config . edit ( ) ; List < String > pathToContainer = defn . getPathToContainerOfField ( ) ; EditableDocument textExtracting = editor . getOrCreateDocument ( pathToContainer . get ( 1 ) ) ; EditableDocument extractors = textExtracting . getOrCreateDocument ( pathToContainer . get ( 2 ) ) ; for ( String configuredExtractorName : extractors . keySet ( ) ) { if ( extractorName . equals ( configuredExtractorName ) ) { EditableDocument extractor = ( EditableDocument ) extractors . get ( configuredExtractorName ) ; String fieldName = defn . getFieldName ( ) ; Object rawValue = defn . getTypedValue ( newValue ) ; extractor . set ( fieldName , rawValue ) ; break ; } } Changes changes = editor . getChanges ( ) ; engine . update ( repositoryName , changes ) ; } | Immediately change and apply the specified extractor field in the current repository configuration to the new value . |
33,093 | public void changeAuthenticatorField ( MappedAttributeDefinition defn , ModelNode newValue , String authenticatorName ) throws RepositoryException , OperationFailedException { ModeShapeEngine engine = getEngine ( ) ; String repositoryName = repositoryName ( ) ; RepositoryConfiguration config = engine . getRepositoryConfiguration ( repositoryName ) ; Editor editor = config . edit ( ) ; EditableDocument security = editor . getOrCreateDocument ( FieldName . SECURITY ) ; EditableArray providers = security . getOrCreateArray ( FieldName . PROVIDERS ) ; for ( String configuredAuthenticatorName : providers . keySet ( ) ) { if ( authenticatorName . equals ( configuredAuthenticatorName ) ) { boolean found = false ; for ( Object nested : providers ) { if ( nested instanceof EditableDocument ) { EditableDocument doc = ( EditableDocument ) nested ; if ( doc . getString ( FieldName . NAME ) . equals ( configuredAuthenticatorName ) ) { String fieldName = defn . getFieldName ( ) ; Object rawValue = defn . getTypedValue ( newValue ) ; doc . set ( fieldName , rawValue ) ; found = true ; break ; } } } if ( ! found ) { EditableDocument doc = Schematic . newDocument ( ) ; doc . set ( FieldName . NAME , configuredAuthenticatorName ) ; String fieldName = defn . getFieldName ( ) ; Object rawValue = defn . getTypedValue ( newValue ) ; doc . set ( fieldName , rawValue ) ; providers . add ( doc ) ; } break ; } } Changes changes = editor . getChanges ( ) ; engine . update ( repositoryName , changes ) ; } | Immediately change and apply the specified authenticator field in the current repository configuration to the new value . |
33,094 | public boolean checkLocks ( boolean exclusive , int depth ) { if ( checkParents ( exclusive ) && checkChildren ( exclusive , depth ) ) { return true ; } return false ; } | checks if a lock of the given exclusivity can be placed only considering children up to depth |
33,095 | public Predicate < T > and ( final Predicate < T > other ) { if ( other == null || other == this ) return this ; return new Predicate < T > ( ) { public boolean test ( T input ) { return Predicate . this . test ( input ) && other . test ( input ) ; } } ; } | Obtain a new predicate that performs the logical AND of this predicate and the supplied predicate . |
33,096 | public Predicate < T > or ( final Predicate < T > other ) { if ( other == null || other == this ) return this ; return new Predicate < T > ( ) { public boolean test ( T input ) { return Predicate . this . test ( input ) || other . test ( input ) ; } } ; } | Obtain a new predicate that performs the logical OR of this predicate and the supplied predicate . |
33,097 | public Predicate < T > negate ( ) { return new Predicate < T > ( ) { public boolean test ( T input ) { return ! Predicate . this . test ( input ) ; } public Predicate < T > negate ( ) { return Predicate . this ; } } ; } | Obtain a new predicate that performs the logical NOT of this predicate . |
33,098 | public static < T > Predicate < T > never ( ) { return new Predicate < T > ( ) { public boolean test ( T input ) { return false ; } } ; } | Return a predicate that is never satisfied . |
33,099 | public static < T > Predicate < T > always ( ) { return new Predicate < T > ( ) { public boolean test ( T input ) { return true ; } } ; } | Return a predicate that is always satisfied . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.