idx int64 0 41.2k | question stringlengths 83 4.15k | target stringlengths 5 715 |
|---|---|---|
9,300 | public void execute ( ) throws UpdateExecutionException { try { sync ( ) ; getMarkLogicClient ( ) . sendUpdateQuery ( getQueryString ( ) , getBindings ( ) , getIncludeInferred ( ) , getBaseURI ( ) ) ; } catch ( ForbiddenUserException | FailedRequestException e ) { throw new UpdateExecutionException ( e ) ; } catch ( RepositoryException e ) { throw new UpdateExecutionException ( e ) ; } catch ( MalformedQueryException e ) { throw new UpdateExecutionException ( e ) ; } catch ( IOException e ) { throw new UpdateExecutionException ( e ) ; } } | execute update query |
9,301 | public int getMatchLen ( int index , int distance , int limit ) { if ( _streamEndWasReached ) { if ( ( _pos + index ) + limit > _streamPos ) { limit = _streamPos - ( _pos + index ) ; } } distance ++ ; int pby = _bufferOffset + _pos + index ; int i ; for ( i = 0 ; i < limit && _bufferBase [ pby + i ] == _bufferBase [ pby + i - distance ] ; i ++ ) { } return i ; } | index + limit have not to exceed _keepSizeAfter ; |
9,302 | public EtcdResponse get ( String key ) throws EtcdException { UriComponentsBuilder builder = UriComponentsBuilder . fromUriString ( KEYSPACE ) ; builder . pathSegment ( key ) ; return execute ( builder , HttpMethod . GET , null , EtcdResponse . class ) ; } | Returns the node with the given key from etcd . |
9,303 | public EtcdResponse put ( final String key , final String value ) throws EtcdException { UriComponentsBuilder builder = UriComponentsBuilder . fromUriString ( KEYSPACE ) ; builder . pathSegment ( key ) ; MultiValueMap < String , String > payload = new LinkedMultiValueMap < > ( 1 ) ; payload . set ( "value" , value ) ; return execute ( builder , HttpMethod . PUT , payload , EtcdResponse . class ) ; } | Sets the value of the node with the given key in etcd . Any previously existing key - value pair is returned as prevNode in the etcd response . |
9,304 | public EtcdResponse delete ( final String key ) throws EtcdException { UriComponentsBuilder builder = UriComponentsBuilder . fromUriString ( KEYSPACE ) ; builder . pathSegment ( key ) ; return execute ( builder , HttpMethod . DELETE , null , EtcdResponse . class ) ; } | Deletes the node with the given key from etcd . |
9,305 | public EtcdMemberResponse listMembers ( ) throws EtcdException { UriComponentsBuilder builder = UriComponentsBuilder . fromUriString ( MEMBERSPACE ) ; return execute ( builder , HttpMethod . GET , null , EtcdMemberResponse . class ) ; } | Returns a representation of all members in the etcd cluster . |
9,306 | private void updateMembers ( ) { try { List < String > locations = new ArrayList < String > ( ) ; EtcdMemberResponse response = listMembers ( ) ; EtcdMember [ ] members = response . getMembers ( ) ; for ( EtcdMember member : members ) { String [ ] clientUrls = member . getClientURLs ( ) ; if ( clientUrls != null ) { for ( String clientUrl : clientUrls ) { try { String version = template . getForObject ( clientUrl + "/version" , String . class ) ; if ( version == null ) { locations . add ( clientUrl ) ; } } catch ( RestClientException e ) { log . debug ( "ignoring URI " + clientUrl + " because of error." , e ) ; } } } } if ( ! locations . isEmpty ( ) ) { this . locations = locations . toArray ( new String [ locations . size ( ) ] ) ; } else { log . debug ( "not updating locations because no location is found" ) ; } } catch ( EtcdException e ) { log . error ( "Could not update etcd cluster member." , e ) ; } } | Updates the locations of the etcd cluster members . |
9,307 | private < T > T execute ( UriComponentsBuilder uriTemplate , HttpMethod method , MultiValueMap < String , String > requestData , Class < T > responseType ) throws EtcdException { long startTimeMillis = System . currentTimeMillis ( ) ; int retry = - 1 ; ResourceAccessException lastException = null ; do { lastException = null ; URI uri = uriTemplate . buildAndExpand ( locations [ locationIndex ] ) . toUri ( ) ; RequestEntity < MultiValueMap < String , String > > requestEntity = new RequestEntity < > ( requestData , null , method , uri ) ; try { ResponseEntity < T > responseEntity = template . exchange ( requestEntity , responseType ) ; return responseEntity . getBody ( ) ; } catch ( HttpStatusCodeException e ) { EtcdError error = null ; try { error = responseConverter . getObjectMapper ( ) . readValue ( e . getResponseBodyAsByteArray ( ) , EtcdError . class ) ; } catch ( IOException ex ) { error = null ; } throw new EtcdException ( error , "Failed to execute " + requestEntity + "." , e ) ; } catch ( ResourceAccessException e ) { log . debug ( "Failed to execute " + requestEntity + ", retrying if possible." , e ) ; if ( locationIndex == locations . length - 1 ) { locationIndex = 0 ; } else { locationIndex ++ ; } lastException = e ; } } while ( retry <= retryCount && System . currentTimeMillis ( ) - startTimeMillis < retryDuration ) ; if ( lastException != null ) { throw lastException ; } else { return null ; } } | Executes the given method on the given location using the given request data . |
9,308 | public static < X > Iterator < X > before ( final Iterator < X > iterator , final Runnable f ) { return new Iterator < X > ( ) { private final Runnable fOnlyOnce = new RunOnlyOnce ( f ) ; public boolean hasNext ( ) { fOnlyOnce . run ( ) ; return iterator . hasNext ( ) ; } public X next ( ) { fOnlyOnce . run ( ) ; return iterator . next ( ) ; } public void remove ( ) { fOnlyOnce . run ( ) ; iterator . remove ( ) ; } } ; } | Run f immediately before the first element of iterator is generated . Exceptions raised by f will prevent the requested behavior on the underlying iterator and can be handled by the caller . |
9,309 | public static < X > Iterator < X > after ( final Iterator < X > iterator , final Runnable f ) { return new Iterator < X > ( ) { private final Runnable fOnlyOnce = new RunOnlyOnce ( f ) ; public boolean hasNext ( ) { final boolean hasNext = iterator . hasNext ( ) ; if ( ! hasNext ) { fOnlyOnce . run ( ) ; } return hasNext ; } public X next ( ) { try { return iterator . next ( ) ; } catch ( NoSuchElementException e ) { fOnlyOnce . run ( ) ; throw e ; } } public void remove ( ) { iterator . remove ( ) ; } } ; } | Run f immediately after the last element of iterator is generated . Exceptions must not be raised by f . |
9,310 | public static < K , V > Map < K , V > zipMap ( Iterable < K > keys , Iterable < V > values ) { Map < K , V > retVal = new LinkedHashMap < > ( ) ; Iterator < K > keysIter = keys . iterator ( ) ; Iterator < V > valsIter = values . iterator ( ) ; while ( keysIter . hasNext ( ) ) { final K key = keysIter . next ( ) ; Preconditions . checkArgument ( valsIter . hasNext ( ) , "number of values[%s] less than number of keys, broke on key[%s]" , retVal . size ( ) , key ) ; retVal . put ( key , valsIter . next ( ) ) ; } Preconditions . checkArgument ( ! valsIter . hasNext ( ) , "number of values[%s] exceeds number of keys[%s]" , retVal . size ( ) + Iterators . size ( valsIter ) , retVal . size ( ) ) ; return retVal ; } | Create a Map from iterables of keys and values . Will throw an exception if there are more keys than values or more values than keys . |
9,311 | public static < K , V > Map < K , V > zipMapPartial ( Iterable < K > keys , Iterable < V > values ) { Map < K , V > retVal = new LinkedHashMap < > ( ) ; Iterator < K > keysIter = keys . iterator ( ) ; Iterator < V > valsIter = values . iterator ( ) ; while ( keysIter . hasNext ( ) ) { final K key = keysIter . next ( ) ; if ( valsIter . hasNext ( ) ) retVal . put ( key , valsIter . next ( ) ) ; else break ; } return retVal ; } | Create a Map from iterables of keys and values . If there are more keys than values or more values than keys the excess will be omitted . |
9,312 | public static long copyToFileAndClose ( InputStream is , File file , long timeout ) throws IOException , TimeoutException { file . getParentFile ( ) . mkdirs ( ) ; try ( OutputStream os = new BufferedOutputStream ( new FileOutputStream ( file ) ) ) { final long retval = copyWithTimeout ( is , os , timeout ) ; os . flush ( ) ; return retval ; } finally { is . close ( ) ; } } | Copy bytes from is to file but timeout if the copy takes too long . The timeout is best effort and not guaranteed . Specifically is . read will not be interrupted . |
9,313 | public static long copyWithTimeout ( InputStream is , OutputStream os , long timeout ) throws IOException , TimeoutException { byte [ ] buffer = new byte [ DEFAULT_BUFFER_SIZE ] ; int n ; long startTime = System . currentTimeMillis ( ) ; long size = 0 ; while ( - 1 != ( n = is . read ( buffer ) ) ) { if ( System . currentTimeMillis ( ) - startTime > timeout ) { throw new TimeoutException ( String . format ( "Copy time has exceeded %,d millis" , timeout ) ) ; } os . write ( buffer , 0 , n ) ; size += n ; } return size ; } | Copy from the input stream to the output stream and tries to exit if the copy exceeds the timeout . The timeout is best effort . Specifically is . read will not be interrupted . |
9,314 | public static FileUtils . FileCopyResult unzip ( final File pulledFile , final File outDir ) throws IOException { if ( ! ( outDir . exists ( ) && outDir . isDirectory ( ) ) ) { throw new ISE ( "outDir[%s] must exist and be a directory" , outDir ) ; } log . info ( "Unzipping file[%s] to [%s]" , pulledFile , outDir ) ; final FileUtils . FileCopyResult result = new FileUtils . FileCopyResult ( ) ; try ( final ZipFile zipFile = new ZipFile ( pulledFile ) ) { final Enumeration < ? extends ZipEntry > enumeration = zipFile . entries ( ) ; while ( enumeration . hasMoreElements ( ) ) { final ZipEntry entry = enumeration . nextElement ( ) ; result . addFiles ( FileUtils . retryCopy ( new ByteSource ( ) { public InputStream openStream ( ) throws IOException { return new BufferedInputStream ( zipFile . getInputStream ( entry ) ) ; } } , new File ( outDir , entry . getName ( ) ) , FileUtils . IS_EXCEPTION , DEFAULT_RETRY_COUNT ) . getFiles ( ) ) ; } } return result ; } | Unzip the pulled file to an output directory . This is only expected to work on zips with lone files and is not intended for zips with directory structures . |
9,315 | public static void scheduleWithFixedDelay ( ScheduledExecutorService exec , Duration delay , Runnable runnable ) { scheduleWithFixedDelay ( exec , delay , delay , runnable ) ; } | Run runnable repeatedly with the given delay between calls . Exceptions are caught and logged as errors . |
9,316 | public static void scheduleWithFixedDelay ( final ScheduledExecutorService exec , final Duration initialDelay , final Duration delay , final Callable < Signal > callable ) { log . debug ( "Scheduling repeatedly: %s with delay %s" , callable , delay ) ; exec . schedule ( new Runnable ( ) { public void run ( ) { try { log . debug ( "Running %s (delay %s)" , callable , delay ) ; if ( callable . call ( ) == Signal . REPEAT ) { log . debug ( "Rescheduling %s (delay %s)" , callable , delay ) ; exec . schedule ( this , delay . getMillis ( ) , TimeUnit . MILLISECONDS ) ; } else { log . debug ( "Stopped rescheduling %s (delay %s)" , callable , delay ) ; } } catch ( Throwable e ) { log . error ( e , "Uncaught exception." ) ; } } } , initialDelay . getMillis ( ) , TimeUnit . MILLISECONDS ) ; } | Run callable repeatedly with the given delay between calls until it returns Signal . STOP . Exceptions are caught and logged as errors . |
9,317 | public static void scheduleAtFixedRate ( ScheduledExecutorService exec , Duration rate , Runnable runnable ) { scheduleAtFixedRate ( exec , rate , rate , runnable ) ; } | Run runnable once every period . Exceptions are caught and logged as errors . |
9,318 | void validateAndPrepare ( Message message , Address [ ] addresses ) throws MessagingException { if ( message . getFrom ( ) == null || message . getFrom ( ) . length == 0 ) { fail ( message , addresses , "No or empty FROM address set!" ) ; } if ( addresses . length == 0 ) { fail ( message , addresses , "No RECIPIENTS set!" ) ; } Address [ ] messageAddresses = message . getAllRecipients ( ) ; if ( messageAddresses == null ) { for ( Address address : addresses ) { message . addRecipient ( Message . RecipientType . TO , address ) ; } } else { out : for ( Address address : addresses ) { for ( Address a : messageAddresses ) { if ( a == null ) { continue ; } if ( a . equals ( address ) ) { continue out ; } } message . addRecipient ( Message . RecipientType . TO , address ) ; } } } | Validate FROM and RECIPIENTS |
9,319 | static Map < String , Collection < String > > extractTextParts ( Multipart multiPart ) throws MessagingException , IOException { HashMap < String , Collection < String > > bodies = new HashMap < > ( ) ; for ( int i = 0 ; i < multiPart . getCount ( ) ; i ++ ) { checkPartForTextType ( bodies , multiPart . getBodyPart ( i ) ) ; } return bodies ; } | Extract parts from Multi - part message . |
9,320 | private static void checkPartForTextType ( HashMap < String , Collection < String > > bodies , Part part ) throws IOException , MessagingException { Object content = part . getContent ( ) ; if ( content instanceof CharSequence ) { String ct = part . getContentType ( ) ; Collection < String > value = bodies . get ( ct ) ; if ( value != null ) { value . add ( content . toString ( ) ) ; } else { value = new LinkedList < > ( ) ; value . add ( content . toString ( ) ) ; bodies . put ( ct , value ) ; } } else if ( content instanceof Multipart ) { Multipart mp = ( Multipart ) content ; for ( int i = 0 ; i < mp . getCount ( ) ; i ++ ) { checkPartForTextType ( bodies , mp . getBodyPart ( i ) ) ; } } } | Recursive find body parts and save them to HashMap |
9,321 | public DirectoryPollerBuilder setPollingInterval ( long interval , TimeUnit timeUnit ) { if ( interval < 0 ) { throw new IllegalArgumentException ( "Argument 'interval' is negative: " + interval ) ; } pollingIntervalInMillis = timeUnit . toMillis ( interval ) ; return this ; } | Set the interval between each poll cycle . Optional parameter . Default value is 1000 milliseconds . |
9,322 | @ ManyToOne ( targetEntity = org . openprovenance . prov . sql . QualifiedName . class , cascade = { CascadeType . ALL } ) @ JoinColumn ( name = "DELEGATE" ) public org . openprovenance . prov . model . QualifiedName getDelegate ( ) { return delegate ; } | Gets the value of the delegate property . |
9,323 | @ ManyToOne ( targetEntity = org . openprovenance . prov . sql . QualifiedName . class , cascade = { CascadeType . ALL } ) @ JoinColumn ( name = "RESPONSIBLE" ) public org . openprovenance . prov . model . QualifiedName getResponsible ( ) { return responsible ; } | Gets the value of the responsible property . |
9,324 | @ ManyToOne ( targetEntity = org . openprovenance . prov . sql . QualifiedName . class , cascade = { CascadeType . ALL } ) @ JoinColumn ( name = "ACTIVITY" ) public org . openprovenance . prov . model . QualifiedName getActivity ( ) { return activity ; } | Gets the value of the activity property . |
9,325 | @ ManyToOne ( targetEntity = org . openprovenance . prov . sql . QualifiedName . class , cascade = { CascadeType . ALL } ) @ JoinColumn ( name = "AGENT" ) public org . openprovenance . prov . model . QualifiedName getAgent ( ) { return agent ; } | Gets the value of the agent property . |
9,326 | @ ManyToOne ( targetEntity = org . openprovenance . prov . sql . QualifiedName . class , cascade = { CascadeType . ALL } ) @ JoinColumn ( name = "SPECIFICENTITY_MENTIONOF_PK" ) public org . openprovenance . prov . model . QualifiedName getSpecificEntity ( ) { return specificEntity ; } | Gets the value of the specificEntity property . |
9,327 | @ ManyToOne ( targetEntity = org . openprovenance . prov . sql . QualifiedName . class , cascade = { CascadeType . ALL } ) @ JoinColumn ( name = "GENERALENTITY_MENTIONOF_PK" ) public org . openprovenance . prov . model . QualifiedName getGeneralEntity ( ) { return generalEntity ; } | Gets the value of the generalEntity property . |
9,328 | @ ManyToOne ( targetEntity = org . openprovenance . prov . sql . QualifiedName . class , cascade = { CascadeType . ALL } ) @ JoinColumn ( name = "BUNDLE" ) public org . openprovenance . prov . model . QualifiedName getBundle ( ) { return bundle ; } | Gets the value of the bundle property . |
9,329 | public String buildAcceptHeader ( ) { StringBuffer mimetypes = new StringBuffer ( ) ; Enumeration < ProvFormat > e = mimeTypeMap . keys ( ) ; String sep = "" ; while ( e . hasMoreElements ( ) ) { ProvFormat f = e . nextElement ( ) ; if ( isInputFormat ( f ) ) { mimetypes . append ( sep ) ; sep = "," ; mimetypes . append ( mimeTypeMap . get ( f ) ) ; } } mimetypes . append ( sep ) ; mimetypes . append ( "*/*;q=0.1" ) ; return mimetypes . toString ( ) ; } | Create a list of mime types supported by ProvToolbox in view of constructing an Accept Header . |
9,330 | public URLConnection connectWithRedirect ( URL theURL ) throws IOException { URLConnection conn = null ; String accept_header = buildAcceptHeader ( ) ; int redirect_count = 0 ; boolean done = false ; while ( ! done ) { if ( theURL . getProtocol ( ) . equals ( "file" ) ) { return null ; } Boolean isHttp = ( theURL . getProtocol ( ) . equals ( "http" ) || theURL . getProtocol ( ) . equals ( "https" ) ) ; logger . debug ( "Requesting: " + theURL . toString ( ) ) ; conn = theURL . openConnection ( ) ; if ( isHttp ) { logger . debug ( "Accept: " + accept_header ) ; conn . setRequestProperty ( "Accept" , accept_header ) ; } conn . setConnectTimeout ( 60000 ) ; conn . setReadTimeout ( 60000 ) ; conn . connect ( ) ; done = true ; if ( isHttp ) { logger . debug ( "Response: " + conn . getHeaderField ( 0 ) ) ; int rc = ( ( HttpURLConnection ) conn ) . getResponseCode ( ) ; if ( ( rc == HttpURLConnection . HTTP_MOVED_PERM ) || ( rc == HttpURLConnection . HTTP_MOVED_TEMP ) || ( rc == HttpURLConnection . HTTP_SEE_OTHER ) || ( rc == 307 ) ) { if ( redirect_count > 10 ) { return null ; } redirect_count ++ ; String loc = conn . getHeaderField ( "Location" ) ; if ( loc != null ) { theURL = new URL ( loc ) ; done = false ; } else { return null ; } } else if ( ( rc < 200 ) || ( rc >= 300 ) ) { return null ; } } } return conn ; } | A method to connect to a URL and follow redirects if any . |
9,331 | public String convertExtensionToMediaType ( String extension ) { ProvFormat format = extensionRevMap . get ( extension ) ; if ( format == null ) return null ; return mimeTypeMap . get ( format ) ; } | Maps an file extension to a Media type |
9,332 | public String getExtension ( ProvFormat format ) { String extension = UNKNOWN ; if ( format != null ) { extension = extensionMap . get ( format ) ; } return extension ; } | Returns an extension for a given type of serialization of PROV |
9,333 | String getOption ( String [ ] options , int index ) { if ( ( options != null ) && ( options . length > index ) ) { return options [ index ] ; } return null ; } | Returns an option at given index in an array of options or null |
9,334 | public List < Variant > getVariants ( ) { List < Variant > vs = new ArrayList < Variant > ( ) ; for ( Map . Entry < String , ProvFormat > entry : mimeTypeRevMap . entrySet ( ) ) { if ( isOutputFormat ( entry . getValue ( ) ) ) { String [ ] parts = entry . getKey ( ) . split ( "/" ) ; MediaType m = new MediaType ( parts [ 0 ] , parts [ 1 ] ) ; vs . add ( new Variant ( m , ( java . util . Locale ) null , ( String ) null ) ) ; } } return vs ; } | Support for content negotiation jax - rs style . Create a list of media type supported by the framework . |
9,335 | public Boolean isInputFormat ( ProvFormat format ) { ProvFormatType t = provTypeMap . get ( format ) ; return ( t . equals ( ProvFormatType . INPUT ) || t . equals ( ProvFormatType . INPUTOUTPUT ) ) ; } | Determines whether this format received as argument is an input format . |
9,336 | public Boolean isOutputFormat ( ProvFormat format ) { ProvFormatType t = provTypeMap . get ( format ) ; return ( t . equals ( ProvFormatType . OUTPUT ) || t . equals ( ProvFormatType . INPUTOUTPUT ) ) ; } | Determines whether this format received as argument is an output format . |
9,337 | public Object loadProvUnknownGraph ( String filename ) { try { Utility u = new Utility ( ) ; CommonTree tree = u . convertASNToTree ( filename ) ; Object o = u . convertTreeToJavaBean ( tree , pFactory ) ; if ( o != null ) { return o ; } } catch ( RecognitionException t1 ) { } catch ( IOException e ) { } try { File in = new File ( filename ) ; ProvDeserialiser deserial = ProvDeserialiser . getThreadProvDeserialiser ( ) ; Document c = deserial . deserialiseDocument ( in ) ; if ( c != null ) { return c ; } } catch ( JAXBException t2 ) { } try { Document o = new org . openprovenance . prov . json . Converter ( pFactory ) . readDocument ( filename ) ; if ( o != null ) { return o ; } } catch ( IOException e ) { } try { org . openprovenance . prov . rdf . Utility rdfU = new org . openprovenance . prov . rdf . Utility ( pFactory , onto ) ; Document doc = rdfU . parseRDF ( filename ) ; if ( doc != null ) { return doc ; } } catch ( RDFParseException e ) { } catch ( RDFHandlerException e ) { } catch ( IOException e ) { } catch ( JAXBException e ) { } System . out . println ( "Unparseable format " + filename ) ; throw new UnsupportedOperationException ( ) ; } | Experimental code trying to load a document without knowing its serialization format . First parser that succeeds returns a results . Not a robust method! |
9,338 | public Document readDocument ( String url ) { try { URL theURL = new URL ( url ) ; URLConnection conn = connectWithRedirect ( theURL ) ; if ( conn == null ) return null ; ProvFormat format = null ; String content_type = conn . getContentType ( ) ; logger . debug ( "Content-type: " + content_type ) ; if ( content_type != null ) { int end = content_type . indexOf ( ";" ) ; if ( end < 0 ) { end = content_type . length ( ) ; } String actual_content_type = content_type . substring ( 0 , end ) . trim ( ) ; logger . debug ( "Found Content-type: " + actual_content_type ) ; format = mimeTypeRevMap . get ( actual_content_type ) ; } logger . debug ( "Format after Content-type: " + format ) ; if ( format == null ) { format = getTypeForFile ( theURL . toString ( ) ) ; } logger . debug ( "Format after extension: " + format ) ; InputStream content_stream = conn . getInputStream ( ) ; return readDocument ( content_stream , format , url ) ; } catch ( IOException e ) { throw new InteropException ( e ) ; } } | Reads a document from a URL . Uses the Content - type header field to determine the mime - type of the resource and therefore the parser to read the document . |
9,339 | public Document readDocumentFromFile ( String filename ) { ProvFormat format = getTypeForFile ( filename ) ; if ( format == null ) { throw new InteropException ( "Unknown output file format: " + filename ) ; } return readDocumentFromFile ( filename , format ) ; } | Reads a document from a file using the file extension to decide which parser to read the file with . |
9,340 | public Document readDocumentFromFile ( String filename , ProvFormat format ) { try { switch ( format ) { case DOT : case JPEG : case PNG : case SVG : throw new UnsupportedOperationException ( ) ; case JSON : { return new org . openprovenance . prov . json . Converter ( pFactory ) . readDocument ( filename ) ; } case PROVN : { Utility u = new Utility ( ) ; CommonTree tree = u . convertASNToTree ( filename ) ; Object o = u . convertTreeToJavaBean ( tree , pFactory ) ; Document doc = ( Document ) o ; return doc ; } case RDFXML : case TRIG : case TURTLE : { org . openprovenance . prov . rdf . Utility rdfU = new org . openprovenance . prov . rdf . Utility ( pFactory , onto ) ; Document doc = rdfU . parseRDF ( filename ) ; return doc ; } case XML : { File in = new File ( filename ) ; ProvDeserialiser deserial = ProvDeserialiser . getThreadProvDeserialiser ( ) ; Document doc = deserial . deserialiseDocument ( in ) ; return doc ; } default : { System . out . println ( "Unknown format " + filename ) ; throw new UnsupportedOperationException ( ) ; } } } catch ( IOException e ) { throw new InteropException ( e ) ; } catch ( RDFParseException e ) { throw new InteropException ( e ) ; } catch ( RDFHandlerException e ) { throw new InteropException ( e ) ; } catch ( JAXBException e ) { throw new InteropException ( e ) ; } catch ( RecognitionException e ) { throw new InteropException ( e ) ; } } | Reads a document from a file using the format to decide which parser to read the file with . |
9,341 | public List < org . openprovenance . prov . model . Other > getOther ( ) { if ( other == null ) { other = new ArrayList < org . openprovenance . prov . model . Other > ( ) ; } return this . other ; } | Gets the value of the other property . |
9,342 | @ ManyToOne ( targetEntity = org . openprovenance . prov . sql . QualifiedName . class , cascade = { CascadeType . ALL } ) @ JoinColumn ( name = "DICTIONARY__DICTIONARYMEMBER_0" ) public org . openprovenance . prov . model . QualifiedName getDictionary ( ) { return dictionary ; } | Gets the value of the dictionary property . |
9,343 | public List < org . openprovenance . prov . model . Entry > getKeyEntityPair ( ) { if ( keyEntityPair == null ) { keyEntityPair = new ArrayList < org . openprovenance . prov . model . Entry > ( ) ; } return this . keyEntityPair ; } | Gets the value of the keyEntityPair property . |
9,344 | protected Key valueToKey ( Value value ) { if ( value instanceof Resource ) { return pFactory . newKey ( convertResourceToQualifiedName ( ( Resource ) value ) , name . PROV_QUALIFIED_NAME ) ; } else if ( value instanceof Literal ) { Literal lit = ( Literal ) value ; QualifiedName type ; QualifiedName xsdtype ; if ( lit . getDatatype ( ) != null ) { xsdtype = convertURIToQualifiedName ( lit . getDatatype ( ) ) ; } else { xsdtype = name . PROV_LANG_STRING ; } Object o = decodeLiteral ( lit ) ; if ( o instanceof QualifiedName ) { return pFactory . newKey ( o , name . PROV_QUALIFIED_NAME ) ; } return pFactory . newKey ( o , xsdtype ) ; } else if ( value instanceof URI ) { URI uri = ( URI ) ( value ) ; return pFactory . newKey ( uri . toString ( ) , name . PROV_QUALIFIED_NAME ) ; } else if ( value instanceof BNode ) { return pFactory . newKey ( bnodeToQualifiedName ( ( BNode ) value ) , name . PROV_QUALIFIED_NAME ) ; } else { return null ; } } | code replicated from valueToObject |
9,345 | @ ManyToOne ( targetEntity = org . openprovenance . prov . sql . QualifiedName . class , cascade = { CascadeType . ALL } ) @ JoinColumn ( name = "COLLECTION" ) public org . openprovenance . prov . model . QualifiedName getCollection ( ) { return collection ; } | Gets the value of the collection property . |
9,346 | @ ManyToMany ( targetEntity = AStatement . class , cascade = { CascadeType . ALL } ) @ JoinTable ( name = "BUNDLE_STATEMENT_JOIN" , joinColumns = { @ JoinColumn ( name = "BUNDLE" ) } , inverseJoinColumns = { @ JoinColumn ( name = "STATEMENT" ) } ) public List < Statement > getStatement ( ) { if ( statement == null ) { statement = new ArrayList < Statement > ( ) ; } return this . statement ; } | Gets the value of the statement property . |
9,347 | @ ManyToMany ( targetEntity = AStatement . class , cascade = { CascadeType . ALL } ) @ JoinTable ( name = "DOCUMENT_STATEMENT_JOIN" , joinColumns = { @ JoinColumn ( name = "DOCUMENT" ) } , inverseJoinColumns = { @ JoinColumn ( name = "STATEMENT" ) } ) public List < StatementOrBundle > getStatementOrBundle ( ) { if ( statementOrBundle == null ) { statementOrBundle = new ArrayList < StatementOrBundle > ( ) ; } return this . statementOrBundle ; } | Gets the value of the statementOrBundle property . |
9,348 | @ Column ( name = "PK" ) @ GeneratedValue ( strategy = GenerationType . AUTO ) public Long getPk ( ) { return pk ; } | Gets the value of the pk property . |
9,349 | public Agent newAgent ( Agent a ) { Agent res = newAgent ( a . getId ( ) ) ; res . getType ( ) . addAll ( a . getType ( ) ) ; res . getLabel ( ) . addAll ( a . getLabel ( ) ) ; return res ; } | Creates a copy of an agent . The copy is shallow in the sense that the new Agent shares the same attributes as the original Agent . |
9,350 | public Entity newEntity ( Entity e ) { Entity res = newEntity ( e . getId ( ) ) ; res . getOther ( ) . addAll ( e . getOther ( ) ) ; res . getType ( ) . addAll ( e . getType ( ) ) ; res . getLabel ( ) . addAll ( e . getLabel ( ) ) ; res . getLocation ( ) . addAll ( e . getLocation ( ) ) ; return res ; } | Creates a copy of an entity . The copy is shallow in the sense that the new Entity shares the same attributes as the original Entity . |
9,351 | public Entry newEntry ( Key key , QualifiedName entity ) { Entry res = of . createEntry ( ) ; res . setKey ( key ) ; res . setEntity ( entity ) ; return res ; } | Factory method for Key - entity entries . Key - entity entries are used to identify the members of a dictionary . |
9,352 | public void setKey ( org . openprovenance . prov . model . Key value ) { this . key = ( org . openprovenance . prov . sql . Key ) value ; } | Sets the value of the key property . |
9,353 | public List < org . openprovenance . prov . model . Key > getKey ( ) { if ( key == null ) { key = AttributeList . populateKnownAttributes ( this , all , org . openprovenance . prov . model . Key . class ) ; } return this . key ; } | Gets the value of the key property . |
9,354 | final public QualifiedName stringToQualifiedName ( String str , org . w3c . dom . Element el ) { if ( str == null ) return null ; int index = str . indexOf ( ':' ) ; if ( index == - 1 ) { QualifiedName qn = pFactory . newQualifiedName ( el . lookupNamespaceURI ( null ) , str , null ) ; return qn ; } String prefix = str . substring ( 0 , index ) ; String local = str . substring ( index + 1 , str . length ( ) ) ; String escapedLocal = qnU . escapeProvLocalName ( qnU . unescapeFromXsdLocalName ( local ) ) ; QualifiedName qn = pFactory . newQualifiedName ( convertNsFromXml ( el . lookupNamespaceURI ( prefix ) ) , escapedLocal , prefix ) ; return qn ; } | Converts a string to a QualifiedName extracting namespace from the DOM . Ensures that the generated qualified name is properly escaped according to PROV - N syntax . |
9,355 | public Document parseRDF ( InputStream inputStream , RDFFormat format , String baseuri ) throws RDFParseException , RDFHandlerException , IOException { RDFParser rdfParser = Rio . createParser ( format ) ; return parseRDF ( inputStream , rdfParser , baseuri ) ; } | Parse from input stream no base uri specified . |
9,356 | public Document parseRDF ( InputStream inputStream , RDFParser rdfParser , String baseuri ) throws IOException , RDFParseException , RDFHandlerException { RdfCollector rdfCollector = new QualifiedCollector ( pFactory , onto ) ; rdfParser . setRDFHandler ( rdfCollector ) ; rdfParser . parse ( inputStream , baseuri ) ; Document doc = rdfCollector . getDocument ( ) ; Namespace ns = doc . getNamespace ( ) ; return doc ; } | Parse from input stream passing base uri . |
9,357 | public boolean hasNoTime ( Statement o ) { if ( o instanceof HasTime ) return false ; if ( o instanceof Activity ) return false ; return true ; } | Indicates whether object has no time field . |
9,358 | public String selectColor ( List < String > colors ) { String tr = "transparent" ; for ( String c : colors ) { if ( ! ( c . equals ( tr ) ) ) return c ; } return tr ; } | returns the first non transparent color |
9,359 | @ ManyToOne ( targetEntity = org . openprovenance . prov . sql . QualifiedName . class , cascade = { CascadeType . ALL } ) @ JoinColumn ( name = "ALTERNATE1" ) public org . openprovenance . prov . model . QualifiedName getAlternate1 ( ) { return alternate1 ; } | Gets the value of the alternate1 property . |
9,360 | @ ManyToOne ( targetEntity = org . openprovenance . prov . sql . QualifiedName . class , cascade = { CascadeType . ALL } ) @ JoinColumn ( name = "ALTERNATE2" ) public org . openprovenance . prov . model . QualifiedName getAlternate2 ( ) { return alternate2 ; } | Gets the value of the alternate2 property . |
9,361 | @ ManyToOne ( targetEntity = org . openprovenance . prov . sql . QualifiedName . class , cascade = { CascadeType . ALL } ) @ JoinColumn ( name = "PLAN" ) public org . openprovenance . prov . model . QualifiedName getPlan ( ) { return plan ; } | Gets the value of the plan property . |
9,362 | @ ManyToOne ( targetEntity = org . openprovenance . prov . sql . QualifiedName . class , cascade = { CascadeType . ALL } ) @ JoinColumn ( name = "INFLUENCEE" ) public org . openprovenance . prov . model . QualifiedName getInfluencee ( ) { return influencee ; } | Gets the value of the influencee property . |
9,363 | @ ManyToOne ( targetEntity = org . openprovenance . prov . sql . QualifiedName . class , cascade = { CascadeType . ALL } ) @ JoinColumn ( name = "INFLUENCER" ) public org . openprovenance . prov . model . QualifiedName getInfluencer ( ) { return influencer ; } | Gets the value of the influencer property . |
9,364 | @ ManyToOne ( targetEntity = org . openprovenance . prov . sql . QualifiedName . class , cascade = { CascadeType . ALL } ) @ JoinColumn ( name = "GENERATED_ENTITY" ) public org . openprovenance . prov . model . QualifiedName getGeneratedEntity ( ) { return generatedEntity ; } | Gets the value of the generatedEntity property . |
9,365 | @ ManyToOne ( targetEntity = org . openprovenance . prov . sql . QualifiedName . class , cascade = { CascadeType . ALL } ) @ JoinColumn ( name = "USED_ENTITY" ) public org . openprovenance . prov . model . QualifiedName getUsedEntity ( ) { return usedEntity ; } | Gets the value of the usedEntity property . |
9,366 | @ ManyToOne ( targetEntity = org . openprovenance . prov . sql . QualifiedName . class , cascade = { CascadeType . ALL } ) @ JoinColumn ( name = "GENERATION" ) public org . openprovenance . prov . model . QualifiedName getGeneration ( ) { return generation ; } | Gets the value of the generation property . |
9,367 | @ ManyToOne ( targetEntity = org . openprovenance . prov . sql . QualifiedName . class , cascade = { CascadeType . ALL } ) @ JoinColumn ( name = "USAGE" ) public org . openprovenance . prov . model . QualifiedName getUsage ( ) { return usage ; } | Gets the value of the usage property . |
9,368 | public AValue getValueItem ( ) { if ( ( avalue == null ) && ( value != null ) ) { if ( type == null ) { avalue = SQLValueConverter . convertToAValue ( vc . getXsdType ( value ) , value ) ; } else if ( value instanceof LangString ) { avalue = SQLValueConverter . convertToAValue ( type , ( ( LangString ) value ) . getValue ( ) ) ; } else if ( value instanceof org . openprovenance . prov . model . QualifiedName ) { avalue = SQLValueConverter . convertToAValue ( type , ( QualifiedName ) value ) ; } else { avalue = SQLValueConverter . convertToAValue ( type , vc . convertToJava ( type , ( String ) value ) ) ; } } return avalue ; } | Gets the value of the test property . |
9,369 | public void setValueItem ( AValue value ) { this . avalue = value ; if ( value != null ) { Object o = SQLValueConverter . convertFromAValue ( value ) ; if ( o != null ) { if ( o instanceof QualifiedName ) { this . value = o ; } else { this . value = o . toString ( ) ; } } } } | Sets the value of the test property . |
9,370 | @ ManyToOne ( targetEntity = org . openprovenance . prov . sql . QualifiedName . class , cascade = { CascadeType . ALL } ) @ JoinColumn ( name = "TRIGGER_" ) public org . openprovenance . prov . model . QualifiedName getTrigger ( ) { return trigger ; } | Gets the value of the trigger property . |
9,371 | @ ManyToOne ( targetEntity = org . openprovenance . prov . sql . QualifiedName . class , cascade = { CascadeType . ALL } ) @ JoinColumn ( name = "STARTER" ) public org . openprovenance . prov . model . QualifiedName getStarter ( ) { return starter ; } | Gets the value of the starter property . |
9,372 | public Object convertJavaBeanToJavaBean ( Document doc , ProvFactory pFactory ) { BeanTraversal bt = new BeanTraversal ( pFactory , pFactory ) ; Document o = bt . doAction ( doc ) ; return o ; } | A conversion function that copies a Java Bean deeply . |
9,373 | @ ManyToOne ( targetEntity = org . openprovenance . prov . sql . QualifiedName . class , cascade = { CascadeType . ALL } ) @ JoinColumn ( name = "QN" ) public QualifiedName getQualifiedName ( ) { return qualifiedName ; } | Gets the value of the qualifiedName property . |
9,374 | @ ManyToOne ( targetEntity = org . openprovenance . prov . sql . QualifiedName . class , cascade = { CascadeType . ALL } ) @ JoinColumn ( name = "ENDER" ) public org . openprovenance . prov . model . QualifiedName getEnder ( ) { return ender ; } | Gets the value of the ender property . |
9,375 | public void updateNamespaces ( Document document ) { Namespace rootNamespace = Namespace . gatherNamespaces ( document ) ; document . setNamespace ( rootNamespace ) ; for ( org . openprovenance . prov . model . Bundle bu : utils . getBundle ( document ) ) { Namespace ns = bu . getNamespace ( ) ; if ( ns != null ) { ns . setParent ( rootNamespace ) ; } else { ns = new Namespace ( ) ; ns . setParent ( rootNamespace ) ; bu . setNamespace ( ns ) ; } } } | After reading a document this method should be called to ensure that Namespaces are properly chained . |
9,376 | @ ManyToOne ( targetEntity = org . openprovenance . prov . sql . QualifiedName . class , cascade = { CascadeType . ALL } ) @ JoinColumn ( name = "INFORMED" ) public org . openprovenance . prov . model . QualifiedName getInformed ( ) { return informed ; } | Gets the value of the informed property . |
9,377 | @ ManyToOne ( targetEntity = org . openprovenance . prov . sql . QualifiedName . class , cascade = { CascadeType . ALL } ) @ JoinColumn ( name = "INFORMANT" ) public org . openprovenance . prov . model . QualifiedName getInformant ( ) { return informant ; } | Gets the value of the informant property . |
9,378 | public < T extends Relation > T add ( T statement , int num , Collection < T > anonRelationCollection , HashMap < QualifiedName , Collection < T > > namedRelationMap , HashMap < QualifiedName , Collection < T > > effectRelationMap , HashMap < QualifiedName , Collection < T > > causeRelationMap ) { QualifiedName aid2 = u . getEffect ( statement ) ; QualifiedName aid1 = u . getCause ( statement ) ; statement = pFactory . newStatement ( statement ) ; QualifiedName id ; if ( statement instanceof Identifiable ) { id = ( ( Identifiable ) statement ) . getId ( ) ; } else { id = null ; } if ( id == null ) { boolean found = false ; Collection < T > relationCollection = effectRelationMap . get ( aid2 ) ; if ( relationCollection == null ) { relationCollection = new LinkedList < T > ( ) ; relationCollection . add ( statement ) ; effectRelationMap . put ( aid2 , relationCollection ) ; } else { for ( T u : relationCollection ) { if ( u . equals ( statement ) ) { found = true ; statement = u ; break ; } } if ( ! found ) { relationCollection . add ( statement ) ; } } relationCollection = causeRelationMap . get ( aid1 ) ; if ( relationCollection == null ) { relationCollection = new LinkedList < T > ( ) ; relationCollection . add ( statement ) ; causeRelationMap . put ( aid1 , relationCollection ) ; } else { if ( ! found ) { relationCollection . add ( statement ) ; } } if ( ! found ) { anonRelationCollection . add ( statement ) ; } } else { Collection < T > relationCollection = namedRelationMap . get ( id ) ; if ( relationCollection == null ) { relationCollection = new LinkedList < T > ( ) ; relationCollection . add ( statement ) ; namedRelationMap . put ( id , relationCollection ) ; } else { boolean found = false ; for ( T u1 : relationCollection ) { if ( sameEdge ( u1 , statement , num ) ) { found = true ; mergeAttributes ( u1 , statement ) ; break ; } } if ( ! found ) { relationCollection . add ( statement ) ; } } } return statement ; } | Add an edge to the graph . Update namedRelationMap effectRelationMap and causeRelationMap accordingly . Edges with different attributes are considered distinct . |
9,379 | public Object marshal ( org . openprovenance . prov . model . Attribute attribute ) { return DOMProcessing . marshalAttribute ( attribute ) ; } | Marshals an Attribute to a DOM Element . |
9,380 | protected PGPSecretKey retrieveSecretKey ( PGPSecretKeyRingCollection secretKeyRingCollection , KeyFilter < PGPSecretKey > keyFilter ) throws PGPException { LOGGER . trace ( "retrieveSecretKey(PGPSecretKeyRingCollection, KeyFilter<PGPSecretKey>)" ) ; LOGGER . trace ( "Secret KeyRing Collection: {}, Key Filter: {}" , secretKeyRingCollection == null ? "not set" : "set" , keyFilter == null ? "not set" : "set" ) ; PGPSecretKey result = null ; Iterator < PGPSecretKeyRing > secretKeyRingIterator = secretKeyRingCollection . getKeyRings ( ) ; PGPSecretKeyRing secretKeyRing = null ; LOGGER . debug ( "Iterating secret key ring" ) ; while ( result == null && secretKeyRingIterator . hasNext ( ) ) { secretKeyRing = secretKeyRingIterator . next ( ) ; Iterator < PGPSecretKey > secretKeyIterator = secretKeyRing . getSecretKeys ( ) ; LOGGER . debug ( "Iterating secret keys in key ring" ) ; while ( secretKeyIterator . hasNext ( ) ) { PGPSecretKey secretKey = secretKeyIterator . next ( ) ; LOGGER . info ( "Found secret key: {}" , secretKey . getKeyID ( ) ) ; LOGGER . debug ( "Checking secret key with filter" ) ; if ( keyFilter . accept ( secretKey ) ) { LOGGER . info ( "Key {} selected from secret key ring" ) ; result = secretKey ; } } } return result ; } | retrieve the appropriate secret key from the secret key ring collection based on the key filter |
9,381 | protected PGPSecretKey findSecretKey ( InputStream secretKey , final long keyId ) throws IOException , PGPException { LOGGER . trace ( "findSecretKey(InputStream, long)" ) ; LOGGER . trace ( "Secret Key: {}, Key ID: {}" , secretKey == null ? "not set" : "set" , keyId ) ; return findSecretKey ( secretKey , new KeyFilter < PGPSecretKey > ( ) { public boolean accept ( PGPSecretKey secretKey ) { return secretKey . getKeyID ( ) == keyId ; } } ) ; } | helper method to read a specific secret key |
9,382 | protected PGPSecretKey findSecretKey ( InputStream secretKey , KeyFilter < PGPSecretKey > keyFilter ) throws IOException , PGPException { LOGGER . trace ( "findSecretKey(InputStream, KeyFilter<PGPSecretKey>)" ) ; PGPSecretKey result = null ; LOGGER . debug ( "Wrapping secret key stream in ArmoredInputStream" ) ; try ( InputStream armoredSecretKey = new ArmoredInputStream ( secretKey ) ) { LOGGER . debug ( "Creating PGPSecretKeyRingCollection" ) ; PGPSecretKeyRingCollection keyRingCollection = new PGPSecretKeyRingCollection ( armoredSecretKey , new BcKeyFingerprintCalculator ( ) ) ; result = retrieveSecretKey ( keyRingCollection , keyFilter ) ; } return result ; } | reads the given secret key and applies the provided key filter |
9,383 | protected PGPPrivateKey findPrivateKey ( PGPSecretKey pgpSecretKey , String password ) throws PGPException { LOGGER . trace ( "findPrivateKey(PGPSecretKey, String)" ) ; LOGGER . trace ( "Secret Key: {}, Password: {}" , pgpSecretKey == null ? "not set" : "set" , password == null ? "not set" : "********" ) ; PGPPrivateKey result = null ; PBESecretKeyDecryptor pbeSecretKeyDecryptor = new BcPBESecretKeyDecryptorBuilder ( new BcPGPDigestCalculatorProvider ( ) ) . build ( password . toCharArray ( ) ) ; LOGGER . info ( "Extracting private key" ) ; result = pgpSecretKey . extractPrivateKey ( pbeSecretKeyDecryptor ) ; if ( result == null && LOGGER . isErrorEnabled ( ) ) { LOGGER . error ( "No private key could be extracted" ) ; } return result ; } | read the private key from the given secret key |
9,384 | protected PGPPublicKey findPublicKey ( InputStream publicKey , KeyFilter < PGPPublicKey > keyFilter ) { LOGGER . trace ( "findPublicKey(InputStream, KeyFilter<PGPPublicKey>)" ) ; LOGGER . trace ( "Public Key: {}, Key Filter: {}" , publicKey == null ? "not set" : "set" , keyFilter == null ? "not set" : "set" ) ; return retrievePublicKey ( readPublicKeyRing ( publicKey ) , keyFilter ) ; } | reads the public key from the given stream |
9,385 | protected PGPPublicKey retrievePublicKey ( PGPPublicKeyRing publicKeyRing , KeyFilter < PGPPublicKey > keyFilter ) { LOGGER . trace ( "retrievePublicKey(PGPPublicKeyRing, KeyFilter<PGPPublicKey>)" ) ; PGPPublicKey result = null ; Iterator < PGPPublicKey > publicKeyIterator = publicKeyRing . getPublicKeys ( ) ; LOGGER . debug ( "Iterating through public keys in public key ring" ) ; while ( result == null && publicKeyIterator . hasNext ( ) ) { PGPPublicKey key = publicKeyIterator . next ( ) ; LOGGER . info ( "Found secret key: {}" , key . getKeyID ( ) ) ; LOGGER . debug ( "Checking public key with filter" ) ; if ( keyFilter . accept ( key ) ) { LOGGER . info ( "Public key {} selected from key ring" , key . getKeyID ( ) ) ; result = key ; } } return result ; } | reads the PGP public key from a PublicKeyRing |
9,386 | protected PGPPublicKeyRing readPublicKeyRing ( InputStream publicKey ) { LOGGER . trace ( "readPublicKeyRing(InputStream)" ) ; PGPPublicKeyRing result = null ; LOGGER . debug ( "Wrapping public key stream in decoder stream" ) ; try ( InputStream decoderStream = PGPUtil . getDecoderStream ( publicKey ) ) { LOGGER . debug ( "Creating PGP Object Factory" ) ; PGPObjectFactory pgpObjectFactory = new PGPObjectFactory ( decoderStream , new BcKeyFingerprintCalculator ( ) ) ; Object o = null ; LOGGER . debug ( "Looking up PGP Public KeyRing" ) ; while ( ( o = pgpObjectFactory . nextObject ( ) ) != null && result == null ) { if ( o instanceof PGPPublicKeyRing ) { LOGGER . info ( "PGP Public KeyRing retrieved" ) ; result = ( PGPPublicKeyRing ) o ; } } } catch ( IOException e ) { LOGGER . error ( "{}" , e . getMessage ( ) ) ; } return result ; } | reads the public key ring from the input stream |
9,387 | public static void copy ( InputStream inputStream , OutputStream outputStream ) throws IOException { LOGGER . trace ( "copy(InputStream, OutputStream)" ) ; copy ( inputStream , outputStream , new byte [ BUFFER_SIZE ] ) ; } | copies the input stream to the output stream |
9,388 | public static void copy ( InputStream inputStream , OutputStream outputStream , byte [ ] buffer ) throws IOException { LOGGER . trace ( "copy(InputStream, OutputStream, byte[])" ) ; copy ( inputStream , outputStream , buffer , null ) ; } | copies the input stream to the output stream using a custom buffer size |
9,389 | public static void copy ( InputStream inputStream , final OutputStream outputStream , byte [ ] buffer , final StreamHandler addtionalHandling ) throws IOException { LOGGER . trace ( "copy(InputStream, OutputStream, byte[], StreamHandler)" ) ; LOGGER . debug ( "buffer size: {} bytes" , ( buffer != null ) ? buffer . length : "null" ) ; process ( inputStream , new StreamHandler ( ) { public void handleStreamBuffer ( byte [ ] buffer , int offset , int length ) throws IOException { outputStream . write ( buffer , offset , length ) ; if ( addtionalHandling != null ) { addtionalHandling . handleStreamBuffer ( buffer , offset , length ) ; } } } , buffer ) ; } | copies the input stream to the output stream using a custom buffer size and applying additional stream handling |
9,390 | public static void process ( InputStream inputStream , StreamHandler handler ) throws IOException { LOGGER . trace ( "process(InputStream, StreamHandler)" ) ; process ( inputStream , handler , new byte [ BUFFER_SIZE ] ) ; } | generic processing of a stream |
9,391 | public static void process ( InputStream inputStream , StreamHandler handler , byte [ ] buffer ) throws IOException { LOGGER . trace ( "process(InputStream, StreamHandler, byte[])" ) ; LOGGER . debug ( "buffer size: {} bytes" , buffer != null ? buffer . length : "null" ) ; int read = - 1 ; while ( ( read = inputStream . read ( buffer ) ) != - 1 ) { LOGGER . debug ( "{} bytes read from stream" , read ) ; handler . handleStreamBuffer ( buffer , 0 , read ) ; } } | generic processing of a stream with a custom buffer |
9,392 | private PGPKeyRingGenerator createKeyRingGenerator ( String userId , String password , int keySize ) { LOGGER . trace ( "createKeyRingGenerator(String, String, int)" ) ; LOGGER . trace ( "User ID: {}, Password: {}, Key Size: {}" , userId , password == null ? "not set" : "********" , keySize ) ; PGPKeyRingGenerator generator = null ; try { LOGGER . debug ( "Creating RSA key pair generator" ) ; RSAKeyPairGenerator generator1 = new RSAKeyPairGenerator ( ) ; generator1 . init ( new RSAKeyGenerationParameters ( BigInteger . valueOf ( 0x10001 ) , getSecureRandom ( ) , keySize , 12 ) ) ; LOGGER . debug ( "Generating Signing Key Pair" ) ; BcPGPKeyPair signingKeyPair = new BcPGPKeyPair ( PGPPublicKey . RSA_SIGN , generator1 . generateKeyPair ( ) , new Date ( ) ) ; LOGGER . debug ( "Generating Encyption Key Pair" ) ; BcPGPKeyPair encryptionKeyPair = new BcPGPKeyPair ( PGPPublicKey . RSA_ENCRYPT , generator1 . generateKeyPair ( ) , new Date ( ) ) ; LOGGER . debug ( "Generating Signature Key Properties" ) ; PGPSignatureSubpacketGenerator signatureSubpacketGenerator = new PGPSignatureSubpacketGenerator ( ) ; signatureSubpacketGenerator . setKeyFlags ( false , KeyFlags . SIGN_DATA | KeyFlags . CERTIFY_OTHER ) ; signatureSubpacketGenerator . setPreferredSymmetricAlgorithms ( false , getPreferredEncryptionAlgorithms ( ) ) ; signatureSubpacketGenerator . setPreferredHashAlgorithms ( false , getPreferredHashingAlgorithms ( ) ) ; signatureSubpacketGenerator . setPreferredCompressionAlgorithms ( false , getPreferredCompressionAlgorithms ( ) ) ; LOGGER . debug ( "Generating Encyption Key Properties" ) ; PGPSignatureSubpacketGenerator encryptionSubpacketGenerator = new PGPSignatureSubpacketGenerator ( ) ; encryptionSubpacketGenerator . setKeyFlags ( false , KeyFlags . ENCRYPT_COMMS | KeyFlags . ENCRYPT_STORAGE ) ; LOGGER . info ( "Creating PGP Key Ring Generator" ) ; generator = new PGPKeyRingGenerator ( PGPPublicKey . RSA_SIGN , signingKeyPair , userId , new BcPGPDigestCalculatorProvider ( ) . get ( HashAlgorithmTags . SHA1 ) , signatureSubpacketGenerator . generate ( ) , null , new BcPGPContentSignerBuilder ( PGPPublicKey . RSA_SIGN , HashAlgorithmTags . SHA256 ) , new BcPBESecretKeyEncryptorBuilder ( getEncryptionAlgorithm ( ) ) . build ( password . toCharArray ( ) ) ) ; generator . addSubKey ( encryptionKeyPair , encryptionSubpacketGenerator . generate ( ) , null ) ; } catch ( PGPException e ) { LOGGER . error ( "{}" , e . getMessage ( ) ) ; generator = null ; } return generator ; } | creates and initializes a PGP Key Ring Generator |
9,393 | @ CacheControl ( policy = { CachePolicy . MUST_REVALIDATE } , maxAge = 15 * 60 ) @ RequestMapping ( "/directions.do" ) public String handleProducDirectionsRequest ( Model model ) { model . addAttribute ( "pageName" , "Directions" ) ; return "page" ; } | Directions page allowing caching for 15 minutes but requiring re - revalidation before serving user a potentially stale resource . |
9,394 | @ CacheControl ( policy = { CachePolicy . PRIVATE , CachePolicy . MUST_REVALIDATE } ) @ RequestMapping ( "/account.do" ) public String handleAccountRequest ( Model model ) { model . addAttribute ( "pageName" , "Your Account" ) ; return "page" ; } | Personalized accounts page . Content is private to the user so it should only be stored in a private cache . |
9,395 | public void makeDisabled ( boolean b ) throws IOException { if ( disabled == b ) { return ; } this . disabled = b ; Collection < P > projects = getItems ( ) ; if ( b ) { if ( disabledSubProjects . isEmpty ( ) ) { for ( P project : projects ) { if ( project . isDisabled ( ) ) { disabledSubProjects . add ( project . getName ( ) ) ; } } } for ( P project : projects ) { project . disable ( ) ; } } else { for ( P project : projects ) { if ( ! disabledSubProjects . contains ( project . getName ( ) ) ) { project . enable ( ) ; } } disabledSubProjects . clear ( ) ; } save ( ) ; ItemListener . fireOnUpdated ( this ) ; } | Marks the build as disabled . |
9,396 | protected void init ( ) { for ( int i = 0 ; i < config . getFilter ( ) . getInclusions ( ) . size ( ) ; i ++ ) { inclusions . add ( Pattern . compile ( config . getFilter ( ) . getInclusions ( ) . get ( i ) ) . asPredicate ( ) ) ; } for ( int i = 0 ; i < config . getFilter ( ) . getExclusions ( ) . size ( ) ; i ++ ) { exclusions . add ( Pattern . compile ( config . getFilter ( ) . getExclusions ( ) . get ( i ) ) . asPredicate ( ) ) ; } } | This method initialises the filter . |
9,397 | public boolean isIncluded ( String endpoint ) { for ( int i = 0 ; i < inclusions . size ( ) ; i ++ ) { if ( inclusions . get ( i ) . test ( endpoint ) ) { return true ; } } return false ; } | This method determines whether the supplied endpoint should be included . |
9,398 | public boolean isExcluded ( String endpoint ) { for ( int i = 0 ; i < exclusions . size ( ) ; i ++ ) { if ( exclusions . get ( i ) . test ( endpoint ) ) { return true ; } } return false ; } | This method determines whether the supplied endpoint should be excluded . |
9,399 | public Message addContent ( String name , String type , String value ) { content . put ( name , new Content ( type , value ) ) ; return this ; } | This method adds new content . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.