idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
33,000
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 .
92
5
33,001
void save ( AbstractJcrNode node ) throws RepositoryException { // first check the node is valid from a cache perspective Set < NodeKey > keysToBeSaved = null ; try { if ( node . isNew ( ) ) { // expected by TCK throw new RepositoryException ( JcrI18n . unableToSaveNodeThatWasCreatedSincePreviousSave . text ( node . getPath ( ) , workspaceName ( ) ) ) ; } AtomicReference < Set < NodeKey > > refToKeys = new AtomicReference < Set < NodeKey > > ( ) ; if ( node . containsChangesWithExternalDependencies ( refToKeys ) ) { // expected by TCK 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 ( ) ) { // The node is above all the other changes, so go ahead and save the whole session ... save ( ) ; return ; } // Perform the save, using 'JcrPreSave' operations ... 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 ) { // Try to figure out which node in this transient state was the problem ... 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 { // Record the save operation ... repository ( ) . statistics ( ) . increment ( ValueMetric . SESSION_SAVES ) ; } catch ( IllegalStateException e ) { // The repository has been shutdown ... } }
Save a subset of the changes made within this session .
751
11
33,002
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 .
85
10
33,003
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 .
104
35
33,004
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 .
44
18
33,005
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 .
73
13
33,006
protected void parse ( String content ) { Tokenizer tokenizer = new CndTokenizer ( false , true ) ; TokenStream tokens = new TokenStream ( content , tokenizer , false ) ; tokens . start ( ) ; while ( tokens . hasNext ( ) ) { // Keep reading while we can recognize one of the two types of statements ... 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 .
194
7
33,007
protected void parseNamespaceMapping ( TokenStream tokens ) { tokens . consume ( ' ' ) ; String prefix = removeQuotes ( tokens . consume ( ) ) ; tokens . consume ( ' ' ) ; String uri = removeQuotes ( tokens . consume ( ) ) ; tokens . consume ( ' ' ) ; // Register the namespace ... context . getNamespaceRegistry ( ) . register ( prefix , uri ) ; }
Parse the namespace mapping statement that is next on the token stream .
88
14
33,008
protected void parseNodeTypeDefinition ( TokenStream tokens ) { // Parse the name, and create the path and a property for the name ... 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" ; } // Read the (optional) supertypes ... List < Name > supertypes = parseSupertypes ( tokens ) ; try { nodeType . setDeclaredSuperTypeNames ( names ( supertypes ) ) ; // Read the node type options (and vendor extensions) ... parseNodeTypeOptions ( tokens , nodeType ) ; // Parse property and child node definitions ... 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 .
227
14
33,009
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 .
41
14
33,010
protected List < Name > parseSupertypes ( TokenStream tokens ) { if ( tokens . canConsume ( ' ' ) ) { // There is at least one supertype ... return parseNameList ( tokens ) ; } return Collections . emptyList ( ) ; }
Parse an optional list of supertypes if they appear next on the token stream .
55
17
33,011
protected List < String > parseStringList ( TokenStream tokens ) { List < String > strings = new ArrayList < String > ( ) ; if ( tokens . canConsume ( ' ' ) ) { // This list is variant ... strings . add ( "?" ) ; } else { // Read names until we see a ',' 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 .
104
19
33,012
protected List < Name > parseNameList ( TokenStream tokens ) { List < Name > names = new ArrayList < Name > ( ) ; if ( ! tokens . canConsume ( ' ' ) ) { // Read names until we see a ',' 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 .
84
19
33,013
protected void parsePropertyOrChildNodeDefinitions ( TokenStream tokens , JcrNodeTypeTemplate nodeType ) throws ConstraintViolationException { while ( true ) { // Keep reading while we see a property definition or child node definition ... if ( tokens . matches ( ' ' ) ) { parsePropertyDefinition ( tokens , nodeType ) ; } else if ( tokens . matches ( ' ' ) ) { parseChildNodeDefinition ( tokens , nodeType ) ; } else { // The next token does not signal either one of these, so stop ... break ; } } }
Parse a node type s property or child node definitions that appear next on the token stream .
117
19
33,014
protected void parsePropertyDefinition ( TokenStream tokens , JcrNodeTypeTemplate nodeType ) throws ConstraintViolationException { tokens . consume ( ' ' ) ; Name name = parseName ( tokens ) ; JcrPropertyDefinitionTemplate propDefn = new JcrPropertyDefinitionTemplate ( context ) ; propDefn . setName ( string ( name ) ) ; // Parse the (optional) required type ... parsePropertyType ( tokens , propDefn , PropertyType . STRING . getName ( ) ) ; // Parse the default values ... parseDefaultValues ( tokens , propDefn ) ; // Parse the property attributes (and vendor extensions) ... parsePropertyAttributes ( tokens , propDefn , nodeType ) ; // Parse the property constraints ... parseValueConstraints ( tokens , propDefn ) ; // Parse the vendor extensions (appearing after the constraints) ... 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 .
243
16
33,015
protected void parsePropertyType ( TokenStream tokens , JcrPropertyDefinitionTemplate propDefn , String defaultPropertyType ) { if ( tokens . canConsume ( ' ' ) ) { // Parse the (optional) property type ... 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 .
171
16
33,016
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 .
77
17
33,017
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 .
81
17
33,018
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" ) ) { // variant on-parent-version 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 .
762
16
33,019
protected void parseQueryOperators ( TokenStream tokens , JcrPropertyDefinitionTemplate propDefn ) { if ( tokens . canConsume ( ' ' ) ) { return ; } // The query operators are expected to be enclosed in a single quote, so therefore will be a single token ... List < String > operators = new ArrayList < String > ( ) ; String operatorList = removeQuotes ( tokens . consume ( ) ) ; // Now split this string on ',' ... 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 .
226
17
33,020
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 .
132
17
33,021
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 .
109
21
33,022
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 .
84
18
33,023
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" , "*" ) ) { // standard JCR 2.0 keywords for SNS ... tokens . canConsume ( ' ' ) ; sns = true ; } else if ( tokens . canConsumeAnyOf ( "MULTIPLE" , "MUL" , "*" ) ) { // from pre-JCR 2.0 ref impl 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" ) ) { // variant on-parent-version 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 .
713
17
33,024
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 .
106
15
33,025
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 .
72
16
33,026
protected final Property parseVendorExtension ( String vendorExtension ) { if ( vendorExtension == null ) return null ; // Remove the curly braces ... 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 .
92
15
33,027
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 .
139
18
33,028
public WorkspaceCache createWorkspace ( String name ) { if ( ! workspaceNames . contains ( name ) ) { if ( ! configuration . isCreatingWorkspacesAllowed ( ) ) { throw new UnsupportedOperationException ( JcrI18n . creatingWorkspacesIsNotAllowedInRepository . text ( getName ( ) ) ) ; } // Otherwise, create the workspace and persist it ... this . workspaceNames . add ( name ) ; refreshRepositoryMetadata ( true ) ; // Now make sure that the "/jcr:system" node is a child of the root node ... 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 ( ) ; } // And notify the others ... 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 .
357
54
33,029
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 ( ) ; //the name of the external connector is used for source name and workspace name String sourceKey = NodeKey . keyForSourceName ( sourceName ) ; String workspaceKey = NodeKey . keyForWorkspaceName ( workspaceName ) ; //ask external system to determine root identifier. 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 ( ) ; // Compute the root key for this workspace ... NodeKey rootKey = new NodeKey ( sourceKey , workspaceKey , rootId ) ; // We know that this workspace is not the system workspace, so find it ... 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 .
385
14
33,030
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 .
74
19
33,031
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 .
146
24
33,032
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
51
14
33,033
public void changeField ( MappedAttributeDefinition defn , ModelNode newValue ) throws RepositoryException , OperationFailedException { ModeShapeEngine engine = getEngine ( ) ; String repositoryName = repositoryName ( ) ; // Get a snapshot of the current configuration ... RepositoryConfiguration config = engine . getRepositoryConfiguration ( repositoryName ) ; // Now start to make changes ... Editor editor = config . edit ( ) ; // Find the Document containing the field ... EditableDocument fieldContainer = editor ; for ( String fieldName : defn . getPathToContainerOfField ( ) ) { fieldContainer = editor . getOrCreateDocument ( fieldName ) ; } // Get the raw value from the model node ... Object rawValue = defn . getTypedValue ( newValue ) ; // Change the field ... String fieldName = defn . getFieldName ( ) ; fieldContainer . set ( fieldName , rawValue ) ; // Apply the changes to the current configuration ... Changes changes = editor . getChanges ( ) ; engine . update ( repositoryName , changes ) ; }
Immediately change and apply the specified field in the current repository configuration to the new value .
223
18
33,034
public void changeIndexProviderField ( MappedAttributeDefinition defn , ModelNode newValue , String indexProviderName ) throws RepositoryException , OperationFailedException { ModeShapeEngine engine = getEngine ( ) ; String repositoryName = repositoryName ( ) ; // Get a snapshot of the current configuration ... RepositoryConfiguration config = engine . getRepositoryConfiguration ( repositoryName ) ; // Now start to make changes ... Editor editor = config . edit ( ) ; // Find the array of sequencer documents ... List < String > pathToContainer = defn . getPathToContainerOfField ( ) ; EditableDocument providers = editor . getOrCreateDocument ( pathToContainer . get ( 0 ) ) ; // The container should be an array ... for ( String configuredProviderName : providers . keySet ( ) ) { // Look for the entry with a name that matches our sequencer name ... if ( indexProviderName . equals ( configuredProviderName ) ) { // All these entries should be nested documents ... EditableDocument provider = ( EditableDocument ) providers . get ( configuredProviderName ) ; // Change the field ... String fieldName = defn . getFieldName ( ) ; // Get the raw value from the model node ... Object rawValue = defn . getTypedValue ( newValue ) ; // And update the field ... provider . set ( fieldName , rawValue ) ; break ; } } // Get and apply the changes to the current configuration. Note that the 'update' call asynchronously // updates the configuration, and returns a Future<JcrRepository> that we could use if we wanted to // wait for the changes to take place. But we don't want/need to wait, so we'll not use the Future ... 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 .
382
20
33,035
public void changeSequencerField ( MappedAttributeDefinition defn , ModelNode newValue , String sequencerName ) throws RepositoryException , OperationFailedException { ModeShapeEngine engine = getEngine ( ) ; String repositoryName = repositoryName ( ) ; // Get a snapshot of the current configuration ... RepositoryConfiguration config = engine . getRepositoryConfiguration ( repositoryName ) ; // Now start to make changes ... Editor editor = config . edit ( ) ; // Find the array of sequencer documents ... List < String > pathToContainer = defn . getPathToContainerOfField ( ) ; EditableDocument sequencing = editor . getOrCreateDocument ( pathToContainer . get ( 0 ) ) ; EditableDocument sequencers = sequencing . getOrCreateArray ( pathToContainer . get ( 1 ) ) ; // The container should be an array ... for ( String configuredSequencerName : sequencers . keySet ( ) ) { // Look for the entry with a name that matches our sequencer name ... if ( sequencerName . equals ( configuredSequencerName ) ) { // All these entries should be nested documents ... EditableDocument sequencer = ( EditableDocument ) sequencers . get ( configuredSequencerName ) ; // Change the field ... String fieldName = defn . getFieldName ( ) ; // Get the raw value from the model node ... Object rawValue = defn . getTypedValue ( newValue ) ; // And update the field ... sequencer . set ( fieldName , rawValue ) ; break ; } } // Get and apply the changes to the current configuration. Note that the 'update' call asynchronously // updates the configuration, and returns a Future<JcrRepository> that we could use if we wanted to // wait for the changes to take place. But we don't want/need to wait, so we'll not use the Future ... 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 .
412
20
33,036
public void changePersistenceField ( MappedAttributeDefinition defn , ModelNode newValue ) throws RepositoryException , OperationFailedException { ModeShapeEngine engine = getEngine ( ) ; String repositoryName = repositoryName ( ) ; // Get a snapshot of the current configuration ... RepositoryConfiguration config = engine . getRepositoryConfiguration ( repositoryName ) ; // Now start to make changes ... Editor editor = config . edit ( ) ; EditableDocument persistence = editor . getOrCreateDocument ( FieldName . STORAGE ) . getOrCreateDocument ( FieldName . PERSISTENCE ) ; // Change the field ... String fieldName = defn . getFieldName ( ) ; // Get the raw value from the model node ... Object rawValue = defn . getTypedValue ( newValue ) ; // And update the field ... persistence . set ( fieldName , rawValue ) ; // Get and apply the changes to the current configuration. Note that the 'update' call asynchronously // updates the configuration, and returns a Future<JcrRepository> that we could use if we wanted to // wait for the changes to take place. But we don't want/need to wait, so we'll not use the Future ... Changes changes = editor . getChanges ( ) ; engine . update ( repositoryName , changes ) ; }
Immediately change and apply the specified persistence field to the repository configuration
275
13
33,037
public void changeSourceField ( MappedAttributeDefinition defn , ModelNode newValue , String sourceName ) throws RepositoryException , OperationFailedException { ModeShapeEngine engine = getEngine ( ) ; String repositoryName = repositoryName ( ) ; // Get a snapshot of the current configuration ... RepositoryConfiguration config = engine . getRepositoryConfiguration ( repositoryName ) ; // Now start to make changes ... Editor editor = config . edit ( ) ; // Find the array of sequencer documents ... EditableDocument externalSources = editor . getOrCreateDocument ( FieldName . EXTERNAL_SOURCES ) ; EditableDocument externalSource = externalSources . getDocument ( sourceName ) ; assert externalSource != null ; // Change the field ... String fieldName = defn . getFieldName ( ) ; // Get the raw value from the model node ... Object rawValue = defn . getTypedValue ( newValue ) ; // And update the field ... externalSource . set ( fieldName , rawValue ) ; // Get and apply the changes to the current configuration. Note that the 'update' call asynchronously // updates the configuration, and returns a Future<JcrRepository> that we could use if we wanted to // wait for the changes to take place. But we don't want/need to wait, so we'll not use the Future ... 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 .
303
20
33,038
public void changeTextExtractorField ( MappedAttributeDefinition defn , ModelNode newValue , String extractorName ) throws RepositoryException , OperationFailedException { ModeShapeEngine engine = getEngine ( ) ; String repositoryName = repositoryName ( ) ; // Get a snapshot of the current configuration ... RepositoryConfiguration config = engine . getRepositoryConfiguration ( repositoryName ) ; // Now start to make changes ... Editor editor = config . edit ( ) ; // Find the array of sequencer documents ... List < String > pathToContainer = defn . getPathToContainerOfField ( ) ; EditableDocument textExtracting = editor . getOrCreateDocument ( pathToContainer . get ( 1 ) ) ; EditableDocument extractors = textExtracting . getOrCreateDocument ( pathToContainer . get ( 2 ) ) ; // The container should be an array ... for ( String configuredExtractorName : extractors . keySet ( ) ) { // Look for the entry with a name that matches our extractor name ... if ( extractorName . equals ( configuredExtractorName ) ) { // All these entries should be nested documents ... EditableDocument extractor = ( EditableDocument ) extractors . get ( configuredExtractorName ) ; // Change the field ... String fieldName = defn . getFieldName ( ) ; // Get the raw value from the model node ... Object rawValue = defn . getTypedValue ( newValue ) ; // And update the field ... 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 .
348
20
33,039
public void changeAuthenticatorField ( MappedAttributeDefinition defn , ModelNode newValue , String authenticatorName ) throws RepositoryException , OperationFailedException { ModeShapeEngine engine = getEngine ( ) ; String repositoryName = repositoryName ( ) ; // Get a snapshot of the current configuration ... RepositoryConfiguration config = engine . getRepositoryConfiguration ( repositoryName ) ; // Now start to make changes ... Editor editor = config . edit ( ) ; // Find the array of sequencer documents ... EditableDocument security = editor . getOrCreateDocument ( FieldName . SECURITY ) ; EditableArray providers = security . getOrCreateArray ( FieldName . PROVIDERS ) ; // The container should be an array ... for ( String configuredAuthenticatorName : providers . keySet ( ) ) { // Look for the entry with a name that matches our authenticator name ... if ( authenticatorName . equals ( configuredAuthenticatorName ) ) { // Find the document in the array with the name field value that matches ... boolean found = false ; for ( Object nested : providers ) { if ( nested instanceof EditableDocument ) { EditableDocument doc = ( EditableDocument ) nested ; if ( doc . getString ( FieldName . NAME ) . equals ( configuredAuthenticatorName ) ) { // Change the field ... String fieldName = defn . getFieldName ( ) ; // Get the raw value from the model node ... Object rawValue = defn . getTypedValue ( newValue ) ; // And update the field ... doc . set ( fieldName , rawValue ) ; found = true ; break ; } } } if ( ! found ) { // Add the nested document ... EditableDocument doc = Schematic . newDocument ( ) ; doc . set ( FieldName . NAME , configuredAuthenticatorName ) ; // Set the field ... String fieldName = defn . getFieldName ( ) ; // Get the raw value from the model node ... Object rawValue = defn . getTypedValue ( newValue ) ; // And update the field ... 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 .
473
20
33,040
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
38
18
33,041
public Predicate < T > and ( final Predicate < T > other ) { if ( other == null || other == this ) return this ; return new Predicate < T > ( ) { @ Override 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 .
73
18
33,042
public Predicate < T > or ( final Predicate < T > other ) { if ( other == null || other == this ) return this ; return new Predicate < T > ( ) { @ Override 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 .
73
18
33,043
public Predicate < T > negate ( ) { return new Predicate < T > ( ) { @ Override public boolean test ( T input ) { return ! Predicate . this . test ( input ) ; } @ Override public Predicate < T > negate ( ) { return Predicate . this ; } } ; }
Obtain a new predicate that performs the logical NOT of this predicate .
67
14
33,044
public static < T > Predicate < T > never ( ) { return new Predicate < T > ( ) { @ Override public boolean test ( T input ) { return false ; } } ; }
Return a predicate that is never satisfied .
42
8
33,045
public static < T > Predicate < T > always ( ) { return new Predicate < T > ( ) { @ Override public boolean test ( T input ) { return true ; } } ; }
Return a predicate that is always satisfied .
42
8
33,046
public static String urlFrom ( String baseUrl , String ... pathSegments ) { StringBuilder urlBuilder = new StringBuilder ( baseUrl ) ; if ( urlBuilder . charAt ( urlBuilder . length ( ) - 1 ) == ' ' ) { urlBuilder . deleteCharAt ( urlBuilder . length ( ) - 1 ) ; } for ( String pathSegment : pathSegments ) { if ( pathSegment . equalsIgnoreCase ( ".." ) ) { urlBuilder . delete ( urlBuilder . lastIndexOf ( "/" ) , urlBuilder . length ( ) ) ; } else { if ( ! pathSegment . startsWith ( "/" ) ) { urlBuilder . append ( "/" ) ; } urlBuilder . append ( pathSegment ) ; } } return urlBuilder . toString ( ) ; }
Creates an url using base url and appending optional segments .
173
13
33,047
public static Value jsonValueToJCRValue ( Object value , ValueFactory valueFactory ) { if ( value == null ) { return null ; } // try the datatypes that can be handled by Jettison if ( value instanceof Integer || value instanceof Long ) { return valueFactory . createValue ( ( ( Number ) value ) . longValue ( ) ) ; } else if ( value instanceof Double || value instanceof Float ) { return valueFactory . createValue ( ( ( Number ) value ) . doubleValue ( ) ) ; } else if ( value instanceof Boolean ) { return valueFactory . createValue ( ( Boolean ) value ) ; } // try to convert to a date String valueString = value . toString ( ) ; for ( DateFormat dateFormat : ISO8601_DATE_PARSERS ) { try { Date date = dateFormat . parse ( valueString ) ; return valueFactory . createValue ( date ) ; } catch ( ParseException e ) { // ignore } catch ( ValueFormatException e ) { // ignore } } // default to a string return valueFactory . createValue ( valueString ) ; }
Converts an object value coming from a JSON object to a JCR value by attempting to convert it to a valid data type .
238
26
33,048
public static boolean isProperlyFormattedKey ( String hexadecimalStr ) { if ( hexadecimalStr == null ) return false ; // Length is expected to be the same as the digest ... final int length = hexadecimalStr . length ( ) ; if ( length != ALGORITHM . getHexadecimalStringLength ( ) ) return false ; // The characters all must be hexadecimal digits ... return StringUtil . isHexString ( hexadecimalStr ) ; }
Determine if the supplied hexadecimal string is potentially a binary key by checking the format of the string .
112
24
33,049
Future < Boolean > shutdown ( ) { // Create a simple executor that will do the backgrounding for us ... final ExecutorService executor = Executors . newSingleThreadExecutor ( new NamedThreadFactory ( "modeshape-repository-stop" ) ) ; try { // Submit a runnable to terminate all sessions ... return executor . submit ( ( ) -> doShutdown ( false ) ) ; } finally { // Now shutdown the executor and return the future ... executor . shutdown ( ) ; } }
Terminate all active sessions .
113
6
33,050
private String getParameter ( List < FileItem > items , String name ) { for ( FileItem i : items ) { if ( i . isFormField ( ) && i . getFieldName ( ) . equals ( name ) ) { return i . getString ( ) ; } } return null ; }
Extracts value of the parameter with given name .
63
11
33,051
private InputStream getStream ( List < FileItem > items ) throws IOException { for ( FileItem i : items ) { if ( ! i . isFormField ( ) && i . getFieldName ( ) . equals ( CONTENT_PARAMETER ) ) { return i . getInputStream ( ) ; } } return null ; }
Gets uploaded file as stream .
72
7
33,052
public static void isNotLessThan ( int argument , int notLessThanValue , String name ) { if ( argument < notLessThanValue ) { throw new IllegalArgumentException ( CommonI18n . argumentMayNotBeLessThan . text ( name , argument , notLessThanValue ) ) ; } }
Check that the argument is not less than the supplied value
70
11
33,053
public static void isNotGreaterThan ( int argument , int notGreaterThanValue , String name ) { if ( argument > notGreaterThanValue ) { throw new IllegalArgumentException ( CommonI18n . argumentMayNotBeGreaterThan . text ( name , argument , notGreaterThanValue ) ) ; } }
Check that the argument is not greater than the supplied value
75
11
33,054
public static void isGreaterThan ( int argument , int greaterThanValue , String name ) { if ( argument <= greaterThanValue ) { throw new IllegalArgumentException ( CommonI18n . argumentMustBeGreaterThan . text ( name , argument , greaterThanValue ) ) ; } }
Check that the argument is greater than the supplied value
67
10
33,055
public static void isLessThan ( int argument , int lessThanValue , String name ) { if ( argument >= lessThanValue ) { throw new IllegalArgumentException ( CommonI18n . argumentMustBeLessThan . text ( name , argument , lessThanValue ) ) ; } }
Check that the argument is less than the supplied value
65
10
33,056
public static void isGreaterThanOrEqualTo ( int argument , int greaterThanOrEqualToValue , String name ) { if ( argument < greaterThanOrEqualToValue ) { throw new IllegalArgumentException ( CommonI18n . argumentMustBeGreaterThanOrEqualTo . text ( name , argument , greaterThanOrEqualToValue ) ) ; } }
Check that the argument is greater than or equal to the supplied value
87
13
33,057
public static void isLessThanOrEqualTo ( int argument , int lessThanOrEqualToValue , String name ) { if ( argument > lessThanOrEqualToValue ) { throw new IllegalArgumentException ( CommonI18n . argumentMustBeLessThanOrEqualTo . text ( name , argument , lessThanOrEqualToValue ) ) ; } }
Check that the argument is less than or equal to the supplied value
85
13
33,058
public static void isPowerOfTwo ( int argument , String name ) { if ( Integer . bitCount ( argument ) != 1 ) { throw new IllegalArgumentException ( CommonI18n . argumentMustBePowerOfTwo . text ( name , argument ) ) ; } }
Check that the argument is a power of 2 .
57
10
33,059
public static void isNotNan ( double argument , String name ) { if ( Double . isNaN ( argument ) ) { throw new IllegalArgumentException ( CommonI18n . argumentMustBeNumber . text ( name ) ) ; } }
Check that the argument is not NaN .
52
9
33,060
public static void isNotZeroLength ( String argument , String name ) { isNotNull ( argument , name ) ; if ( argument . length ( ) <= 0 ) { throw new IllegalArgumentException ( CommonI18n . argumentMayNotBeNullOrZeroLength . text ( name ) ) ; } }
Check that the string is non - null and has length > 0
64
13
33,061
public static void isNotEmpty ( String argument , String name ) { isNotZeroLength ( argument , name ) ; if ( argument != null && argument . trim ( ) . length ( ) == 0 ) { throw new IllegalArgumentException ( CommonI18n . argumentMayNotBeNullOrZeroLengthOrEmpty . text ( name ) ) ; } }
Check that the string is not empty is not null and does not contain only whitespace .
74
18
33,062
public static void isNotNull ( Object argument , String name ) { if ( argument == null ) { throw new IllegalArgumentException ( CommonI18n . argumentMayNotBeNull . text ( name ) ) ; } }
Check that the specified argument is non - null
47
9
33,063
public static void isNull ( Object argument , String name ) { if ( argument != null ) { throw new IllegalArgumentException ( CommonI18n . argumentMustBeNull . text ( name ) ) ; } }
Check that the argument is null
45
6
33,064
public static void isInstanceOf ( Object argument , Class < ? > expectedClass , String name ) { isNotNull ( argument , name ) ; if ( ! expectedClass . isInstance ( argument ) ) { throw new IllegalArgumentException ( CommonI18n . argumentMustBeInstanceOf . text ( name , argument . getClass ( ) , expectedClass . getName ( ) ) ) ; } }
Check that the object is an instance of the specified Class
84
11
33,065
public static < C > C getInstanceOf ( Object argument , Class < C > expectedClass , String name ) { isInstanceOf ( argument , expectedClass , name ) ; return expectedClass . cast ( argument ) ; }
due to cast in return
46
5
33,066
public static void isNotEmpty ( Iterator < ? > argument , String name ) { isNotNull ( argument , name ) ; if ( ! argument . hasNext ( ) ) { throw new IllegalArgumentException ( CommonI18n . argumentMayNotBeEmpty . text ( name ) ) ; } }
Checks that the iterator is not empty and throws an exception if it is .
64
16
33,067
public static void isNotEmpty ( Collection < ? > argument , String name ) { isNotNull ( argument , name ) ; if ( argument . isEmpty ( ) ) { throw new IllegalArgumentException ( CommonI18n . argumentMayNotBeEmpty . text ( name ) ) ; } }
Check that the collection is not empty
62
7
33,068
public static void isEmpty ( Object [ ] argument , String name ) { isNotNull ( argument , name ) ; if ( argument . length > 0 ) { throw new IllegalArgumentException ( CommonI18n . argumentMustBeEmpty . text ( name ) ) ; } }
Check that the array is empty
58
6
33,069
public static void isNotEmpty ( Object [ ] argument , String name ) { isNotNull ( argument , name ) ; if ( argument . length == 0 ) { throw new IllegalArgumentException ( CommonI18n . argumentMayNotBeEmpty . text ( name ) ) ; } }
Check that the array is not empty
60
7
33,070
public static void contains ( Collection < ? > argument , Object value , String name ) { isNotNull ( argument , name ) ; if ( ! argument . contains ( value ) ) { throw new IllegalArgumentException ( CommonI18n . argumentDidNotContainObject . text ( name , getObjectName ( value ) ) ) ; } }
Check that the collection contains the value
72
7
33,071
public static void containsKey ( Map < ? , ? > argument , Object key , String name ) { isNotNull ( argument , name ) ; if ( ! argument . containsKey ( key ) ) { throw new IllegalArgumentException ( CommonI18n . argumentDidNotContainKey . text ( name , getObjectName ( key ) ) ) ; } }
Check that the map contains the key
76
7
33,072
public static void containsNoNulls ( Iterable < ? > argument , String name ) { isNotNull ( argument , name ) ; int i = 0 ; for ( Object object : argument ) { if ( object == null ) { throw new IllegalArgumentException ( CommonI18n . argumentMayNotContainNullValue . text ( name , i ) ) ; } ++ i ; } }
Check that the collection is not null and contains no nulls
82
12
33,073
public static void hasSizeOfAtLeast ( Collection < ? > argument , int minimumSize , String name ) { isNotNull ( argument , name ) ; if ( argument . size ( ) < minimumSize ) { throw new IllegalArgumentException ( CommonI18n . argumentMustBeOfMinimumSize . text ( name , Collection . class . getSimpleName ( ) , argument . size ( ) , minimumSize ) ) ; } }
Check that the collection contains at least the supplied number of elements
91
12
33,074
public static void hasSizeOfAtMost ( Collection < ? > argument , int maximumSize , String name ) { isNotNull ( argument , name ) ; if ( argument . size ( ) > maximumSize ) { throw new IllegalArgumentException ( CommonI18n . argumentMustBeOfMinimumSize . text ( name , Collection . class . getSimpleName ( ) , argument . size ( ) , maximumSize ) ) ; } }
Check that the collection contains no more than the supplied number of elements
90
13
33,075
public static void hasSizeOfAtLeast ( Object [ ] argument , int minimumSize , String name ) { isNotNull ( argument , name ) ; if ( argument . length < minimumSize ) { throw new IllegalArgumentException ( CommonI18n . argumentMustBeOfMinimumSize . text ( name , Object [ ] . class . getSimpleName ( ) , argument . length , minimumSize ) ) ; } }
Check that the array contains at least the supplied number of elements
88
12
33,076
public static void hasSizeOfAtMost ( Object [ ] argument , int maximumSize , String name ) { isNotNull ( argument , name ) ; if ( argument . length > maximumSize ) { throw new IllegalArgumentException ( CommonI18n . argumentMustBeOfMinimumSize . text ( name , Object [ ] . class . getSimpleName ( ) , argument . length , maximumSize ) ) ; } }
Check that the array contains no more than the supplied number of elements
87
13
33,077
public static String jodaFormat ( ZonedDateTime dateTime ) { CheckArg . isNotNull ( dateTime , "dateTime" ) ; return dateTime . format ( JODA_ISO8601_FORMATTER ) ; }
Returns the ISO8601 string of a given date - time instance with timezone information trying to be as closed as possible to what the JODA date - time library would return .
51
37
33,078
protected final < T > T processStream ( Binary binary , BinaryOperation < T > operation ) throws Exception { InputStream stream = binary . getStream ( ) ; if ( stream == null ) { throw new IllegalArgumentException ( "The binary value is empty" ) ; } try { return operation . execute ( stream ) ; } finally { stream . close ( ) ; } }
Allows subclasses to process the stream of binary value property in safe fashion making sure the stream is closed at the end of the operation .
78
27
33,079
public void addLanguage ( QueryParser languageParser ) { CheckArg . isNotNull ( languageParser , "languageParser" ) ; this . parsers . put ( languageParser . getLanguage ( ) . trim ( ) . toLowerCase ( ) , languageParser ) ; }
Add a language to this engine by supplying its parser .
57
11
33,080
public Set < String > getLanguages ( ) { Set < String > result = new HashSet < String > ( ) ; for ( QueryParser parser : parsers . values ( ) ) { result . add ( parser . getLanguage ( ) ) ; } return Collections . unmodifiableSet ( result ) ; }
Get the set of languages that this engine is capable of parsing .
65
13
33,081
public QueryParser getParserFor ( String language ) { CheckArg . isNotNull ( language , "language" ) ; return parsers . get ( language . trim ( ) . toLowerCase ( ) ) ; }
Get the parser for the supplied language .
45
8
33,082
public static Builder createBuilder ( ExecutionContext context , NodeTypes nodeTypes ) { CheckArg . isNotNull ( context , "context" ) ; CheckArg . isNotNull ( nodeTypes , "nodeTypes" ) ; return new Builder ( context , nodeTypes ) ; }
Obtain a new instance for building Schemata objects .
57
12
33,083
public void show ( JcrNode node ) { this . node = node ; if ( node . getAcl ( ) == null ) { this . displayDisabledEditor ( ) ; } else if ( this . isAclDefined ( node ) ) { this . selectFirstPrincipalAndDisplayPermissions ( node ) ; } else { this . displayEveryonePermissions ( ) ; } }
Displays permissions for the given node .
82
8
33,084
protected AstNode parseMaterializedViewStatement ( DdlTokenStream tokens , AstNode parentNode ) throws ParsingException { assert tokens != null ; assert parentNode != null ; markStartOfStatement ( tokens ) ; /* ---------------------------------------------------------------------- CREATE MATERIALIZED VIEW [ schema. ]materialized_view [ column_alias [, column_alias]... ] [ OF [ schema. ]object_type ] .................... (MORE...) EXAMPLES: CREATE MATERIALIZED VIEW LOG ON products WITH ROWID, SEQUENCE (prod_id) INCLUDING NEW VALUES; CREATE MATERIALIZED VIEW sales_mv BUILD IMMEDIATE REFRESH FAST ON COMMIT AS SELECT t.calendar_year, p.prod_id, SUM(s.amount_sold) AS sum_sales FROM times t, products p, sales s WHERE t.time_id = s.time_id AND p.prod_id = s.prod_id GROUP BY t.calendar_year, p.prod_id; ---------------------------------------------------------------------- */ boolean isLog = tokens . canConsume ( STMT_CREATE_MATERIALIZED_VEIW_LOG ) ; tokens . canConsume ( STMT_CREATE_MATERIALIZED_VIEW ) ; String name = parseName ( tokens ) ; AstNode node = null ; if ( isLog ) { node = nodeFactory ( ) . node ( name , parentNode , TYPE_CREATE_MATERIALIZED_VIEW_LOG_STATEMENT ) ; } else { node = nodeFactory ( ) . node ( name , parentNode , TYPE_CREATE_MATERIALIZED_VIEW_STATEMENT ) ; } parseUntilTerminator ( tokens ) ; markEndOfStatement ( tokens , node ) ; return node ; }
Parses DDL CREATE MATERIALIZED VIEW statement This could either be a standard view or a VIEW LOG ON statement .
396
28
33,085
private String parseContentBetweenParens ( final DdlTokenStream tokens ) throws ParsingException { tokens . consume ( L_PAREN ) ; // don't include first paren in expression int numLeft = 1 ; int numRight = 0 ; final StringBuilder text = new StringBuilder ( ) ; while ( tokens . hasNext ( ) ) { if ( tokens . matches ( L_PAREN ) ) { ++ numLeft ; } else if ( tokens . matches ( R_PAREN ) ) { if ( numLeft == ++ numRight ) { tokens . consume ( R_PAREN ) ; // don't include last paren in expression break ; } } final String token = tokens . consume ( ) ; // don't add space if empty or if this token or previous token is a period if ( ! PERIOD . equals ( token ) && ( text . length ( ) != 0 ) && ( PERIOD . charAt ( 0 ) != ( text . charAt ( text . length ( ) - 1 ) ) ) ) { text . append ( SPACE ) ; } text . append ( token ) ; } if ( ( numLeft != numRight ) || ( text . length ( ) == 0 ) ) { throw new ParsingException ( tokens . nextPosition ( ) ) ; } return text . toString ( ) ; }
The tokens must start with a left paren end with a right paren and have content between . Any parens in the content must have matching parens .
277
34
33,086
protected boolean isColumnDefinitionStart ( DdlTokenStream tokens , String columnMixinType ) throws ParsingException { boolean result = isColumnDefinitionStart ( tokens ) ; if ( ! result && TYPE_ALTER_COLUMN_DEFINITION . equals ( columnMixinType ) ) { for ( String start : INLINE_COLUMN_PROPERTY_START ) { if ( tokens . matches ( TokenStream . ANY_VALUE , start ) ) return true ; } } return result ; }
Utility method to additionally check if MODIFY definition without datatype
107
15
33,087
public static ExtractFromRow extractPath ( final int indexInRow , final NodeCache cache , TypeSystem types ) { final TypeFactory < Path > type = types . getPathFactory ( ) ; final boolean trace = NodeSequence . LOGGER . isTraceEnabled ( ) ; return new ExtractFromRow ( ) { @ Override public TypeFactory < Path > getType ( ) { return type ; } @ Override public Object getValueInRow ( RowAccessor row ) { CachedNode node = row . getNode ( indexInRow ) ; if ( node == null ) return null ; Path path = node . getPath ( cache ) ; if ( trace ) NodeSequence . LOGGER . trace ( "Extracting path from {0}" , path ) ; return path ; } @ Override public String toString ( ) { return "(extract-path)" ; } } ; }
Create an extractor that extracts the path from the node at the given position in the row .
187
19
33,088
public static ExtractFromRow extractParentPath ( final int indexInRow , final NodeCache cache , TypeSystem types ) { final TypeFactory < Path > type = types . getPathFactory ( ) ; final boolean trace = NodeSequence . LOGGER . isTraceEnabled ( ) ; return new ExtractFromRow ( ) { @ Override public TypeFactory < Path > getType ( ) { return type ; } @ Override public Object getValueInRow ( RowAccessor row ) { CachedNode node = row . getNode ( indexInRow ) ; if ( node == null ) return null ; NodeKey parentKey = node . getParentKey ( cache ) ; if ( parentKey == null ) return null ; CachedNode parent = cache . getNode ( parentKey ) ; if ( parent == null ) return null ; Path parentPath = parent . getPath ( cache ) ; if ( trace ) NodeSequence . LOGGER . trace ( "Extracting parent path from {0}: {1}" , node . getPath ( cache ) , parentPath ) ; return parentPath ; } @ Override public String toString ( ) { return "(extract-parent-path)" ; } } ; }
Create an extractor that extracts the parent path from the node at the given position in the row .
252
20
33,089
public static ExtractFromRow extractRelativePath ( final int indexInRow , final Path relativePath , final NodeCache cache , TypeSystem types ) { CheckArg . isNotNull ( relativePath , "relativePath" ) ; final TypeFactory < Path > type = types . getPathFactory ( ) ; final boolean trace = NodeSequence . LOGGER . isTraceEnabled ( ) ; return new ExtractFromRow ( ) { @ Override public TypeFactory < Path > getType ( ) { return type ; } @ Override public Object getValueInRow ( RowAccessor row ) { CachedNode node = row . getNode ( indexInRow ) ; if ( node == null ) return null ; Path nodePath = node . getPath ( cache ) ; try { Path path = nodePath . resolve ( relativePath ) ; if ( trace ) NodeSequence . LOGGER . trace ( "Extracting relative path {2} from {0}: {2}" , node . getPath ( cache ) , relativePath , path ) ; return path ; } catch ( InvalidPathException e ) { return null ; } } @ Override public String toString ( ) { return "(extract-relative-path)" ; } } ; }
Create an extractor that extracts the path from the node at the given position in the row and applies the relative path .
258
24
33,090
public static ExtractFromRow extractPropertyValue ( final Name propertyName , final int indexInRow , final NodeCache cache , final TypeFactory < ? > desiredType ) { return new ExtractFromRow ( ) { @ Override public Object getValueInRow ( RowAccessor row ) { CachedNode node = row . getNode ( indexInRow ) ; if ( node == null ) return null ; org . modeshape . jcr . value . Property prop = node . getProperty ( propertyName , cache ) ; return prop == null ? null : desiredType . create ( prop . getFirstValue ( ) ) ; } @ Override public TypeFactory < ? > getType ( ) { return desiredType ; } } ; }
Create an extractor that extracts the property value from the node at the given position in the row .
152
20
33,091
protected final boolean reindex ( String workspaceName , NodeKey key , Path path , Name primaryType , Set < Name > mixinTypes , Properties properties , boolean queryable ) { if ( predicate . matchesType ( primaryType , mixinTypes ) ) { reindexNode ( workspaceName , key , path , primaryType , mixinTypes , properties , queryable ) ; return true ; } return false ; }
Reindex the specific node .
85
6
33,092
protected NodeCacheIterator nodes ( String workspaceName , Path path ) { // Determine which filter we should use based upon the workspace name. For the system workspace, // all queryable nodes are included. For all other workspaces, all queryable nodes are included except // for those that are actually stored in the system workspace (e.g., the "/jcr:system" nodes). NodeFilter nodeFilterForWorkspace = nodeFilterForWorkspace ( workspaceName ) ; if ( nodeFilterForWorkspace == null ) return null ; // always append a shared nodes filter to the end of the workspace filter, // JCR #14.16 -If a query matches a descendant node of a shared set, it appears in query results only once. NodeFilter compositeFilter = new CompositeNodeFilter ( nodeFilterForWorkspace , sharedNodesFilter ( ) ) ; // Then create an iterator over that workspace ... NodeCache cache = repo . getWorkspaceCache ( workspaceName ) ; NodeKey startingNode = null ; if ( path != null ) { CachedNode node = getNodeAtPath ( path , cache ) ; if ( node != null ) startingNode = node . getKey ( ) ; } else { startingNode = cache . getRootKey ( ) ; } if ( startingNode != null ) { return new NodeCacheIterator ( cache , startingNode , compositeFilter ) ; } return null ; }
Return an iterator over all nodes at or below the specified path in the named workspace using the supplied filter .
289
21
33,093
public RestNode addCustomProperty ( String name , String value ) { customProperties . put ( name , value ) ; return this ; }
Adds a custom property to this node meaning a property which is not among the standard JCR properties
29
19
33,094
protected final void checkForCheckedOut ( ) throws VersionException , RepositoryException { if ( ! node . isCheckedOut ( ) ) { // Node is not checked out, so changing property is only allowed if OPV of property is 'ignore' ... JcrPropertyDefinition defn = getDefinition ( ) ; if ( defn . getOnParentVersion ( ) != OnParentVersionAction . IGNORE ) { // Can't change this property ... String path = getParent ( ) . getPath ( ) ; throw new VersionException ( JcrI18n . nodeIsCheckedIn . text ( path ) ) ; } } }
Verifies that this node is either not versionable or that it is versionable but checked out .
132
20
33,095
protected final CachedNode node ( ) throws ItemNotFoundException , InvalidItemStateException { CachedNode node = sessionCache ( ) . getNode ( key ) ; if ( node == null ) { if ( sessionCache ( ) . isDestroyed ( key ) ) { throw new InvalidItemStateException ( "The node with key " + key + " has been removed in this session." ) ; } throw new ItemNotFoundException ( "The node with key " + key + " no longer exists." ) ; } return node ; }
Get the cached node .
112
5
33,096
final JcrPropertyDefinition propertyDefinitionFor ( org . modeshape . jcr . value . Property property , Name primaryType , Set < Name > mixinTypes , NodeTypes nodeTypes ) throws ConstraintViolationException { // Figure out the JCR property type ... boolean single = property . isSingle ( ) ; boolean skipProtected = false ; JcrPropertyDefinition defn = findBestPropertyDefinition ( primaryType , mixinTypes , property , single , skipProtected , false , nodeTypes ) ; if ( defn != null ) return defn ; // See if there is a definition that has constraints that were violated ... defn = findBestPropertyDefinition ( primaryType , mixinTypes , property , single , skipProtected , true , nodeTypes ) ; String pName = readable ( property . getName ( ) ) ; String loc = location ( ) ; if ( defn != null ) { I18n msg = JcrI18n . propertyNoLongerSatisfiesConstraints ; throw new ConstraintViolationException ( msg . text ( pName , loc , defn . getName ( ) , defn . getDeclaringNodeType ( ) . getName ( ) ) ) ; } CachedNode node = sessionCache ( ) . getNode ( key ) ; String ptype = readable ( node . getPrimaryType ( sessionCache ( ) ) ) ; String mixins = readable ( node . getMixinTypes ( sessionCache ( ) ) ) ; String pstr = property . getString ( session . namespaces ( ) ) ; throw new ConstraintViolationException ( JcrI18n . propertyNoLongerHasValidDefinition . text ( pstr , loc , ptype , mixins ) ) ; }
Find the property definition for the property given this node s primary type and mixin types .
368
18
33,097
final JcrPropertyDefinition findBestPropertyDefinition ( Name primaryTypeNameOfParent , Collection < Name > mixinTypeNamesOfParent , org . modeshape . jcr . value . Property property , boolean isSingle , boolean skipProtected , boolean skipConstraints , NodeTypes nodeTypes ) { JcrPropertyDefinition definition = null ; int propertyType = PropertyTypeUtil . jcrPropertyTypeFor ( property ) ; // If single-valued ... ValueFactories factories = context ( ) . getValueFactories ( ) ; if ( isSingle ) { // Create a value for the ModeShape property value ... Object value = property . getFirstValue ( ) ; Value jcrValue = new JcrValue ( factories , propertyType , value ) ; definition = nodeTypes . findPropertyDefinition ( session , primaryTypeNameOfParent , mixinTypeNamesOfParent , property . getName ( ) , jcrValue , true , skipProtected ) ; } else { // Create values for the ModeShape property value ... Value [ ] jcrValues = new Value [ property . size ( ) ] ; int index = 0 ; for ( Object value : property ) { jcrValues [ index ++ ] = new JcrValue ( factories , propertyType , value ) ; } definition = nodeTypes . findPropertyDefinition ( session , primaryTypeNameOfParent , mixinTypeNamesOfParent , property . getName ( ) , jcrValues , skipProtected ) ; } if ( definition != null ) return definition ; // No definition that allowed the values ... return null ; }
Find the best property definition in this node s primary type and mixin types .
326
16
33,098
protected final AbstractJcrNode childNode ( Name name , Type expectedType ) throws PathNotFoundException , ItemNotFoundException , InvalidItemStateException { ChildReference ref = node ( ) . getChildReferences ( sessionCache ( ) ) . getChild ( name ) ; if ( ref == null ) { String msg = JcrI18n . childNotFoundUnderNode . text ( readable ( name ) , location ( ) , session . workspaceName ( ) ) ; throw new PathNotFoundException ( msg ) ; } return session ( ) . node ( ref . getKey ( ) , expectedType , key ( ) ) ; }
Get the JCR node for the named child .
131
10
33,099
protected LinkedList < Property > autoCreatePropertiesFor ( Name nodeName , Name primaryType , PropertyFactory propertyFactory , NodeTypes capabilities ) { Collection < JcrPropertyDefinition > autoPropDefns = capabilities . getAutoCreatedPropertyDefinitions ( primaryType ) ; if ( autoPropDefns . isEmpty ( ) ) { return null ; } // There is at least one auto-created property on this node ... LinkedList < Property > props = new LinkedList < Property > ( ) ; for ( JcrPropertyDefinition defn : autoPropDefns ) { Name propName = defn . getInternalName ( ) ; if ( defn . hasDefaultValues ( ) ) { // This may or may not be auto-created; we don't care ... Object [ ] defaultValues = defn . getRawDefaultValues ( ) ; Property prop = null ; if ( defn . isMultiple ( ) ) { prop = propertyFactory . create ( propName , defaultValues ) ; } else { prop = propertyFactory . create ( propName , defaultValues [ 0 ] ) ; } props . add ( prop ) ; } } return props ; }
If there are any auto - created properties create them and return them in a list .
241
17