idx int64 0 41.2k | question stringlengths 74 4.04k | target stringlengths 7 750 |
|---|---|---|
33,200 | public static SiblingCounter constant ( final int count ) { assert count > - 1 ; return new SiblingCounter ( ) { public int countSiblingsNamed ( Name childName ) { return count ; } } ; } | Create a sibling counter that always return the supplied count regardless of the name or node . |
33,201 | public static SiblingCounter alter ( final SiblingCounter counter , final int delta ) { assert counter != null ; return new SiblingCounter ( ) { public int countSiblingsNamed ( Name childName ) { int count = counter . countSiblingsNamed ( childName ) + delta ; return count > 0 ? count : 0 ; } } ; } | Creates a sibling counter that alters another counter by a constant value . |
33,202 | public RestWorkspaces getWorkspaces ( HttpServletRequest request , String repositoryName ) throws RepositoryException { assert request != null ; assert repositoryName != null ; RestWorkspaces workspaces = new RestWorkspaces ( ) ; Session session = getSession ( request , repositoryName , null ) ; for ( String workspaceName : session . getWorkspace ( ) . getAccessibleWorkspaceNames ( ) ) { String repositoryUrl = RestHelper . urlFrom ( request ) ; workspaces . addWorkspace ( workspaceName , repositoryUrl ) ; } return workspaces ; } | Returns the list of workspaces available to this user within the named repository . |
33,203 | public Response backupRepository ( ServletContext context , HttpServletRequest request , String repositoryName , BackupOptions options ) throws RepositoryException { final File backupLocation = resolveBackupLocation ( context ) ; Session session = getSession ( request , repositoryName , null ) ; String repositoryVersion = session . getRepository ( ) . getDescriptorValue ( Repository . REP_VERSION_DESC ) . getString ( ) . replaceAll ( "\\." , "" ) ; final String backupName = "modeshape_" + repositoryVersion + "_" + repositoryName + "_backup_" + DATE_FORMAT . format ( new Date ( ) ) ; final File backup = new File ( backupLocation , backupName ) ; if ( ! backup . mkdirs ( ) ) { throw new RuntimeException ( "Cannot create backup folder: " + backup ) ; } logger . debug ( "Backing up repository '{0}' to '{1}', using '{2}'" , repositoryName , backup , options ) ; RepositoryManager repositoryManager = ( ( org . modeshape . jcr . api . Workspace ) session . getWorkspace ( ) ) . getRepositoryManager ( ) ; repositoryManager . backupRepository ( backup , options ) ; final String backupURL ; try { backupURL = backup . toURI ( ) . toURL ( ) . toString ( ) ; } catch ( MalformedURLException e ) { throw new RuntimeException ( e ) ; } JSONAble responseContent = new JSONAble ( ) { public JSONObject toJSON ( ) throws JSONException { JSONObject object = new JSONObject ( ) ; object . put ( "name" , backupName ) ; object . put ( "url" , backupURL ) ; return object ; } } ; return Response . status ( Response . Status . CREATED ) . entity ( responseContent ) . build ( ) ; } | Performs a repository backup . |
33,204 | public Response restoreRepository ( ServletContext context , HttpServletRequest request , String repositoryName , String backupName , RestoreOptions options ) throws RepositoryException { if ( StringUtil . isBlank ( backupName ) ) { throw new IllegalArgumentException ( "The name of the backup cannot be null" ) ; } File backup = resolveBackup ( context , backupName ) ; logger . debug ( "Restoring repository '{0}' from backup '{1}' using '{2}'" , repositoryName , backup , options ) ; Session session = getSession ( request , repositoryName , null ) ; RepositoryManager repositoryManager = ( ( org . modeshape . jcr . api . Workspace ) session . getWorkspace ( ) ) . getRepositoryManager ( ) ; final Problems problems = repositoryManager . restoreRepository ( backup , options ) ; if ( ! problems . hasProblems ( ) ) { return Response . ok ( ) . build ( ) ; } List < JSONAble > response = new ArrayList < JSONAble > ( problems . size ( ) ) ; for ( Problem problem : problems ) { RestException exception = problem . getThrowable ( ) != null ? new RestException ( problem . getMessage ( ) , problem . getThrowable ( ) ) : new RestException ( problem . getMessage ( ) ) ; response . add ( exception ) ; } return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . entity ( response ) . build ( ) ; } | Restores a repository using an existing backup . |
33,205 | public void add ( T value ) { Lock lock = this . lock . writeLock ( ) ; try { lock . lock ( ) ; doAddValue ( value ) ; } finally { lock . unlock ( ) ; } } | Add a new value to these statistics . |
33,206 | public T getTotal ( ) { Lock lock = this . lock . readLock ( ) ; lock . lock ( ) ; try { return this . total ; } finally { lock . unlock ( ) ; } } | Get the aggregate sum of the values in the series . |
33,207 | public T getMaximum ( ) { Lock lock = this . lock . readLock ( ) ; lock . lock ( ) ; try { return this . maximum ; } finally { lock . unlock ( ) ; } } | Get the maximum value in the series . |
33,208 | public T getMinimum ( ) { Lock lock = this . lock . readLock ( ) ; lock . lock ( ) ; try { return this . minimum != null ? this . minimum : ( T ) this . math . createZeroValue ( ) ; } finally { lock . unlock ( ) ; } } | Get the minimum value in the series . |
33,209 | public int getCount ( ) { Lock lock = this . lock . readLock ( ) ; lock . lock ( ) ; try { return this . count ; } finally { lock . unlock ( ) ; } } | Get the number of values that have been measured . |
33,210 | public void reset ( ) { Lock lock = this . lock . writeLock ( ) ; lock . lock ( ) ; try { doReset ( ) ; } finally { lock . unlock ( ) ; } } | Reset the statistics in this object and clear out any stored information . |
33,211 | public static String getSubstitutedProperty ( String value , PropertyAccessor propertyAccessor ) { if ( value == null || value . trim ( ) . length ( ) == 0 ) return value ; StringBuilder sb = new StringBuilder ( value ) ; int startName = sb . indexOf ( CURLY_PREFIX ) ; if ( startName == - 1 ) return value ; while ( startName != - 1 ) { String defaultValue = null ; int endName = sb . indexOf ( CURLY_SUFFIX , startName ) ; if ( endName == - 1 ) { return sb . toString ( ) ; } String varString = sb . substring ( startName + 2 , endName ) ; if ( varString . indexOf ( DEFAULT_DELIM ) > - 1 ) { List < String > defaults = split ( varString , DEFAULT_DELIM ) ; varString = defaults . get ( 0 ) ; if ( defaults . size ( ) == 2 ) { defaultValue = defaults . get ( 1 ) ; } } String constValue = null ; List < String > vars = split ( varString , VAR_DELIM ) ; for ( final String var : vars ) { constValue = System . getenv ( var ) ; if ( constValue == null ) { constValue = propertyAccessor . getProperty ( var ) ; } if ( constValue != null ) { break ; } } if ( constValue == null && defaultValue != null ) { constValue = defaultValue ; } if ( constValue != null ) { sb = sb . replace ( startName , endName + 1 , constValue ) ; startName = sb . indexOf ( CURLY_PREFIX ) ; } else { startName = sb . indexOf ( CURLY_PREFIX , endName ) ; } } return sb . toString ( ) ; } | getSubstitutedProperty is called to perform the property substitution on the value . |
33,212 | private static List < String > split ( String str , String splitter ) { StringTokenizer tokens = new StringTokenizer ( str , splitter ) ; ArrayList < String > l = new ArrayList < > ( tokens . countTokens ( ) ) ; while ( tokens . hasMoreTokens ( ) ) { l . add ( tokens . nextToken ( ) ) ; } return l ; } | Split a string into pieces based on delimiters . Similar to the perl function of the same name . The delimiters are not included in the returned strings . |
33,213 | protected void checkFileNotExcluded ( String id , File file ) { if ( isExcluded ( file ) ) { String msg = JcrI18n . fileConnectorCannotStoreFileThatIsExcluded . text ( getSourceName ( ) , id , file . getAbsolutePath ( ) ) ; throw new DocumentStoreException ( id , msg ) ; } } | Utility method to ensure that the file is writable by this connector . |
33,214 | public static String filter ( String message ) { if ( message == null ) { return ( null ) ; } char content [ ] = new char [ message . length ( ) ] ; message . getChars ( 0 , message . length ( ) , content , 0 ) ; StringBuilder result = new StringBuilder ( content . length + 50 ) ; for ( int i = 0 ; i < content . length ; i ++ ) { switch ( content [ i ] ) { case '<' : result . append ( "<" ) ; break ; case '>' : result . append ( ">" ) ; break ; case '&' : result . append ( "&" ) ; break ; case '"' : result . append ( """ ) ; break ; default : result . append ( content [ i ] ) ; } } return ( result . toString ( ) ) ; } | Filter the specified message string for characters that are sensitive in HTML . This avoids potential attacks caused by including JavaScript codes in the request URL that is often reported in error messages . |
33,215 | public static Cookie [ ] parseCookieHeader ( String header ) { if ( ( header == null ) || ( header . length ( ) < 1 ) ) { return ( new Cookie [ 0 ] ) ; } ArrayList < Cookie > cookies = new ArrayList < Cookie > ( ) ; while ( header . length ( ) > 0 ) { int semicolon = header . indexOf ( ';' ) ; if ( semicolon < 0 ) { semicolon = header . length ( ) ; } if ( semicolon == 0 ) { break ; } String token = header . substring ( 0 , semicolon ) ; if ( semicolon < header . length ( ) ) { header = header . substring ( semicolon + 1 ) ; } else { header = "" ; } try { int equals = token . indexOf ( '=' ) ; if ( equals > 0 ) { String name = token . substring ( 0 , equals ) . trim ( ) ; String value = token . substring ( equals + 1 ) . trim ( ) ; cookies . add ( new Cookie ( name , value ) ) ; } } catch ( Throwable e ) { } } return cookies . toArray ( new Cookie [ cookies . size ( ) ] ) ; } | Parse a cookie header into an array of cookies according to RFC 2109 . |
33,216 | public static String URLDecode ( String str , String enc ) { if ( str == null ) { return ( null ) ; } byte [ ] bytes = null ; try { if ( enc == null ) { bytes = str . getBytes ( ) ; } else { bytes = str . getBytes ( enc ) ; } } catch ( UnsupportedEncodingException uee ) { } return URLDecode ( bytes , enc ) ; } | Decode and return the specified URL - encoded String . |
33,217 | public static String URLDecode ( byte [ ] bytes , String enc ) { if ( bytes == null ) { return ( null ) ; } int len = bytes . length ; int ix = 0 ; int ox = 0 ; while ( ix < len ) { byte b = bytes [ ix ++ ] ; if ( b == '+' ) { b = ( byte ) ' ' ; } else if ( b == '%' ) { b = ( byte ) ( ( convertHexDigit ( bytes [ ix ++ ] ) << 4 ) + convertHexDigit ( bytes [ ix ++ ] ) ) ; } bytes [ ox ++ ] = b ; } if ( enc != null ) { try { return new String ( bytes , 0 , ox , enc ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } } return new String ( bytes , 0 , ox ) ; } | Decode and return the specified URL - encoded byte array . |
33,218 | public static boolean streamNotConsumed ( HttpServletRequest request ) { try { ServletInputStream servletInputStream = request . getInputStream ( ) ; return request . getContentLength ( ) != 0 && servletInputStream . available ( ) > 0 ; } catch ( IOException e ) { return false ; } } | Checks if the input stream of the given request is nor isn t consumed . This method is backwards - compatible with Servlet 2 . x as in Servlet 3 . x there is a isFinished method . |
33,219 | public static JcrAccessControlList defaultAcl ( AccessControlManagerImpl acm ) { JcrAccessControlList acl = new JcrAccessControlList ( "/" ) ; try { acl . principals . put ( SimplePrincipal . EVERYONE , new AccessControlEntryImpl ( SimplePrincipal . EVERYONE , acm . privileges ( ) ) ) ; } catch ( AccessControlException e ) { } return acl ; } | Creates default Access Control List . |
33,220 | public boolean hasPrivileges ( SecurityContext sc , Privilege [ ] privileges ) { for ( AccessControlEntryImpl ace : principals . values ( ) ) { if ( ace . getPrincipal ( ) . getName ( ) . equals ( SimplePrincipal . EVERYONE . getName ( ) ) ) { if ( ace . hasPrivileges ( privileges ) ) { return true ; } } if ( ace . getPrincipal ( ) . getName ( ) . equals ( username ( sc . getUserName ( ) ) ) ) { if ( ace . hasPrivileges ( privileges ) ) { return true ; } } if ( sc . hasRole ( ace . getPrincipal ( ) . getName ( ) ) ) { if ( ace . hasPrivileges ( privileges ) ) { return true ; } } } return false ; } | Tests privileges relatively to the given security context . |
33,221 | public Privilege [ ] getPrivileges ( SecurityContext context ) { ArrayList < Privilege > privs = new ArrayList < Privilege > ( ) ; for ( AccessControlEntryImpl ace : principals . values ( ) ) { if ( ace . getPrincipal ( ) . equals ( SimplePrincipal . EVERYONE ) ) { privs . addAll ( Arrays . asList ( ace . getPrivileges ( ) ) ) ; } if ( ace . getPrincipal ( ) . getName ( ) . equals ( username ( context . getUserName ( ) ) ) ) { privs . addAll ( Arrays . asList ( ace . getPrivileges ( ) ) ) ; } if ( context . hasRole ( ace . getPrincipal ( ) . getName ( ) ) ) { privs . addAll ( Arrays . asList ( ace . getPrivileges ( ) ) ) ; } } Privilege [ ] res = new Privilege [ privs . size ( ) ] ; privs . toArray ( res ) ; return res ; } | Lists all privileges defined by this access list for the given user . |
33,222 | private String username ( String username ) { return ( username . startsWith ( "<" ) && username . endsWith ( ">" ) ) ? username . substring ( 1 , username . length ( ) - 1 ) : username ; } | Removes brackets enclosing given user name |
33,223 | public NodeCache getNodeCache ( String workspaceName ) throws WorkspaceNotFoundException { NodeCache cache = overriddenNodeCachesByWorkspaceName . get ( workspaceName ) ; if ( cache == null ) { cache = repositoryCache . getWorkspaceCache ( workspaceName ) ; } return cache ; } | Get the NodeCache for the given workspace name . The result will either be the overridden value supplied in the constructor or the workspace cache from the referenced RepositoryCache . |
33,224 | public QueryContext with ( Schemata schemata ) { CheckArg . isNotNull ( schemata , "schemata" ) ; return new QueryContext ( context , repositoryCache , workspaceNames , overriddenNodeCachesByWorkspaceName , schemata , indexDefns , nodeTypes , bufferManager , hints , problems , variables ) ; } | Obtain a copy of this context except that the copy uses the supplied schemata . |
33,225 | public QueryContext with ( Problems problems ) { return new QueryContext ( context , repositoryCache , workspaceNames , overriddenNodeCachesByWorkspaceName , schemata , indexDefns , nodeTypes , bufferManager , hints , problems , variables ) ; } | Obtain a copy of this context except that the copy uses the supplied problem container . |
33,226 | public QueryContext with ( Map < String , Object > variables ) { return new QueryContext ( context , repositoryCache , workspaceNames , overriddenNodeCachesByWorkspaceName , schemata , indexDefns , nodeTypes , bufferManager , hints , problems , variables ) ; } | Obtain a copy of this context except that the copy uses the supplied variables . |
33,227 | public void scoreText ( String text , int factor , String ... keywords ) { if ( text != null && keywords != null ) { String lowercaseText = text . toLowerCase ( ) ; for ( String keyword : keywords ) { if ( keyword == null ) continue ; String lowercaseKeyword = keyword . toLowerCase ( ) ; int index = 0 ; while ( true ) { index = lowercaseText . indexOf ( lowercaseKeyword , index ) ; if ( index == - 1 ) break ; score += factor ; ++ index ; } } } } | Increment the score if the given text contains any of the supply keywords . |
33,228 | protected String removeUnusedPredicates ( String expression ) { assert expression != null ; java . util . regex . Matcher matcher = UNUSABLE_PREDICATE_PATTERN . matcher ( expression ) ; StringBuffer sb = new StringBuffer ( ) ; if ( matcher . find ( ) ) { do { String predicateStr = matcher . group ( 0 ) ; String unusablePredicateStr = matcher . group ( 1 ) ; if ( unusablePredicateStr != null ) { predicateStr = "" ; } matcher . appendReplacement ( sb , predicateStr ) ; } while ( matcher . find ( ) ) ; matcher . appendTail ( sb ) ; expression = sb . toString ( ) ; } return expression ; } | Replace certain XPath patterns that are not used or understood . |
33,229 | protected String replaceXPathPatterns ( String expression ) { assert expression != null ; expression = expression . replaceAll ( "[\\|]{2,}" , "|" ) ; expression = expression . replaceAll ( "/(\\([^|]+)(\\|){2,}([^)]+\\))" , "(/$1$2$3)?" ) ; expression = expression . replaceAll ( "/\\(\\|+([^)]+)\\)" , "(?:/($1))?" ) ; expression = expression . replaceAll ( "/\\((([^|]+)(\\|[^|]+)*)\\|+\\)" , "(?:/($1))?" ) ; expression = expression . replaceAll ( "\\[\\]" , "(?:\\\\[\\\\d+\\\\])?" ) ; expression = expression . replaceAll ( "\\[[*]\\]" , "(?:\\\\[\\\\d+\\\\])?" ) ; expression = expression . replaceAll ( "\\[0\\]" , "(?:\\\\[0\\\\])?" ) ; expression = expression . replaceAll ( "\\[([1-9]\\d*)\\]" , "\\\\[$1\\\\]" ) ; expression = expression . replaceAll ( "(?<!\\\\)\\[([^\\]]*)\\]$" , "/$1" ) ; java . util . regex . Matcher matcher = SEQUENCE_PATTERN . matcher ( expression ) ; StringBuffer sb = new StringBuffer ( ) ; boolean result = matcher . find ( ) ; if ( result ) { do { String sequenceStr = matcher . group ( 1 ) ; boolean optional = false ; if ( sequenceStr . startsWith ( "0," ) ) { sequenceStr = sequenceStr . replaceFirst ( "^0," , "" ) ; optional = true ; } if ( sequenceStr . endsWith ( ",0" ) ) { sequenceStr = sequenceStr . replaceFirst ( ",0$" , "" ) ; optional = true ; } if ( sequenceStr . contains ( ",0," ) ) { sequenceStr = sequenceStr . replaceAll ( ",0," , "," ) ; optional = true ; } sequenceStr = sequenceStr . replaceAll ( "," , "|" ) ; String replacement = "\\\\[(?:" + sequenceStr + ")\\\\]" ; if ( optional ) { replacement = "(?:" + replacement + ")?" ; } matcher . appendReplacement ( sb , replacement ) ; result = matcher . find ( ) ; } while ( result ) ; matcher . appendTail ( sb ) ; expression = sb . toString ( ) ; } expression = expression . replaceAll ( "[*]([^/(\\\\])" , "[^/]*$1" ) ; expression = expression . replaceAll ( "(?<!\\[\\^/\\])[*]" , "[^/]*" ) ; expression = expression . replaceAll ( "[/]{2,}$" , "(?:/[^/]*)*" ) ; expression = expression . replaceAll ( "[/]{2,}" , "(?:/[^/]*)*/" ) ; return expression ; } | Replace certain XPath patterns including some predicates with substrings that are compatible with regular expressions . |
33,230 | public Object get ( String name ) { Object obj = document . get ( name ) ; return ( obj instanceof BasicArray ) ? ( ( BasicArray ) obj ) . toArray ( ) : obj ; } | Gets property value . |
33,231 | private void readFromStream ( InputStream in ) throws IOException { document = DocumentFactory . newDocument ( Json . read ( in ) ) ; } | Reads document content from the stream . |
33,232 | public final String [ ] getPathExpressions ( ) { String pathExpression = this . pathExpression ; Object [ ] pathExpressions = this . pathExpressions ; if ( pathExpression == null && ( pathExpressions == null || pathExpressions . length == 0 ) ) { return new String [ ] { } ; } if ( pathExpression != null && ( pathExpressions == null || pathExpressions . length == 0 ) ) { return new String [ ] { pathExpression } ; } List < String > expressions = new ArrayList < String > ( pathExpressions . length + 1 ) ; addExpression ( expressions , pathExpression ) ; for ( Object value : pathExpressions ) { addExpression ( expressions , value ) ; } return expressions . toArray ( new String [ expressions . size ( ) ] ) ; } | Obtain the path expressions as configured on the sequencer . This method always returns a copy to prevent modification of the values . |
33,233 | public final boolean isAccepted ( String mimeType ) { if ( mimeType != null && hasAcceptedMimeTypes ( ) ) { return getAcceptedMimeTypes ( ) . contains ( mimeType . trim ( ) ) ; } return true ; } | Determine if this sequencer has been configured to accept and process content with the supplied MIME type . |
33,234 | private List < SessionNode > getChangedNodesAtOrBelowChildrenFirst ( Path nodePath ) { List < SessionNode > changedNodesChildrenFirst = new ArrayList < SessionNode > ( ) ; for ( NodeKey key : changedNodes . keySet ( ) ) { SessionNode changedNode = changedNodes . get ( key ) ; boolean isAtOrBelow = false ; try { isAtOrBelow = changedNode . isAtOrBelow ( this , nodePath ) ; } catch ( NodeNotFoundException e ) { isAtOrBelow = false ; } if ( ! isAtOrBelow ) { continue ; } int insertIndex = changedNodesChildrenFirst . size ( ) ; Path changedNodePath = changedNode . getPath ( this ) ; for ( int i = 0 ; i < changedNodesChildrenFirst . size ( ) ; i ++ ) { if ( changedNodesChildrenFirst . get ( i ) . getPath ( this ) . isAncestorOf ( changedNodePath ) ) { insertIndex = i ; break ; } } changedNodesChildrenFirst . add ( insertIndex , changedNode ) ; } return changedNodesChildrenFirst ; } | Returns the list of changed nodes at or below the given path starting with the children . |
33,235 | private void completeTransaction ( final String txId , String wsName ) { getWorkspace ( ) . clear ( ) ; setWorkspaceCache ( sharedWorkspaceCache ( ) ) ; COMPLETE_FUNCTION_BY_TX_AND_WS . compute ( txId , ( transactionId , funcsByWsName ) -> { funcsByWsName . remove ( wsName ) ; if ( funcsByWsName . isEmpty ( ) ) { LOCKED_KEYS_BY_TX_ID . remove ( txId ) ; return null ; } return funcsByWsName ; } ) ; } | Signal that the transaction that was active and in which this session participated has completed and that this session should no longer use a transaction - specific workspace cache . |
33,236 | private void rollback ( Transaction txn , Exception cause ) throws Exception { try { txn . rollback ( ) ; } catch ( Exception e ) { logger . debug ( e , "Error while rolling back transaction " + txn ) ; } finally { throw cause ; } } | Rolling back given transaction caused by given cause . |
33,237 | public static Date createDate ( Calendar target ) { return new java . sql . Date ( target . getTime ( ) . getTime ( ) ) ; } | Creates normalized SQL Date Object based on the target Calendar |
33,238 | public void mergeNodes ( DdlTokenStream tokens , AstNode firstNode , AstNode secondNode ) { assert tokens != null ; assert firstNode != null ; assert secondNode != null ; int firstStartIndex = ( Integer ) firstNode . getProperty ( DDL_START_CHAR_INDEX ) ; int secondStartIndex = ( Integer ) secondNode . getProperty ( DDL_START_CHAR_INDEX ) ; int deltaLength = ( ( String ) secondNode . getProperty ( DDL_EXPRESSION ) ) . length ( ) ; Position startPosition = new Position ( firstStartIndex , 1 , 0 ) ; Position endPosition = new Position ( ( secondStartIndex + deltaLength ) , 1 , 0 ) ; String source = tokens . getContentBetween ( startPosition , endPosition ) ; firstNode . setProperty ( DDL_EXPRESSION , source ) ; firstNode . setProperty ( DDL_LENGTH , source . length ( ) ) ; } | Merges second node into first node by re - setting expression source and length . |
33,239 | protected AstNode parseCreateStatement ( DdlTokenStream tokens , AstNode parentNode ) throws ParsingException { assert tokens != null ; assert parentNode != null ; AstNode stmtNode = null ; if ( tokens . matches ( STMT_CREATE_SCHEMA ) ) { stmtNode = parseCreateSchemaStatement ( tokens , parentNode ) ; } else if ( tokens . matches ( STMT_CREATE_TABLE ) || tokens . matches ( STMT_CREATE_GLOBAL_TEMPORARY_TABLE ) || tokens . matches ( STMT_CREATE_LOCAL_TEMPORARY_TABLE ) ) { stmtNode = parseCreateTableStatement ( tokens , parentNode ) ; } else if ( tokens . matches ( STMT_CREATE_VIEW ) || tokens . matches ( STMT_CREATE_OR_REPLACE_VIEW ) ) { stmtNode = parseCreateViewStatement ( tokens , parentNode ) ; } else if ( tokens . matches ( STMT_CREATE_ASSERTION ) ) { stmtNode = parseCreateAssertionStatement ( tokens , parentNode ) ; } else if ( tokens . matches ( STMT_CREATE_CHARACTER_SET ) ) { stmtNode = parseCreateCharacterSetStatement ( tokens , parentNode ) ; } else if ( tokens . matches ( STMT_CREATE_COLLATION ) ) { stmtNode = parseCreateCollationStatement ( tokens , parentNode ) ; } else if ( tokens . matches ( STMT_CREATE_TRANSLATION ) ) { stmtNode = parseCreateTranslationStatement ( tokens , parentNode ) ; } else if ( tokens . matches ( STMT_CREATE_DOMAIN ) ) { stmtNode = parseCreateDomainStatement ( tokens , parentNode ) ; } else { markStartOfStatement ( tokens ) ; stmtNode = parseIgnorableStatement ( tokens , "CREATE UNKNOWN" , parentNode ) ; Position position = getCurrentMarkedPosition ( ) ; String msg = DdlSequencerI18n . unknownCreateStatement . text ( position . getLine ( ) , position . getColumn ( ) ) ; DdlParserProblem problem = new DdlParserProblem ( DdlConstants . Problems . WARNING , position , msg ) ; stmtNode . setProperty ( DDL_PROBLEM , problem . toString ( ) ) ; markEndOfStatement ( tokens , stmtNode ) ; } return stmtNode ; } | Parses DDL CREATE statement based on SQL 92 specifications . |
33,240 | protected AstNode parseAlterStatement ( DdlTokenStream tokens , AstNode parentNode ) throws ParsingException { assert tokens != null ; assert parentNode != null ; if ( tokens . matches ( ALTER , TABLE ) ) { return parseAlterTableStatement ( tokens , parentNode ) ; } else if ( tokens . matches ( "ALTER" , "DOMAIN" ) ) { markStartOfStatement ( tokens ) ; tokens . consume ( "ALTER" , "DOMAIN" ) ; String domainName = parseName ( tokens ) ; AstNode alterNode = nodeFactory ( ) . node ( domainName , parentNode , TYPE_ALTER_DOMAIN_STATEMENT ) ; parseUntilTerminator ( tokens ) ; markEndOfStatement ( tokens , alterNode ) ; return alterNode ; } return null ; } | Parses DDL ALTER statement based on SQL 92 specifications . |
33,241 | protected String getTableElementsString ( DdlTokenStream tokens , boolean useTerminator ) throws ParsingException { assert tokens != null ; StringBuilder sb = new StringBuilder ( 100 ) ; if ( useTerminator ) { while ( ! isTerminator ( tokens ) ) { sb . append ( SPACE ) . append ( tokens . consume ( ) ) ; } } else { tokens . consume ( L_PAREN ) ; int iParen = 0 ; while ( tokens . hasNext ( ) ) { if ( tokens . matches ( L_PAREN ) ) { iParen ++ ; } else if ( tokens . matches ( R_PAREN ) ) { if ( iParen == 0 ) { tokens . consume ( R_PAREN ) ; break ; } iParen -- ; } if ( isComment ( tokens ) ) { tokens . consume ( ) ; } else { sb . append ( SPACE ) . append ( tokens . consume ( ) ) ; } } } return sb . toString ( ) ; } | Method which extracts the table element string from a CREATE TABLE statement . |
33,242 | protected void parseConstraintAttributes ( DdlTokenStream tokens , AstNode constraintNode ) throws ParsingException { assert tokens != null ; assert constraintNode != null ; if ( tokens . canConsume ( "INITIALLY" , "DEFERRED" ) ) { AstNode attrNode = nodeFactory ( ) . node ( "CONSTRAINT_ATTRIBUTE" , constraintNode , TYPE_CONSTRAINT_ATTRIBUTE ) ; attrNode . setProperty ( PROPERTY_VALUE , "INITIALLY DEFERRED" ) ; } if ( tokens . canConsume ( "INITIALLY" , "IMMEDIATE" ) ) { AstNode attrNode = nodeFactory ( ) . node ( "CONSTRAINT_ATTRIBUTE" , constraintNode , TYPE_CONSTRAINT_ATTRIBUTE ) ; attrNode . setProperty ( PROPERTY_VALUE , "INITIALLY IMMEDIATE" ) ; } if ( tokens . canConsume ( "NOT" , "DEFERRABLE" ) ) { AstNode attrNode = nodeFactory ( ) . node ( "CONSTRAINT_ATTRIBUTE" , constraintNode , TYPE_CONSTRAINT_ATTRIBUTE ) ; attrNode . setProperty ( PROPERTY_VALUE , "NOT DEFERRABLE" ) ; } if ( tokens . canConsume ( "DEFERRABLE" ) ) { AstNode attrNode = nodeFactory ( ) . node ( "CONSTRAINT_ATTRIBUTE" , constraintNode , TYPE_CONSTRAINT_ATTRIBUTE ) ; attrNode . setProperty ( PROPERTY_VALUE , "DEFERRABLE" ) ; } if ( tokens . canConsume ( "INITIALLY" , "DEFERRED" ) ) { AstNode attrNode = nodeFactory ( ) . node ( "CONSTRAINT_ATTRIBUTE" , constraintNode , TYPE_CONSTRAINT_ATTRIBUTE ) ; attrNode . setProperty ( PROPERTY_VALUE , "INITIALLY DEFERRED" ) ; } if ( tokens . canConsume ( "INITIALLY" , "IMMEDIATE" ) ) { AstNode attrNode = nodeFactory ( ) . node ( "CONSTRAINT_ATTRIBUTE" , constraintNode , TYPE_CONSTRAINT_ATTRIBUTE ) ; attrNode . setProperty ( PROPERTY_VALUE , "INITIALLY IMMEDIATE" ) ; } } | Parses the attributes associated with any in - line column constraint definition or a table constrain definition . |
33,243 | protected List < String > getDataTypeStartWords ( ) { if ( allDataTypeStartWords == null ) { allDataTypeStartWords = new ArrayList < String > ( ) ; allDataTypeStartWords . addAll ( DataTypes . DATATYPE_START_WORDS ) ; allDataTypeStartWords . addAll ( getCustomDataTypeStartWords ( ) ) ; } return allDataTypeStartWords ; } | Returns a list of data type start words which can be used to help identify a column definition sub - statement . |
33,244 | protected String consumeIdentifier ( DdlTokenStream tokens ) throws ParsingException { String value = tokens . consume ( ) ; if ( value . charAt ( 0 ) == '"' ) { int length = value . length ( ) ; value = value . substring ( 1 , length - 1 ) ; } return value ; } | Consumes an token identifier which can be of the form of a simple string or a double - quoted string . |
33,245 | protected boolean parseColumnNameList ( DdlTokenStream tokens , AstNode parentNode , String referenceType ) { boolean parsedColumns = false ; List < String > columnNameList = new ArrayList < String > ( ) ; if ( tokens . matches ( L_PAREN ) ) { tokens . consume ( L_PAREN ) ; columnNameList = parseNameList ( tokens ) ; if ( ! columnNameList . isEmpty ( ) ) { parsedColumns = true ; } tokens . consume ( R_PAREN ) ; } for ( String columnName : columnNameList ) { nodeFactory ( ) . node ( columnName , parentNode , referenceType ) ; } return parsedColumns ; } | Adds column reference nodes to a parent node . Returns true if column references added false if not . |
33,246 | protected List < String > parseNameList ( DdlTokenStream tokens ) throws ParsingException { List < String > names = new LinkedList < String > ( ) ; while ( true ) { names . add ( parseName ( tokens ) ) ; if ( ! tokens . canConsume ( COMMA ) ) { break ; } } return names ; } | Parses a comma separated list of names . |
33,247 | protected String parseUntilTerminator ( DdlTokenStream tokens ) throws ParsingException { final StringBuilder sb = new StringBuilder ( ) ; boolean lastTokenWasPeriod = false ; Position prevPosition = ( tokens . hasNext ( ) ? tokens . nextPosition ( ) : Position . EMPTY_CONTENT_POSITION ) ; String prevToken = "" ; while ( tokens . hasNext ( ) && ! tokens . matches ( DdlTokenizer . STATEMENT_KEY ) && ( ( doUseTerminator ( ) && ! isTerminator ( tokens ) ) || ! doUseTerminator ( ) ) ) { final Position currPosition = tokens . nextPosition ( ) ; final String thisToken = tokens . consume ( ) ; final boolean thisTokenIsPeriod = thisToken . equals ( PERIOD ) ; final boolean thisTokenIsComma = thisToken . equals ( COMMA ) ; if ( lastTokenWasPeriod || thisTokenIsPeriod || thisTokenIsComma ) { sb . append ( thisToken ) ; } else if ( ( currPosition . getIndexInContent ( ) - prevPosition . getIndexInContent ( ) - prevToken . length ( ) ) > 0 ) { sb . append ( SPACE ) . append ( thisToken ) ; } else { sb . append ( thisToken ) ; } if ( thisTokenIsPeriod ) { lastTokenWasPeriod = true ; } else { lastTokenWasPeriod = false ; } prevToken = thisToken ; prevPosition = currPosition ; } return sb . toString ( ) ; } | Utility method which parses tokens until a terminator is found another statement is identified or there are no more tokens . |
33,248 | protected String parseUntilSemiColon ( DdlTokenStream tokens ) throws ParsingException { StringBuilder sb = new StringBuilder ( ) ; boolean lastTokenWasPeriod = false ; while ( tokens . hasNext ( ) && ! tokens . matches ( SEMICOLON ) ) { String thisToken = tokens . consume ( ) ; boolean thisTokenIsPeriod = thisToken . equals ( PERIOD ) ; boolean thisTokenIsComma = thisToken . equals ( COMMA ) ; if ( lastTokenWasPeriod || thisTokenIsPeriod || thisTokenIsComma ) { sb . append ( thisToken ) ; } else { sb . append ( SPACE ) . append ( thisToken ) ; } if ( thisTokenIsPeriod ) { lastTokenWasPeriod = true ; } else { lastTokenWasPeriod = false ; } } return sb . toString ( ) ; } | Utility method which parses tokens until a semicolon is found or there are no more tokens . |
33,249 | final boolean registerListener ( NodeTypes . Listener listener ) { return listener != null ? this . listeners . addIfAbsent ( listener ) : false ; } | Add a listener that will be notified when the NodeTypes changes . Listeners will be called in a single thread and should do almost no work . |
33,250 | boolean isNodeTypeInUse ( Name nodeTypeName ) throws InvalidQueryException { String nodeTypeString = nodeTypeName . getString ( context . getNamespaceRegistry ( ) ) ; String expression = "SELECT * from [" + nodeTypeString + "] LIMIT 1" ; TypeSystem typeSystem = context . getValueFactories ( ) . getTypeSystem ( ) ; QueryCommand command = queryParser . parseQuery ( expression , typeSystem ) ; assert command != null : "Could not parse " + expression ; Schemata schemata = getRepositorySchemata ( ) ; RepositoryCache repoCache = repository . repositoryCache ( ) ; RepositoryQueryManager queryManager = repository . queryManager ( ) ; Set < String > workspaceNames = repoCache . getWorkspaceNames ( ) ; Map < String , NodeCache > overridden = null ; NodeTypes nodeTypes = repository . nodeTypeManager ( ) . getNodeTypes ( ) ; RepositoryIndexes indexDefns = repository . queryManager ( ) . getIndexes ( ) ; CancellableQuery query = queryManager . query ( context , repoCache , workspaceNames , overridden , command , schemata , indexDefns , nodeTypes , null , null ) ; try { QueryResults result = query . execute ( ) ; if ( result . isEmpty ( ) ) return false ; if ( result . getRowCount ( ) < 0 ) { NodeSequence seq = result . getRows ( ) ; Batch batch = seq . nextBatch ( ) ; while ( batch != null ) { if ( batch . hasNext ( ) ) return true ; batch = seq . nextBatch ( ) ; } return false ; } return result . getRowCount ( ) > 0 ; } catch ( RepositoryException e ) { logger . error ( e , JcrI18n . errorCheckingNodeTypeUsage , nodeTypeName , e . getLocalizedMessage ( ) ) ; return true ; } } | Check if the named node type is in use in any workspace in the repository |
33,251 | protected void doInitialize ( IndexProvider provider ) throws RepositoryException { Reflection . setValue ( provider , "context" , repository . context ( ) ) ; Reflection . setValue ( provider , "environment" , repository . environment ( ) ) ; provider . initialize ( ) ; Method postInitialize = Reflection . findMethod ( IndexProvider . class , "postInitialize" ) ; Reflection . invokeAccessibly ( provider , postInitialize , new Object [ ] { } ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Successfully initialized index provider '{0}' in repository '{1}'" , provider . getName ( ) , repository . name ( ) ) ; } } | Initialize the supplied provider . |
33,252 | IndexWriter getIndexWriterForProviders ( Set < String > providerNames ) { List < IndexProvider > reindexProviders = new LinkedList < > ( ) ; for ( IndexProvider provider : providers . values ( ) ) { if ( providerNames . contains ( provider . getName ( ) ) ) { reindexProviders . add ( provider ) ; } } return CompositeIndexWriter . create ( reindexProviders ) ; } | Get the query index writer that will delegate to only those registered providers with the given names . |
33,253 | public void start ( ) { ObjectName beanName = null ; try { MBeanServer server = ManagementFactory . getPlatformMBeanServer ( ) ; beanName = getObjectName ( ) ; server . registerMBean ( this , beanName ) ; } catch ( InstanceAlreadyExistsException e ) { LOGGER . warn ( JcrI18n . mBeanAlreadyRegistered , beanName ) ; } catch ( Exception e ) { LOGGER . error ( e , JcrI18n . cannotRegisterMBean , beanName ) ; } } | Initializes & registers this MBean with the local MBean server . |
33,254 | public void stop ( ) { MBeanServer server = ManagementFactory . getPlatformMBeanServer ( ) ; ObjectName beanName = null ; try { beanName = getObjectName ( ) ; server . unregisterMBean ( beanName ) ; } catch ( InstanceNotFoundException e ) { LOGGER . debug ( "JMX bean {0} not found" , beanName ) ; } catch ( Exception e ) { LOGGER . error ( e , JcrI18n . cannotUnRegisterMBean , beanName ) ; } } | Un - registers the bean from the JMX server . |
33,255 | public void show ( String repository , final boolean changeHistory ) { this . repository = repository ; refreshWorkspacesAndReloadNode ( null , ROOT_PATH , changeHistory ) ; } | Shows content of the root node of the first reachable workspace of the given repository . |
33,256 | public void show ( final String repository , final String workspace , final String path , final boolean changeHistory ) { this . repository = repository ; this . refreshWorkspacesAndReloadNode ( null , path , changeHistory ) ; } | Shows nodes identified by repository workspace and path to node . |
33,257 | private void refreshWorkspacesAndReloadNode ( final String name , final String path , final boolean changeHistory ) { showLoadIcon ( ) ; console . jcrService ( ) . getWorkspaces ( repository , new AsyncCallback < String [ ] > ( ) { public void onFailure ( Throwable caught ) { hideLoadIcon ( ) ; RemoteException e = ( RemoteException ) caught ; SC . say ( caught . getMessage ( ) ) ; if ( e . code ( ) == RemoteException . SECURITY_ERROR ) { console . loadRepositoriesList ( ) ; } } public void onSuccess ( String [ ] workspaces ) { wsp . setWorkspaceNames ( workspaces ) ; getAndDisplayNode ( path , changeHistory ) ; hideLoadIcon ( ) ; } } ) ; } | Reloads values of the combo box with workspace names . |
33,258 | public void getAndDisplayNode ( final String path , final boolean changeHistory ) { showLoadIcon ( ) ; console . jcrService ( ) . node ( repository ( ) , workspace ( ) , path , new AsyncCallback < JcrNode > ( ) { public void onFailure ( Throwable caught ) { hideLoadIcon ( ) ; SC . say ( caught . getMessage ( ) ) ; } public void onSuccess ( JcrNode node ) { displayNode ( node ) ; console . changeWorkspaceInURL ( workspace ( ) , changeHistory ) ; console . changePathInURL ( path , changeHistory ) ; hideLoadIcon ( ) ; } } ) ; } | Reads node with given path and selected repository and workspace . |
33,259 | private void displayNode ( JcrNode node ) { this . node = node ; this . path = node . getPath ( ) ; pathLabel . display ( node . getPath ( ) ) ; childrenEditor . show ( node ) ; propertiesEditor . show ( node ) ; permissionsEditor . show ( node ) ; displayBinaryContent ( node ) ; } | Displays specified node . |
33,260 | public void save ( ) { SC . ask ( "Do you want to save changes" , new BooleanCallback ( ) { public void execute ( Boolean yesSelected ) { if ( yesSelected ) { jcrService ( ) . save ( repository ( ) , workspace ( ) , new BaseCallback < Object > ( ) { public void onSuccess ( Object result ) { session ( ) . setHasChanges ( false ) ; updateControls ( ) ; } } ) ; } } } ) ; } | Save session s changes . |
33,261 | public void showAddNodeDialog ( ) { jcrService ( ) . getPrimaryTypes ( node . getRepository ( ) , node . getWorkspace ( ) , null , false , new AsyncCallback < String [ ] > ( ) { public void onFailure ( Throwable caught ) { SC . say ( caught . getMessage ( ) ) ; } public void onSuccess ( String [ ] result ) { addNodeDialog . setPrimaryTypes ( result ) ; addNodeDialog . showModal ( ) ; } } ) ; } | Prepares dialog for creating new node . |
33,262 | public void exportXML ( String name , boolean skipBinary , boolean noRecurse ) { console . jcrService ( ) . export ( repository , workspace ( ) , path ( ) , name , true , true , new AsyncCallback < Object > ( ) { public void onFailure ( Throwable caught ) { SC . say ( caught . getMessage ( ) ) ; } public void onSuccess ( Object result ) { SC . say ( "Complete" ) ; } } ) ; } | Exports contents to the given file . |
33,263 | public void importXML ( String name , int option ) { console . jcrService ( ) . importXML ( repository , workspace ( ) , path ( ) , name , option , new AsyncCallback < Object > ( ) { public void onFailure ( Throwable caught ) { SC . say ( caught . getMessage ( ) ) ; } public void onSuccess ( Object result ) { SC . say ( "Complete" ) ; } } ) ; } | Imports contents from the given file . |
33,264 | protected String branchRefForName ( String branchName ) { String remoteName = connector . remoteName ( ) ; return remoteName != null ? remoteBranchPrefix ( remoteName ) + branchName : LOCAL_BRANCH_PREFIX + branchName ; } | Obtain the name of the branch reference |
33,265 | protected void addBranchesAsChildren ( Git git , CallSpecification spec , DocumentWriter writer ) throws GitAPIException { Set < String > remoteBranchPrefixes = remoteBranchPrefixes ( ) ; if ( remoteBranchPrefixes . isEmpty ( ) ) { ListBranchCommand command = git . branchList ( ) ; List < Ref > branches = command . call ( ) ; Collections . sort ( branches , REVERSE_REF_COMPARATOR ) ; for ( Ref ref : branches ) { String name = ref . getName ( ) ; name = name . replace ( GitFunction . LOCAL_BRANCH_PREFIX , "" ) ; writer . addChild ( spec . childId ( name ) , name ) ; } return ; } ListBranchCommand command = git . branchList ( ) ; command . setListMode ( ListMode . REMOTE ) ; List < Ref > branches = command . call ( ) ; Collections . sort ( branches , REVERSE_REF_COMPARATOR ) ; Set < String > uniqueNames = new HashSet < String > ( ) ; for ( Ref ref : branches ) { String name = ref . getName ( ) ; if ( uniqueNames . contains ( name ) ) continue ; boolean skip = false ; for ( String remoteBranchPrefix : remoteBranchPrefixes ) { if ( name . startsWith ( remoteBranchPrefix ) ) { name = name . replaceFirst ( remoteBranchPrefix , "" ) ; break ; } skip = true ; } if ( skip ) continue ; if ( uniqueNames . add ( name ) ) writer . addChild ( spec . childId ( name ) , name ) ; } } | Add the names of the branches as children of the current node . |
33,266 | protected void addTagsAsChildren ( Git git , CallSpecification spec , DocumentWriter writer ) throws GitAPIException { ListTagCommand command = git . tagList ( ) ; List < Ref > tags = command . call ( ) ; Collections . sort ( tags , REVERSE_REF_COMPARATOR ) ; for ( Ref ref : tags ) { String fullName = ref . getName ( ) ; String name = fullName . replaceFirst ( TAG_PREFIX , "" ) ; writer . addChild ( spec . childId ( name ) , name ) ; } } | Add the names of the tags as children of the current node . |
33,267 | protected void addCommitsAsChildren ( Git git , CallSpecification spec , DocumentWriter writer , int pageSize ) throws GitAPIException { LogCommand command = git . log ( ) ; command . setSkip ( 0 ) ; command . setMaxCount ( pageSize ) ; int actual = 0 ; String commitId = null ; for ( RevCommit commit : command . call ( ) ) { commitId = commit . getName ( ) ; writer . addChild ( spec . childId ( commitId ) , commitId ) ; ++ actual ; } if ( actual == pageSize ) { writer . addPage ( spec . getId ( ) , commitId , pageSize , PageWriter . UNKNOWN_TOTAL_SIZE ) ; } } | Add the first page of commits in the history names of the tags as children of the current node . |
33,268 | protected void addCommitsAsPageOfChildren ( Git git , Repository repository , CallSpecification spec , PageWriter writer , PageKey pageKey ) throws GitAPIException , IOException { RevWalk walker = new RevWalk ( repository ) ; try { String lastCommitIdName = pageKey . getOffsetString ( ) ; ObjectId lastCommitId = repository . resolve ( lastCommitIdName ) ; int pageSize = ( int ) pageKey . getBlockSize ( ) ; LogCommand command = git . log ( ) ; command . add ( lastCommitId ) ; command . setMaxCount ( pageSize + 1 ) ; int actual = 0 ; String commitId = null ; for ( RevCommit commit : command . call ( ) ) { commitId = commit . getName ( ) ; if ( commitId . equals ( lastCommitIdName ) ) continue ; writer . addChild ( spec . childId ( commitId ) , commitId ) ; ++ actual ; } if ( actual == pageSize ) { assert commitId != null ; writer . addPage ( pageKey . getParentId ( ) , commitId , pageSize , PageWriter . UNKNOWN_TOTAL_SIZE ) ; } } finally { walker . dispose ( ) ; } } | Add an additional page of commits in the history names of the tags as children of the current node . |
33,269 | boolean isAsOrMoreConstrainedThan ( PropertyDefinition other , ExecutionContext context ) { String [ ] otherConstraints = other . getValueConstraints ( ) ; if ( otherConstraints == null || otherConstraints . length == 0 ) { return true ; } String [ ] constraints = this . getValueConstraints ( ) ; if ( constraints == null || constraints . length == 0 ) { return false ; } int type = this . getRequiredType ( ) ; int otherType = other . getRequiredType ( ) ; if ( type == otherType && type != PropertyType . UNDEFINED ) { ConstraintChecker thisChecker = createChecker ( context , type , constraints ) ; ConstraintChecker thatChecker = createChecker ( context , otherType , otherConstraints ) ; return thisChecker . isAsOrMoreConstrainedThan ( thatChecker ) ; } Set < String > thatLiterals = new HashSet < String > ( ) ; for ( String literal : otherConstraints ) { thatLiterals . add ( literal ) ; } for ( String literal : constraints ) { if ( ! thatLiterals . contains ( literal ) ) return false ; } return true ; } | Determine if the constraints on this definition are as - constrained or more - constrained than those on the supplied definition . |
33,270 | protected void initializeStorage ( File directory ) throws BinaryStoreException { FileUtil . delete ( directory ) ; if ( ! directory . exists ( ) ) { logger . debug ( "Creating temporary directory for transient binary store: {0}" , directory . getAbsolutePath ( ) ) ; directory . mkdirs ( ) ; } if ( ! directory . canRead ( ) ) { throw new BinaryStoreException ( JcrI18n . unableToReadTemporaryDirectory . text ( directory . getAbsolutePath ( ) , JAVA_IO_TMPDIR ) ) ; } if ( ! directory . canWrite ( ) ) { throw new BinaryStoreException ( JcrI18n . unableToWriteTemporaryDirectory . text ( directory . getAbsolutePath ( ) , JAVA_IO_TMPDIR ) ) ; } } | Ensures that the directory used by this binary store exists and can be both read and written to . |
33,271 | public Workspace addWorkspace ( String name , String repositoryUrl ) { Workspace workspace = new Workspace ( name , repositoryUrl ) ; workspaces . add ( workspace ) ; return workspace ; } | Adds a new workspace to the list of workspaces . |
33,272 | protected void modifyProperties ( NodeKey key , Name primaryType , Set < Name > mixinTypes , Map < Name , AbstractPropertyChange > propChanges ) { } | Handle the addition change and removal of one or more properties of a single node . This method is called once for each existing node whose properties are modified . |
33,273 | protected void addNode ( String workspaceName , NodeKey key , Path path , Name primaryType , Set < Name > mixinTypes , Properties properties ) { } | Handle the addition of a node . |
33,274 | protected void removeNode ( String workspaceName , NodeKey key , NodeKey parentKey , Path path , Name primaryType , Set < Name > mixinTypes ) { } | Handle the removal of a node . |
33,275 | protected void changeNode ( String workspaceName , NodeKey key , Path path , Name primaryType , Set < Name > mixinTypes ) { } | Handle the change of a node . |
33,276 | protected void moveNode ( String workspaceName , NodeKey key , Name primaryType , Set < Name > mixinTypes , NodeKey oldParent , NodeKey newParent , Path newPath , Path oldPath ) { } | Handle the move of a node . |
33,277 | protected void renameNode ( String workspaceName , NodeKey key , Path newPath , Segment oldSegment , Name primaryType , Set < Name > mixinTypes ) { } | Handle the renaming of a node . |
33,278 | protected void reorderNode ( String workspaceName , NodeKey key , Name primaryType , Set < Name > mixinTypes , NodeKey parent , Path newPath , Path oldPath , Path reorderedBeforePath , Map < NodeKey , Map < Path , Path > > snsPathChangesByNodeKey ) { } | Handle the reordering of a node . |
33,279 | public static < T1 , T2 > TypeFactory < Tuple2 < T1 , T2 > > typeFactory ( TypeFactory < T1 > type1 , TypeFactory < T2 > type2 ) { return new Tuple2TypeFactory < > ( type1 , type2 ) ; } | Create a type factory for tuples of size 2 . |
33,280 | public static < T1 , T2 , T3 > TypeFactory < Tuple3 < T1 , T2 , T3 > > typeFactory ( TypeFactory < T1 > type1 , TypeFactory < T2 > type2 , TypeFactory < T3 > type3 ) { return new Tuple3TypeFactory < > ( type1 , type2 , type3 ) ; } | Create a type factory for tuples of size 3 . |
33,281 | public static < T1 , T2 , T3 , T4 > TypeFactory < Tuple4 < T1 , T2 , T3 , T4 > > typeFactory ( TypeFactory < T1 > type1 , TypeFactory < T2 > type2 , TypeFactory < T3 > type3 , TypeFactory < T4 > type4 ) { return new Tuple4TypeFactory < > ( type1 , type2 , type3 , type4 ) ; } | Create a type factory for tuples of size 4 . |
33,282 | public static TypeFactory < ? > typeFactory ( TypeFactory < ? > type , int tupleSize ) { if ( tupleSize <= 1 ) return type ; if ( tupleSize == 2 ) return typeFactory ( type , type ) ; if ( tupleSize == 3 ) return typeFactory ( type , type , type ) ; if ( tupleSize == 4 ) return typeFactory ( type , type , type , type ) ; Collection < TypeFactory < ? > > types = new ArrayList < > ( tupleSize ) ; for ( int i = 0 ; i != tupleSize ; ++ i ) { types . add ( type ) ; } return new TupleNTypeFactory ( types ) ; } | Create a type factory for uniform tuples . |
33,283 | private Privilege [ ] privileges ( Set < String > names ) throws ValueFormatException , AccessControlException , RepositoryException { Privilege [ ] privileges = new Privilege [ names . size ( ) ] ; int i = 0 ; for ( String name : names ) { privileges [ i ++ ] = privilegeFromName ( name ) ; } return privileges ; } | Constructs list of Privilege objects using privilege s name . |
33,284 | protected static String determineMethodsAllowed ( StoredObject so ) { try { if ( so != null ) { if ( so . isNullResource ( ) ) { return NULL_RESOURCE_METHODS_ALLOWED ; } else if ( so . isFolder ( ) ) { return RESOURCE_METHODS_ALLOWED + FOLDER_METHOD_ALLOWED ; } return RESOURCE_METHODS_ALLOWED ; } } catch ( Exception e ) { } return LESS_ALLOWED_METHODS ; } | Determines the methods normally allowed for the resource . |
33,285 | protected AstNode parseCreateIndex ( DdlTokenStream tokens , AstNode parentNode ) throws ParsingException { assert tokens != null ; assert parentNode != null ; markStartOfStatement ( tokens ) ; tokens . consume ( CREATE ) ; boolean isUnique = tokens . canConsume ( "UNIQUE" ) ; tokens . consume ( "INDEX" ) ; String indexName = parseName ( tokens ) ; tokens . consume ( "ON" ) ; String tableName = parseName ( tokens ) ; AstNode indexNode = nodeFactory ( ) . node ( indexName , parentNode , TYPE_CREATE_INDEX_STATEMENT ) ; indexNode . setProperty ( UNIQUE_INDEX , isUnique ) ; indexNode . setProperty ( TABLE_NAME , tableName ) ; parseIndexTableColumns ( tokens , indexNode ) ; parseUntilTerminator ( tokens ) ; markEndOfStatement ( tokens , indexNode ) ; return indexNode ; } | Parses DDL CREATE INDEX |
33,286 | protected AstNode parseCreateRole ( DdlTokenStream tokens , AstNode parentNode ) throws ParsingException { assert tokens != null ; assert parentNode != null ; markStartOfStatement ( tokens ) ; tokens . consume ( CREATE , "ROLE" ) ; String functionName = parseName ( tokens ) ; AstNode functionNode = nodeFactory ( ) . node ( functionName , parentNode , TYPE_CREATE_ROLE_STATEMENT ) ; markEndOfStatement ( tokens , functionNode ) ; return functionNode ; } | Parses DDL CREATE ROLE statement |
33,287 | protected void parseColumns ( DdlTokenStream tokens , AstNode tableNode , boolean isAlterTable ) throws ParsingException { String tableElementString = getTableElementsString ( tokens , false ) ; DdlTokenStream localTokens = new DdlTokenStream ( tableElementString , DdlTokenStream . ddlTokenizer ( false ) , false ) ; localTokens . start ( ) ; StringBuilder unusedTokensSB = new StringBuilder ( ) ; do { if ( isColumnDefinitionStart ( localTokens ) ) { parseColumnDefinition ( localTokens , tableNode , isAlterTable ) ; } else { unusedTokensSB . append ( SPACE ) . append ( localTokens . consume ( ) ) ; } } while ( localTokens . canConsume ( COMMA ) ) ; if ( unusedTokensSB . length ( ) > 0 ) { String msg = DdlSequencerI18n . unusedTokensParsingColumnDefinition . text ( tableNode . getName ( ) ) ; DdlParserProblem problem = new DdlParserProblem ( Problems . WARNING , getCurrentMarkedPosition ( ) , msg ) ; problem . setUnusedSource ( unusedTokensSB . toString ( ) ) ; addProblem ( problem , tableNode ) ; } } | Utility method designed to parse columns within an ALTER TABLE ADD statement . |
33,288 | public static Set < Column > getColumnsReferencedBy ( Visitable visitable ) { if ( visitable == null ) return Collections . emptySet ( ) ; final Set < Column > symbols = new HashSet < Column > ( ) ; Visitors . visitAll ( visitable , new AbstractVisitor ( ) { protected void addColumnFor ( SelectorName selectorName , String property ) { symbols . add ( new Column ( selectorName , property , property ) ) ; } public void visit ( Column column ) { symbols . add ( column ) ; } public void visit ( EquiJoinCondition joinCondition ) { addColumnFor ( joinCondition . selector1Name ( ) , joinCondition . getProperty1Name ( ) ) ; addColumnFor ( joinCondition . selector2Name ( ) , joinCondition . getProperty2Name ( ) ) ; } public void visit ( PropertyExistence prop ) { addColumnFor ( prop . selectorName ( ) , prop . getPropertyName ( ) ) ; } public void visit ( PropertyValue prop ) { addColumnFor ( prop . selectorName ( ) , prop . getPropertyName ( ) ) ; } public void visit ( ReferenceValue ref ) { String propertyName = ref . getPropertyName ( ) ; if ( propertyName != null ) { addColumnFor ( ref . selectorName ( ) , propertyName ) ; } } } ) ; return symbols ; } | Get the set of Column objects that represent those columns referenced by the visitable object . |
33,289 | protected static void removeTralingZeros ( StringBuilder sb ) { int endIndex = sb . length ( ) ; if ( endIndex > 0 ) { -- endIndex ; int index = endIndex ; while ( sb . charAt ( index ) == '0' ) { -- index ; } if ( index < endIndex ) sb . delete ( index + 1 , endIndex + 1 ) ; } } | Utility to remove the trailing 0 s . |
33,290 | public static void write ( String content , File file ) throws IOException { CheckArg . isNotNull ( file , "destination file" ) ; if ( content != null ) { write ( content , new FileOutputStream ( file ) ) ; } } | Write the entire contents of the supplied string to the given file . |
33,291 | public static void closeQuietly ( Closeable closeable ) { if ( closeable == null ) { return ; } try { closeable . close ( ) ; } catch ( Throwable t ) { LOGGER . debug ( t , "Ignored error at closing stream" ) ; } } | Closes the closable silently . Any exceptions are ignored . |
33,292 | public void setNullResource ( boolean f ) { this . isNullRessource = f ; this . isFolder = false ; this . creationDate = null ; this . lastModified = null ; this . contentLength = 0 ; this . mimeType = null ; } | Sets a StoredObject as a lock - null resource |
33,293 | protected void endContent ( ) throws RepositoryException { String content = StringUtil . normalize ( contentBuilder . toString ( ) ) ; contentBuilder = null ; if ( content . length ( ) > 0 ) { startNode ( XmlLexicon . ELEMENT_CONTENT , XmlLexicon . ELEMENT_CONTENT ) ; currentNode . setProperty ( XmlLexicon . ELEMENT_CONTENT , content ) ; endNode ( ) ; } } | See if there is any element content that needs to be completed . |
33,294 | public void show ( int x , int y ) { disabledHLayout . setSize ( "100%" , "100%" ) ; disabledHLayout . setStyleName ( "disabledBackgroundStyle" ) ; disabledHLayout . show ( ) ; loadingImg . setSize ( "100px" , "100px" ) ; loadingImg . setTop ( y ) ; loadingImg . setLeft ( x ) ; loadingImg . show ( ) ; loadingImg . bringToFront ( ) ; } | Shows loading indicator at the given place of screen . |
33,295 | void checkout ( AbstractJcrNode node ) throws LockException , RepositoryException { checkVersionable ( node ) ; if ( node . isLocked ( ) && ! node . holdsLock ( ) ) { throw new LockException ( JcrI18n . lockTokenNotHeld . text ( node . getPath ( ) ) ) ; } if ( ! node . hasProperty ( JcrLexicon . BASE_VERSION ) ) { return ; } if ( node . getProperty ( JcrLexicon . IS_CHECKED_OUT ) . getBoolean ( ) ) { return ; } SessionCache versionSession = session . spawnSessionCache ( false ) ; MutableCachedNode versionable = versionSession . mutable ( node . key ( ) ) ; NodeKey baseVersionKey = node . getBaseVersion ( ) . key ( ) ; PropertyFactory props = propertyFactory ( ) ; Reference baseVersionRef = session . referenceFactory ( ) . create ( baseVersionKey , true ) ; versionable . setProperty ( versionSession , props . create ( JcrLexicon . PREDECESSORS , new Object [ ] { baseVersionRef } ) ) ; versionable . setProperty ( versionSession , props . create ( JcrLexicon . IS_CHECKED_OUT , Boolean . TRUE ) ) ; versionSession . save ( ) ; } | Checks out the given node updating version - related properties on the node as needed . |
33,296 | public ExecutionContext with ( Map < String , String > data ) { Map < String , String > newData = data ; if ( newData == null ) { if ( this . data . isEmpty ( ) ) return this ; } else { newData = Collections . unmodifiableMap ( new HashMap < String , String > ( data ) ) ; } return new ExecutionContext ( securityContext , namespaceRegistry , propertyFactory , threadPools , binaryStore , newData , processId , decoder , encoder , stringFactory , binaryFactory , booleanFactory , dateFactory , decimalFactory , doubleFactory , longFactory , nameFactory , pathFactory , referenceFactory , weakReferenceFactory , simpleReferenceFactory , uriFactory , objectFactory , locale ) ; } | Create a new execution context that mirrors this context but that contains the supplied data . Note that the supplied map is always copied to ensure that it is immutable . |
33,297 | public ExecutionContext with ( String key , String value ) { Map < String , String > newData = data ; if ( value == null ) { if ( this . data . isEmpty ( ) || ! this . data . containsKey ( key ) ) { return this ; } newData = new HashMap < String , String > ( data ) ; newData . remove ( key ) ; newData = Collections . unmodifiableMap ( newData ) ; } else { newData = new HashMap < String , String > ( data ) ; newData . put ( key , value ) ; newData = Collections . unmodifiableMap ( newData ) ; } return new ExecutionContext ( securityContext , namespaceRegistry , propertyFactory , threadPools , binaryStore , newData , processId , decoder , encoder , stringFactory , binaryFactory , booleanFactory , dateFactory , decimalFactory , doubleFactory , longFactory , nameFactory , pathFactory , referenceFactory , weakReferenceFactory , simpleReferenceFactory , uriFactory , objectFactory , locale ) ; } | Create a new execution context that mirrors this context but that contains the supplied key - value pair in the new context s data . |
33,298 | public ExecutionContext with ( Locale locale ) { return new ExecutionContext ( securityContext , namespaceRegistry , propertyFactory , threadPools , binaryStore , data , processId , decoder , encoder , stringFactory , binaryFactory , booleanFactory , dateFactory , decimalFactory , doubleFactory , longFactory , nameFactory , pathFactory , referenceFactory , weakReferenceFactory , simpleReferenceFactory , uriFactory , objectFactory , locale ) ; } | Create a new execution context that mirrors this context but that contains the supplied locale . |
33,299 | protected void initializeDefaultNamespaces ( NamespaceRegistry namespaceRegistry ) { if ( namespaceRegistry == null ) return ; namespaceRegistry . register ( JcrLexicon . Namespace . PREFIX , JcrLexicon . Namespace . URI ) ; namespaceRegistry . register ( JcrMixLexicon . Namespace . PREFIX , JcrMixLexicon . Namespace . URI ) ; namespaceRegistry . register ( JcrNtLexicon . Namespace . PREFIX , JcrNtLexicon . Namespace . URI ) ; namespaceRegistry . register ( ModeShapeLexicon . Namespace . PREFIX , ModeShapeLexicon . Namespace . URI ) ; } | Method that initializes the default namespaces for namespace registries . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.