idx int64 0 41.2k | question stringlengths 74 4.04k | target stringlengths 7 750 |
|---|---|---|
33,400 | public static List < Class < ? > > convertArgumentClassesToPrimitives ( Class < ? > ... arguments ) { if ( arguments == null || arguments . length == 0 ) return Collections . emptyList ( ) ; List < Class < ? > > result = new ArrayList < Class < ? > > ( arguments . length ) ; for ( Class < ? > clazz : arguments ) { if ( clazz == Boolean . class ) clazz = Boolean . TYPE ; else if ( clazz == Character . class ) clazz = Character . TYPE ; else if ( clazz == Byte . class ) clazz = Byte . TYPE ; else if ( clazz == Short . class ) clazz = Short . TYPE ; else if ( clazz == Integer . class ) clazz = Integer . TYPE ; else if ( clazz == Long . class ) clazz = Long . TYPE ; else if ( clazz == Float . class ) clazz = Float . TYPE ; else if ( clazz == Double . class ) clazz = Double . TYPE ; else if ( clazz == Void . class ) clazz = Void . TYPE ; result . add ( clazz ) ; } return result ; } | Convert any argument classes to primitives . |
33,401 | public static String getClassName ( final Class < ? > clazz ) { final String fullName = clazz . getName ( ) ; final int fullNameLength = fullName . length ( ) ; int numArrayDimensions = 0 ; while ( numArrayDimensions < fullNameLength ) { final char c = fullName . charAt ( numArrayDimensions ) ; if ( c != '[' ) { String name = null ; switch ( c ) { case 'L' : { name = fullName . subSequence ( numArrayDimensions + 1 , fullNameLength ) . toString ( ) ; break ; } case 'B' : { name = "byte" ; break ; } case 'C' : { name = "char" ; break ; } case 'D' : { name = "double" ; break ; } case 'F' : { name = "float" ; break ; } case 'I' : { name = "int" ; break ; } case 'J' : { name = "long" ; break ; } case 'S' : { name = "short" ; break ; } case 'Z' : { name = "boolean" ; break ; } case 'V' : { name = "void" ; break ; } default : { name = fullName . subSequence ( numArrayDimensions , fullNameLength ) . toString ( ) ; } } if ( numArrayDimensions == 0 ) { return name ; } if ( numArrayDimensions < BRACKETS_PAIR . length ) { name = name + BRACKETS_PAIR [ numArrayDimensions ] ; } else { for ( int i = 0 ; i < numArrayDimensions ; i ++ ) { name = name + BRACKETS_PAIR [ 1 ] ; } } return name ; } ++ numArrayDimensions ; } return fullName ; } | Returns the name of the class . The result will be the fully - qualified class name or the readable form for arrays and primitive types . |
33,402 | public static void setValue ( Object instance , String fieldName , Object value ) { try { Field f = findFieldRecursively ( instance . getClass ( ) , fieldName ) ; if ( f == null ) throw new NoSuchMethodException ( "Cannot find field " + fieldName + " on " + instance . getClass ( ) + " or superclasses" ) ; f . setAccessible ( true ) ; f . set ( instance , value ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } } | Sets the value of a field of an object instance via reflection |
33,403 | public static Method findMethod ( Class < ? > type , String methodName ) { try { return type . getDeclaredMethod ( methodName ) ; } catch ( NoSuchMethodException e ) { if ( type . equals ( Object . class ) || type . isInterface ( ) ) { throw new RuntimeException ( e ) ; } return findMethod ( type . getSuperclass ( ) , methodName ) ; } } | Searches for a method with a given name in a class . |
33,404 | public Method [ ] findMethods ( Pattern methodNamePattern ) { final Method [ ] allMethods = this . targetClass . getMethods ( ) ; final List < Method > result = new ArrayList < Method > ( ) ; for ( int i = 0 ; i < allMethods . length ; i ++ ) { final Method m = allMethods [ i ] ; if ( methodNamePattern . matcher ( m . getName ( ) ) . matches ( ) ) { result . add ( m ) ; } } return result . toArray ( new Method [ result . size ( ) ] ) ; } | Find the methods on the target class that matches the supplied method name . |
33,405 | public Object invokeGetterMethodOnTarget ( String javaPropertyName , Object target ) throws NoSuchMethodException , SecurityException , IllegalArgumentException , IllegalAccessException , InvocationTargetException { String [ ] methodNamesArray = findMethodNames ( "get" + javaPropertyName ) ; if ( methodNamesArray . length <= 0 ) { methodNamesArray = findMethodNames ( "is" + javaPropertyName ) ; } if ( methodNamesArray . length <= 0 ) { methodNamesArray = findMethodNames ( "are" + javaPropertyName ) ; } return invokeBestMethodOnTarget ( methodNamesArray , target ) ; } | Find and execute the getter method on the target class for the supplied property name . If no such method is found a NoSuchMethodException is thrown . |
33,406 | public void setProperty ( Object target , Property property , Object value ) throws SecurityException , IllegalArgumentException , NoSuchMethodException , IllegalAccessException , InvocationTargetException { CheckArg . isNotNull ( target , "target" ) ; CheckArg . isNotNull ( property , "property" ) ; CheckArg . isNotNull ( property . getName ( ) , "property.getName()" ) ; invokeSetterMethodOnTarget ( property . getName ( ) , target , value ) ; } | Set the property on the supplied target object to the specified value . |
33,407 | public Object getProperty ( Object target , Property property ) throws SecurityException , IllegalArgumentException , NoSuchMethodException , IllegalAccessException , InvocationTargetException { CheckArg . isNotNull ( target , "target" ) ; CheckArg . isNotNull ( property , "property" ) ; CheckArg . isNotNull ( property . getName ( ) , "property.getName()" ) ; return invokeGetterMethodOnTarget ( property . getName ( ) , target ) ; } | Get current value for the property on the supplied target object . |
33,408 | public String getPropertyAsString ( Object target , Property property ) throws SecurityException , IllegalArgumentException , NoSuchMethodException , IllegalAccessException , InvocationTargetException { Object value = getProperty ( target , property ) ; StringBuilder sb = new StringBuilder ( ) ; writeObjectAsString ( value , sb , false ) ; return sb . toString ( ) ; } | Get current value represented as a string for the property on the supplied target object . |
33,409 | public String getSourceKey ( ) { if ( sourceKey == null ) { sourceKey = key . substring ( SOURCE_START_INDEX , SOURCE_END_INDEX ) ; } return sourceKey ; } | Get the multi - character key uniquely identifying the repository s storage source in which this node appears . |
33,410 | public String getWorkspaceKey ( ) { if ( workspaceKey == null ) { workspaceKey = key . substring ( WORKSPACE_START_INDEX , WORKSPACE_END_INDEX ) ; } return workspaceKey ; } | Get the multi - character key uniquely identifying the workspace in which the node appears . |
33,411 | public QueryBuilder union ( ) { this . firstQuery = query ( ) ; this . firstQuerySetOperation = Operation . UNION ; this . firstQueryAll = false ; clear ( false ) ; return this ; } | Perform a UNION between the query as defined prior to this method and the query that will be defined following this method . |
33,412 | public QueryBuilder unionAll ( ) { this . firstQuery = query ( ) ; this . firstQuerySetOperation = Operation . UNION ; this . firstQueryAll = true ; clear ( false ) ; return this ; } | Perform a UNION ALL between the query as defined prior to this method and the query that will be defined following this method . |
33,413 | public QueryBuilder intersect ( ) { this . firstQuery = query ( ) ; this . firstQuerySetOperation = Operation . INTERSECT ; this . firstQueryAll = false ; clear ( false ) ; return this ; } | Perform an INTERSECT between the query as defined prior to this method and the query that will be defined following this method . |
33,414 | public QueryBuilder intersectAll ( ) { this . firstQuery = query ( ) ; this . firstQuerySetOperation = Operation . INTERSECT ; this . firstQueryAll = true ; clear ( false ) ; return this ; } | Perform an INTERSECT ALL between the query as defined prior to this method and the query that will be defined following this method . |
33,415 | public QueryBuilder except ( ) { this . firstQuery = query ( ) ; this . firstQuerySetOperation = Operation . EXCEPT ; this . firstQueryAll = false ; clear ( false ) ; return this ; } | Perform an EXCEPT between the query as defined prior to this method and the query that will be defined following this method . |
33,416 | public QueryBuilder exceptAll ( ) { this . firstQuery = query ( ) ; this . firstQuerySetOperation = Operation . EXCEPT ; this . firstQueryAll = true ; clear ( false ) ; return this ; } | Perform an EXCEPT ALL between the query as defined prior to this method and the query that will be defined following this method . |
33,417 | public static IndexChangeAdapter forMultipleColumns ( ExecutionContext context , NodeTypePredicate matcher , String workspaceName , ProvidedIndex < ? > index , Iterable < IndexChangeAdapter > adapters ) { return new MultiColumnChangeAdapter ( context , workspaceName , matcher , index , adapters ) ; } | Creates a composite change adapter which handles the case when an index has multiple columns . |
33,418 | private boolean checkSupportedAudio ( ) { AudioHeader header = audioFile . getAudioHeader ( ) ; bitrate = header . getBitRateAsNumber ( ) ; sampleRate = header . getSampleRateAsNumber ( ) ; channels = header . getChannels ( ) ; if ( header . getChannels ( ) . toLowerCase ( ) . contains ( "stereo" ) ) { channels = "2" ; } if ( header instanceof MP3AudioHeader ) { duration = ( ( MP3AudioHeader ) header ) . getPreciseTrackLength ( ) ; } else if ( header instanceof Mp4AudioHeader ) { duration = ( double ) ( ( Mp4AudioHeader ) header ) . getPreciseLength ( ) ; } else { duration = ( double ) header . getTrackLength ( ) ; } Tag tag = audioFile . getTag ( ) ; artist = tag . getFirst ( FieldKey . ARTIST ) ; album = tag . getFirst ( FieldKey . ALBUM ) ; title = tag . getFirst ( FieldKey . TITLE ) ; comment = tag . getFirst ( FieldKey . COMMENT ) ; year = tag . getFirst ( FieldKey . YEAR ) ; track = tag . getFirst ( FieldKey . TRACK ) ; genre = tag . getFirst ( FieldKey . GENRE ) ; artwork = new ArrayList < > ( ) ; for ( Artwork a : tag . getArtworkList ( ) ) { AudioMetadataArtwork ama = new AudioMetadataArtwork ( ) ; ama . setMimeType ( a . getMimeType ( ) ) ; if ( a . getPictureType ( ) >= 0 ) { ama . setType ( a . getPictureType ( ) ) ; } ama . setData ( a . getBinaryData ( ) ) ; artwork . add ( ama ) ; } return true ; } | Parse tags common for all audio files . |
33,419 | static < T > LocalUniqueIndex < T > create ( String name , String workspaceName , DB db , Converter < T > converter , BTreeKeySerializer < T > valueSerializer , Serializer < T > rawSerializer ) { return new LocalUniqueIndex < > ( name , workspaceName , db , converter , valueSerializer , rawSerializer ) ; } | Create a new index that allows only a single value for each unique key . |
33,420 | protected Object columnValue ( Object value ) { switch ( type ) { case PATH : case NAME : case STRING : case REFERENCE : case SIMPLEREFERENCE : case WEAKREFERENCE : case URI : return valueFactories . getStringFactory ( ) . create ( value ) ; case DATE : return ( ( DateTime ) value ) . getMilliseconds ( ) ; default : return value ; } } | Converts representation of the given value using type conversation rules between JCR type of this column and Elasticsearch core type of this column . |
33,421 | protected Object cast ( Object value ) { switch ( type ) { case STRING : return valueFactories . getStringFactory ( ) . create ( value ) ; case LONG : return valueFactories . getLongFactory ( ) . create ( value ) ; case NAME : return valueFactories . getNameFactory ( ) . create ( value ) ; case PATH : return valueFactories . getPathFactory ( ) . create ( value ) ; case DATE : return valueFactories . getDateFactory ( ) . create ( value ) ; case BOOLEAN : return valueFactories . getBooleanFactory ( ) . create ( value ) ; case URI : return valueFactories . getUriFactory ( ) . create ( value ) ; case REFERENCE : return valueFactories . getReferenceFactory ( ) . create ( value ) ; case SIMPLEREFERENCE : return valueFactories . getSimpleReferenceFactory ( ) . create ( value ) ; case WEAKREFERENCE : return valueFactories . getWeakReferenceFactory ( ) . create ( value ) ; default : return value ; } } | Converts given value to the value of JCR type of this column . |
33,422 | public boolean indexExists ( String name ) throws IOException { CloseableHttpClient client = HttpClients . createDefault ( ) ; HttpHead head = new HttpHead ( String . format ( "http://%s:%d/%s" , host , port , name ) ) ; try { CloseableHttpResponse response = client . execute ( head ) ; return response . getStatusLine ( ) . getStatusCode ( ) == HttpStatus . SC_OK ; } finally { head . releaseConnection ( ) ; } } | Tests for the index existence with specified name . |
33,423 | public boolean createIndex ( String name , String type , EsRequest mappings ) throws IOException { if ( indexExists ( name ) ) { return true ; } CloseableHttpClient client = HttpClients . createDefault ( ) ; HttpPost method = new HttpPost ( String . format ( "http://%s:%d/%s" , host , port , name ) ) ; try { StringEntity requestEntity = new StringEntity ( mappings . toString ( ) , ContentType . APPLICATION_JSON ) ; method . setEntity ( requestEntity ) ; CloseableHttpResponse resp = client . execute ( method ) ; return resp . getStatusLine ( ) . getStatusCode ( ) == HttpStatus . SC_OK ; } finally { method . releaseConnection ( ) ; } } | Creates new index . |
33,424 | public boolean deleteIndex ( String name ) throws IOException { CloseableHttpClient client = HttpClients . createDefault ( ) ; HttpDelete delete = new HttpDelete ( String . format ( "http://%s:%d/%s" , host , port , name ) ) ; try { CloseableHttpResponse resp = client . execute ( delete ) ; return resp . getStatusLine ( ) . getStatusCode ( ) == HttpStatus . SC_OK ; } finally { delete . releaseConnection ( ) ; } } | Deletes index . |
33,425 | public boolean storeDocument ( String name , String type , String id , EsRequest doc ) throws IOException { CloseableHttpClient client = HttpClients . createDefault ( ) ; HttpPost method = new HttpPost ( String . format ( "http://%s:%d/%s/%s/%s" , host , port , name , type , id ) ) ; try { StringEntity requestEntity = new StringEntity ( doc . toString ( ) , ContentType . APPLICATION_JSON ) ; method . setEntity ( requestEntity ) ; CloseableHttpResponse resp = client . execute ( method ) ; int statusCode = resp . getStatusLine ( ) . getStatusCode ( ) ; return statusCode == HttpStatus . SC_CREATED || statusCode == HttpStatus . SC_OK ; } finally { method . releaseConnection ( ) ; } } | Indexes document . |
33,426 | public EsRequest getDocument ( String name , String type , String id ) throws IOException { CloseableHttpClient client = HttpClients . createDefault ( ) ; HttpGet method = new HttpGet ( String . format ( "http://%s:%d/%s/%s/%s" , host , port , name , type , id ) ) ; try { CloseableHttpResponse resp = client . execute ( method ) ; int status = resp . getStatusLine ( ) . getStatusCode ( ) ; switch ( status ) { case HttpStatus . SC_OK : EsResponse doc = EsResponse . read ( resp . getEntity ( ) . getContent ( ) ) ; return new EsRequest ( ( Document ) doc . get ( "_source" ) ) ; case HttpStatus . SC_NOT_ACCEPTABLE : case HttpStatus . SC_NOT_FOUND : return null ; default : throw new IOException ( resp . getStatusLine ( ) . getReasonPhrase ( ) ) ; } } finally { method . releaseConnection ( ) ; } } | Searches indexed document . |
33,427 | public boolean deleteDocument ( String name , String type , String id ) throws IOException { CloseableHttpClient client = HttpClients . createDefault ( ) ; HttpDelete delete = new HttpDelete ( String . format ( "http://%s:%d/%s/%s/%s" , host , port , name , type , id ) ) ; try { return client . execute ( delete ) . getStatusLine ( ) . getStatusCode ( ) == HttpStatus . SC_OK ; } finally { delete . releaseConnection ( ) ; } } | Deletes document . |
33,428 | public void deleteAll ( String name , String type ) throws IOException { CloseableHttpClient client = HttpClients . createDefault ( ) ; HttpPost method = new HttpPost ( String . format ( "http://%s:%d/%s/%s" , host , port , name , type ) ) ; try { EsRequest query = new EsRequest ( ) ; query . put ( "query" , new MatchAllQuery ( ) . build ( ) ) ; StringEntity requestEntity = new StringEntity ( query . toString ( ) , ContentType . APPLICATION_JSON ) ; method . setEntity ( requestEntity ) ; method . setHeader ( " X-HTTP-Method-Override" , "DELETE" ) ; CloseableHttpResponse resp = client . execute ( method ) ; int status = resp . getStatusLine ( ) . getStatusCode ( ) ; if ( status != HttpStatus . SC_OK ) { throw new IOException ( resp . getStatusLine ( ) . getReasonPhrase ( ) ) ; } } finally { method . releaseConnection ( ) ; } } | Deletes all documents . |
33,429 | public void flush ( String name ) throws IOException { CloseableHttpClient client = HttpClients . createDefault ( ) ; HttpPost method = new HttpPost ( String . format ( "http://%s:%d/%s/_flush" , host , port , name ) ) ; try { CloseableHttpResponse resp = client . execute ( method ) ; int status = resp . getStatusLine ( ) . getStatusCode ( ) ; if ( status != HttpStatus . SC_OK ) { throw new IOException ( resp . getStatusLine ( ) . getReasonPhrase ( ) ) ; } } finally { method . releaseConnection ( ) ; } } | Flushes index data . |
33,430 | public EsResponse search ( String name , String type , EsRequest query ) throws IOException { CloseableHttpClient client = HttpClients . createDefault ( ) ; HttpPost method = new HttpPost ( String . format ( "http://%s:%d/%s/%s/_search" , host , port , name , type ) ) ; try { StringEntity requestEntity = new StringEntity ( query . toString ( ) , ContentType . APPLICATION_JSON ) ; method . setEntity ( requestEntity ) ; CloseableHttpResponse resp = client . execute ( method ) ; int status = resp . getStatusLine ( ) . getStatusCode ( ) ; if ( status != HttpStatus . SC_OK ) { throw new IOException ( resp . getStatusLine ( ) . getReasonPhrase ( ) ) ; } return EsResponse . read ( resp . getEntity ( ) . getContent ( ) ) ; } finally { method . releaseConnection ( ) ; } } | Executes query . |
33,431 | protected String doGetString ( NamespaceRegistry namespaceRegistry , TextEncoder encoder , TextEncoder delimiterEncoder ) { if ( encoder == null ) encoder = DEFAULT_ENCODER ; final String delimiter = delimiterEncoder != null ? delimiterEncoder . encode ( DELIMITER_STR ) : DELIMITER_STR ; StringBuilder sb = new StringBuilder ( ) ; if ( this . isAbsolute ( ) ) sb . append ( delimiter ) ; boolean first = true ; for ( Segment segment : this ) { if ( first ) { first = false ; } else { sb . append ( delimiter ) ; } assert segment != null ; sb . append ( segment . getString ( namespaceRegistry , encoder , delimiterEncoder ) ) ; } String result = sb . toString ( ) ; return result ; } | Method that creates the string representation . This method works two different ways depending upon whether the namespace registry is provided . |
33,432 | public Lock lock ( AbstractJcrNode node , boolean isDeep , boolean isSessionScoped , long timeoutHint , String ownerInfo ) throws LockException , AccessDeniedException , InvalidItemStateException , RepositoryException { if ( ! node . isLockable ( ) ) { throw new LockException ( JcrI18n . nodeNotLockable . text ( node . location ( ) ) ) ; } if ( node . isLocked ( ) ) { throw new LockException ( JcrI18n . alreadyLocked . text ( node . location ( ) ) ) ; } if ( node . isNew ( ) || node . isModified ( ) ) { throw new InvalidItemStateException ( JcrI18n . changedNodeCannotBeLocked . text ( node . location ( ) ) ) ; } ModeShapeLock lock = lockManager . lock ( session , node . node ( ) , isDeep , isSessionScoped , timeoutHint , ownerInfo ) ; String token = lock . getLockToken ( ) ; lockTokens . add ( token ) ; return lock . lockFor ( session ) ; } | Attempt to obtain a lock on the supplied node . |
33,433 | protected String removeQuotes ( String text ) { assert text != null ; if ( text . length ( ) > 2 ) { char first = text . charAt ( 0 ) ; if ( first == '"' || first == '\'' ) { int indexOfLast = text . length ( ) - 1 ; char last = text . charAt ( indexOfLast ) ; if ( last == first ) { text = text . substring ( 1 , indexOfLast ) ; } } } return text ; } | Remove any leading and trailing single - quotes or double - quotes from the supplied text . |
33,434 | public void write ( Document document ) { assert document != null ; ++ count ; ++ totalCount ; if ( count > maxDocumentsPerFile ) { close ( ) ; count = 1 ; } try { if ( stream == null ) { ++ fileCount ; String suffix = StringUtil . justifyRight ( Long . toString ( fileCount ) , BackupService . NUM_CHARS_IN_FILENAME_SUFFIX , '0' ) ; String filename = filenamePrefix + "_" + suffix + DOCUMENTS_EXTENSION ; if ( compress ) filename = filename + GZIP_EXTENSION ; currentFile = new File ( parentDirectory , filename ) ; OutputStream fileStream = new FileOutputStream ( currentFile ) ; if ( compress ) fileStream = new GZIPOutputStream ( fileStream ) ; stream = new BufferedOutputStream ( fileStream ) ; } Json . write ( document , stream ) ; stream . write ( ( byte ) '\n' ) ; } catch ( IOException e ) { problems . addError ( JcrI18n . problemsWritingDocumentToBackup , currentFile . getAbsolutePath ( ) , e . getMessage ( ) ) ; } } | Append the supplied document to the files . |
33,435 | public Query constrainedBy ( Constraint constraint ) { return new Query ( source , constraint , orderings ( ) , columns , getLimits ( ) , distinct ) ; } | Create a copy of this query but one that uses the supplied constraint . |
33,436 | public Query orderedBy ( List < Ordering > orderings ) { return new Query ( source , constraint , orderings , columns , getLimits ( ) , distinct ) ; } | Create a copy of this query but one whose results should be ordered by the supplied orderings . |
33,437 | public Query returning ( List < Column > columns ) { return new Query ( source , constraint , orderings ( ) , columns , getLimits ( ) , distinct ) ; } | Create a copy of this query but that returns results with the supplied columns . |
33,438 | public Query adding ( Column ... columns ) { List < Column > newColumns = null ; if ( this . columns != null ) { newColumns = new ArrayList < Column > ( this . columns ) ; for ( Column column : columns ) { newColumns . add ( column ) ; } } else { newColumns = Arrays . asList ( columns ) ; } return new Query ( source , constraint , orderings ( ) , newColumns , getLimits ( ) , distinct ) ; } | Create a copy of this query but that returns results that include the columns specified by this query as well as the supplied columns . |
33,439 | private void getCredentials ( ) { jcrService . getUserName ( new BaseCallback < String > ( ) { public void onSuccess ( String name ) { showMainForm ( name ) ; } } ) ; } | Checks user s credentials . |
33,440 | public void loadNodeSpecifiedByURL ( ) { repositoriesList . select ( jcrURL . getRepository ( ) , jcrURL . getWorkspace ( ) , jcrURL . getPath ( ) , true ) ; } | Reconstructs URL and points browser to the requested node path . |
33,441 | public void showMainForm ( String userName ) { align ( ) ; changeUserName ( userName ) ; mainForm . addMember ( header ) ; mainForm . addMember ( repositoryHeader ) ; mainForm . addMember ( viewPort ) ; mainForm . addMember ( strut ( 30 ) ) ; mainForm . addMember ( footer ) ; setLayoutWidth ( LAYOUT_WIDTH ) ; loadData ( ) ; htmlHistory . addValueChangeHandler ( this ) ; mainForm . draw ( ) ; } | Shows main page for the logged in user . |
33,442 | public void changeRepositoryInURL ( String name , boolean changeHistory ) { jcrURL . setRepository ( name ) ; if ( changeHistory ) { htmlHistory . newItem ( jcrURL . toString ( ) , false ) ; } } | Changes repository name in URL displayed by browser . |
33,443 | public void changeWorkspaceInURL ( String name , boolean changeHistory ) { jcrURL . setWorkspace ( name ) ; if ( changeHistory ) { htmlHistory . newItem ( jcrURL . toString ( ) , false ) ; } } | Changes workspace in the URL displayed by browser . |
33,444 | public void changePathInURL ( String path , boolean changeHistory ) { jcrURL . setPath ( path ) ; if ( changeHistory ) { htmlHistory . newItem ( jcrURL . toString ( ) , false ) ; } } | Changes node path in the URL displayed by browser . |
33,445 | public void showRepositories ( Collection < RepositoryName > names ) { repositoriesList . show ( names ) ; display ( repositoriesList ) ; this . hideRepository ( ) ; } | Displays list of availables repositories . |
33,446 | public void displayContent ( String repository , String workspace , String path , boolean changeHistory ) { contents . show ( repository , workspace , path , changeHistory ) ; displayRepository ( repository ) ; display ( contents ) ; changeRepositoryInURL ( repository , changeHistory ) ; } | Displays node for the given repository workspace and path . |
33,447 | public int removeAllChildren ( Node node ) throws RepositoryException { isNotNull ( node , "node" ) ; int childrenRemoved = 0 ; NodeIterator iter = node . getNodes ( ) ; while ( iter . hasNext ( ) ) { Node child = iter . nextNode ( ) ; child . remove ( ) ; ++ childrenRemoved ; } return childrenRemoved ; } | Remove all children from the specified node |
33,448 | public Node getNode ( Node node , String relativePath , boolean required ) throws RepositoryException { isNotNull ( node , "node" ) ; isNotNull ( relativePath , "relativePath" ) ; Node result = null ; try { result = node . getNode ( relativePath ) ; } catch ( PathNotFoundException e ) { if ( required ) { throw e ; } } return result ; } | Get the node under a specified node at a location defined by the specified relative path . If node is required then a problem is created and added to the Problems list . |
33,449 | public String getReadable ( Node node ) { if ( node == null ) return "" ; try { return node . getPath ( ) ; } catch ( RepositoryException err ) { return node . toString ( ) ; } } | Get the readable string form for a specified node . |
33,450 | public Node findOrCreateNode ( Session session , String path , String nodeType ) throws RepositoryException { return findOrCreateNode ( session , path , nodeType , nodeType ) ; } | Get or create a node at the specified path and node type . |
33,451 | public Node findOrCreateChild ( Node parent , String name ) throws RepositoryException { return findOrCreateChild ( parent , name , null ) ; } | Get or create a node with the specified node under the specified parent node . |
33,452 | public Node findOrCreateChild ( Node parent , String name , String nodeType ) throws RepositoryException { return findOrCreateNode ( parent , name , nodeType , nodeType ) ; } | Get or create a node with the specified node and node type under the specified parent node . |
33,453 | public void onEachNode ( Session session , boolean includeSystemNodes , NodeOperation operation ) throws Exception { Node node = session . getRootNode ( ) ; operation . run ( node ) ; NodeIterator iter = node . getNodes ( ) ; while ( iter . hasNext ( ) ) { Node child = iter . nextNode ( ) ; if ( ! includeSystemNodes && child . getName ( ) . equals ( "jcr:system" ) ) continue ; operation . run ( child ) ; onEachNodeBelow ( child , operation ) ; } } | Execute the supplied operation on each node in the workspace accessible by the supplied session . |
33,454 | public List < AstNode > getChildrenForType ( AstNode astNode , String nodeType ) { CheckArg . isNotNull ( astNode , "astNode" ) ; CheckArg . isNotNull ( nodeType , "nodeType" ) ; List < AstNode > childrenOfType = new ArrayList < AstNode > ( ) ; for ( AstNode child : astNode . getChildren ( ) ) { if ( hasMixinType ( child , nodeType ) ) { childrenOfType . add ( child ) ; } List < AstNode > subChildrenOfType = getChildrenForType ( child , nodeType ) ; childrenOfType . addAll ( subChildrenOfType ) ; } return childrenOfType ; } | Utility method to obtain the children of a given node that match the given type |
33,455 | private List < AbstractJcrNode > findOutputNodes ( AbstractJcrNode rootOutputNode ) throws RepositoryException { if ( rootOutputNode . isNew ( ) ) { return Arrays . asList ( rootOutputNode ) ; } List < AbstractJcrNode > nodes = new ArrayList < AbstractJcrNode > ( ) ; NodeIterator childrenIt = rootOutputNode . getNodesInternal ( ) ; while ( childrenIt . hasNext ( ) ) { Node child = childrenIt . nextNode ( ) ; if ( child . isNew ( ) ) { nodes . add ( ( AbstractJcrNode ) child ) ; } } return nodes ; } | Finds the top nodes which have been created during the sequencing process based on the original output node . It is important that this is called before the session is saved because it uses the new flag . |
33,456 | private void removeExistingOutputNodes ( AbstractJcrNode parentOfOutput , String outputNodeName , String selectedPath , String logMsg ) throws RepositoryException { if ( TRACE ) { LOGGER . trace ( "Looking under '{0}' for existing output to be removed for {1}" , parentOfOutput . getPath ( ) , logMsg ) ; } NodeIterator outputIter = parentOfOutput . getNodesInternal ( outputNodeName ) ; while ( outputIter . hasNext ( ) ) { Node outputNode = outputIter . nextNode ( ) ; if ( outputNode . isNodeType ( DERIVED_NODE_TYPE_NAME ) && outputNode . hasProperty ( DERIVED_FROM_PROPERTY_NAME ) ) { String derivedFrom = outputNode . getProperty ( DERIVED_FROM_PROPERTY_NAME ) . getString ( ) ; if ( selectedPath . equals ( derivedFrom ) ) { if ( DEBUG ) { LOGGER . debug ( "Removing existing output node '{0}' for {1}" , outputNode . getPath ( ) , logMsg ) ; } outputNode . remove ( ) ; } } } } | Remove any existing nodes that were generated by previous sequencing operations of the node at the selected path . |
33,457 | private boolean contentExists ( BinaryKey key , boolean alive ) throws BinaryStoreException { try { String query = "SELECT payload from modeshape.binary where cid='" + key . toString ( ) + "'" ; query = alive ? query + " and usage=1;" : query + " and usage = 0;" ; ResultSet rs = session . execute ( query ) ; return rs . iterator ( ) . hasNext ( ) ; } catch ( RuntimeException e ) { throw new BinaryStoreException ( e ) ; } } | Test content for existence . |
33,458 | private ByteBuffer buffer ( InputStream stream ) throws IOException { stream . reset ( ) ; ByteArrayOutputStream bout = new ByteArrayOutputStream ( ) ; IoUtil . write ( stream , bout ) ; return ByteBuffer . wrap ( bout . toByteArray ( ) ) ; } | Converts input stream into ByteBuffer . |
33,459 | public static Map < SelectorName , SelectorName > getSelectorAliasesByName ( Visitable visitable ) { final Map < SelectorName , SelectorName > result = new HashMap < SelectorName , SelectorName > ( ) ; Visitors . visitAll ( visitable , new Visitors . AbstractVisitor ( ) { public void visit ( AllNodes allNodes ) { if ( allNodes . hasAlias ( ) ) { result . put ( allNodes . name ( ) , allNodes . aliasOrName ( ) ) ; } } public void visit ( NamedSelector selector ) { if ( selector . hasAlias ( ) ) { result . put ( selector . name ( ) , selector . aliasOrName ( ) ) ; } } } ) ; return result ; } | Get a map of the selector aliases keyed by their names . |
33,460 | public String getComment ( int index ) { if ( comments == null || index < 0 || index >= comments . size ( ) ) { throw new IllegalArgumentException ( "Not a valid comment index: " + index ) ; } return comments . elementAt ( index ) ; } | Returns the index th comment retrieved from the file . |
33,461 | protected boolean hasPrivileges ( Privilege [ ] privileges ) { for ( Privilege p : privileges ) { if ( ! contains ( this . privileges , p ) ) { return false ; } } return true ; } | Tests given privileges . |
33,462 | protected boolean addIfNotPresent ( Privilege [ ] privileges ) { ArrayList < Privilege > list = new ArrayList < Privilege > ( ) ; Collections . addAll ( list , privileges ) ; boolean res = combineRecursively ( list , privileges ) ; this . privileges . addAll ( list ) ; return res ; } | Adds specified privileges to this entry . |
33,463 | protected boolean combineRecursively ( List < Privilege > list , Privilege [ ] privileges ) { boolean res = false ; for ( Privilege p : privileges ) { if ( p . isAggregate ( ) ) { res = combineRecursively ( list , p . getAggregatePrivileges ( ) ) ; } else if ( ! contains ( list , p ) ) { list . add ( p ) ; res = true ; } } return res ; } | Adds specified privileges to the given list . |
33,464 | protected NodeSequence createNodeSequenceForSource ( QueryCommand originalQuery , QueryContext context , PlanNode sourceNode , Columns columns , QuerySources sources ) { for ( PlanNode indexNode : sourceNode . getChildren ( ) ) { if ( indexNode . getType ( ) != Type . INDEX ) continue ; IndexPlan index = indexNode . getProperty ( Property . INDEX_SPECIFICATION , IndexPlan . class ) ; NodeSequence sequence = createNodeSequenceForSource ( originalQuery , context , sourceNode , index , columns , sources ) ; if ( sequence != null ) { indexNode . setProperty ( Property . INDEX_USED , Boolean . TRUE ) ; return sequence ; } LOGGER . debug ( "Skipping disabled index '{0}' from provider '{1}' in workspace(s) {2} for query: {3}" , index . getName ( ) , index . getProviderName ( ) , context . getWorkspaceNames ( ) , originalQuery ) ; } return sources . allNodes ( 1.0f , - 1 ) ; } | Create a node sequence for the given source . |
33,465 | protected NodeSequence createNodeSequenceForSource ( QueryCommand originalQuery , QueryContext context , PlanNode sourceNode , IndexPlan index , Columns columns , QuerySources sources ) { if ( index . getProviderName ( ) == null ) { String name = index . getName ( ) ; String pathStr = ( String ) index . getParameters ( ) . get ( IndexPlanners . PATH_PARAMETER ) ; if ( pathStr != null ) { if ( IndexPlanners . NODE_BY_PATH_INDEX_NAME . equals ( name ) ) { PathFactory paths = context . getExecutionContext ( ) . getValueFactories ( ) . getPathFactory ( ) ; Path path = paths . create ( pathStr ) ; return sources . singleNode ( path , 1.0f ) ; } if ( IndexPlanners . CHILDREN_BY_PATH_INDEX_NAME . equals ( name ) ) { PathFactory paths = context . getExecutionContext ( ) . getValueFactories ( ) . getPathFactory ( ) ; Path path = paths . create ( pathStr ) ; return sources . childNodes ( path , 1.0f ) ; } if ( IndexPlanners . DESCENDANTS_BY_PATH_INDEX_NAME . equals ( name ) ) { PathFactory paths = context . getExecutionContext ( ) . getValueFactories ( ) . getPathFactory ( ) ; Path path = paths . create ( pathStr ) ; return sources . descendantNodes ( path , 1.0f ) ; } } String idStr = ( String ) index . getParameters ( ) . get ( IndexPlanners . ID_PARAMETER ) ; if ( idStr != null ) { if ( IndexPlanners . NODE_BY_ID_INDEX_NAME . equals ( name ) ) { StringFactory string = context . getExecutionContext ( ) . getValueFactories ( ) . getStringFactory ( ) ; String id = string . create ( idStr ) ; final String workspaceName = context . getWorkspaceNames ( ) . iterator ( ) . next ( ) ; return sources . singleNode ( workspaceName , id , 1.0f ) ; } } } return null ; } | Create a node sequence for the given index |
33,466 | private String getHash ( ) { try { Node contentNode = getContextNode ( ) ; Property data = contentNode . getProperty ( Property . JCR_DATA ) ; Binary bin = ( Binary ) data . getBinary ( ) ; return String . format ( "{%s}%s" , HASH_ALGORITHM , bin . getHexHash ( ) ) ; } catch ( RepositoryException e ) { return "" ; } } | Get the hexadecimal form of the SHA - 1 hash of the contents . |
33,467 | public void setWorkspaceNames ( String [ ] values ) { col2 . combo . setValueMap ( values ) ; if ( values . length > 0 ) { col2 . combo . setValue ( values [ 0 ] ) ; } } | Assigns workspace names to the combo box into column 2 . |
33,468 | private Set < String > versionLabelsFor ( Version version ) throws RepositoryException { if ( ! version . getParent ( ) . equals ( this ) ) { throw new VersionException ( JcrI18n . invalidVersion . text ( version . getPath ( ) , getPath ( ) ) ) ; } String versionId = version . getIdentifier ( ) ; PropertyIterator iter = versionLabels ( ) . getProperties ( ) ; if ( iter . getSize ( ) == 0 ) return Collections . emptySet ( ) ; Set < String > labels = new HashSet < String > ( ) ; while ( iter . hasNext ( ) ) { javax . jcr . Property prop = iter . nextProperty ( ) ; if ( versionId . equals ( prop . getString ( ) ) ) { labels . add ( prop . getName ( ) ) ; } } return labels ; } | Returns the version labels that point to the given version |
33,469 | private int computeCredsHashCode ( Credentials c ) { if ( c instanceof SimpleCredentials ) { return computeSimpleCredsHashCode ( ( SimpleCredentials ) c ) ; } return c . hashCode ( ) ; } | Returns Credentials instance hash code . Handles instances of SimpleCredentials in a special way . |
33,470 | public int getSameNameSiblingIndex ( ) { int snsIndex = 1 ; if ( this . parent == null ) { return snsIndex ; } for ( AstNode sibling : this . parent . getChildren ( ) ) { if ( sibling == this ) { break ; } if ( sibling . getName ( ) . equals ( this . name ) ) { ++ snsIndex ; } } return snsIndex ; } | Get the current same - name - sibling index . |
33,471 | public String getAbsolutePath ( ) { StringBuilder pathBuilder = new StringBuilder ( "/" ) . append ( this . getName ( ) ) ; AstNode parent = this . getParent ( ) ; while ( parent != null ) { pathBuilder . insert ( 0 , "/" + parent . getName ( ) ) ; parent = parent . getParent ( ) ; } return pathBuilder . toString ( ) ; } | Get the current path of this node |
33,472 | public AstNode setProperty ( String name , Object value ) { CheckArg . isNotNull ( name , "name" ) ; CheckArg . isNotNull ( value , "value" ) ; properties . put ( name , value ) ; return this ; } | Set the property with the given name to the supplied value . Any existing property with the same name will be replaced . |
33,473 | public AstNode setProperty ( String name , Object ... values ) { CheckArg . isNotNull ( name , "name" ) ; CheckArg . isNotNull ( values , "value" ) ; if ( values . length != 0 ) { properties . put ( name , Arrays . asList ( values ) ) ; } return this ; } | Set the property with the given name to the supplied values . If there is at least one value the new property will replace any existing property with the same name . This method does nothing if zero values are supplied . |
33,474 | protected String removeBracketsAndQuotes ( String text , Position position ) { return removeBracketsAndQuotes ( text , true , position ) ; } | Remove all leading and trailing single - quotes double - quotes or square brackets from the supplied text . If multiple properly - paired quotes or brackets are found they will all be removed . |
33,475 | protected String removeBracketsAndQuotes ( String text , boolean recursive , Position position ) { if ( text . length ( ) > 0 ) { char firstChar = text . charAt ( 0 ) ; switch ( firstChar ) { case '\'' : case '"' : if ( text . charAt ( text . length ( ) - 1 ) != firstChar ) { String msg = GraphI18n . expectingValidName . text ( text , position . getLine ( ) , position . getColumn ( ) ) ; throw new ParsingException ( position , msg ) ; } String removed = text . substring ( 1 , text . length ( ) - 1 ) ; return recursive ? removeBracketsAndQuotes ( removed , recursive , position ) : removed ; case '[' : if ( text . charAt ( text . length ( ) - 1 ) != ']' ) { String msg = GraphI18n . expectingValidName . text ( text , position . getLine ( ) , position . getColumn ( ) ) ; throw new ParsingException ( position , msg ) ; } removed = text . substring ( 1 , text . length ( ) - 1 ) ; return recursive ? removeBracketsAndQuotes ( removed , recursive , position ) : removed ; } } return text ; } | Remove any leading and trailing single - quotes double - quotes or square brackets from the supplied text . |
33,476 | private String [ ] propertyDefs ( Node node ) throws RepositoryException { ArrayList < String > list = new ArrayList < > ( ) ; NodeType primaryType = node . getPrimaryNodeType ( ) ; PropertyDefinition [ ] defs = primaryType . getPropertyDefinitions ( ) ; for ( PropertyDefinition def : defs ) { if ( ! def . isProtected ( ) ) { list . add ( def . getName ( ) ) ; } } NodeType [ ] mixinType = node . getMixinNodeTypes ( ) ; for ( NodeType type : mixinType ) { defs = type . getPropertyDefinitions ( ) ; for ( PropertyDefinition def : defs ) { if ( ! def . isProtected ( ) ) { list . add ( def . getName ( ) ) ; } } } String [ ] res = new String [ list . size ( ) ] ; list . toArray ( res ) ; return res ; } | Gets the list of properties available to the given node . |
33,477 | private AccessControlList findAccessList ( AccessControlManager acm , String path ) throws RepositoryException { AccessControlPolicy [ ] policy = acm . getPolicies ( path ) ; if ( policy != null && policy . length > 0 ) { return ( AccessControlList ) policy [ 0 ] ; } policy = acm . getEffectivePolicies ( path ) ; if ( policy != null && policy . length > 0 ) { return ( AccessControlList ) policy [ 0 ] ; } return null ; } | Searches access list for the given node . |
33,478 | private Collection < JcrProperty > getProperties ( String repository , String workspace , String path , Node node ) throws RepositoryException { ArrayList < PropertyDefinition > names = new ArrayList < > ( ) ; NodeType primaryType = node . getPrimaryNodeType ( ) ; PropertyDefinition [ ] defs = primaryType . getPropertyDefinitions ( ) ; names . addAll ( Arrays . asList ( defs ) ) ; NodeType [ ] mixinType = node . getMixinNodeTypes ( ) ; for ( NodeType type : mixinType ) { defs = type . getPropertyDefinitions ( ) ; names . addAll ( Arrays . asList ( defs ) ) ; } ArrayList < JcrProperty > list = new ArrayList < > ( ) ; for ( PropertyDefinition def : names ) { String name = def . getName ( ) ; String type = PropertyType . nameFromValue ( def . getRequiredType ( ) ) ; Property p = null ; try { p = node . getProperty ( def . getName ( ) ) ; } catch ( PathNotFoundException e ) { } String display = values ( def , p ) ; String value = def . isMultiple ( ) ? multiValue ( p ) : singleValue ( p , def , repository , workspace , path ) ; list . add ( new JcrProperty ( name , type , value , display ) ) ; } return list ; } | Reads properties of the given node . |
33,479 | private String values ( PropertyDefinition pd , Property p ) throws RepositoryException { if ( p == null ) { return "N/A" ; } if ( pd . getRequiredType ( ) == PropertyType . BINARY ) { return "BINARY" ; } if ( ! p . isMultiple ( ) ) { return p . getString ( ) ; } return multiValue ( p ) ; } | Displays property value as string |
33,480 | private AccessControlEntry pick ( AccessControlList acl , String principal ) throws RepositoryException { for ( AccessControlEntry entry : acl . getAccessControlEntries ( ) ) { if ( entry . getPrincipal ( ) . getName ( ) . equals ( principal ) ) { return entry ; } } return null ; } | Picks access entry for the given principal . |
33,481 | private Privilege [ ] excludePrivilege ( Privilege [ ] privileges , JcrPermission permission ) { ArrayList < Privilege > list = new ArrayList < > ( ) ; for ( Privilege privilege : privileges ) { if ( ! privilege . getName ( ) . equalsIgnoreCase ( permission . getName ( ) ) ) { list . add ( privilege ) ; } } Privilege [ ] res = new Privilege [ list . size ( ) ] ; list . toArray ( res ) ; return res ; } | Excludes given privilege . |
33,482 | private Privilege [ ] includePrivilege ( AccessControlManager acm , Privilege [ ] privileges , JcrPermission permission ) throws RepositoryException { ArrayList < Privilege > list = new ArrayList < > ( ) ; for ( Privilege privilege : privileges ) { if ( ! privilege . getName ( ) . equalsIgnoreCase ( permission . getName ( ) ) ) { list . add ( privilege ) ; } } list . add ( acm . privilegeFromName ( permission . getJcrName ( ) ) ) ; Privilege [ ] res = new Privilege [ list . size ( ) ] ; list . toArray ( res ) ; return res ; } | Includes given privilege . |
33,483 | public static FileSystemBinaryStore create ( File directory , File trash ) { String key = directory . getAbsolutePath ( ) ; FileSystemBinaryStore store = INSTANCES . get ( key ) ; if ( store == null ) { store = trash != null ? new FileSystemBinaryStore ( directory , trash ) : new FileSystemBinaryStore ( directory ) ; FileSystemBinaryStore existing = INSTANCES . putIfAbsent ( key , store ) ; if ( existing != null ) { store = existing ; } } return store ; } | Creates a new FS binary store instance |
33,484 | protected void loadRemaining ( ) { if ( ! loadedAll ) { assert targetNumRowsInMemory >= 0L ; assert batchSize != null ; Batch batch = original . nextBatch ( ) ; boolean loadIntoMemory = inMemoryBatches != null && actualNumRowsInMemory < targetNumRowsInMemory ; while ( batch != null ) { long rows = loadBatch ( batch , loadIntoMemory , null ) ; if ( batchSize . get ( ) == 0L ) batchSize . set ( rows ) ; if ( loadIntoMemory ) { assert inMemoryBatches != null ; if ( actualNumRowsInMemory >= targetNumRowsInMemory ) loadIntoMemory = false ; } batch = original . nextBatch ( ) ; } long numInMemory = inMemoryBatches != null ? actualNumRowsInMemory : 0L ; totalSize = offHeapBatchesSupplier . size ( ) + numInMemory ; loadedAll = true ; restartBatches ( ) ; } } | Load all of the remaining rows from the supplied sequence into the buffer . |
33,485 | public BinaryKey moveValue ( BinaryKey key , String source , String destination ) throws BinaryStoreException { final BinaryStore sourceStore ; if ( source == null ) { sourceStore = findBinaryStoreContainingKey ( key ) ; } else { sourceStore = selectBinaryStore ( source ) ; } if ( sourceStore == null || ! sourceStore . hasBinary ( key ) ) { throw new BinaryStoreException ( JcrI18n . unableToFindBinaryValue . text ( key , sourceStore ) ) ; } BinaryStore destinationStore = selectBinaryStore ( destination ) ; if ( sourceStore . equals ( destinationStore ) ) { return key ; } final BinaryValue binaryValue = storeValue ( sourceStore . getInputStream ( key ) , destination , false ) ; sourceStore . markAsUnused ( java . util . Collections . singleton ( key ) ) ; return binaryValue . getKey ( ) ; } | Move a value from one named store to another store |
33,486 | public void moveValue ( BinaryKey key , String destination ) throws BinaryStoreException { moveValue ( key , null , destination ) ; } | Move a BinaryKey to a named store |
33,487 | public BinaryStore findBinaryStoreContainingKey ( BinaryKey key ) { Iterator < Map . Entry < String , BinaryStore > > binaryStoreIterator = getNamedStoreIterator ( ) ; while ( binaryStoreIterator . hasNext ( ) ) { BinaryStore bs = binaryStoreIterator . next ( ) . getValue ( ) ; if ( bs . hasBinary ( key ) ) { return bs ; } } return null ; } | Get the named binary store that contains the key |
33,488 | private BinaryStore selectBinaryStore ( String hint ) { BinaryStore namedBinaryStore = null ; if ( hint != null ) { logger . trace ( "Selecting named binary store for hint: " + hint ) ; namedBinaryStore = namedStores . get ( hint ) ; } if ( namedBinaryStore == null ) { namedBinaryStore = getDefaultBinaryStore ( ) ; } logger . trace ( "Selected binary store: " + namedBinaryStore . toString ( ) ) ; return namedBinaryStore ; } | Select a named binary store for the given hint |
33,489 | public void start ( ) { if ( state == State . RUNNING ) return ; final Lock lock = this . lock . writeLock ( ) ; try { lock . lock ( ) ; this . state = State . STARTING ; ThreadFactory threadFactory = new NamedThreadFactory ( "modeshape-start-repo" ) ; repositoryStarterService = Executors . newCachedThreadPool ( threadFactory ) ; state = State . RUNNING ; } catch ( RuntimeException e ) { state = State . NOT_RUNNING ; throw e ; } finally { lock . unlock ( ) ; } } | Start this engine to make it available for use . This method does nothing if the engine is already running . |
33,490 | public Future < Boolean > shutdown ( boolean forceShutdownOfAllRepositories ) { if ( ! forceShutdownOfAllRepositories ) { final Lock lock = this . lock . readLock ( ) ; try { lock . lock ( ) ; for ( JcrRepository repository : repositories . values ( ) ) { switch ( repository . getState ( ) ) { case NOT_RUNNING : case STOPPING : break ; case RESTORING : case RUNNING : case STARTING : return ImmediateFuture . create ( Boolean . FALSE ) ; } } } finally { lock . unlock ( ) ; } } final ExecutorService executor = Executors . newSingleThreadExecutor ( ) ; try { return executor . submit ( this :: doShutdown ) ; } finally { executor . shutdown ( ) ; } } | Shutdown this engine optionally stopping all still - running repositories . |
33,491 | protected boolean doShutdown ( ) { if ( state == State . NOT_RUNNING ) { LOGGER . debug ( "Engine already shut down." ) ; return true ; } LOGGER . debug ( "Shutting down engine..." ) ; final Lock lock = this . lock . writeLock ( ) ; try { lock . lock ( ) ; state = State . STOPPING ; if ( ! repositories . isEmpty ( ) ) { Queue < Future < Boolean > > repoFutures = new LinkedList < Future < Boolean > > ( ) ; Queue < String > repoNames = new LinkedList < String > ( ) ; for ( JcrRepository repository : repositories . values ( ) ) { if ( repository != null ) { repoNames . add ( repository . getName ( ) ) ; repoFutures . add ( repository . shutdown ( ) ) ; } } while ( repoFutures . peek ( ) != null ) { String repoName = repoNames . poll ( ) ; try { repoFutures . poll ( ) . get ( ) ; repositories . remove ( repoName ) ; } catch ( ExecutionException | InterruptedException e ) { Logger . getLogger ( getClass ( ) ) . error ( e , JcrI18n . failedToShutdownDeployedRepository , repoName ) ; } } } if ( repositories . isEmpty ( ) ) { repositoryStarterService . shutdown ( ) ; repositoryStarterService = null ; this . state = State . NOT_RUNNING ; } else { this . state = State . RUNNING ; } } catch ( RuntimeException e ) { this . state = State . RUNNING ; throw e ; } finally { lock . unlock ( ) ; } return this . state != State . RUNNING ; } | Do the work of shutting down this engine and its repositories . |
33,492 | public Map < String , State > getRepositories ( ) { checkRunning ( ) ; Map < String , State > results = new HashMap < String , State > ( ) ; final Lock lock = this . lock . readLock ( ) ; try { lock . lock ( ) ; for ( JcrRepository repository : repositories . values ( ) ) { results . put ( repository . getName ( ) , repository . getState ( ) ) ; } } finally { lock . unlock ( ) ; } return Collections . unmodifiableMap ( results ) ; } | Get an instantaneous snapshot of the JCR repositories and their state . Note that the results are accurate only when this methods returns . |
33,493 | protected Collection < JcrRepository > repositories ( ) { if ( this . state == State . RUNNING ) { final Lock lock = this . lock . readLock ( ) ; try { lock . lock ( ) ; return new ArrayList < JcrRepository > ( repositories . values ( ) ) ; } finally { lock . unlock ( ) ; } } return Collections . emptyList ( ) ; } | Returns a copy of the repositories . Note that when returned not all repositories may be active . |
33,494 | protected JcrRepository deploy ( final RepositoryConfiguration repositoryConfiguration , final String repositoryKey ) throws ConfigurationException , RepositoryException { CheckArg . isNotNull ( repositoryConfiguration , "repositoryConfiguration" ) ; checkRunning ( ) ; final String repoName = repositoryKey != null ? repositoryKey : repositoryConfiguration . getName ( ) ; Problems problems = repositoryConfiguration . validate ( ) ; if ( problems . hasErrors ( ) ) { throw new ConfigurationException ( problems , JcrI18n . repositoryConfigurationIsNotValid . text ( repoName , problems . toString ( ) ) ) ; } JcrRepository repository = null ; final Lock lock = this . lock . writeLock ( ) ; try { lock . lock ( ) ; if ( this . repositories . containsKey ( repoName ) ) { throw new RepositoryException ( JcrI18n . repositoryIsAlreadyDeployed . text ( repoName ) ) ; } repository = new JcrRepository ( repositoryConfiguration ) ; this . repositories . put ( repoName , repository ) ; } finally { lock . unlock ( ) ; } return repository ; } | Deploy a new repository with the given configuration . This method will fail if this engine already contains a repository with the specified name . |
33,495 | public Status validateRequest ( final NormalisedPath requestPath , HttpServerExchange exchange , OpenApiOperation openApiOperation ) { requireNonNull ( requestPath , "A request path is required" ) ; requireNonNull ( exchange , "An exchange is required" ) ; requireNonNull ( openApiOperation , "An OpenAPI operation is required" ) ; Status status = validatePathParameters ( requestPath , openApiOperation ) ; if ( status != null ) return status ; status = validateQueryParameters ( exchange , openApiOperation ) ; if ( status != null ) return status ; status = validateHeader ( exchange , openApiOperation ) ; if ( status != null ) return status ; Object body = exchange . getAttachment ( BodyHandler . REQUEST_BODY ) ; if ( body == null && ValidatorHandler . config . skipBodyValidation ) return null ; status = validateRequestBody ( body , openApiOperation ) ; return status ; } | Validate the request against the given API operation |
33,496 | public Status validateResponse ( final HttpServerExchange exchange , final SwaggerOperation swaggerOperation ) { requireNonNull ( exchange , "An exchange is required" ) ; requireNonNull ( swaggerOperation , "A swagger operation is required" ) ; io . swagger . models . Response swaggerResponse = swaggerOperation . getOperation ( ) . getResponses ( ) . get ( Integer . toString ( exchange . getStatusCode ( ) ) ) ; if ( swaggerResponse == null ) { swaggerResponse = swaggerOperation . getOperation ( ) . getResponses ( ) . get ( "default" ) ; } if ( swaggerResponse == null ) { return new Status ( "ERR11015" , exchange . getStatusCode ( ) , swaggerOperation . getPathString ( ) . original ( ) ) ; } if ( swaggerResponse . getSchema ( ) == null ) { return null ; } String body = exchange . getOutputStream ( ) . toString ( ) ; if ( body == null || body . length ( ) == 0 ) { return new Status ( "ERR11016" , swaggerOperation . getMethod ( ) , swaggerOperation . getPathString ( ) . original ( ) ) ; } return schemaValidator . validate ( body , swaggerResponse . getSchema ( ) ) ; } | Validate the given response against the API operation . |
33,497 | public Status validate ( final Object value , final Property schema ) { return doValidate ( value , schema , null ) ; } | Validate the given value against the given property schema . |
33,498 | public Status validate ( final Object value , final Model schema , SchemaValidatorsConfig config ) { return doValidate ( value , schema , config ) ; } | Validate the given value against the given model schema . |
33,499 | public Status validateResponseContent ( Object responseContent , OpenApiOperation openApiOperation , String statusCode , String mediaTypeName ) { if ( responseContent instanceof String ) { responseContent = convertStrToObjTree ( ( String ) responseContent ) ; } JsonNode schema = getContentSchema ( openApiOperation , statusCode , mediaTypeName ) ; if ( schema == null || schema . isMissingNode ( ) ) { if ( openApiOperation . getOperation ( ) . getResponses ( ) . containsKey ( String . valueOf ( statusCode ) ) ) { return null ; } schema = getContentSchema ( openApiOperation , DEFAULT_STATUS_CODE , mediaTypeName ) ; if ( schema == null || schema . isMissingNode ( ) ) return null ; } if ( ( responseContent != null && schema == null ) || ( responseContent == null && schema != null ) ) { return new Status ( VALIDATOR_RESPONSE_CONTENT_UNEXPECTED , openApiOperation . getMethod ( ) , openApiOperation . getPathString ( ) . original ( ) ) ; } config . setTypeLoose ( false ) ; return schemaValidator . validate ( responseContent , schema , config ) ; } | validate a given response content object |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.