idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
4,400 | private void advanceIntoFile ( ) throws XMLStreamException , JournalException { XMLEvent event = reader . nextEvent ( ) ; if ( ! event . isStartDocument ( ) ) { throw new JournalException ( "Expecting XML document header, but event was '" + event + "'" ) ; } event = reader . nextTag ( ) ; if ( ! isStartTagEvent ( event... | Advance past the document header to the first JournalEntry . |
4,401 | public synchronized ConsumerJournalEntry readJournalEntry ( ) throws JournalException , XMLStreamException { if ( ! open ) { return null ; } if ( ! advancedPastHeader ) { advanceIntoFile ( ) ; advancedPastHeader = true ; } XMLEvent next = reader . peek ( ) ; while ( next . isCharacters ( ) && next . asCharacters ( ) . ... | Advance past any white space and then see whether we have any more JournalEntry tags . If we don t just return null . |
4,402 | public synchronized void shutdown ( ) throws JournalException { try { if ( open ) { reader . close ( ) ; open = false ; } } catch ( XMLStreamException e ) { throw new JournalException ( e ) ; } } | On the first call Just close the reader . |
4,403 | public String fileToString ( File f ) throws MelcoePDPException { ByteArrayOutputStream out = new ByteArrayOutputStream ( ) ; byte [ ] bytes = new byte [ 1024 ] ; try { FileInputStream fis = new FileInputStream ( f ) ; int count = fis . read ( bytes ) ; while ( count > - 1 ) { out . write ( bytes , 0 , count ) ; count ... | Read file and return contents as a string |
4,404 | public Map < String , String > getDocumentMetadata ( InputStream docIS ) { Map < String , String > metadata = new HashMap < String , String > ( ) ; try { DocumentBuilderFactory factory = DocumentBuilderFactory . newInstance ( ) ; DocumentBuilder docBuilder = factory . newDocumentBuilder ( ) ; Document doc = docBuilder ... | Obtains the metadata for the given document . |
4,405 | public static String getOptionalStringParameter ( Map < String , String > parameters , String parameterName , String defaultValue ) { validateParameters ( parameters ) ; validateParameterName ( parameterName ) ; String value = parameters . get ( parameterName ) ; return value == null ? defaultValue : value ; } | Get an optional String parameter If not found use the default value . |
4,406 | public static boolean getOptionalBooleanParameter ( Map < String , String > parameters , String parameterName , boolean defaultValue ) throws JournalException { validateParameters ( parameters ) ; validateParameterName ( parameterName ) ; String string = parameters . get ( parameterName ) ; if ( string == null ) { retu... | Get an optional boolean parameter . If not found use the default value . |
4,407 | public static File parseParametersForWritableDirectory ( Map < String , String > parameters , String parameterName ) throws JournalException { String directoryString = parameters . get ( parameterName ) ; if ( directoryString == null ) { throw new JournalException ( "'" + parameterName + "' is required." ) ; } File dir... | Look in the parameters for the path to a writable directory . The parameter is required . |
4,408 | public static String parseParametersForFilenamePrefix ( Map < String , String > parameters ) { return getOptionalStringParameter ( parameters , PARAMETER_JOURNAL_FILENAME_PREFIX , DEFAULT_FILENAME_PREFIX ) ; } | Look for a string to use as a prefix for the names of the journal files . Default is fedoraJournal |
4,409 | public void itemStateChanged ( ItemEvent e ) { if ( e . getStateChange ( ) == ItemEvent . DESELECTED ) { m_customPIDField . setEditable ( false ) ; } else if ( e . getStateChange ( ) == ItemEvent . SELECTED ) { m_customPIDField . setEditable ( true ) ; } } | for the checkbox |
4,410 | protected AbstractPolicy handleDocument ( Document doc , PolicyFinder policyFinder ) throws ParsingException { Element root = doc . getDocumentElement ( ) ; String name = root . getTagName ( ) ; if ( name . equals ( "Policy" ) ) { return Policy . getInstance ( root ) ; } else if ( name . equals ( "PolicySet" ) ) { retu... | A private method that handles reading the policy and creates the correct kind of AbstractPolicy . Because this makes use of the policyFinder it cannot be reused between finders . Consider moving to policyManager which is not intended to be reused outside of a policyFinderModule which is not intended to be reused amongs... |
4,411 | protected static String [ ] makeComponents ( String resourceId ) { if ( resourceId == null || resourceId . isEmpty ( ) || ! resourceId . startsWith ( "/" ) ) { return null ; } List < String > components = new ArrayList < String > ( ) ; String [ ] parts = resourceId . split ( "\\/" ) ; int bufPrimer = 0 ; for ( int x = ... | Splits a XACML hierarchical resource - id value into a set of resource - id values that can be matched against a policy . |
4,412 | public String [ ] getDetails ( Locale locale ) { if ( m_details == null || m_details . length == 0 ) { return s_emptyStringArray ; } String [ ] ret = new String [ m_details . length ] ; for ( int i = 0 ; i < m_details . length ; i ++ ) { ret [ i ] = getLocalizedOrCode ( m_bundleName , locale , m_code , null ) ; } retur... | Gets any detail messages preferring the provided locale . |
4,413 | private static String getLocalizedOrCode ( String bundleName , Locale locale , String code , String [ ] values ) { ResourceBundle bundle = null ; if ( bundleName != null ) { bundle = ResourceBundle . getBundle ( bundleName , locale ) ; } if ( bundle == null ) { return code ; } String locMessage = bundle . getString ( c... | Gets the message from the resource bundle formatting it if needed and on failure just returns the code . |
4,414 | public Object invokeAndClose ( ManagementDelegate delegate , JournalWriter writer ) throws ServerException , JournalException { Object result = invokeMethod ( delegate , writer ) ; close ( ) ; return result ; } | A convenience method that invokes the management method and then closes the JournalEntry thereby cleaning up any temp files . |
4,415 | public static Datastream setDatastreamDefaults ( Datastream ds ) throws ObjectIntegrityException { if ( ( ds . DSMIME == null || ds . DSMIME . isEmpty ( ) ) && ds . DSControlGrp . equalsIgnoreCase ( "X" ) ) { ds . DSMIME = "text/xml" ; } if ( ds . DSState == null || ds . DSState . isEmpty ( ) ) { ds . DSState = "A" ; }... | Check for null values in attributes and set them to empty string so null does not appear in XML attribute values . This helps in XML validation of required attributes . If null is the attribute value then validation would incorrectly consider in a valid non - empty value . Also we set some other default values here . |
4,416 | protected static void appendXMLStream ( InputStream in , PrintWriter writer , String encoding ) throws ObjectIntegrityException , UnsupportedEncodingException , StreamIOException { if ( in == null ) { throw new ObjectIntegrityException ( "Object's inline xml " + "stream cannot be null." ) ; } try { InputStreamReader ch... | Appends XML to a PrintWriter . Essentially just appends all text content of the inputStream trimming any leading and trailing whitespace . It does his in a streaming fashion with resource consumption entirely comprised of fixed internal buffers . |
4,417 | protected static void validateAudit ( AuditRecord audit ) throws ObjectIntegrityException { if ( audit . id == null || audit . id . isEmpty ( ) ) { throw new ObjectIntegrityException ( "Audit record must have id." ) ; } if ( audit . date == null ) { throw new ObjectIntegrityException ( "Audit record must have date." ) ... | The audit record is created by the system so programmatic validation here is o . k . Normally validation takes place via XML Schema and Schematron . |
4,418 | public String getValue ( boolean asAbsolutePath ) { String path = m_value ; if ( asAbsolutePath ) { if ( path != null && m_isFilePath ) { File f = new File ( path ) ; if ( ! f . isAbsolute ( ) ) { path = FEDORA_HOME + File . separator + path ; } } } return path ; } | Gets the value of the parameter . Prepends the location of FEDORA_HOME if asAbsolutePath is true and the parameter location does not already specify an absolute pathname . |
4,419 | public void addArgument ( String key , InputStream stream ) throws JournalException { checkOpen ( ) ; if ( stream == null ) { arguments . put ( key , null ) ; } else { try { File tempFile = JournalHelper . copyToTempFile ( stream ) ; arguments . put ( key , tempFile ) ; } catch ( IOException e ) { throw new JournalExce... | If handed an InputStream as an argument copy it to a temp file and store that File in the arguments map instead . If the InputStream is null store null in the arguments map . |
4,420 | public InputStream getStreamArgument ( String name ) throws JournalException { checkOpen ( ) ; File file = ( File ) arguments . get ( name ) ; if ( file == null ) { return null ; } else { try { return new FileInputStream ( file ) ; } catch ( FileNotFoundException e ) { throw new JournalException ( e ) ; } } } | If they ask for an InputStream argument get the File from the arguments map and create an InputStream on that file . If the value from the map is null return null . |
4,421 | public void close ( ) { checkOpen ( ) ; open = false ; for ( Object arg : arguments . values ( ) ) { if ( arg instanceof File ) { File file = ( File ) arg ; if ( JournalHelper . isTempFile ( file ) ) { if ( file . exists ( ) ) { file . delete ( ) ; } } } } } | This should be called when usage of the object is complete to clean up any temporary files that were created for the journal entry to use . |
4,422 | private File createTempFilename ( File permanentFile , File journalDirectory ) { String tempFilename = "_" + permanentFile . getName ( ) ; File file2 = new File ( journalDirectory , tempFilename ) ; return file2 ; } | The temporary filename is the permanent name preceded by an underscore . |
4,423 | private FileWriter createTempFile ( File tempfile ) throws IOException , JournalException { boolean created = tempfile . createNewFile ( ) ; if ( ! created ) { throw new JournalException ( "Unable to create file '" + tempfile . getPath ( ) + "'." ) ; } return new FileWriter ( tempfile ) ; } | Create and open the temporary file . |
4,424 | private XMLEventWriter createXmlEventWriter ( FileWriter fileWriter ) throws FactoryConfigurationError , XMLStreamException { XMLOutputFactory factory = XMLOutputFactory . newInstance ( ) ; return new IndentingXMLEventWriter ( factory . createXMLEventWriter ( fileWriter ) ) ; } | Create an XMLEventWriter for this file . Make it a pretty indenting writer . |
4,425 | public void closeIfAppropriate ( ) throws JournalException { synchronized ( JournalWriter . SYNCHRONIZER ) { if ( ! open ) { return ; } long currentSize = tempFile . length ( ) ; if ( sizeLimit > 0 && currentSize > sizeLimit ) { close ( ) ; } } } | Check the size limit and see whether the file is big enough to close . We could also check the age limit here but we trust the timer to handle that . |
4,426 | public void close ( ) throws JournalException { synchronized ( JournalWriter . SYNCHRONIZER ) { if ( ! open ) { return ; } try { parent . getDocumentTrailer ( xmlWriter ) ; xmlWriter . close ( ) ; fileWriter . close ( ) ; timer . cancel ( ) ; try { FileMovingUtil . move ( tempFile , file ) ; } catch ( IOException e ) {... | Write the document trailer clean up everything and rename the file . Set the flag saying we are closed . |
4,427 | @ SuppressWarnings ( "unchecked" ) public Result combine ( EvaluationCtx context , @ SuppressWarnings ( "rawtypes" ) List parameters , @ SuppressWarnings ( "rawtypes" ) List policyElements ) { logger . info ( "Combining using: " + getIdentifier ( ) ) ; boolean atLeastOneError = false ; boolean atLeastOnePermit = false ... | Applies the combining rule to the set of policies based on the evaluation context . |
4,428 | private Object invokeTarget ( Object target , Method method , Object [ ] args ) throws Throwable { Object returnValue ; try { returnValue = method . invoke ( target , args ) ; } catch ( InvocationTargetException ite ) { throw ite . getTargetException ( ) ; } return returnValue ; } | Invoke the underlying method catching any InvocationTargetException and rethrowing the target exception |
4,429 | private void deletePolicy ( String pid ) throws GeneralException { LOG . debug ( "Deleting policy " + pid ) ; try { m_policyIndex . deletePolicy ( pid ) ; } catch ( PolicyIndexException e ) { throw new GeneralException ( "Error deleting policy " + pid + " from policy index: " + e . getMessage ( ) , e ) ; } } | Remove the specified policy from the cache |
4,430 | private final static int defaultPort ( String scheme ) { if ( scheme == null ) { return - 1 ; } Integer port = defaultPorts . get ( scheme . trim ( ) . toLowerCase ( ) ) ; return ( port != null ) ? port . intValue ( ) : - 1 ; } | Return the default port used by a given scheme . |
4,431 | public String describeAllowedMimeTypes ( ) { if ( bindingMIMETypes == null || bindingMIMETypes . length == 0 ) { return ANY_MIME_TYPE ; } StringBuffer out = new StringBuffer ( ) ; for ( int i = 0 ; i < bindingMIMETypes . length ; i ++ ) { String allowed = bindingMIMETypes [ i ] ; if ( allowed == null ) { return ANY_MIM... | In human readable string describe which mime types are allowed . |
4,432 | public void postInitModule ( ) throws ModuleInitializationException { ManagementDelegate delegate = serverInterface . getManagementDelegate ( ) ; if ( delegate == null ) { throw new ModuleInitializationException ( "Can't get a ManagementDelegate from Server.getModule()" , getRole ( ) ) ; } worker . setManagementDelegat... | Get the ManagementDelegate module and pass it to the worker . |
4,433 | private void copyPropertiesOverParameters ( Map < String , String > parameters ) { Properties properties = System . getProperties ( ) ; for ( Object object : properties . keySet ( ) ) { String key = ( String ) object ; if ( key . startsWith ( SYSTEM_PROPERTY_PREFIX ) ) { parameters . put ( key . substring ( SYSTEM_PROP... | Augment and perhaps override the server parameters using any System Property whose name begins with fedora . journal . . So for example a System Property of fedora . journal . mode will override a server parameter of mode . |
4,434 | private void parseParameters ( Map < String , String > parameters ) throws ModuleInitializationException { logger . info ( "Parameters: " + parameters ) ; String mode = parameters . get ( PARAMETER_JOURNAL_MODE ) ; if ( mode == null ) { inRecoveryMode = false ; } else if ( mode . equals ( VALUE_JOURNAL_MODE_NORMAL ) ) ... | Check the parameters for required values and for acceptable values . At this point the only parameter we care about is mode . |
4,435 | public static JournalReader getInstance ( Map < String , String > parameters , String role , JournalRecoveryLog recoveryLog , ServerInterface server ) throws ModuleInitializationException { try { Object journalReader = JournalHelper . createInstanceAccordingToParameter ( PARAMETER_JOURNAL_READER_CLASSNAME , new Class [... | Create an instance of the proper JournalReader child class as determined by the server parameters . |
4,436 | protected void checkRepositoryHash ( String hash ) throws JournalException { if ( ! server . hasInitialized ( ) ) { throw new IllegalStateException ( "The repository has is not available until " + "the server is fully initialized." ) ; } JournalException hashException = null ; if ( hash == null ) { hashException = new ... | Compare the repository hash from the journal file with the current hash obtained from the server . If they do not match either throw an exception or simply log it depending on the parameters . This method must not be called before the server has completed initialization . That s the only way we can be confident that th... |
4,437 | private StartElement getJournalEntryStartTag ( XMLEventReader reader ) throws XMLStreamException , JournalException { XMLEvent event = reader . nextTag ( ) ; if ( ! isStartTagEvent ( event , QNAME_TAG_JOURNAL_ENTRY ) ) { throw getNotStartTagException ( QNAME_TAG_JOURNAL_ENTRY , event ) ; } return event . asStartElement... | Get the next event and complain if it isn t a JournalEntry start tag . |
4,438 | private void readArguments ( XMLEventReader reader , ConsumerJournalEntry cje ) throws XMLStreamException , JournalException { while ( true ) { XMLEvent nextTag = reader . nextTag ( ) ; if ( isStartTagEvent ( nextTag , QNAME_TAG_ARGUMENT ) ) { readArgument ( nextTag , reader , cje ) ; } else if ( isEndTagEvent ( nextTa... | Read arguments and add them to the event until we hit the end tag for the event . |
4,439 | private void readStreamArgument ( XMLEventReader reader , ConsumerJournalEntry journalEntry , String name ) throws XMLStreamException , JournalException { try { File tempFile = JournalHelper . createTempFile ( ) ; DecodingBase64OutputStream decoder = new DecodingBase64OutputStream ( new FileOutputStream ( tempFile ) ) ... | An InputStream argument appears as a Base64 - encoded String . It must be decoded and written to a temp file so it can be presented to the management method as an InputStream again . |
4,440 | private JournalException getUnexpectedEventInArgumentException ( String name , String argumentType , String methodName , XMLEvent event ) { return new JournalException ( "Unexpected event while processing '" + name + "' argument (type = '" + argumentType + "') for '" + methodName + "' method call: event is '" + event +... | If we encounter an unexpected event when reading the a method argument create an exception with all of the pertinent information . |
4,441 | public void addDatastream ( Datastream datastream , boolean addNewVersion ) throws ServerException { assertNotInvalidated ( ) ; assertNotPendingRemoval ( ) ; m_obj . addDatastreamVersion ( datastream , addNewVersion ) ; } | Adds a datastream to the object . |
4,442 | public Date [ ] removeDatastream ( String id , Date start , Date end ) throws ServerException { assertNotInvalidated ( ) ; assertNotPendingRemoval ( ) ; ArrayList < Datastream > removeList = new ArrayList < Datastream > ( ) ; for ( Datastream ds : m_obj . datastreams ( id ) ) { boolean doRemove = false ; if ( start != ... | Removes a datastream from the object . |
4,443 | private String resolveSubjectToDatastream ( String subject ) throws ServerException { String pidURI = PID . toURI ( m_obj . getPid ( ) ) ; if ( subject . startsWith ( pidURI ) ) { if ( subject . length ( ) == pidURI . length ( ) ) { return "RELS-EXT" ; } if ( subject . charAt ( pidURI . length ( ) ) == '/' ) { return "... | from the relationship subject determine which datastream to modify etc |
4,444 | public void commit ( String logMessage ) throws ServerException { assertNotInvalidated ( ) ; m_mgr . doCommit ( Server . USE_DEFINITIVE_STORE , m_context , m_obj , logMessage , m_pendingRemoval ) ; m_committed = true ; invalidate ( ) ; } | Saves the changes thus far to the permanent copy of the digital object . |
4,445 | public void write ( char [ ] cbuf , int off , int len ) throws IOException { try { String indexedHash = RmiJournalReceiverHelper . figureIndexedHash ( repositoryHash , itemIndex ) ; receiver . writeText ( indexedHash , new String ( cbuf , off , len ) ) ; itemIndex ++ ; } catch ( JournalException e ) { throw new IOExcep... | Each time characters are written send them to the receiver . Keep track of how many writes so we can create a proper item hash . |
4,446 | public void close ( ) throws IOException { try { if ( ! m_closed ) { receiver . closeFile ( ) ; m_closed = true ; } } catch ( JournalException e ) { throw new IOException ( e ) ; } } | Time to close the file? Tell the receiver . |
4,447 | @ SuppressWarnings ( "unchecked" ) public static Map < String , Set < String > > getAttributes ( Subject subject ) { Map < String , Set < String > > attributes = null ; if ( subject . getPublicCredentials ( ) == null ) { return new HashMap < String , Set < String > > ( ) ; } @ SuppressWarnings ( "rawtypes" ) Iterator <... | Get the attribute map of String keys to Set< ; String> ; values This method will not return a null |
4,448 | public void closeAndRename ( File archiveDirectory ) throws JournalException { try { xmlReader . close ( ) ; fileReader . close ( ) ; File archiveFile = new File ( archiveDirectory , file . getName ( ) ) ; try { FileMovingUtil . move ( file , archiveFile ) ; } catch ( IOException e ) { throw new JournalException ( "Fai... | When we have processed the file move it to the archive directory . |
4,449 | public void doNew ( String [ ] dropdownMimeTypes , boolean makeSelected ) { int i = getTabIndex ( "New..." ) ; m_tabbedPane . setComponentAt ( i , new NewDatastreamPane ( dropdownMimeTypes ) ) ; i = getTabIndex ( "New..." ) ; m_tabbedPane . setToolTipTextAt ( i , "Add a new datastream to this object" ) ; m_tabbedPane .... | Set the content of the New ... JPanel to a fresh new datastream entry panel and switch to it if needed . |
4,450 | public void updateNewRelsExt ( String pid ) throws Exception { if ( ! hasRelsExt ( ) && getTabIndex ( "New RELS-EXT..." ) == - 1 ) { m_tabbedPane . insertTab ( "New RELS-EXT..." , newIcon , new NewRelsExtDatastreamPane ( m_owner , pid , this ) , "Add a RELS-EXT datastream to this object" , getTabIndex ( "New..." ) ) ; ... | Set the content of the New Rels - Ext ... JPanel to a fresh new datastream entry panel and switch to it if needed . |
4,451 | private int getDatastreamPaneIndex ( String id ) { int index = - 1 ; for ( int i = 0 ; i < m_datastreamPanes . length ; i ++ ) { if ( m_datastreamPanes [ i ] . getItemId ( ) . equals ( id ) ) { index = i ; break ; } } return index ; } | Gets the index of the pane containing the datastream with the given id . |
4,452 | protected void refresh ( String dsID ) { int i = getTabIndex ( dsID ) ; try { List < Datastream > versions = Administrator . APIM . getDatastreamHistory ( m_pid , dsID ) ; m_currentVersionMap . put ( dsID , versions . get ( i ) ) ; logger . debug ( "New create date is: " + versions . get ( i ) . getCreateDate ( ) ) ; D... | Refresh the content of the tab for the indicated datastream with the latest information from the server . |
4,453 | protected void addDatastreamTab ( String dsID , boolean reInitNewPanel ) throws Exception { DatastreamPane [ ] newArray = new DatastreamPane [ m_datastreamPanes . length + 1 ] ; for ( int i = 0 ; i < m_datastreamPanes . length ; i ++ ) { newArray [ i ] = m_datastreamPanes [ i ] ; } List < Datastream > versions = Admini... | Add a new tab with a new datastream . |
4,454 | private void loginForm ( HttpServletResponse response ) throws IOException { response . reset ( ) ; response . addHeader ( "WWW-Authenticate" , "Basic realm=\"!!Fedora Repository Server\"" ) ; response . setStatus ( HttpServletResponse . SC_UNAUTHORIZED ) ; OutputStream out = response . getOutputStream ( ) ; out . writ... | Sends a 401 error to the browser . This forces a login box to be displayed allowing the user to login . |
4,455 | private Subject authenticate ( HttpServletRequest req ) { String authorization = req . getHeader ( "authorization" ) ; if ( authorization == null || authorization . trim ( ) . isEmpty ( ) ) { return null ; } Subject subject = ( Subject ) req . getSession ( ) . getAttribute ( authorization ) ; if ( subject != null ) { r... | Performs the authentication . Once a Subject is obtained it is stored in the users session . Subsequent requests check for the existence of this object before performing the authentication again . |
4,456 | private Principal getUserPrincipal ( Subject subject ) { Principal userPrincipal = null ; Set < Principal > principals = subject . getPrincipals ( ) ; if ( userClassNames != null && userClassNames . size ( ) > 0 ) { for ( Principal p : principals ) { if ( userPrincipal == null && userClassNames . contains ( p . getClas... | Given a subject obtain the userPrincipal from it . The user principal is defined by a Principal class that can be defined in the web . xml file . If this is undefined the first principal found is assumed to be the userPrincipal . |
4,457 | private Set < String > getUserRoles ( Subject subject ) { Set < String > userRoles = null ; Set < Principal > principals = subject . getPrincipals ( ) ; if ( roleClassNames != null && roleClassNames . size ( ) > 0 ) { for ( Principal p : principals ) { if ( roleClassNames . contains ( p . getClass ( ) . getName ( ) ) )... | Obtains the roles for the user based on the class names and attribute names provided in the web . xml file . |
4,458 | private void addRolesToSubject ( Subject subject , Set < String > userRoles ) { if ( userRoles == null ) { userRoles = Collections . emptySet ( ) ; } Map < String , Set < String > > attributes = SubjectUtils . getAttributes ( subject ) ; Set < String > roles = attributes . get ( ROLE_KEY ) ; if ( roles == null ) { role... | Adds roles to the Subject object . |
4,459 | private void populateFedoraAttributes ( Subject subject , Set < String > userRoles , HttpServletRequest request ) { Map < String , Set < String > > attributes = SubjectUtils . getAttributes ( subject ) ; Set < String > roles = attributes . get ( FEDORA_ROLE_KEY ) ; if ( roles == null ) { roles = new HashSet < String > ... | Add roles and other subject attributes where Fedora expects them - a Map called FEDORA_AUX_SUBJECT_ATTRIBUTES . Roles will be put in fedoraRole and others will be named as - is . |
4,460 | private void denyAccess ( HttpServletResponse response , String message ) throws IOException { StringBuilder sb = new StringBuilder ( ) ; sb . append ( "Fedora: 403 " ) . append ( message . toUpperCase ( ) ) ; response . reset ( ) ; response . setStatus ( HttpServletResponse . SC_FORBIDDEN ) ; response . setContentType... | Outputs an access denied message . |
4,461 | private void loginForm ( HttpServletResponse response ) { response . reset ( ) ; response . addHeader ( "WWW-Authenticate" , "Basic realm=\"!!Fedora Repository Server\"" ) ; response . setStatus ( HttpServletResponse . SC_UNAUTHORIZED ) ; } | Sends a 401 error to the browser . This forces a login screen to be displayed allowing the user to login . |
4,462 | public void shutdown ( ) throws ModuleShutdownException { try { consumerThread . shutdown ( ) ; reader . shutdown ( ) ; recoveryLog . shutdown ( "Server is shutting down." ) ; } catch ( JournalException e ) { throw new ModuleShutdownException ( "Error closing journal reader." , role , e ) ; } } | Tell the thread the reader and the log to shut down . |
4,463 | public static PID getInstance ( String pidString ) { try { return new PID ( pidString ) ; } catch ( MalformedPIDException e ) { throw new FaultException ( "Malformed PID: " + e . getMessage ( ) , e ) ; } } | Factory method that throws an unchecked exception if it s not well - formed . |
4,464 | public static String normalize ( String pidString ) throws MalformedPIDException { if ( pidString == null ) { throw new MalformedPIDException ( "PID is null." ) ; } return normalize ( pidString , 0 , pidString . length ( ) ) ; } | Return the normalized form of the given pid string or throw a MalformedPIDException . |
4,465 | public static SimpleURIReference toURIReference ( String pidString ) { SimpleURIReference ref = null ; try { ref = new SimpleURIReference ( new URI ( toURI ( pidString ) ) ) ; } catch ( URISyntaxException e ) { throw new Error ( e ) ; } return ref ; } | Return a URIReference of some PID string assuming it is well - formed . |
4,466 | public static void main ( String [ ] args ) throws Exception { if ( args . length > 0 ) { PID p = new PID ( args [ 0 ] ) ; System . out . println ( "Normalized : " + p . toString ( ) ) ; System . out . println ( "To filename : " + p . toFilename ( ) ) ; System . out . println ( "From filename : " + PID . fromFilen... | Command - line interactive tester . If one arg given prints normalized form of that PID and exits . If no args enters interactive mode . |
4,467 | private ObjectFields getObjectFields ( String pid ) throws UnrecognizedFieldException , ObjectIntegrityException , RepositoryConfigurationException , StreamIOException , ServerException { DOReader r = m_repoReader . getReader ( Server . USE_DEFINITIVE_STORE , ReadOnlyContext . EMPTY , pid ) ; ObjectFields f ; Datastrea... | For the given pid get a reader on the object from the repository and return an ObjectFields object with resultFields fields populated . |
4,468 | private static final boolean isDCProp ( String in ) { if ( in . equals ( "mDate" ) || in . equals ( "dcmDate" ) ) { return false ; } for ( String n : FieldSearchSQLImpl . DB_COLUMN_NAMES ) { if ( n . startsWith ( "dc" ) && n . toLowerCase ( ) . indexOf ( in . toLowerCase ( ) ) == 2 ) { return true ; } } return false ; ... | Tell whether a field name as given in the search request is a dublin core field . |
4,469 | public Set < Triple > getTriplesForObject ( DOReader reader ) throws ResourceIndexException { Set < Triple > objectTriples = new HashSet < Triple > ( ) ; try { for ( String modelRelobject : reader . getContentModels ( ) ) { if ( m_generators . containsKey ( modelRelobject ) ) { objectTriples . addAll ( m_generators . g... | Gets all triples implied by the object s models . |
4,470 | public void validate ( StreamSource objectSource ) throws ServerException { DOValidatorSchematronResult result = null ; try { Transformer vtransformer = validatingStyleSheet . newTransformer ( ) ; DOMResult validationResult = new DOMResult ( ) ; vtransformer . transform ( objectSource , validationResult ) ; result = ne... | Run the Schematron validation on a Fedora object . |
4,471 | private Templates setUp ( String preprocessorPath , String fedoraschemaPath , String phase ) throws ObjectValidityException , TransformerException { String key = fedoraschemaPath + "#" + phase ; Templates templates = generatedStyleSheets . get ( key ) ; if ( templates == null ) { rulesSource = fileToStreamSource ( fedo... | Run setup to prepare for Schematron validation . This entails dynamically creating the validating stylesheet using the preprocessor and the schema . |
4,472 | private Templates createValidatingStyleSheet ( StreamSource rulesSource , StreamSource preprocessorSource , String phase ) throws ObjectValidityException , TransformerException { ReadableCharArrayWriter out = new ReadableCharArrayWriter ( 4096 ) ; try { Transformer ptransformer = XmlTransformUtility . getTransformer ( ... | Create the validating stylesheet which will be used to perform the actual Schematron validation . The validating stylesheet is created dynamically using the preprocessor stylesheet and the Schematron schema for Fedora . The phase is key . The stylesheet is created for the appropriate phase as specified in the Schematro... |
4,473 | public boolean exists ( String pid ) throws LowlevelStorageException { Connection connection = null ; PreparedStatement statement = null ; ResultSet rs = null ; try { connection = connectionPool . getReadOnlyConnection ( ) ; statement = connection . prepareStatement ( selectByIdQuery ) ; statement . setString ( 1 , pid... | Checks to see whether a pid exists in the registry . Makes no audits of the number of registrations or the paths registered . |
4,474 | private void setObjectDefaults ( DigitalObject obj ) { if ( obj . getCreateDate ( ) == null ) obj . setCreateDate ( m_now ) ; if ( obj . getLastModDate ( ) == null ) obj . setLastModDate ( m_now ) ; Iterator < String > dsIds = obj . datastreamIdIterator ( ) ; while ( dsIds . hasNext ( ) ) { String dsid = dsIds . next (... | - Sets datastream sizes to 0 |
4,475 | public static void main ( String [ ] args ) throws ClassNotFoundException { LogConfig . initMinimal ( ) ; if ( args . length < 4 || args . length > 7 ) { die ( "Expected 4 to 7 arguments" , true ) ; } File sourceDir = new File ( args [ 0 ] ) ; if ( ! sourceDir . isDirectory ( ) ) { die ( "Not a directory: " + sourceDir... | Command - line utility to convert objects from one format to another . |
4,476 | private String objectToString ( Object obj , String xsdType ) { if ( obj == null ) { return "null" ; } String javaType = obj . getClass ( ) . getCanonicalName ( ) ; String term ; if ( javaType != null && javaType . equals ( "java.util.Date" ) ) { term = DateUtility . convertDateToXSDString ( ( Date ) obj ) ; } else if ... | Get the String value of an object based on its class or XML Schema Datatype . |
4,477 | private void encodeAttributes ( List attributes , PrintStream out , Indenter indenter ) { Iterator it = attributes . iterator ( ) ; while ( it . hasNext ( ) ) { Attribute attr = ( Attribute ) ( it . next ( ) ) ; attr . encode ( out , indenter ) ; } } | Private helper function to encode the attribute sets |
4,478 | private void encodeSubject ( Subject subject , PrintStream out , Indenter indenter ) { char [ ] indent = indenter . makeString ( ) . toCharArray ( ) ; out . print ( indent ) ; out . append ( "<Subject SubjectCategory=\"" ) . append ( subject . getCategory ( ) . toString ( ) ) . append ( '"' ) ; List subjectAttrs = subj... | Private helper function to encode the subjects |
4,479 | public void init ( FilterConfig filterConfig ) { String m = "L init() " ; try { logger . debug ( m + ">" ) ; super . init ( filterConfig ) ; m = FilterSetup . getFilterNameAbbrev ( FILTER_NAME ) + " init() " ; inited = false ; if ( ! initErrors ) { Set < String > temp = new HashSet < String > ( ) ; if ( ATTRIBUTES2RETU... | public Boolean REQUIRE_RETURNED_ATTRS = Boolean . FALSE ; |
4,480 | public String upload ( final File file ) throws IOException { if ( Administrator . INSTANCE == null ) { return fc . uploadFile ( file ) ; } else { String msg = "Uploading " + file . length ( ) + " bytes to " + fc . getUploadURL ( ) ; Dimension d = Administrator . PROGRESS . getSize ( ) ; Administrator . PROGRESS . setS... | Send a file to the server getting back the identifier . |
4,481 | public static void main ( String [ ] args ) { try { if ( args . length == 5 || args . length == 6 ) { String protocol = args [ 0 ] ; int port = Integer . parseInt ( args [ 1 ] ) ; String user = args [ 2 ] ; String password = args [ 3 ] ; String fileName = args [ 4 ] ; String context = Constants . FEDORA_DEFAULT_APP_CON... | Test this class by uploading the given file three times . First with the provided credentials as an InputStream . Second with the provided credentials as a File . Third with bogus credentials as a File . |
4,482 | private File getFedoraHomeDir ( ) throws ServletException { String fedoraHome = Constants . FEDORA_HOME ; if ( fedoraHome == null ) { failStartup ( "FEDORA_HOME was not configured properly. It must be " + "set via the fedora.home servlet init-param (preferred), " + "the fedora.home system property, or the FEDORA_HOME ... | Validates and returns the value of FEDORA_HOME . |
4,483 | public Validation validate ( Context context , String pid , Date asOfDateTime ) throws ServerException { try { logger . debug ( "Entered validate" ) ; m_authz . enforceValidate ( context , pid , asOfDateTime ) ; return ecmValidator . validate ( context , pid , asOfDateTime ) ; } finally { if ( logger . isInfoEnabled ( ... | Validate the object against the datacontracts from the objects content model . This method just delegates the validation to EcmValidator |
4,484 | private void addAuditRecord ( Context context , DOWriter w , String action , String componentID , String justification , Date nowUTC ) throws ServerException { AuditRecord audit = new AuditRecord ( ) ; audit . id = w . newAuditRecordID ( ) ; audit . processType = "Fedora API-M" ; audit . action = action ; audit . compo... | Creates a new audit record and adds it to the digital object audit trail . |
4,485 | private static void appendAltIDs ( StringBuilder logMsg , String [ ] altIDs ) { logMsg . append ( ", altIDs: " ) ; if ( altIDs == null ) { logMsg . append ( "null" ) ; } else { for ( String altID : altIDs ) { logMsg . append ( "'" ) . append ( altID ) . append ( "'" ) ; } } } | Appends alt IDs to the log message . |
4,486 | public void setValidators ( Map < String , ? extends DOObjectValidator > validators ) { logger . info ( "Adding {} object validators" , validators . size ( ) ) ; m_validators . putAll ( validators ) ; if ( m_validators . size ( ) > 0 ) { m_enabled = true ; } } | spring config of the validators |
4,487 | public void install ( ) throws InstallationFailedException { installDir . mkdirs ( ) ; try { OutputStream out = new FileOutputStream ( new File ( installDir , "install.properties" ) ) ; _opts . dump ( out ) ; out . close ( ) ; } catch ( Exception e ) { throw new InstallationFailedException ( e . getMessage ( ) , e ) ; ... | Install the distribution based on the options . |
4,488 | public static void main ( String [ ] args ) { LogConfig . initMinimal ( ) ; try { Distribution dist = new ClassLoaderDistribution ( ) ; InstallOptions opts = null ; if ( args . length == 0 ) { opts = new InstallOptions ( dist ) ; } else { Map < String , String > props = new HashMap < String , String > ( ) ; for ( Strin... | Command - line entry point . |
4,489 | private static void printException ( Exception e ) { if ( e instanceof InstallationCancelledException ) { System . out . println ( "Installation cancelled." ) ; return ; } boolean recognized = false ; String msg = "ERROR: " ; if ( e instanceof InstallationFailedException ) { msg += "Installation failed: " + e . getMess... | Print a message appropriate for the given exception in as human - readable way as possible . |
4,490 | public void run ( ) { try { waitUntilServerIsInitialized ( ) ; recoveryLog . log ( "Start recovery." ) ; while ( true ) { if ( shutdown ) { break ; } ConsumerJournalEntry cje = reader . readJournalEntry ( ) ; if ( cje == null ) { break ; } cje . invokeMethod ( delegate , recoveryLog ) ; cje . close ( ) ; } reader . shu... | Wait until the server completes its initialization then process journal entries until the reader says there are no more or until a shutdown is requested . |
4,491 | private void waitUntilServerIsInitialized ( ) { int i = 0 ; for ( ; i < 60 ; i ++ ) { if ( server . hasInitialized ( ) || shutdown ) { return ; } try { Thread . sleep ( 1000 ) ; } catch ( InterruptedException e ) { logger . warn ( "Thread was interrupted" ) ; } } logger . error ( "Can't recover from the Journal - " + "... | Wait for the server to initialize . If we wait too long give up and shut down the thread . |
4,492 | private static Schema getSchema ( InputStream schemaStream ) throws SAXException { Schema result ; synchronized ( SCHEMA_FACTORY ) { result = SCHEMA_FACTORY . newSchema ( new StreamSource ( schemaStream ) ) ; } return result ; } | Schema Factory is not thread safe |
4,493 | public AbstractPolicy parse ( InputStream policyStream , boolean schemaValidate ) throws ValidationException { Document doc = null ; DocumentBuilder domParser = null ; try { domParser = XmlTransformUtility . borrowDocumentBuilder ( ) ; domParser . setErrorHandler ( THROW_ALL ) ; doc = domParser . parse ( policyStream )... | Parses the given policy and optionally schema validates it . |
4,494 | public void exportAndBind ( ) throws RemoteException , AlreadyBoundException , InterruptedException { Registry registry = LocateRegistry . createRegistry ( arguments . getRegistryPortNumber ( ) ) ; registry . rebind ( RMI_BINDING_NAME , this ) ; Thread . sleep ( 2000 ) ; logger . info ( "RmiJournalReceiver is ready - j... | Create an RMI registry and bind this object to the expected name . |
4,495 | private void updateTriples ( Set < Triple > set , boolean delete ) throws ResourceIndexException { try { if ( delete ) { _writer . delete ( getTripleIterator ( set ) , _syncUpdates ) ; } else { _writer . add ( getTripleIterator ( set ) , _syncUpdates ) ; } } catch ( Exception e ) { throw new ResourceIndexException ( "E... | Applies the given adds or deletes to the triplestore . If _syncUpdates is true changes will be flushed before returning . |
4,496 | private void updateTripleDiffs ( Set < Triple > existing , Set < Triple > desired ) throws ResourceIndexException { HashSet < Triple > obsoleteTriples = new HashSet < Triple > ( existing ) ; obsoleteTriples . removeAll ( desired ) ; updateTriples ( obsoleteTriples , true ) ; HashSet < Triple > newTriples = new HashSet ... | Computes the difference between the given sets and applies the appropriate deletes and adds to the triplestore . If _syncUpdates is true changes will be flushed before returning . |
4,497 | private TripleIterator getTripleIterator ( final Set < Triple > set ) { return new TripleIterator ( ) { private final Iterator < Triple > _iter = set . iterator ( ) ; public boolean hasNext ( ) { return _iter . hasNext ( ) ; } public Triple next ( ) { return getLocalizedTriple ( _iter . next ( ) ) ; } public void close... | Gets a Trippi TripleIterator for the given set . |
4,498 | private Triple getLocalizedTriple ( Triple triple ) { try { return _connector . getElementFactory ( ) . createTriple ( getLocalizedResource ( triple . getSubject ( ) ) , getLocalizedResource ( triple . getPredicate ( ) ) , getLocalizedObject ( triple . getObject ( ) ) ) ; } catch ( GraphElementFactoryException e ) { th... | Gets a Triple appropriate for writing to the store . |
4,499 | private URIReference getLocalizedResource ( Node n ) throws GraphElementFactoryException { if ( n instanceof URIReference ) { URIReference u = ( URIReference ) n ; return _connector . getElementFactory ( ) . createResource ( u . getURI ( ) ) ; } else { throw new RuntimeException ( "Error localizing triple; " + n . getC... | Gets a localized URIReference based on the given Node . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.