idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
4,500
private ObjectNode getLocalizedObject ( Node n ) throws GraphElementFactoryException { if ( n instanceof URIReference ) { return getLocalizedResource ( n ) ; } else if ( n instanceof Literal ) { Literal l = ( Literal ) n ; GraphElementFactory elementFactory = _connector . getElementFactory ( ) ; if ( l . getDatatypeURI...
Gets a localized URIReference or Literal based on the given Node .
4,501
private void scanThroughFilesForNextJournalEntry ( ) throws JournalException { try { while ( true ) { if ( currentFile != null ) { advancePastWhitespace ( currentFile . getReader ( ) ) ; XMLEvent next = currentFile . getReader ( ) . peek ( ) ; if ( isStartTagEvent ( next , QNAME_TAG_JOURNAL_ENTRY ) ) { return ; } else ...
Advance to the next journal entry if there is one . If we find one the current file will be pointing to it . If we don t find one there will be no current file .
4,502
protected JournalInputFile openNextFile ( ) throws JournalException { File [ ] journalFiles = MultiFileJournalHelper . getSortedArrayOfJournalFiles ( journalDirectory , filenamePrefix ) ; if ( journalFiles . length == 0 ) { return null ; } JournalInputFile nextFile = new JournalInputFile ( journalFiles [ 0 ] ) ; recove...
Look in the directory for files that match the prefix . If there are none leave with currentFile still null . If we find one advance into it .
4,503
public static boolean sameResource ( URIReference u1 , String u2 ) { return u1 . getURI ( ) . toString ( ) . equals ( u2 ) ; }
Tells whether the given resources are equivalent with one given as a URI string .
4,504
public static boolean sameLiteral ( Literal l1 , String l2 , URI type , String lang ) { if ( l1 . getLexicalForm ( ) . equals ( l2 ) && eq ( l1 . getLanguage ( ) , lang ) ) { if ( l1 . getDatatypeURI ( ) == null ) { return type == null ; } else { return type != null && type . equals ( l1 . getDatatypeURI ( ) ) ; } } el...
Tells whether the given literals are equivalent with one given as a set of simple values .
4,505
public static boolean sameSubject ( SubjectNode s1 , String s2 ) { if ( s1 instanceof URIReference ) { return sameResource ( ( URIReference ) s1 , s2 ) ; } else { return false ; } }
Tells whether the given subjects are equivalent with one given as a URI string .
4,506
public static boolean sameObject ( ObjectNode o1 , String o2 , boolean isLiteral , URI type , String lang ) { if ( o1 instanceof URIReference ) { return sameResource ( ( URIReference ) o1 , o2 ) ; } else if ( o1 instanceof Literal || isLiteral ) { return sameLiteral ( ( Literal ) o1 , o2 , type , lang ) ; } else { retu...
Tells whether the given objects are equivalent with one given as a set of simple values .
4,507
public void close ( ) throws IOException { if ( open ) { if ( residual . length ( ) > 0 ) { throw new IOException ( "Base64 error - data is not properly" + "padded to 4-character groups." ) ; } stream . close ( ) ; open = false ; } }
Close the writer . If there are any residual characters at this point the data stream was not a valid Base64 encoding .
4,508
private int countRelations ( String relationName , Set < RelationshipTuple > objectRelations ) { int count = 0 ; if ( objectRelations == null ) { return 0 ; } for ( RelationshipTuple objectRelation : objectRelations ) { if ( objectRelation . predicate . equals ( relationName ) ) { count ++ ; } } return count ; }
Private utility method . Counts the number of relations with a given name in a list of relatiosn
4,509
public void setXMLContent ( byte [ ] xmlContent ) { if ( m_dsType == DS_TYPE . INLINE_XML ) { ( ( DatastreamXMLMetadata ) m_ds ) . xmlContent = xmlContent ; ( ( DatastreamXMLMetadata ) m_ds ) . DSSize = ( xmlContent != null ) ? xmlContent . length : - 1 ; } else if ( m_dsType == DS_TYPE . MANAGED ) { ByteArrayInputStre...
Update the XML content of the datastream wrapped by this class
4,510
public void setDSMDClass ( int DSMDClass ) { if ( m_dsType == DS_TYPE . INLINE_XML ) ( ( DatastreamXMLMetadata ) m_ds ) . DSMDClass = DSMDClass ; else if ( m_dsType == DS_TYPE . MANAGED ) ( ( DatastreamManagedContent ) m_ds ) . DSMDClass = DSMDClass ; else throw new RuntimeException ( "XML datastreams must be of type M...
Set the DSMDClass of the datastream wrapped by this class
4,511
public Map < RDFName , List < DCField > > getMap ( ) { Map < RDFName , List < DCField > > map = new HashMap < RDFName , List < DCField > > ( 15 ) ; if ( m_titles != null ) map . put ( DC . TITLE , m_titles ) ; if ( m_creators != null ) map . put ( DC . CREATOR , m_creators ) ; if ( m_subjects != null ) map . put ( DC ....
Returns a Map with RDFName keys each value containing List of String values for that field .
4,512
public void setSecuritySpec ( String serviceRoleID , String methodName , Hashtable < String , String > properties ) throws GeneralException { logger . debug ( ">>>>>> setSecuritySpec: " + " serviceRoleID=" + serviceRoleID + " methodName=" + methodName + " property count=" + properties . size ( ) ) ; if ( serviceRoleID ...
Set the security properties at the backend service or for a method of that backend service .
4,513
public Hashtable < String , String > getSecuritySpec ( String serviceRoleID , String methodName ) { if ( serviceRoleID == null || serviceRoleID . isEmpty ( ) ) { return getDefaultSecuritySpec ( ) ; } else if ( methodName == null || methodName . isEmpty ( ) ) { return rolePropertiesTable . get ( serviceRoleID ) ; } else...
Get security properties for either the a backend service or a method within that backend service .
4,514
public static String getElementNodeValue ( Node node ) { StringWriter sw = new StringWriter ( 2000 ) ; if ( node . getNodeType ( ) == Node . ELEMENT_NODE ) { NodeList all = node . getChildNodes ( ) ; for ( int i = 0 ; i < all . getLength ( ) ; i ++ ) { if ( all . item ( i ) . getNodeType ( ) == Node . TEXT_NODE || all ...
Extracts all textual and CDATA content from the given node and its children .
4,515
public static Document stringToDOM ( String xmlString , boolean namespaceAware ) { try { InputSource in = new InputSource ( ) ; in . setCharacterStream ( new StringReader ( xmlString ) ) ; DocumentBuilderFactory dbFact = DocumentBuilderFactory . newInstance ( ) ; dbFact . setNamespaceAware ( namespaceAware ) ; return d...
Parses an XML document from a String to a DOM .
4,516
public static final ReadOnlyContext getContext ( String messageProtocol , String subjectId , String password , boolean noOp ) throws Exception { MultiValueMap < URI > environmentMap = beginEnvironmentMap ( messageProtocol ) ; environmentMap . lock ( ) ; return getContext ( null , environmentMap , subjectId , password ,...
needed only for rebuild
4,517
public static boolean copy ( InputStream source , ByteBuffer destination ) { try { byte [ ] buffer = new byte [ 4096 ] ; int n = 0 ; while ( - 1 != ( n = source . read ( buffer ) ) ) { destination . put ( buffer , 0 , n ) ; } return true ; } catch ( IOException e ) { return false ; } }
This method should only be used when the ByteBuffer is known to be able to accomodate the input!
4,518
public static boolean copy ( File source , File destination ) { boolean result = true ; if ( source . isDirectory ( ) ) { if ( destination . exists ( ) ) { result = result && destination . isDirectory ( ) ; } else { result = result && destination . mkdirs ( ) ; } File [ ] children = source . listFiles ( ) ; for ( File ...
Copy a file or directory .
4,519
public static boolean delete ( File file ) { boolean result = true ; if ( file == null ) { return false ; } if ( file . exists ( ) ) { if ( file . isDirectory ( ) ) { File [ ] children = file . listFiles ( ) ; for ( File child : children ) { result = result && delete ( child ) ; } } result = result && file . delete ( )...
Delete a File .
4,520
public static Map < String , String > loadMap ( File f ) throws IOException { Properties props = new Properties ( ) ; FileInputStream in = new FileInputStream ( f ) ; try { props . load ( in ) ; Map < String , String > map = new HashMap < String , String > ( ) ; Set < Entry < Object , Object > > entrySet = props . entr...
Loads a Map from the given Properties file .
4,521
public void init ( ServletConfig config ) throws ServletException { m_cache = new HashMap < String , Templates > ( ) ; m_creds = new HashMap < String , UsernamePasswordCredentials > ( ) ; m_cManager = new PoolingClientConnectionManager ( ) ; m_cManager . getSchemeRegistry ( ) . register ( new Scheme ( "https" , 443 , S...
Initialize the servlet by setting up the stylesheet cache the http connection manager and configuring credentials for the http client .
4,522
private void apply ( String style , String source , HttpServletRequest req , HttpServletResponse res ) throws Exception { if ( style == null ) { throw new TransformerException ( "No style parameter supplied" ) ; } if ( source == null ) { throw new TransformerException ( "No source parameter supplied" ) ; } InputStream ...
Apply stylesheet to source document
4,523
private Templates tryCache ( String url ) throws Exception { Templates x = ( Templates ) m_cache . get ( url ) ; if ( x == null ) { synchronized ( m_cache ) { if ( ! m_cache . containsKey ( url ) ) { TransformerFactory factory = TransformerFactory . newInstance ( ) ; if ( factory . getClass ( ) . getName ( ) . equals (...
Maintain prepared stylesheets in memory for reuse
4,524
private UsernamePasswordCredentials getCreds ( String url ) throws Exception { url = normalizeURL ( url ) ; url = url . substring ( url . indexOf ( "/" ) + 2 ) ; UsernamePasswordCredentials longestMatch = null ; int longestMatchLength = 0 ; Iterator < String > iter = m_creds . keySet ( ) . iterator ( ) ; while ( iter ....
Return the credentials for the realmPath that most closely matches the given url or null if none found .
4,525
private static String normalizeURL ( String urlString ) throws MalformedURLException { URL url = new URL ( urlString ) ; if ( url . getPort ( ) == - 1 ) { return url . getProtocol ( ) + "://" + url . getHost ( ) + ":" + url . getDefaultPort ( ) + url . getFile ( ) + ( url . getRef ( ) != null ? "#" + url . getRef ( ) :...
Return a URL string in which the port is always specified .
4,526
protected static Document getDocument ( InputStream in ) throws Exception { DocumentBuilder builder = XmlTransformUtility . borrowDocumentBuilder ( ) ; Document doc = null ; try { doc = builder . parse ( in ) ; } finally { XmlTransformUtility . returnDocumentBuilder ( builder ) ; } return doc ; }
Get a new DOM Document object from parsing the specified InputStream .
4,527
public void init ( String type , InputStream data , boolean viewOnly ) throws IOException { setContent ( data ) ; }
Initializes the handler . This should only be called once per instance and is guaranteed to have been called when this component is provided by the ContentHandlerFactory . The viewOnly parameter signals to ContentEditor implementations that editing capabilities are not desired by the caller .
4,528
public void init ( ServletConfig config ) throws ServletException { super . init ( config ) ; m_management = ( Management ) m_server . getModule ( "org.fcrepo.server.management.Management" ) ; if ( m_management == null ) { throw new ServletException ( "Unable to get Management module from server." ) ; } }
Initialize servlet . Gets a reference to the fedora Server object .
4,529
public static List < MethodDefinition > getMethodDefinitions ( String sDefPID ) throws IOException { return MethodDefinition . parse ( Administrator . DOWNLOADER . getDatastreamDissemination ( sDefPID , "METHODMAP" , null ) ) ; }
Get the list of MethodDefinition objects defined by the indicated service definition .
4,530
public static ObjectFields getObjectFields ( String pid , String [ ] fields ) throws IOException { FieldSearchQuery query = new FieldSearchQuery ( ) ; Condition condition = new Condition ( ) ; condition . setProperty ( "pid" ) ; condition . setOperator ( ComparisonOperator . fromValue ( "eq" ) ) ; condition . setValue ...
Get the indicated fields of the indicated object from the repository .
4,531
private final Map < String , String > getFormFields ( Node parent ) { String method = "getFormFields(Node parent)" ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( enter ( method ) ) ; } Map < String , String > formfields = new Hashtable < String , String > ( ) ; getFormFields ( parent , formfields ) ; if ( logg...
initial setup call
4,532
private final void getFormFields ( Node parent , Map < String , String > formfields ) { String method = "getFormFields(Node parent, Map formfields)" ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( enter ( method ) ) ; } NodeList children = parent . getChildNodes ( ) ; for ( int i = 0 ; i < children . getLength ...
inner recursive call
4,533
public void setData ( byte [ ] data ) throws IOException { output = new ByteArrayOutputStream ( ) ; output . write ( data ) ; output . flush ( ) ; setContentLength ( output . size ( ) ) ; }
Sets the body of this response .
4,534
public String getResponseHeaderValue ( String name , String defaultVal ) { if ( m_response . containsHeader ( name ) ) { return m_response . getFirstHeader ( name ) . getValue ( ) ; } else { return defaultVal ; } }
Return the first value of a header or the default if the fighter is not present
4,535
private void addMethodDefTriples ( URIReference objURI , DOReader reader , Set < Triple > set ) throws ResourceIndexException { try { for ( MethodDef element : getAbstractMethods ( reader ) ) { add ( objURI , MODEL . DEFINES_METHOD , element . methodName , set ) ; } } catch ( ResourceIndexException e ) { throw e ; } ca...
Add a defines statement for the given sDef for each abstract method it defines .
4,536
private Map < String , Map < String , String > > parseTransportParameters ( Map < String , String > parameters ) throws JournalException { Map < String , Map < String , String > > allTransports = new LinkedHashMap < String , Map < String , String > > ( ) ; for ( String key : parameters . keySet ( ) ) { if ( isTransport...
Create a Map of Maps holding parameters for all of the transports .
4,537
private Map < String , String > getThisTransportMap ( Map < String , Map < String , String > > allTransports , String transportName ) { if ( ! allTransports . containsKey ( transportName ) ) { allTransports . put ( transportName , new HashMap < String , String > ( ) ) ; } return allTransports . get ( transportName ) ; ...
If we don t yet have a map for this transport name create one .
4,538
private Timer createTimer ( ) { Timer fileTimer = new Timer ( ) ; if ( ageLimit >= 0 ) { fileTimer . schedule ( new CloseFileTimerTask ( ) , ageLimit ) ; } return fileTimer ; }
Create the timer and schedule a task that will let us know when the file is too old to continue . If the age limit is 0 or negative we treat it as no limit .
4,539
public void writeJournalEntry ( CreatorJournalEntry journalEntry , XMLEventWriter writer ) throws JournalException { super . writeJournalEntry ( journalEntry , writer ) ; }
make this public so the TransportRequest class can call it .
4,540
public void writeDocumentHeader ( XMLEventWriter writer , String repositoryHash , Date currentDate ) throws JournalException { super . writeDocumentHeader ( writer , repositoryHash , currentDate ) ; }
make this public so the Transport classes can call it via TransportParent .
4,541
private void sendRequestToAllTransports ( TransportRequest request ) throws JournalException { Map < String , JournalException > crucialExceptions = new LinkedHashMap < String , JournalException > ( ) ; Map < String , JournalException > nonCrucialExceptions = new LinkedHashMap < String , JournalException > ( ) ; for ( ...
Send a request for some operation to the Transports . Send it to all of them even if one or more throws an Exception . Report any exceptions when all Transports have been attempted .
4,542
public MIMETypedStream viewObjectProfile ( ) throws ServerException { try { ObjectProfile profile = m_access . getObjectProfile ( context , reader . GetObjectPID ( ) , asOfDateTime ) ; Reader in = null ; try { ReadableCharArrayWriter out = new ReadableCharArrayWriter ( 1024 ) ; DefaultSerializer . objectProfileToXML ( ...
Returns an HTML rendering of the object profile which contains key metadata from the object plus URLs for the object s Dissemination Index and Item Index . The data is returned as HTML in a presentation - oriented format . This is accomplished by doing an XSLT transform on the XML that is obtained from getObjectProfile...
4,543
public MIMETypedStream viewMethodIndex ( ) throws ServerException { if ( reader . hasContentModel ( Models . SERVICE_DEFINITION_3_0 ) || reader . hasContentModel ( Models . SERVICE_DEPLOYMENT_3_0 ) ) { return noMethodIndexMsg ( ) ; } ObjectMethodsDef [ ] methods = m_access . listMethods ( context , reader . GetObjectPI...
Returns an HTML rendering of the Dissemination Index for the object . The Dissemination Index is a list of method definitions that represent all disseminations possible on the object . The Dissemination Index is returned as HTML in a presentation - oriented format . This is accomplished by doing an XSLT transform on th...
4,544
public MIMETypedStream viewItemIndex ( ) throws ServerException { Reader in = null ; try { ReadableCharArrayWriter out = new ReadableCharArrayWriter ( 4096 ) ; ObjectInfoAsXML . getItemIndex ( reposBaseURL , context . getEnvironmentValue ( Constants . FEDORA_APP_CONTEXT_NAME ) , reader , asOfDateTime , out ) ; out . cl...
Returns an HTML rendering of the Item Index for the object . The Item Index is a list of all datastreams in the object . The datastream items can be data or metadata . The Item Index is returned as HTML in a presentation - oriented format . This is accomplished by doing an XSLT transform on the XML that is obtained fro...
4,545
public MIMETypedStream viewDublinCore ( ) throws ServerException { Datastream dcmd = null ; Reader in = null ; try { ReadableCharArrayWriter out = new ReadableCharArrayWriter ( 512 ) ; dcmd = reader . GetDatastream ( "DC" , asOfDateTime ) ; ObjectInfoAsXML . getOAIDublinCore ( dcmd , out ) ; out . close ( ) ; in = out ...
Returns the Dublin Core record for the object if one exists . The record is returned as HTML in a presentation - oriented format .
4,546
public static MethodDef [ ] reflectMethods ( ) { ArrayList < MethodDef > methodList = new ArrayList < MethodDef > ( ) ; MethodDef method = null ; method = new MethodDef ( ) ; method . methodName = "viewObjectProfile" ; method . methodLabel = "View description of the object" ; method . methodParms = new MethodParmDef [ ...
Method implementation of reflectMethods from the InternalService interface . This will return an array of method definitions that constitute the behaviors of the Default Disseminator which is associated with every Fedora object . These will be the methods promulgated by the DefaultDisseminator interface .
4,547
public static Connection getDefaultConnection ( ServerConfiguration serverConfig ) { ModuleConfiguration poolConfig = serverConfig . getModuleConfiguration ( "org.fcrepo.server.storage.ConnectionPoolManager" ) ; String datastoreID = poolConfig . getParameter ( "defaultPoolName" , Parameter . class ) . getValue ( ) ; Da...
Gets a connection to the database specified in connection pool module s defaultPoolName config value . This allows us to the connect to the database without the server running .
4,548
public void close ( ) { readLock . lock ( ) ; try { if ( container != null ) { try { container . close ( ) ; container = null ; log . info ( "Closed container" ) ; } catch ( XmlException e ) { log . warn ( "close failed: " + e . getMessage ( ) , e ) ; } } if ( manager != null ) { try { manager . close ( ) ; manager = n...
Closes the dbxml container and manager .
4,549
public void addNamespace ( String prefix , String namespaceURI ) { if ( prefix == null || namespaceURI == null ) { throw new IllegalArgumentException ( "null arguments not allowed." ) ; } if ( namespaceURI . equals ( XMLConstants . XML_NS_URI ) ) { throw new IllegalArgumentException ( "Adding a new namespace for " + XM...
Add a prefix to namespace mapping .
4,550
public ValidationResult validate ( ObjectInfo object ) { if ( object == null ) { throw new NullPointerException ( "object may not be null." ) ; } ValidationResult result = new ValidationResult ( object ) ; Collection < String > contentmodels = object . getContentModels ( ) ; if ( contentmodels . size ( ) == 0 ) { resul...
Each object is expected to have at least one content model . Validate each of the content models .
4,551
private void confirmMatchForDsTypeModel ( ValidationResult result , DsTypeModel typeModel , String contentModelPid , ObjectInfo object ) { String id = typeModel . getId ( ) ; DatastreamInfo dsInfo = object . getDatastreamInfo ( id ) ; if ( dsInfo == null ) { result . addNote ( ValidationResultNotation . noMatchingDatas...
The object must have a datastream to match each dsTypeModel in the content model . Matching a dsTypeModel means equal IDs and an acceptable form .
4,552
private boolean meetsConstraint ( String value , String constraint ) { return ( constraint == null ) || constraint . equals ( value ) ; }
If the constraint is not null the value must match it .
4,553
private static File createTempFile ( File baseFile ) { File parentDirectory = baseFile . getParentFile ( ) ; String filename = baseFile . getName ( ) ; return new File ( parentDirectory , '_' + filename ) ; }
Create a temporary File object . Prefix the name of the base file with an underscore .
4,554
public void doGet ( HttpServletRequest request , HttpServletResponse response ) throws IOException , ServletException { String api = request . getParameter ( "api" ) ; if ( api == null || api . length ( ) == 0 ) { response . setContentType ( "text/html; charset=UTF-8" ) ; getIndex ( response . getWriter ( ) ) ; } else ...
Respond to an HTTP GET request . The single parameter api indicates which WSDL file to provide . If no parameters are given a simple HTML index is given instead .
4,555
private void getIndex ( PrintWriter out ) { out . append ( "<html><body>WSDL Index<ul>\n" ) ; Iterator < String > names = _WSDL_PATHS . keySet ( ) . iterator ( ) ; while ( names . hasNext ( ) ) { String name = names . next ( ) ; out . append ( "<li> <a href=\"?api=" + name + "\">" + name + "</a></li>\n" ) ; } out . app...
Get a simple HTML index pointing to each WSDL file provided by the servlet .
4,556
private void getWSDL ( String api , String requestURL , PrintWriter out ) throws IOException , ServletException { String wsdlPath = ( String ) _WSDL_PATHS . get ( api ) ; if ( wsdlPath != null ) { File schemaFile = new File ( _serverDir , _XSD_PATH ) ; File sourceWSDL = new File ( _serverDir , wsdlPath ) ; String baseU...
Get the self - contained WSDL given the api name and request URL .
4,557
private String getFedoraBaseURL ( String requestURL ) throws ServletException { int i = requestURL . lastIndexOf ( _SERVLET_PATH ) ; if ( i != - 1 ) { return requestURL . substring ( 0 , i ) ; } else { throw new ServletException ( "Unable to determine Fedora baseURL " + "from request URL. Request URL does not contain ...
Determine the base URL of the Fedora webapp given the request URL to this servlet .
4,558
public void init ( ) throws ServletException { String fedoraHome = Constants . FEDORA_HOME ; if ( fedoraHome == null || fedoraHome . length ( ) == 0 ) { throw new ServletException ( "FEDORA_HOME is not defined" ) ; } else { _serverDir = new File ( new File ( fedoraHome ) , "server" ) ; if ( ! _serverDir . isDirectory (...
Initialize by setting serverDir based on FEDORA_HOME .
4,559
static Node parseInput ( InputStream input , String rootTag ) throws ParsingException { NodeList nodes = null ; try { DocumentBuilderFactory factory = DocumentBuilderFactory . newInstance ( ) ; factory . setIgnoringComments ( true ) ; DocumentBuilder builder = null ; factory . setNamespaceAware ( true ) ; if ( ipRefere...
Tries to Parse the given output as a Context document .
4,560
private MethodParmDef [ ] getParms ( MethodDef [ ] methods , String methodName ) throws MethodNotFoundException , ServerException { for ( MethodDef element : methods ) { if ( element . methodName . equalsIgnoreCase ( methodName ) ) { return element . methodParms ; } } throw new MethodNotFoundException ( "[getParms] The...
Get the parms out of a particular service method definition .
4,561
public ServerConfiguration copy ( ) throws IOException { ReadableByteArrayOutputStream out = new ReadableByteArrayOutputStream ( ) ; serialize ( out ) ; return new ServerConfigurationParser ( out . toInputStream ( ) ) . parse ( ) ; }
Make an exact copy of this ServerConfiguration .
4,562
public void applyProperties ( Properties props ) { Iterator < ? > iter = props . keySet ( ) . iterator ( ) ; while ( iter . hasNext ( ) ) { String fullName = ( String ) iter . next ( ) ; String value = props . getProperty ( fullName ) . trim ( ) ; if ( fullName . indexOf ( ":" ) != - 1 && value != null && value . lengt...
Apply the given properties to this ServerConfiguration . Trims leading and trailing spaces from the property values before applying them .
4,563
private static String strip ( String in ) { if ( in == null ) { return null ; } String out = in . trim ( ) ; if ( out . length ( ) == 0 ) { return null ; } else { return out ; } }
resulting string is empty in incoming string is null .
4,564
public static void main ( String [ ] args ) throws Exception { if ( args . length < 1 || args . length > 2 ) { throw new IOException ( "One or two arguments expected." ) ; } ServerConfiguration config = new ServerConfigurationParser ( new FileInputStream ( new File ( args [ 0 ] ) ) ) . parse ( ) ; if ( args . length ==...
Deserialize then output the given configuration . If two parameters are given the first one is the filename and the second is the properties file to apply before re - serializing .
4,565
protected StreamSource resolveRepositoryURI ( String path ) throws TransformerException { StreamSource resolvedSource = null ; try { if ( path != null ) { URL url = new URL ( path ) ; InputStream in = url . openStream ( ) ; if ( in != null ) { resolvedSource = new StreamSource ( in ) ; } } else { throw new TransformerE...
Resolves the repository URI .
4,566
public Writer open ( ) throws IOException { switch ( state ) { case OPEN : throw new IllegalStateException ( "File " + tempFile + " is already open." ) ; case CLOSED : throw new IllegalStateException ( "File " + tempFile + " has been closed already." ) ; default : state = State . OPEN ; tempFile . createNewFile ( ) ; f...
Create the file with its in progress filename .
4,567
public void close ( ) throws IOException { switch ( state ) { case READY : throw new IllegalStateException ( "File " + tempFile + " hasn't been opened yet." ) ; case CLOSED : throw new IllegalStateException ( "File " + tempFile + " has been closed already." ) ; default : fileWriter . close ( ) ; tempFile . renameTo ( f...
Close the writer and rename the file .
4,568
public BackendSecuritySpec parseBeSecurity ( ) throws BackendSecurityParserException { try { BackendSecurityDeserializer bsd = new BackendSecurityDeserializer ( m_encoding , m_validate ) ; return bsd . deserialize ( m_beSecurityPath ) ; } catch ( Throwable th ) { throw new BackendSecurityParserException ( "[DefaultBack...
Parses the beSecurity configuration file .
4,569
public void setExtProperty ( String propName , String propValue ) { if ( m_extProperties == null ) { m_extProperties = new HashMap < String , String > ( ) ; } m_extProperties . put ( propName , propValue ) ; }
Sets an extended property on the object .
4,570
public String getExtProperty ( String propName ) { if ( m_extProperties == null ) { return null ; } return m_extProperties . get ( propName ) ; }
Gets an extended property value given the property name .
4,571
public boolean hasRelationship ( PredicateNode predicate , ObjectNode object ) { return hasRelationship ( PID . toURIReference ( m_pid ) , predicate , object ) ; }
assumes m_pid as subject ; ie RELS - EXT only
4,572
public Set < RelationshipTuple > getRelationships ( PredicateNode predicate , ObjectNode object ) { return getRelationships ( PID . toURIReference ( m_pid ) , predicate , object ) ; }
assume m_pid as subject ; ie RELS - EXT only
4,573
private Set < RelationshipTuple > getRels ( String relsDatastreamName ) { List < Datastream > relsDatastreamVersions = m_datastreams . get ( relsDatastreamName ) ; if ( relsDatastreamVersions == null || relsDatastreamVersions . size ( ) == 0 ) { return new HashSet < RelationshipTuple > ( ) ; } Datastream latestRels = r...
Given a relationships datastream name return the relationships contained in that datastream
4,574
public boolean isHostProxyable ( String host ) { return getProxyHost ( ) != null && getProxyPort ( ) > 0 && ( nonProxyPattern == null || ! nonProxyPattern . matcher ( host ) . matches ( ) ) ; }
Checks whether a proxy has been configured and the given host is not in the nonProxyHost list or the nonProxyList is empty .
4,575
public static String fileExtensionForMIMEType ( String mimeType ) { loadMappings ( ) ; String ext = mimeTypeToExtensionMap . get ( mimeType ) ; if ( ext == null ) ext = "dat" ; return ext ; }
Get an appropriate extension for a MIME type .
4,576
private static HashMap < String , String > loadMappings ( ) { HashMap < String , String > mimeTypeToExtensionMap = new HashMap < String , String > ( ) ; String fileSep = System . getProperty ( "file.separator" ) ; StringBuffer buf = new StringBuffer ( ) ; buf . append ( System . getProperty ( "user.home" ) ) ; buf . ap...
Load the MIME type mappings into memory .
4,577
private static void loadMIMETypesFile ( String path ) { try { File f = new File ( path ) ; logger . debug ( "Attempting to load MIME types file \"" + path + "\"" ) ; if ( ! ( f . exists ( ) && f . isFile ( ) ) ) logger . debug ( "Regular file \"" + path + "\" does not exist." ) ; else { LineNumberReader r = new LineNum...
Attempt to load a MIME types file . Throws no exceptions .
4,578
public static String figureIndexedHash ( String repositoryHash , long entryIndex ) { return String . valueOf ( ( entryIndex + repositoryHash ) . hashCode ( ) ) ; }
The writer and the receiver each use this method to figure the hash on each journal entry . If the receiver calculates a different hash from the one that appears on the entry it will throw an exception .
4,579
public String ingest ( Context context , InputStream serialization , String logMessage , String format , String encoding , String pid ) throws ServerException { try { CreatorJournalEntry cje = new CreatorJournalEntry ( METHOD_INGEST , context ) ; cje . addArgument ( ARGUMENT_NAME_SERIALIZATION , serialization ) ; cje ....
Let the delegate do it and then write a journal entry .
4,580
private URIReference addCommonTriples ( DOReader reader , Set < Triple > set ) throws ResourceIndexException { try { URIReference objURI = new SimpleURIReference ( new URI ( PID . toURI ( reader . GetObjectPID ( ) ) ) ) ; addCoreObjectTriples ( reader , objURI , set ) ; Datastream [ ] datastreams = reader . GetDatastre...
Add the common core and datastream triples for the given object .
4,581
private void addDCTriples ( Datastream ds , URIReference objURI , Set < Triple > set ) throws Exception { DCFields dc = new DCFields ( ds . getContentStream ( ) ) ; Map < RDFName , List < DCField > > map = dc . getMap ( ) ; for ( RDFName predicate : map . keySet ( ) ) { for ( DCField dcField : map . get ( predicate ) )...
Add a statement about the object for each predicate value pair expressed in the DC datastream .
4,582
public void doFilter ( ServletRequest request , ServletResponse response , FilterChain filterChain ) throws IOException , ServletException { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Entering FilterRestApiFlash.doThisSubclass()" ) ; } HttpServletRequest httpRequest = ( HttpServletRequest ) request ; HttpSe...
Perform flash client response filtering
4,583
public void copy ( Datastream target ) { target . isNew = isNew ; target . DatastreamID = DatastreamID ; if ( DatastreamAltIDs != null ) { target . DatastreamAltIDs = new String [ DatastreamAltIDs . length ] ; for ( int i = 0 ; i < DatastreamAltIDs . length ; i ++ ) { target . DatastreamAltIDs [ i ] = DatastreamAltIDs ...
Copy this instance into target
4,584
public void println ( String str ) { super . println ( str ) ; if ( Administrator . WATCH_AREA != null ) { String buf = m_out . toString ( ) ; m_out . reset ( ) ; Administrator . WATCH_AREA . append ( buf ) ; } }
Every time this is called the buffer is cleared an output is sent to the JTextArea .
4,585
private void setNumeric ( PreparedStatement stmt , int varIndex , String columnName , String value ) throws SQLException { try { stmt . setInt ( varIndex , Integer . parseInt ( value ) ) ; } catch ( NumberFormatException e ) { try { stmt . setLong ( varIndex , Long . parseLong ( value ) ) ; } catch ( NumberFormatExcept...
Sets a numeric value in the prepared statement . Parsing the string is attempted as an int then a long and if that fails a SQLException is thrown .
4,586
private String getSelector ( String [ ] columns , String [ ] values , String uniqueColumn ) throws SQLException { String selector = null ; for ( int i = 0 ; i < columns . length ; i ++ ) { if ( columns [ i ] . equals ( uniqueColumn ) ) { selector = values [ i ] ; } } if ( selector != null ) { return selector ; } else {...
Gets the value in the given array whose associated column name matches the given uniqueColumn name .
4,587
public static boolean pingServer ( String protocol , String user , String pass ) { try { getServerResponse ( protocol , user , pass , "/describe" ) ; return true ; } catch ( Exception e ) { logger . debug ( "Assuming the server isn't running because " + "describe request failed" , e ) ; return false ; } }
Tell whether the server is running by pinging it as a client .
4,588
public static void reloadPolicies ( String protocol , String user , String pass ) throws IOException { getServerResponse ( protocol , user , pass , "/management/control?action=reloadPolicies" ) ; }
Signals for the server to reload its policies .
4,589
public static boolean isURLFedoraServer ( String url ) { URI uri = URI . create ( url ) ; String scheme = uri . getScheme ( ) ; if ( ! scheme . equals ( "http" ) && ! scheme . equals ( "https" ) ) { return false ; } String fHost = CONFIG . getParameter ( FEDORA_SERVER_HOST , Parameter . class ) . getValue ( ) ; String ...
Tell whether the given URL appears to be referring to somewhere within the Fedora webapp .
4,590
private static boolean getArgBoolean ( String [ ] args , int position , boolean defaultValue ) { if ( args . length > position ) { String lowerArg = args [ position ] . toLowerCase ( ) ; if ( lowerArg . equals ( "true" ) || lowerArg . equals ( "yes" ) ) { return true ; } else if ( lowerArg . equals ( "false" ) || lower...
Get boolean argument from list of arguments at position ; use defaultValue if not present
4,591
public void setHTTPPort ( ) throws InstallationFailedException { Element httpConnector = ( Element ) getDocument ( ) . selectSingleNode ( HTTP_CONNECTOR_XPATH ) ; if ( httpConnector == null ) { throw new InstallationFailedException ( "Unable to set server.xml HTTP Port. XPath for Connector element failed." ) ; } httpCo...
Sets the http port and Fedora default http connector options .
4,592
private void fillNextLine ( ) { try { while ( nextLine == null && ! eof ) { String line = reader . readLine ( ) ; if ( line == null ) { eof = true ; reader . close ( ) ; } else if ( isBlank ( line ) ) { continue ; } else if ( isComment ( line ) ) { continue ; } else { nextLine = line ; } } } catch ( IOException e ) { t...
Scan through the file until we get an EOF or a good line .
4,593
public String getLemma ( ) { StringBuilder builder = new StringBuilder ( ) ; int i = 0 ; for ( TermWord tw : this . term . getWords ( ) ) { if ( i > 0 ) builder . append ( TermSuiteConstants . WHITESPACE ) ; builder . append ( tw . getWord ( ) . getLemma ( ) ) ; i ++ ; } return builder . toString ( ) ; }
Returns the concatenation of inner words lemmas .
4,594
public static AEADBlockCipher getNewCipher ( Mode blockMode ) { AESEngine aesEngine = new AESEngine ( ) ; switch ( blockMode ) { case GCM : return new GCMBlockCipher ( aesEngine ) ; default : throw new RuntimeException ( "Block cipher not found" ) ; } }
Retrieve a new instance of the block mode provided
4,595
public byte [ ] encrypt ( final byte [ ] iv , final byte [ ] message ) throws RuntimeException { AEADParameters aeadParams = new AEADParameters ( new KeyParameter ( key ) , TAG_LENGTH , iv , authData ) ; cipher . init ( true , aeadParams ) ; byte [ ] cipherText = newBuffer ( cipher . getOutputSize ( message . length ) ...
Given the iv encrypt the provided data
4,596
public byte [ ] encrypt ( String iv , String message , Encoder encoder ) { return encrypt ( encoder . decode ( iv ) , encoder . decode ( message ) ) ; }
Given the iv encrypt and encode the provided data
4,597
public void addToMap ( Map < String , String > properties , Map < String , List < Float > > rawHistogramData ) { for ( Entry < String , String > entrySet : properties . entrySet ( ) ) { String key = entrySet . getKey ( ) ; String value = entrySet . getValue ( ) ; try { Float floatValue = Float . parseFloat ( value ) ; ...
Overriding this to weed out the - 999 . 0 values in the dataset
4,598
public void append ( String firstVal , String ... otherVals ) throws IOException { output . append ( firstVal ) ; for ( String v : otherVals ) output . append ( valSep ) . append ( v ) ; output . append ( lineSep ) ; }
Appends a line to the writer . The values are separated using the current separator an line separator is appended at the end .
4,599
public static byte [ ] checkLength ( byte [ ] data , int size ) { if ( data == null ) { throw new IllegalArgumentException ( "Data to check the length of are null." ) ; } if ( data . length < size ) { throw new IllegalArgumentException ( "Invalid length: " + data . length ) ; } return data ; }
Validate the length of the data provided