id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
9,200
fcrepo3/fcrepo
fcrepo-common/src/main/java/org/fcrepo/common/rdf/JRDF.java
JRDF.sameSubject
public static boolean sameSubject(SubjectNode s1, String s2) { if (s1 instanceof URIReference) { return sameResource((URIReference) s1, s2); } else { return false; } }
java
public static boolean sameSubject(SubjectNode s1, String s2) { if (s1 instanceof URIReference) { return sameResource((URIReference) s1, s2); } else { return false; } }
[ "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. @param s1 first subject. @param s2 second subject, given as a URI string. @return true if equivalent, false otherwise.
[ "Tells", "whether", "the", "given", "subjects", "are", "equivalent", "with", "one", "given", "as", "a", "URI", "string", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-common/src/main/java/org/fcrepo/common/rdf/JRDF.java#L151-L157
9,201
fcrepo3/fcrepo
fcrepo-common/src/main/java/org/fcrepo/common/rdf/JRDF.java
JRDF.sameObject
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 { return false; } }
java
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 { return false; } }
[ "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", "{", "return", "false", ";", "}", "}" ]
Tells whether the given objects are equivalent, with one given as a set of simple values. @param o1 first node. @param o2 second node URI (if isLiteral is false) or lexical value (if isLiteral is true) @param isLiteral whether the second node is a literal. @param type second literal's datatype URI string, if applicable. @param lang second literal's language tag string, if applicable. @return true if equivalent, false otherwise.
[ "Tells", "whether", "the", "given", "objects", "are", "equivalent", "with", "one", "given", "as", "a", "set", "of", "simple", "values", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-common/src/main/java/org/fcrepo/common/rdf/JRDF.java#L222-L234
9,202
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/journal/helpers/DecodingBase64OutputStream.java
DecodingBase64OutputStream.close
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; } }
java
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; } }
[ "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. @throws IOException from the inner OutputStream.
[ "Close", "the", "writer", ".", "If", "there", "are", "any", "residual", "characters", "at", "this", "point", "the", "data", "stream", "was", "not", "a", "valid", "Base64", "encoding", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/helpers/DecodingBase64OutputStream.java#L76-L85
9,203
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/validation/ecm/OwlValidator.java
OwlValidator.countRelations
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)) {//This is one of the restricted relations count++; } } return count; }
java
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)) {//This is one of the restricted relations count++; } } return count; }
[ "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", ")", ")", "{", "//This is one of the restricted relations", "count", "++", ";", "}", "}", "return", "count", ";", "}" ]
Private utility method. Counts the number of relations with a given name in a list of relatiosn @param relationName the relation name @param objectRelations the list of relations @return the number of relations with relationName in the list
[ "Private", "utility", "method", ".", "Counts", "the", "number", "of", "relations", "with", "a", "given", "name", "in", "a", "list", "of", "relatiosn" ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/validation/ecm/OwlValidator.java#L367-L380
9,204
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/storage/types/XMLDatastreamProcessor.java
XMLDatastreamProcessor.setXMLContent
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) { ByteArrayInputStream bais = new ByteArrayInputStream(xmlContent); MIMETypedStream s = new MIMETypedStream("text/xml", bais, null,xmlContent.length); try { ((DatastreamManagedContent)m_ds).putContentStream(s); } catch (StreamIOException e) { throw new RuntimeException("Unable to update managed datastream contents", e); } } else // coding error if trying to use other datastream type throw new RuntimeException("XML datastreams must be of type Managed or Inline"); }
java
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) { ByteArrayInputStream bais = new ByteArrayInputStream(xmlContent); MIMETypedStream s = new MIMETypedStream("text/xml", bais, null,xmlContent.length); try { ((DatastreamManagedContent)m_ds).putContentStream(s); } catch (StreamIOException e) { throw new RuntimeException("Unable to update managed datastream contents", e); } } else // coding error if trying to use other datastream type throw new RuntimeException("XML datastreams must be of type Managed or Inline"); }
[ "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", ")", "{", "ByteArrayInputStream", "bais", "=", "new", "ByteArrayInputStream", "(", "xmlContent", ")", ";", "MIMETypedStream", "s", "=", "new", "MIMETypedStream", "(", "\"text/xml\"", ",", "bais", ",", "null", ",", "xmlContent", ".", "length", ")", ";", "try", "{", "(", "(", "DatastreamManagedContent", ")", "m_ds", ")", ".", "putContentStream", "(", "s", ")", ";", "}", "catch", "(", "StreamIOException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Unable to update managed datastream contents\"", ",", "e", ")", ";", "}", "}", "else", "// coding error if trying to use other datastream type", "throw", "new", "RuntimeException", "(", "\"XML datastreams must be of type Managed or Inline\"", ")", ";", "}" ]
Update the XML content of the datastream wrapped by this class @param xmlContent
[ "Update", "the", "XML", "content", "of", "the", "datastream", "wrapped", "by", "this", "class" ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/storage/types/XMLDatastreamProcessor.java#L199-L214
9,205
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/storage/types/XMLDatastreamProcessor.java
XMLDatastreamProcessor.setDSMDClass
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 // coding error if trying to use other datastream type throw new RuntimeException("XML datastreams must be of type Managed or Inline"); }
java
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 // coding error if trying to use other datastream type throw new RuntimeException("XML datastreams must be of type Managed or Inline"); }
[ "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", "// coding error if trying to use other datastream type", "throw", "new", "RuntimeException", "(", "\"XML datastreams must be of type Managed or Inline\"", ")", ";", "}" ]
Set the DSMDClass of the datastream wrapped by this class @param DSMDClass
[ "Set", "the", "DSMDClass", "of", "the", "datastream", "wrapped", "by", "this", "class" ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/storage/types/XMLDatastreamProcessor.java#L220-L229
9,206
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/utilities/DCFields.java
DCFields.getMap
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.SUBJECT, m_subjects); if (m_descriptions != null) map.put(DC.DESCRIPTION, m_descriptions); if (m_publishers != null) map.put(DC.PUBLISHER, m_publishers); if (m_contributors != null) map.put(DC.CONTRIBUTOR, m_contributors); if (m_dates != null) map.put(DC.DATE, m_dates); if (m_types != null) map.put(DC.TYPE, m_types); if (m_formats != null) map.put(DC.FORMAT, m_formats); if (m_identifiers != null) map.put(DC.IDENTIFIER, m_identifiers); if (m_sources != null) map.put(DC.SOURCE, m_sources); if (m_languages != null) map.put(DC.LANGUAGE, m_languages); if (m_relations != null) map.put(DC.RELATION, m_relations); if (m_coverages != null) map.put(DC.COVERAGE, m_coverages); if (m_rights != null) map.put(DC.RIGHTS, m_rights); return map; }
java
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.SUBJECT, m_subjects); if (m_descriptions != null) map.put(DC.DESCRIPTION, m_descriptions); if (m_publishers != null) map.put(DC.PUBLISHER, m_publishers); if (m_contributors != null) map.put(DC.CONTRIBUTOR, m_contributors); if (m_dates != null) map.put(DC.DATE, m_dates); if (m_types != null) map.put(DC.TYPE, m_types); if (m_formats != null) map.put(DC.FORMAT, m_formats); if (m_identifiers != null) map.put(DC.IDENTIFIER, m_identifiers); if (m_sources != null) map.put(DC.SOURCE, m_sources); if (m_languages != null) map.put(DC.LANGUAGE, m_languages); if (m_relations != null) map.put(DC.RELATION, m_relations); if (m_coverages != null) map.put(DC.COVERAGE, m_coverages); if (m_rights != null) map.put(DC.RIGHTS, m_rights); return map; }
[ "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", ".", "SUBJECT", ",", "m_subjects", ")", ";", "if", "(", "m_descriptions", "!=", "null", ")", "map", ".", "put", "(", "DC", ".", "DESCRIPTION", ",", "m_descriptions", ")", ";", "if", "(", "m_publishers", "!=", "null", ")", "map", ".", "put", "(", "DC", ".", "PUBLISHER", ",", "m_publishers", ")", ";", "if", "(", "m_contributors", "!=", "null", ")", "map", ".", "put", "(", "DC", ".", "CONTRIBUTOR", ",", "m_contributors", ")", ";", "if", "(", "m_dates", "!=", "null", ")", "map", ".", "put", "(", "DC", ".", "DATE", ",", "m_dates", ")", ";", "if", "(", "m_types", "!=", "null", ")", "map", ".", "put", "(", "DC", ".", "TYPE", ",", "m_types", ")", ";", "if", "(", "m_formats", "!=", "null", ")", "map", ".", "put", "(", "DC", ".", "FORMAT", ",", "m_formats", ")", ";", "if", "(", "m_identifiers", "!=", "null", ")", "map", ".", "put", "(", "DC", ".", "IDENTIFIER", ",", "m_identifiers", ")", ";", "if", "(", "m_sources", "!=", "null", ")", "map", ".", "put", "(", "DC", ".", "SOURCE", ",", "m_sources", ")", ";", "if", "(", "m_languages", "!=", "null", ")", "map", ".", "put", "(", "DC", ".", "LANGUAGE", ",", "m_languages", ")", ";", "if", "(", "m_relations", "!=", "null", ")", "map", ".", "put", "(", "DC", ".", "RELATION", ",", "m_relations", ")", ";", "if", "(", "m_coverages", "!=", "null", ")", "map", ".", "put", "(", "DC", ".", "COVERAGE", ",", "m_coverages", ")", ";", "if", "(", "m_rights", "!=", "null", ")", "map", ".", "put", "(", "DC", ".", "RIGHTS", ",", "m_rights", ")", ";", "return", "map", ";", "}" ]
Returns a Map with RDFName keys, each value containing List of String values for that field.
[ "Returns", "a", "Map", "with", "RDFName", "keys", "each", "value", "containing", "List", "of", "String", "values", "for", "that", "field", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/utilities/DCFields.java#L172-L192
9,207
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/security/BackendSecuritySpec.java
BackendSecuritySpec.setSecuritySpec
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 == null || serviceRoleID.isEmpty()) { throw new GeneralException("serviceRoleID is missing."); } // if methodRoleID is missing, then set properties at the service level. if (methodName == null || methodName.isEmpty()) { rolePropertiesTable.put(serviceRoleID, properties); // otherwise set properties at the method level, but only if // parent service-level properties already exist. } else { Hashtable<String, String> serviceProps = rolePropertiesTable.get(serviceRoleID); if (serviceProps == null) { throw new GeneralException("Cannot add method-level security properties" + " if there are no properties defined for the backend service that the " + " method is part of. "); } String roleKey = serviceRoleID + "/" + methodName; rolePropertiesTable.put(roleKey, properties); } }
java
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 == null || serviceRoleID.isEmpty()) { throw new GeneralException("serviceRoleID is missing."); } // if methodRoleID is missing, then set properties at the service level. if (methodName == null || methodName.isEmpty()) { rolePropertiesTable.put(serviceRoleID, properties); // otherwise set properties at the method level, but only if // parent service-level properties already exist. } else { Hashtable<String, String> serviceProps = rolePropertiesTable.get(serviceRoleID); if (serviceProps == null) { throw new GeneralException("Cannot add method-level security properties" + " if there are no properties defined for the backend service that the " + " method is part of. "); } String roleKey = serviceRoleID + "/" + methodName; rolePropertiesTable.put(roleKey, properties); } }
[ "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", "==", "null", "||", "serviceRoleID", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "GeneralException", "(", "\"serviceRoleID is missing.\"", ")", ";", "}", "// if methodRoleID is missing, then set properties at the service level.", "if", "(", "methodName", "==", "null", "||", "methodName", ".", "isEmpty", "(", ")", ")", "{", "rolePropertiesTable", ".", "put", "(", "serviceRoleID", ",", "properties", ")", ";", "// otherwise set properties at the method level, but only if", "// parent service-level properties already exist.", "}", "else", "{", "Hashtable", "<", "String", ",", "String", ">", "serviceProps", "=", "rolePropertiesTable", ".", "get", "(", "serviceRoleID", ")", ";", "if", "(", "serviceProps", "==", "null", ")", "{", "throw", "new", "GeneralException", "(", "\"Cannot add method-level security properties\"", "+", "\" if there are no properties defined for the backend service that the \"", "+", "\" method is part of. \"", ")", ";", "}", "String", "roleKey", "=", "serviceRoleID", "+", "\"/\"", "+", "methodName", ";", "rolePropertiesTable", ".", "put", "(", "roleKey", ",", "properties", ")", ";", "}", "}" ]
Set the security properties at the backend service or for a method of that backend service. @param serviceRoleID - the role identifier for a service. Valid values for this parameter are: - a sDep PID for a backend service - "default" to indicate the default properties for any service - "fedoraInternalCall-1" for Fedora calling back to itself as a service @param methodName - optional method name within the backend service. If specified security properties at the service method level will be recorded. If null, service properties at the service level will be recorded. @param properties
[ "Set", "the", "security", "properties", "at", "the", "backend", "service", "or", "for", "a", "method", "of", "that", "backend", "service", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/security/BackendSecuritySpec.java#L64-L91
9,208
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/security/BackendSecuritySpec.java
BackendSecuritySpec.getSecuritySpec
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 { String roleKey = serviceRoleID + "/" + methodName; // First see if there is already a role key at the method level Hashtable<String, String> properties = rolePropertiesTable.get(roleKey); // if we did not find security properties for the method level, // roll up to the parent service level and get properties. if (properties == null) { properties = rolePropertiesTable.get(serviceRoleID); } // if we did not find method or service-level properties, // roll up the the default level and get default properties. if (properties == null) { properties = getDefaultSecuritySpec(); } return properties; } }
java
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 { String roleKey = serviceRoleID + "/" + methodName; // First see if there is already a role key at the method level Hashtable<String, String> properties = rolePropertiesTable.get(roleKey); // if we did not find security properties for the method level, // roll up to the parent service level and get properties. if (properties == null) { properties = rolePropertiesTable.get(serviceRoleID); } // if we did not find method or service-level properties, // roll up the the default level and get default properties. if (properties == null) { properties = getDefaultSecuritySpec(); } return properties; } }
[ "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", "{", "String", "roleKey", "=", "serviceRoleID", "+", "\"/\"", "+", "methodName", ";", "// First see if there is already a role key at the method level", "Hashtable", "<", "String", ",", "String", ">", "properties", "=", "rolePropertiesTable", ".", "get", "(", "roleKey", ")", ";", "// if we did not find security properties for the method level,", "// roll up to the parent service level and get properties.", "if", "(", "properties", "==", "null", ")", "{", "properties", "=", "rolePropertiesTable", ".", "get", "(", "serviceRoleID", ")", ";", "}", "// if we did not find method or service-level properties,", "// roll up the the default level and get default properties.", "if", "(", "properties", "==", "null", ")", "{", "properties", "=", "getDefaultSecuritySpec", "(", ")", ";", "}", "return", "properties", ";", "}", "}" ]
Get security properties for either the a backend service or a method within that backend service. @param serviceRoleID - role identifier for a backend service. Valid options: - "default" (the overall default for backend services) - "fedoraInternalCall-1" (the role key for fedora calling back to itself) - A sDep PID (e.g., "sDep:9") as the identifier for a backend service @param methodName - a method name that is specified within a sDep service. If values is null, then this method will return the security properties defined for the backend service specified by the serviceRoleID parameter. @return a Hashtable containing the backend security properties for the role or role/method. The security property names, defined in BackendSecurityDeserializer.java, are: - BackendSecurityDeserializer.CALL_BASIC_AUTH - BackendSecurityDeserializer.CALL_SSL - BackendSecurityDeserializer.CALL_USERNAME - BackendSecurityDeserializer.CALL_PASSWORD - BackendSecurityDeserializer.CALLBACK_BASIC_AUTH - BackendSecurityDeserializer.CALLBACK_SSL - BackendSecurityDeserializer.IPLIST
[ "Get", "security", "properties", "for", "either", "the", "a", "backend", "service", "or", "a", "method", "within", "that", "backend", "service", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/security/BackendSecuritySpec.java#L126-L149
9,209
fcrepo3/fcrepo
fcrepo-common/src/main/java/org/fcrepo/utilities/xml/DOM.java
DOM.getElementNodeValue
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.item(i).getNodeType() == Node.CDATA_SECTION_NODE) { // TODO: Check if we exceed the limit for getNodeValue sw.append(all.item(i).getNodeValue()); } } } return sw.toString(); }
java
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.item(i).getNodeType() == Node.CDATA_SECTION_NODE) { // TODO: Check if we exceed the limit for getNodeValue sw.append(all.item(i).getNodeValue()); } } } return sw.toString(); }
[ "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", ".", "item", "(", "i", ")", ".", "getNodeType", "(", ")", "==", "Node", ".", "CDATA_SECTION_NODE", ")", "{", "// TODO: Check if we exceed the limit for getNodeValue", "sw", ".", "append", "(", "all", ".", "item", "(", "i", ")", ".", "getNodeValue", "(", ")", ")", ";", "}", "}", "}", "return", "sw", ".", "toString", "(", ")", ";", "}" ]
Extracts all textual and CDATA content from the given node and its children. @param node the node to get the content from. @return the textual content of node.
[ "Extracts", "all", "textual", "and", "CDATA", "content", "from", "the", "given", "node", "and", "its", "children", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-common/src/main/java/org/fcrepo/utilities/xml/DOM.java#L49-L62
9,210
fcrepo3/fcrepo
fcrepo-common/src/main/java/org/fcrepo/utilities/xml/DOM.java
DOM.stringToDOM
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 dbFact.newDocumentBuilder().parse(in); } catch (IOException e) { log.warn("I/O error when parsing XML :" + e.getMessage() + "\n" + xmlString, e); } catch (SAXException e) { log.warn("Parse error when parsing XML :" + e.getMessage() + "\n" + xmlString, e); } catch (ParserConfigurationException e) { log.warn("Parser configuration error when parsing XML :" + e.getMessage() + "\n" + xmlString, e); } return null; }
java
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 dbFact.newDocumentBuilder().parse(in); } catch (IOException e) { log.warn("I/O error when parsing XML :" + e.getMessage() + "\n" + xmlString, e); } catch (SAXException e) { log.warn("Parse error when parsing XML :" + e.getMessage() + "\n" + xmlString, e); } catch (ParserConfigurationException e) { log.warn("Parser configuration error when parsing XML :" + e.getMessage() + "\n" + xmlString, e); } return null; }
[ "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", "dbFact", ".", "newDocumentBuilder", "(", ")", ".", "parse", "(", "in", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "log", ".", "warn", "(", "\"I/O error when parsing XML :\"", "+", "e", ".", "getMessage", "(", ")", "+", "\"\\n\"", "+", "xmlString", ",", "e", ")", ";", "}", "catch", "(", "SAXException", "e", ")", "{", "log", ".", "warn", "(", "\"Parse error when parsing XML :\"", "+", "e", ".", "getMessage", "(", ")", "+", "\"\\n\"", "+", "xmlString", ",", "e", ")", ";", "}", "catch", "(", "ParserConfigurationException", "e", ")", "{", "log", ".", "warn", "(", "\"Parser configuration error when parsing XML :\"", "+", "e", ".", "getMessage", "(", ")", "+", "\"\\n\"", "+", "xmlString", ",", "e", ")", ";", "}", "return", "null", ";", "}" ]
Parses an XML document from a String to a DOM. @param xmlString a String containing an XML document. @param namespaceAware if {@code true} the parsed DOM will reflect any XML namespaces declared in the document @return The document in a DOM or {@code null} on errors.
[ "Parses", "an", "XML", "document", "from", "a", "String", "to", "a", "DOM", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-common/src/main/java/org/fcrepo/utilities/xml/DOM.java#L74-L96
9,211
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/ReadOnlyContext.java
ReadOnlyContext.getContext
public static final ReadOnlyContext getContext(String messageProtocol, String subjectId, String password, /* * String[] * roles, */ boolean noOp) throws Exception { MultiValueMap<URI> environmentMap = beginEnvironmentMap(messageProtocol); environmentMap.lock(); // no request to grok more from return getContext(null, environmentMap, subjectId, password, /* roles, */ null, noOp); }
java
public static final ReadOnlyContext getContext(String messageProtocol, String subjectId, String password, /* * String[] * roles, */ boolean noOp) throws Exception { MultiValueMap<URI> environmentMap = beginEnvironmentMap(messageProtocol); environmentMap.lock(); // no request to grok more from return getContext(null, environmentMap, subjectId, password, /* roles, */ null, noOp); }
[ "public", "static", "final", "ReadOnlyContext", "getContext", "(", "String", "messageProtocol", ",", "String", "subjectId", ",", "String", "password", ",", "/*\n * String[]\n * roles,\n */", "boolean", "noOp", ")", "throws", "Exception", "{", "MultiValueMap", "<", "URI", ">", "environmentMap", "=", "beginEnvironmentMap", "(", "messageProtocol", ")", ";", "environmentMap", ".", "lock", "(", ")", ";", "// no request to grok more from", "return", "getContext", "(", "null", ",", "environmentMap", ",", "subjectId", ",", "password", ",", "/* roles, */", "null", ",", "noOp", ")", ";", "}" ]
needed only for rebuild
[ "needed", "only", "for", "rebuild" ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/ReadOnlyContext.java#L385-L397
9,212
fcrepo3/fcrepo
fcrepo-common/src/main/java/org/fcrepo/utilities/FileUtils.java
FileUtils.copy
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; } }
java
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; } }
[ "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! @param source @param destination @return success of the operation
[ "This", "method", "should", "only", "be", "used", "when", "the", "ByteBuffer", "is", "known", "to", "be", "able", "to", "accomodate", "the", "input!" ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-common/src/main/java/org/fcrepo/utilities/FileUtils.java#L58-L69
9,213
fcrepo3/fcrepo
fcrepo-common/src/main/java/org/fcrepo/utilities/FileUtils.java
FileUtils.copy
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 element : children) { result = result && copy(new File(source, element.getName()), new File(destination, element.getName())); } return result; } else { try { InputStream in = new FileInputStream(source); OutputStream out = new FileOutputStream(destination); result = result && copy(in, out); in.close(); out.close(); return result; } catch (IOException e) { return false; } } }
java
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 element : children) { result = result && copy(new File(source, element.getName()), new File(destination, element.getName())); } return result; } else { try { InputStream in = new FileInputStream(source); OutputStream out = new FileOutputStream(destination); result = result && copy(in, out); in.close(); out.close(); return result; } catch (IOException e) { return false; } } }
[ "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", "element", ":", "children", ")", "{", "result", "=", "result", "&&", "copy", "(", "new", "File", "(", "source", ",", "element", ".", "getName", "(", ")", ")", ",", "new", "File", "(", "destination", ",", "element", ".", "getName", "(", ")", ")", ")", ";", "}", "return", "result", ";", "}", "else", "{", "try", "{", "InputStream", "in", "=", "new", "FileInputStream", "(", "source", ")", ";", "OutputStream", "out", "=", "new", "FileOutputStream", "(", "destination", ")", ";", "result", "=", "result", "&&", "copy", "(", "in", ",", "out", ")", ";", "in", ".", "close", "(", ")", ";", "out", ".", "close", "(", ")", ";", "return", "result", ";", "}", "catch", "(", "IOException", "e", ")", "{", "return", "false", ";", "}", "}", "}" ]
Copy a file or directory. @param source @param destination @return <code>true</code> if the operation was successful; <code>false</code> otherwise (which includes a null input).
[ "Copy", "a", "file", "or", "directory", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-common/src/main/java/org/fcrepo/utilities/FileUtils.java#L79-L107
9,214
fcrepo3/fcrepo
fcrepo-common/src/main/java/org/fcrepo/utilities/FileUtils.java
FileUtils.delete
public static boolean delete(File file) { boolean result = true; if (file == null) { return false; } if (file.exists()) { if (file.isDirectory()) { // 1. delete content of directory: File[] children = file.listFiles(); for (File child : children) { //for each file: result = result && delete(child); }//next file } result = result && file.delete(); } //else: input directory does not exist or is not a directory return result; }
java
public static boolean delete(File file) { boolean result = true; if (file == null) { return false; } if (file.exists()) { if (file.isDirectory()) { // 1. delete content of directory: File[] children = file.listFiles(); for (File child : children) { //for each file: result = result && delete(child); }//next file } result = result && file.delete(); } //else: input directory does not exist or is not a directory return result; }
[ "public", "static", "boolean", "delete", "(", "File", "file", ")", "{", "boolean", "result", "=", "true", ";", "if", "(", "file", "==", "null", ")", "{", "return", "false", ";", "}", "if", "(", "file", ".", "exists", "(", ")", ")", "{", "if", "(", "file", ".", "isDirectory", "(", ")", ")", "{", "// 1. delete content of directory:", "File", "[", "]", "children", "=", "file", ".", "listFiles", "(", ")", ";", "for", "(", "File", "child", ":", "children", ")", "{", "//for each file:", "result", "=", "result", "&&", "delete", "(", "child", ")", ";", "}", "//next file", "}", "result", "=", "result", "&&", "file", ".", "delete", "(", ")", ";", "}", "//else: input directory does not exist or is not a directory", "return", "result", ";", "}" ]
Delete a File. @param file the File to delete. @return <code>true</code> if the operation was successful; <code>false</code> otherwise (which includes a null input).
[ "Delete", "a", "File", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-common/src/main/java/org/fcrepo/utilities/FileUtils.java#L134-L151
9,215
fcrepo3/fcrepo
fcrepo-common/src/main/java/org/fcrepo/utilities/FileUtils.java
FileUtils.loadMap
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.entrySet(); for (Entry<Object, Object> entry : entrySet) { // The casts to String should always succeed map.put((String) entry.getKey(), (String) entry.getValue()); } return map; } finally { try { in.close(); } catch (IOException e) { } } }
java
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.entrySet(); for (Entry<Object, Object> entry : entrySet) { // The casts to String should always succeed map.put((String) entry.getKey(), (String) entry.getValue()); } return map; } finally { try { in.close(); } catch (IOException e) { } } }
[ "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", ".", "entrySet", "(", ")", ";", "for", "(", "Entry", "<", "Object", ",", "Object", ">", "entry", ":", "entrySet", ")", "{", "// The casts to String should always succeed", "map", ".", "put", "(", "(", "String", ")", "entry", ".", "getKey", "(", ")", ",", "(", "String", ")", "entry", ".", "getValue", "(", ")", ")", ";", "}", "return", "map", ";", "}", "finally", "{", "try", "{", "in", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "}", "}", "}" ]
Loads a Map from the given Properties file. @param f the Properties file to parse. @return a Map&lt;String, String&gt; representing the given Properties file. @throws IOException @see java.util.Properties @see java.util.Map
[ "Loads", "a", "Map", "from", "the", "given", "Properties", "file", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-common/src/main/java/org/fcrepo/utilities/FileUtils.java#L226-L244
9,216
fcrepo3/fcrepo
fcrepo-webapp/fcrepo-webapp-saxon/src/main/java/org/fcrepo/localservices/saxon/SaxonServlet.java
SaxonServlet.init
@Override 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, SSLSocketFactory.getSocketFactory())); m_cManager.getSchemeRegistry().register( new Scheme("https-tomcat", 8443, SSLSocketFactory.getSocketFactory())); m_cManager.getSchemeRegistry().register( new Scheme("http", 80, PlainSocketFactory.getSocketFactory())); m_cManager.getSchemeRegistry().register( new Scheme("http-tomcat", 8080, PlainSocketFactory.getSocketFactory())); Enumeration<?> enm = config.getInitParameterNames(); while (enm.hasMoreElements()) { String name = (String) enm.nextElement(); if (name.startsWith(CRED_PARAM_START)) { String value = config.getInitParameter(name); if (value.indexOf(":") == -1) { throw new ServletException("Malformed credentials for " + name + " -- expected ':' user/pass delimiter"); } String[] parts = value.split(":"); String user = parts[0]; StringBuffer pass = new StringBuffer(); for (int i = 1; i < parts.length; i++) { if (i > 1) { pass.append(':'); } pass.append(parts[i]); } m_creds.put(name.substring(CRED_PARAM_START.length()), new UsernamePasswordCredentials(user, pass .toString())); } } }
java
@Override 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, SSLSocketFactory.getSocketFactory())); m_cManager.getSchemeRegistry().register( new Scheme("https-tomcat", 8443, SSLSocketFactory.getSocketFactory())); m_cManager.getSchemeRegistry().register( new Scheme("http", 80, PlainSocketFactory.getSocketFactory())); m_cManager.getSchemeRegistry().register( new Scheme("http-tomcat", 8080, PlainSocketFactory.getSocketFactory())); Enumeration<?> enm = config.getInitParameterNames(); while (enm.hasMoreElements()) { String name = (String) enm.nextElement(); if (name.startsWith(CRED_PARAM_START)) { String value = config.getInitParameter(name); if (value.indexOf(":") == -1) { throw new ServletException("Malformed credentials for " + name + " -- expected ':' user/pass delimiter"); } String[] parts = value.split(":"); String user = parts[0]; StringBuffer pass = new StringBuffer(); for (int i = 1; i < parts.length; i++) { if (i > 1) { pass.append(':'); } pass.append(parts[i]); } m_creds.put(name.substring(CRED_PARAM_START.length()), new UsernamePasswordCredentials(user, pass .toString())); } } }
[ "@", "Override", "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", ",", "SSLSocketFactory", ".", "getSocketFactory", "(", ")", ")", ")", ";", "m_cManager", ".", "getSchemeRegistry", "(", ")", ".", "register", "(", "new", "Scheme", "(", "\"https-tomcat\"", ",", "8443", ",", "SSLSocketFactory", ".", "getSocketFactory", "(", ")", ")", ")", ";", "m_cManager", ".", "getSchemeRegistry", "(", ")", ".", "register", "(", "new", "Scheme", "(", "\"http\"", ",", "80", ",", "PlainSocketFactory", ".", "getSocketFactory", "(", ")", ")", ")", ";", "m_cManager", ".", "getSchemeRegistry", "(", ")", ".", "register", "(", "new", "Scheme", "(", "\"http-tomcat\"", ",", "8080", ",", "PlainSocketFactory", ".", "getSocketFactory", "(", ")", ")", ")", ";", "Enumeration", "<", "?", ">", "enm", "=", "config", ".", "getInitParameterNames", "(", ")", ";", "while", "(", "enm", ".", "hasMoreElements", "(", ")", ")", "{", "String", "name", "=", "(", "String", ")", "enm", ".", "nextElement", "(", ")", ";", "if", "(", "name", ".", "startsWith", "(", "CRED_PARAM_START", ")", ")", "{", "String", "value", "=", "config", ".", "getInitParameter", "(", "name", ")", ";", "if", "(", "value", ".", "indexOf", "(", "\":\"", ")", "==", "-", "1", ")", "{", "throw", "new", "ServletException", "(", "\"Malformed credentials for \"", "+", "name", "+", "\" -- expected ':' user/pass delimiter\"", ")", ";", "}", "String", "[", "]", "parts", "=", "value", ".", "split", "(", "\":\"", ")", ";", "String", "user", "=", "parts", "[", "0", "]", ";", "StringBuffer", "pass", "=", "new", "StringBuffer", "(", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "parts", ".", "length", ";", "i", "++", ")", "{", "if", "(", "i", ">", "1", ")", "{", "pass", ".", "append", "(", "'", "'", ")", ";", "}", "pass", ".", "append", "(", "parts", "[", "i", "]", ")", ";", "}", "m_creds", ".", "put", "(", "name", ".", "substring", "(", "CRED_PARAM_START", ".", "length", "(", ")", ")", ",", "new", "UsernamePasswordCredentials", "(", "user", ",", "pass", ".", "toString", "(", ")", ")", ")", ";", "}", "}", "}" ]
Initialize the servlet by setting up the stylesheet cache, the http connection manager, and configuring credentials for the http client.
[ "Initialize", "the", "servlet", "by", "setting", "up", "the", "stylesheet", "cache", "the", "http", "connection", "manager", "and", "configuring", "credentials", "for", "the", "http", "client", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-webapp/fcrepo-webapp-saxon/src/main/java/org/fcrepo/localservices/saxon/SaxonServlet.java#L93-L130
9,217
fcrepo3/fcrepo
fcrepo-webapp/fcrepo-webapp-saxon/src/main/java/org/fcrepo/localservices/saxon/SaxonServlet.java
SaxonServlet.apply
private void apply(String style, String source, HttpServletRequest req, HttpServletResponse res) throws Exception { // Validate parameters if (style == null) { throw new TransformerException("No style parameter supplied"); } if (source == null) { throw new TransformerException("No source parameter supplied"); } InputStream sourceStream = null; try { // Load the stylesheet (adding to cache if necessary) Templates pss = tryCache(style); Transformer transformer = pss.newTransformer(); Enumeration<?> p = req.getParameterNames(); while (p.hasMoreElements()) { String name = (String) p.nextElement(); if (!(name.equals("style") || name.equals("source"))) { String value = req.getParameter(name); transformer.setParameter(name, new StringValue(value)); } } // Start loading the document to be transformed sourceStream = getInputStream(source); // Set the appropriate output mime type String mime = pss.getOutputProperties() .getProperty(OutputKeys.MEDIA_TYPE); if (mime == null) { res.setContentType("text/html"); } else { res.setContentType(mime); } // Transform StreamSource ss = new StreamSource(sourceStream); ss.setSystemId(source); transformer.transform(ss, new StreamResult(res.getOutputStream())); } finally { if (sourceStream != null) { try { sourceStream.close(); } catch (Exception e) { } } } }
java
private void apply(String style, String source, HttpServletRequest req, HttpServletResponse res) throws Exception { // Validate parameters if (style == null) { throw new TransformerException("No style parameter supplied"); } if (source == null) { throw new TransformerException("No source parameter supplied"); } InputStream sourceStream = null; try { // Load the stylesheet (adding to cache if necessary) Templates pss = tryCache(style); Transformer transformer = pss.newTransformer(); Enumeration<?> p = req.getParameterNames(); while (p.hasMoreElements()) { String name = (String) p.nextElement(); if (!(name.equals("style") || name.equals("source"))) { String value = req.getParameter(name); transformer.setParameter(name, new StringValue(value)); } } // Start loading the document to be transformed sourceStream = getInputStream(source); // Set the appropriate output mime type String mime = pss.getOutputProperties() .getProperty(OutputKeys.MEDIA_TYPE); if (mime == null) { res.setContentType("text/html"); } else { res.setContentType(mime); } // Transform StreamSource ss = new StreamSource(sourceStream); ss.setSystemId(source); transformer.transform(ss, new StreamResult(res.getOutputStream())); } finally { if (sourceStream != null) { try { sourceStream.close(); } catch (Exception e) { } } } }
[ "private", "void", "apply", "(", "String", "style", ",", "String", "source", ",", "HttpServletRequest", "req", ",", "HttpServletResponse", "res", ")", "throws", "Exception", "{", "// Validate parameters", "if", "(", "style", "==", "null", ")", "{", "throw", "new", "TransformerException", "(", "\"No style parameter supplied\"", ")", ";", "}", "if", "(", "source", "==", "null", ")", "{", "throw", "new", "TransformerException", "(", "\"No source parameter supplied\"", ")", ";", "}", "InputStream", "sourceStream", "=", "null", ";", "try", "{", "// Load the stylesheet (adding to cache if necessary)", "Templates", "pss", "=", "tryCache", "(", "style", ")", ";", "Transformer", "transformer", "=", "pss", ".", "newTransformer", "(", ")", ";", "Enumeration", "<", "?", ">", "p", "=", "req", ".", "getParameterNames", "(", ")", ";", "while", "(", "p", ".", "hasMoreElements", "(", ")", ")", "{", "String", "name", "=", "(", "String", ")", "p", ".", "nextElement", "(", ")", ";", "if", "(", "!", "(", "name", ".", "equals", "(", "\"style\"", ")", "||", "name", ".", "equals", "(", "\"source\"", ")", ")", ")", "{", "String", "value", "=", "req", ".", "getParameter", "(", "name", ")", ";", "transformer", ".", "setParameter", "(", "name", ",", "new", "StringValue", "(", "value", ")", ")", ";", "}", "}", "// Start loading the document to be transformed", "sourceStream", "=", "getInputStream", "(", "source", ")", ";", "// Set the appropriate output mime type", "String", "mime", "=", "pss", ".", "getOutputProperties", "(", ")", ".", "getProperty", "(", "OutputKeys", ".", "MEDIA_TYPE", ")", ";", "if", "(", "mime", "==", "null", ")", "{", "res", ".", "setContentType", "(", "\"text/html\"", ")", ";", "}", "else", "{", "res", ".", "setContentType", "(", "mime", ")", ";", "}", "// Transform", "StreamSource", "ss", "=", "new", "StreamSource", "(", "sourceStream", ")", ";", "ss", ".", "setSystemId", "(", "source", ")", ";", "transformer", ".", "transform", "(", "ss", ",", "new", "StreamResult", "(", "res", ".", "getOutputStream", "(", ")", ")", ")", ";", "}", "finally", "{", "if", "(", "sourceStream", "!=", "null", ")", "{", "try", "{", "sourceStream", ".", "close", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "}", "}", "}", "}" ]
Apply stylesheet to source document
[ "Apply", "stylesheet", "to", "source", "document" ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-webapp/fcrepo-webapp-saxon/src/main/java/org/fcrepo/localservices/saxon/SaxonServlet.java#L188-L243
9,218
fcrepo3/fcrepo
fcrepo-webapp/fcrepo-webapp-saxon/src/main/java/org/fcrepo/localservices/saxon/SaxonServlet.java
SaxonServlet.tryCache
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("net.sf.saxon.TransformerFactoryImpl")) { factory.setAttribute(FeatureKeys.VERSION_WARNING, Boolean.FALSE); } StreamSource ss = new StreamSource(getInputStream(url)); ss.setSystemId(url); x = factory.newTemplates(ss); m_cache.put(url, x); } } } return x; }
java
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("net.sf.saxon.TransformerFactoryImpl")) { factory.setAttribute(FeatureKeys.VERSION_WARNING, Boolean.FALSE); } StreamSource ss = new StreamSource(getInputStream(url)); ss.setSystemId(url); x = factory.newTemplates(ss); m_cache.put(url, x); } } } return x; }
[ "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", "(", "\"net.sf.saxon.TransformerFactoryImpl\"", ")", ")", "{", "factory", ".", "setAttribute", "(", "FeatureKeys", ".", "VERSION_WARNING", ",", "Boolean", ".", "FALSE", ")", ";", "}", "StreamSource", "ss", "=", "new", "StreamSource", "(", "getInputStream", "(", "url", ")", ")", ";", "ss", ".", "setSystemId", "(", "url", ")", ";", "x", "=", "factory", ".", "newTemplates", "(", "ss", ")", ";", "m_cache", ".", "put", "(", "url", ",", "x", ")", ";", "}", "}", "}", "return", "x", ";", "}" ]
Maintain prepared stylesheets in memory for reuse
[ "Maintain", "prepared", "stylesheets", "in", "memory", "for", "reuse" ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-webapp/fcrepo-webapp-saxon/src/main/java/org/fcrepo/localservices/saxon/SaxonServlet.java#L248-L265
9,219
fcrepo3/fcrepo
fcrepo-webapp/fcrepo-webapp-saxon/src/main/java/org/fcrepo/localservices/saxon/SaxonServlet.java
SaxonServlet.getCreds
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.hasNext()) { String realmPath = (String) iter.next(); if (url.startsWith(realmPath)) { int matchLength = realmPath.length(); if (matchLength > longestMatchLength) { longestMatchLength = matchLength; longestMatch = (UsernamePasswordCredentials) m_creds .get(realmPath); } } } return longestMatch; }
java
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.hasNext()) { String realmPath = (String) iter.next(); if (url.startsWith(realmPath)) { int matchLength = realmPath.length(); if (matchLength > longestMatchLength) { longestMatchLength = matchLength; longestMatch = (UsernamePasswordCredentials) m_creds .get(realmPath); } } } return longestMatch; }
[ "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", ".", "hasNext", "(", ")", ")", "{", "String", "realmPath", "=", "(", "String", ")", "iter", ".", "next", "(", ")", ";", "if", "(", "url", ".", "startsWith", "(", "realmPath", ")", ")", "{", "int", "matchLength", "=", "realmPath", ".", "length", "(", ")", ";", "if", "(", "matchLength", ">", "longestMatchLength", ")", "{", "longestMatchLength", "=", "matchLength", ";", "longestMatch", "=", "(", "UsernamePasswordCredentials", ")", "m_creds", ".", "get", "(", "realmPath", ")", ";", "}", "}", "}", "return", "longestMatch", ";", "}" ]
Return the credentials for the realmPath that most closely matches the given url, or null if none found.
[ "Return", "the", "credentials", "for", "the", "realmPath", "that", "most", "closely", "matches", "the", "given", "url", "or", "null", "if", "none", "found", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-webapp/fcrepo-webapp-saxon/src/main/java/org/fcrepo/localservices/saxon/SaxonServlet.java#L299-L320
9,220
fcrepo3/fcrepo
fcrepo-webapp/fcrepo-webapp-saxon/src/main/java/org/fcrepo/localservices/saxon/SaxonServlet.java
SaxonServlet.normalizeURL
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() : ""); } else { return urlString; } }
java
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() : ""); } else { return urlString; } }
[ "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", "(", ")", ":", "\"\"", ")", ";", "}", "else", "{", "return", "urlString", ";", "}", "}" ]
Return a URL string in which the port is always specified.
[ "Return", "a", "URL", "string", "in", "which", "the", "port", "is", "always", "specified", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-webapp/fcrepo-webapp-saxon/src/main/java/org/fcrepo/localservices/saxon/SaxonServlet.java#L325-L335
9,221
fcrepo3/fcrepo
fcrepo-common/src/main/java/org/fcrepo/utilities/XmlSerializer.java
XmlSerializer.getDocument
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; }
java
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; }
[ "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. @param in the InputStream to parse. @return a new DOM Document object. @throws ParserConfigurationException if a DocumentBuilder cannot be created. @throws SAXException If any parse errors occur. @throws IOException If any IO errors occur.
[ "Get", "a", "new", "DOM", "Document", "object", "from", "parsing", "the", "specified", "InputStream", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-common/src/main/java/org/fcrepo/utilities/XmlSerializer.java#L260-L270
9,222
fcrepo3/fcrepo
fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/objecteditor/ImageContentViewer.java
ImageContentViewer.init
@Override public void init(String type, InputStream data, boolean viewOnly) throws IOException { setContent(data); }
java
@Override public void init(String type, InputStream data, boolean viewOnly) throws IOException { setContent(data); }
[ "@", "Override", "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.
[ "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", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/objecteditor/ImageContentViewer.java#L64-L68
9,223
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/management/SpringManagementServlet.java
SpringManagementServlet.init
@Override 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."); } }
java
@Override 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."); } }
[ "@", "Override", "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. @throws ServletException If the servet cannot be initialized.
[ "Initialize", "servlet", ".", "Gets", "a", "reference", "to", "the", "fedora", "Server", "object", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/management/SpringManagementServlet.java#L20-L28
9,224
fcrepo3/fcrepo
fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/objecteditor/Util.java
Util.getMethodDefinitions
public static List<MethodDefinition> getMethodDefinitions(String sDefPID) throws IOException { return MethodDefinition.parse(Administrator.DOWNLOADER .getDatastreamDissemination(sDefPID, "METHODMAP", null)); }
java
public static List<MethodDefinition> getMethodDefinitions(String sDefPID) throws IOException { return MethodDefinition.parse(Administrator.DOWNLOADER .getDatastreamDissemination(sDefPID, "METHODMAP", null)); }
[ "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.
[ "Get", "the", "list", "of", "MethodDefinition", "objects", "defined", "by", "the", "indicated", "service", "definition", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/objecteditor/Util.java#L84-L88
9,225
fcrepo3/fcrepo
fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/objecteditor/Util.java
Util.getObjectFields
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(pid); FieldSearchQuery.Conditions conds = new FieldSearchQuery.Conditions(); conds.getCondition().add(condition); ObjectFactory factory = new ObjectFactory(); query.setConditions(factory.createFieldSearchQueryConditions(conds)); FieldSearchResult result = Administrator.APIA .findObjects(TypeUtility.convertStringtoAOS(fields), new BigInteger("1"), query); ResultList resultList = result.getResultList(); if (resultList == null || resultList.getObjectFields() == null && resultList.getObjectFields().size() == 0) { throw new IOException("Object not found in repository"); } return resultList.getObjectFields().get(0); }
java
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(pid); FieldSearchQuery.Conditions conds = new FieldSearchQuery.Conditions(); conds.getCondition().add(condition); ObjectFactory factory = new ObjectFactory(); query.setConditions(factory.createFieldSearchQueryConditions(conds)); FieldSearchResult result = Administrator.APIA .findObjects(TypeUtility.convertStringtoAOS(fields), new BigInteger("1"), query); ResultList resultList = result.getResultList(); if (resultList == null || resultList.getObjectFields() == null && resultList.getObjectFields().size() == 0) { throw new IOException("Object not found in repository"); } return resultList.getObjectFields().get(0); }
[ "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", "(", "pid", ")", ";", "FieldSearchQuery", ".", "Conditions", "conds", "=", "new", "FieldSearchQuery", ".", "Conditions", "(", ")", ";", "conds", ".", "getCondition", "(", ")", ".", "add", "(", "condition", ")", ";", "ObjectFactory", "factory", "=", "new", "ObjectFactory", "(", ")", ";", "query", ".", "setConditions", "(", "factory", ".", "createFieldSearchQueryConditions", "(", "conds", ")", ")", ";", "FieldSearchResult", "result", "=", "Administrator", ".", "APIA", ".", "findObjects", "(", "TypeUtility", ".", "convertStringtoAOS", "(", "fields", ")", ",", "new", "BigInteger", "(", "\"1\"", ")", ",", "query", ")", ";", "ResultList", "resultList", "=", "result", ".", "getResultList", "(", ")", ";", "if", "(", "resultList", "==", "null", "||", "resultList", ".", "getObjectFields", "(", ")", "==", "null", "&&", "resultList", ".", "getObjectFields", "(", ")", ".", "size", "(", ")", "==", "0", ")", "{", "throw", "new", "IOException", "(", "\"Object not found in repository\"", ")", ";", "}", "return", "resultList", ".", "getObjectFields", "(", ")", ".", "get", "(", "0", ")", ";", "}" ]
Get the indicated fields of the indicated object from the repository.
[ "Get", "the", "indicated", "fields", "of", "the", "indicated", "object", "from", "the", "repository", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/objecteditor/Util.java#L93-L115
9,226
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/security/servletfilters/pubcookie/FilterPubcookie.java
FilterPubcookie.getFormFields
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 (logger.isDebugEnabled()) { logger.debug(exit(method)); } return formfields; }
java
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 (logger.isDebugEnabled()) { logger.debug(exit(method)); } return formfields; }
[ "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", "(", "logger", ".", "isDebugEnabled", "(", ")", ")", "{", "logger", ".", "debug", "(", "exit", "(", "method", ")", ")", ";", "}", "return", "formfields", ";", "}" ]
initial, setup call
[ "initial", "setup", "call" ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/security/servletfilters/pubcookie/FilterPubcookie.java#L166-L177
9,227
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/security/servletfilters/pubcookie/FilterPubcookie.java
FilterPubcookie.getFormFields
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(); i++) { Node child = children.item(i); String tag = child.getNodeName(); if ("input".equalsIgnoreCase(tag)) { NamedNodeMap attributes = child.getAttributes(); Node typeNode = attributes.getNamedItem("type"); String type = typeNode.getNodeValue(); Node nameNode = attributes.getNamedItem("name"); String name = nameNode.getNodeValue(); Node valueNode = attributes.getNamedItem("value"); String value = ""; if (valueNode != null) { value = valueNode.getNodeValue(); } if ("hidden".equalsIgnoreCase(type) && value != null) { if (logger.isDebugEnabled()) { logger.debug(format("capturing hidden fields", name, value)); } formfields.put(name, value); } } getFormFields(child, formfields); } if (logger.isDebugEnabled()) { logger.debug(exit(method)); } }
java
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(); i++) { Node child = children.item(i); String tag = child.getNodeName(); if ("input".equalsIgnoreCase(tag)) { NamedNodeMap attributes = child.getAttributes(); Node typeNode = attributes.getNamedItem("type"); String type = typeNode.getNodeValue(); Node nameNode = attributes.getNamedItem("name"); String name = nameNode.getNodeValue(); Node valueNode = attributes.getNamedItem("value"); String value = ""; if (valueNode != null) { value = valueNode.getNodeValue(); } if ("hidden".equalsIgnoreCase(type) && value != null) { if (logger.isDebugEnabled()) { logger.debug(format("capturing hidden fields", name, value)); } formfields.put(name, value); } } getFormFields(child, formfields); } if (logger.isDebugEnabled()) { logger.debug(exit(method)); } }
[ "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", "(", ")", ";", "i", "++", ")", "{", "Node", "child", "=", "children", ".", "item", "(", "i", ")", ";", "String", "tag", "=", "child", ".", "getNodeName", "(", ")", ";", "if", "(", "\"input\"", ".", "equalsIgnoreCase", "(", "tag", ")", ")", "{", "NamedNodeMap", "attributes", "=", "child", ".", "getAttributes", "(", ")", ";", "Node", "typeNode", "=", "attributes", ".", "getNamedItem", "(", "\"type\"", ")", ";", "String", "type", "=", "typeNode", ".", "getNodeValue", "(", ")", ";", "Node", "nameNode", "=", "attributes", ".", "getNamedItem", "(", "\"name\"", ")", ";", "String", "name", "=", "nameNode", ".", "getNodeValue", "(", ")", ";", "Node", "valueNode", "=", "attributes", ".", "getNamedItem", "(", "\"value\"", ")", ";", "String", "value", "=", "\"\"", ";", "if", "(", "valueNode", "!=", "null", ")", "{", "value", "=", "valueNode", ".", "getNodeValue", "(", ")", ";", "}", "if", "(", "\"hidden\"", ".", "equalsIgnoreCase", "(", "type", ")", "&&", "value", "!=", "null", ")", "{", "if", "(", "logger", ".", "isDebugEnabled", "(", ")", ")", "{", "logger", ".", "debug", "(", "format", "(", "\"capturing hidden fields\"", ",", "name", ",", "value", ")", ")", ";", "}", "formfields", ".", "put", "(", "name", ",", "value", ")", ";", "}", "}", "getFormFields", "(", "child", ",", "formfields", ")", ";", "}", "if", "(", "logger", ".", "isDebugEnabled", "(", ")", ")", "{", "logger", ".", "debug", "(", "exit", "(", "method", ")", ")", ";", "}", "}" ]
inner, recursive call
[ "inner", "recursive", "call" ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/security/servletfilters/pubcookie/FilterPubcookie.java#L180-L212
9,228
fcrepo3/fcrepo
fcrepo-security/fcrepo-security-pep/src/main/java/org/fcrepo/server/security/xacml/pep/rest/filters/DataResponseWrapper.java
DataResponseWrapper.setData
public void setData(byte[] data) throws IOException { output = new ByteArrayOutputStream(); output.write(data); output.flush(); setContentLength(output.size()); }
java
public void setData(byte[] data) throws IOException { output = new ByteArrayOutputStream(); output.write(data); output.flush(); setContentLength(output.size()); }
[ "public", "void", "setData", "(", "byte", "[", "]", "data", ")", "throws", "IOException", "{", "output", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "output", ".", "write", "(", "data", ")", ";", "output", ".", "flush", "(", ")", ";", "setContentLength", "(", "output", ".", "size", "(", ")", ")", ";", "}" ]
Sets the body of this response. @param data the data to set the body of this reponse to @throws IOException
[ "Sets", "the", "body", "of", "this", "response", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-security/fcrepo-security-pep/src/main/java/org/fcrepo/server/security/xacml/pep/rest/filters/DataResponseWrapper.java#L126-L131
9,229
fcrepo3/fcrepo
fcrepo-common/src/main/java/org/fcrepo/common/http/HttpInputStream.java
HttpInputStream.getResponseHeaderValue
public String getResponseHeaderValue(String name, String defaultVal) { if (m_response.containsHeader(name)) { return m_response.getFirstHeader(name).getValue(); } else { return defaultVal; } }
java
public String getResponseHeaderValue(String name, String defaultVal) { if (m_response.containsHeader(name)) { return m_response.getFirstHeader(name).getValue(); } else { return defaultVal; } }
[ "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 @param name the header name @param defaultVal the default value @return String
[ "Return", "the", "first", "value", "of", "a", "header", "or", "the", "default", "if", "the", "fighter", "is", "not", "present" ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-common/src/main/java/org/fcrepo/common/http/HttpInputStream.java#L101-L107
9,230
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/resourceIndex/ServiceDefinitionTripleGenerator_3_0.java
ServiceDefinitionTripleGenerator_3_0.addMethodDefTriples
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; } catch (Exception e) { throw new ResourceIndexException("Error adding method def " + "triples", e); } }
java
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; } catch (Exception e) { throw new ResourceIndexException("Error adding method def " + "triples", e); } }
[ "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", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "ResourceIndexException", "(", "\"Error adding method def \"", "+", "\"triples\"", ",", "e", ")", ";", "}", "}" ]
Add a "defines" statement for the given sDef for each abstract method it defines.
[ "Add", "a", "defines", "statement", "for", "the", "given", "sDef", "for", "each", "abstract", "method", "it", "defines", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/resourceIndex/ServiceDefinitionTripleGenerator_3_0.java#L68-L82
9,231
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/journal/readerwriter/multicast/MulticastJournalWriter.java
MulticastJournalWriter.parseTransportParameters
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 (isTransportParameter(key)) { Map<String, String> thisTransport = getThisTransportMap(allTransports, getTransportName(key)); thisTransport.put(getTransportParameterName(key), parameters .get(key)); } } return allTransports; }
java
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 (isTransportParameter(key)) { Map<String, String> thisTransport = getThisTransportMap(allTransports, getTransportName(key)); thisTransport.put(getTransportParameterName(key), parameters .get(key)); } } return allTransports; }
[ "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", "(", "isTransportParameter", "(", "key", ")", ")", "{", "Map", "<", "String", ",", "String", ">", "thisTransport", "=", "getThisTransportMap", "(", "allTransports", ",", "getTransportName", "(", "key", ")", ")", ";", "thisTransport", ".", "put", "(", "getTransportParameterName", "(", "key", ")", ",", "parameters", ".", "get", "(", "key", ")", ")", ";", "}", "}", "return", "allTransports", ";", "}" ]
Create a Map of Maps, holding parameters for all of the transports. @throws JournalException
[ "Create", "a", "Map", "of", "Maps", "holding", "parameters", "for", "all", "of", "the", "transports", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/readerwriter/multicast/MulticastJournalWriter.java#L127-L141
9,232
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/journal/readerwriter/multicast/MulticastJournalWriter.java
MulticastJournalWriter.getThisTransportMap
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); }
java
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); }
[ "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.
[ "If", "we", "don", "t", "yet", "have", "a", "map", "for", "this", "transport", "name", "create", "one", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/readerwriter/multicast/MulticastJournalWriter.java#L167-L173
9,233
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/journal/readerwriter/multicast/MulticastJournalWriter.java
MulticastJournalWriter.createTimer
private Timer createTimer() { Timer fileTimer = new Timer(); // if the age limit is 0 or negative, treat it as "no limit". if (ageLimit >= 0) { fileTimer.schedule(new CloseFileTimerTask(), ageLimit); } return fileTimer; }
java
private Timer createTimer() { Timer fileTimer = new Timer(); // if the age limit is 0 or negative, treat it as "no limit". if (ageLimit >= 0) { fileTimer.schedule(new CloseFileTimerTask(), ageLimit); } return fileTimer; }
[ "private", "Timer", "createTimer", "(", ")", "{", "Timer", "fileTimer", "=", "new", "Timer", "(", ")", ";", "// if the age limit is 0 or negative, treat it as \"no limit\".", "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".
[ "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", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/readerwriter/multicast/MulticastJournalWriter.java#L370-L379
9,234
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/journal/readerwriter/multicast/MulticastJournalWriter.java
MulticastJournalWriter.writeJournalEntry
@Override public void writeJournalEntry(CreatorJournalEntry journalEntry, XMLEventWriter writer) throws JournalException { super.writeJournalEntry(journalEntry, writer); }
java
@Override public void writeJournalEntry(CreatorJournalEntry journalEntry, XMLEventWriter writer) throws JournalException { super.writeJournalEntry(journalEntry, writer); }
[ "@", "Override", "public", "void", "writeJournalEntry", "(", "CreatorJournalEntry", "journalEntry", ",", "XMLEventWriter", "writer", ")", "throws", "JournalException", "{", "super", ".", "writeJournalEntry", "(", "journalEntry", ",", "writer", ")", ";", "}" ]
make this public, so the TransportRequest class can call it.
[ "make", "this", "public", "so", "the", "TransportRequest", "class", "can", "call", "it", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/readerwriter/multicast/MulticastJournalWriter.java#L440-L445
9,235
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/journal/readerwriter/multicast/MulticastJournalWriter.java
MulticastJournalWriter.writeDocumentHeader
@Override public void writeDocumentHeader(XMLEventWriter writer, String repositoryHash, Date currentDate) throws JournalException { super.writeDocumentHeader(writer, repositoryHash, currentDate); }
java
@Override public void writeDocumentHeader(XMLEventWriter writer, String repositoryHash, Date currentDate) throws JournalException { super.writeDocumentHeader(writer, repositoryHash, currentDate); }
[ "@", "Override", "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.
[ "make", "this", "public", "so", "the", "Transport", "classes", "can", "call", "it", "via", "TransportParent", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/readerwriter/multicast/MulticastJournalWriter.java#L451-L456
9,236
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/journal/readerwriter/multicast/MulticastJournalWriter.java
MulticastJournalWriter.sendRequestToAllTransports
private void sendRequestToAllTransports(TransportRequest request) throws JournalException { Map<String, JournalException> crucialExceptions = new LinkedHashMap<String, JournalException>(); Map<String, JournalException> nonCrucialExceptions = new LinkedHashMap<String, JournalException>(); /* * Send the request to all transports, accumulating any Exceptions as we * go. That way, we increase the likeihood that at least one Transport * succeeded in the request. */ for (String transportName : transports.keySet()) { Transport transport = transports.get(transportName); try { logger.debug("Sending " + request.getClass().getSimpleName() + " to transport '" + transportName + "'"); request.performRequest(transport); } catch (JournalException e) { if (transport.isCrucial()) { crucialExceptions.put(transportName, e); } else { nonCrucialExceptions.put(transportName, e); } } } /* * Report the Exceptions. Report the non-crucial ones first, in case the * Server decides to take some definitive action on a crucial Exception. */ reportNonCrucialExceptions(nonCrucialExceptions); reportCrucialExceptions(crucialExceptions); }
java
private void sendRequestToAllTransports(TransportRequest request) throws JournalException { Map<String, JournalException> crucialExceptions = new LinkedHashMap<String, JournalException>(); Map<String, JournalException> nonCrucialExceptions = new LinkedHashMap<String, JournalException>(); /* * Send the request to all transports, accumulating any Exceptions as we * go. That way, we increase the likeihood that at least one Transport * succeeded in the request. */ for (String transportName : transports.keySet()) { Transport transport = transports.get(transportName); try { logger.debug("Sending " + request.getClass().getSimpleName() + " to transport '" + transportName + "'"); request.performRequest(transport); } catch (JournalException e) { if (transport.isCrucial()) { crucialExceptions.put(transportName, e); } else { nonCrucialExceptions.put(transportName, e); } } } /* * Report the Exceptions. Report the non-crucial ones first, in case the * Server decides to take some definitive action on a crucial Exception. */ reportNonCrucialExceptions(nonCrucialExceptions); reportCrucialExceptions(crucialExceptions); }
[ "private", "void", "sendRequestToAllTransports", "(", "TransportRequest", "request", ")", "throws", "JournalException", "{", "Map", "<", "String", ",", "JournalException", ">", "crucialExceptions", "=", "new", "LinkedHashMap", "<", "String", ",", "JournalException", ">", "(", ")", ";", "Map", "<", "String", ",", "JournalException", ">", "nonCrucialExceptions", "=", "new", "LinkedHashMap", "<", "String", ",", "JournalException", ">", "(", ")", ";", "/*\n * Send the request to all transports, accumulating any Exceptions as we\n * go. That way, we increase the likeihood that at least one Transport\n * succeeded in the request.\n */", "for", "(", "String", "transportName", ":", "transports", ".", "keySet", "(", ")", ")", "{", "Transport", "transport", "=", "transports", ".", "get", "(", "transportName", ")", ";", "try", "{", "logger", ".", "debug", "(", "\"Sending \"", "+", "request", ".", "getClass", "(", ")", ".", "getSimpleName", "(", ")", "+", "\" to transport '\"", "+", "transportName", "+", "\"'\"", ")", ";", "request", ".", "performRequest", "(", "transport", ")", ";", "}", "catch", "(", "JournalException", "e", ")", "{", "if", "(", "transport", ".", "isCrucial", "(", ")", ")", "{", "crucialExceptions", ".", "put", "(", "transportName", ",", "e", ")", ";", "}", "else", "{", "nonCrucialExceptions", ".", "put", "(", "transportName", ",", "e", ")", ";", "}", "}", "}", "/*\n * Report the Exceptions. Report the non-crucial ones first, in case the\n * Server decides to take some definitive action on a crucial Exception.\n */", "reportNonCrucialExceptions", "(", "nonCrucialExceptions", ")", ";", "reportCrucialExceptions", "(", "crucialExceptions", ")", ";", "}" ]
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. @param request the request object @param args the arguments to be passed to the request object @throws JournalException if there were any crucial problems.
[ "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", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/readerwriter/multicast/MulticastJournalWriter.java#L480-L513
9,237
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/access/defaultdisseminator/DefaultDisseminatorImpl.java
DefaultDisseminatorImpl.viewObjectProfile
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(profile, asOfDateTime, out); out.close(); in = out.toReader(); } catch (IOException ioe) { throw new GeneralException("[DefaultDisseminatorImpl] An error has occurred. " + "The error was a \"" + ioe.getClass().getName() + "\" . The " + "Reason was \"" + ioe.getMessage() + "\" ."); } //InputStream in = getObjectProfile().getStream(); ReadableByteArrayOutputStream bytes = new ReadableByteArrayOutputStream(4096); PrintWriter out = new PrintWriter( new OutputStreamWriter(bytes, Charset.forName("UTF-8"))); File xslFile = new File(reposHomeDir, "access/viewObjectProfile.xslt"); Templates template = XmlTransformUtility.getTemplates(xslFile); Transformer transformer = template.newTransformer(); transformer.setParameter("fedora", context .getEnvironmentValue(Constants.FEDORA_APP_CONTEXT_NAME)); transformer.transform(new StreamSource(in), new StreamResult(out)); out.close(); return new MIMETypedStream("text/html", bytes.toInputStream(), null, bytes.length()); } catch (Exception e) { throw new DisseminationException("[DefaultDisseminatorImpl] had an error " + "in transforming xml for viewObjectProfile. " + "Underlying exception was: " + e.getMessage()); } }
java
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(profile, asOfDateTime, out); out.close(); in = out.toReader(); } catch (IOException ioe) { throw new GeneralException("[DefaultDisseminatorImpl] An error has occurred. " + "The error was a \"" + ioe.getClass().getName() + "\" . The " + "Reason was \"" + ioe.getMessage() + "\" ."); } //InputStream in = getObjectProfile().getStream(); ReadableByteArrayOutputStream bytes = new ReadableByteArrayOutputStream(4096); PrintWriter out = new PrintWriter( new OutputStreamWriter(bytes, Charset.forName("UTF-8"))); File xslFile = new File(reposHomeDir, "access/viewObjectProfile.xslt"); Templates template = XmlTransformUtility.getTemplates(xslFile); Transformer transformer = template.newTransformer(); transformer.setParameter("fedora", context .getEnvironmentValue(Constants.FEDORA_APP_CONTEXT_NAME)); transformer.transform(new StreamSource(in), new StreamResult(out)); out.close(); return new MIMETypedStream("text/html", bytes.toInputStream(), null, bytes.length()); } catch (Exception e) { throw new DisseminationException("[DefaultDisseminatorImpl] had an error " + "in transforming xml for viewObjectProfile. " + "Underlying exception was: " + e.getMessage()); } }
[ "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", "(", "profile", ",", "asOfDateTime", ",", "out", ")", ";", "out", ".", "close", "(", ")", ";", "in", "=", "out", ".", "toReader", "(", ")", ";", "}", "catch", "(", "IOException", "ioe", ")", "{", "throw", "new", "GeneralException", "(", "\"[DefaultDisseminatorImpl] An error has occurred. \"", "+", "\"The error was a \\\"\"", "+", "ioe", ".", "getClass", "(", ")", ".", "getName", "(", ")", "+", "\"\\\" . The \"", "+", "\"Reason was \\\"\"", "+", "ioe", ".", "getMessage", "(", ")", "+", "\"\\\" .\"", ")", ";", "}", "//InputStream in = getObjectProfile().getStream();", "ReadableByteArrayOutputStream", "bytes", "=", "new", "ReadableByteArrayOutputStream", "(", "4096", ")", ";", "PrintWriter", "out", "=", "new", "PrintWriter", "(", "new", "OutputStreamWriter", "(", "bytes", ",", "Charset", ".", "forName", "(", "\"UTF-8\"", ")", ")", ")", ";", "File", "xslFile", "=", "new", "File", "(", "reposHomeDir", ",", "\"access/viewObjectProfile.xslt\"", ")", ";", "Templates", "template", "=", "XmlTransformUtility", ".", "getTemplates", "(", "xslFile", ")", ";", "Transformer", "transformer", "=", "template", ".", "newTransformer", "(", ")", ";", "transformer", ".", "setParameter", "(", "\"fedora\"", ",", "context", ".", "getEnvironmentValue", "(", "Constants", ".", "FEDORA_APP_CONTEXT_NAME", ")", ")", ";", "transformer", ".", "transform", "(", "new", "StreamSource", "(", "in", ")", ",", "new", "StreamResult", "(", "out", ")", ")", ";", "out", ".", "close", "(", ")", ";", "return", "new", "MIMETypedStream", "(", "\"text/html\"", ",", "bytes", ".", "toInputStream", "(", ")", ",", "null", ",", "bytes", ".", "length", "(", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "DisseminationException", "(", "\"[DefaultDisseminatorImpl] had an error \"", "+", "\"in transforming xml for viewObjectProfile. \"", "+", "\"Underlying exception was: \"", "+", "e", ".", "getMessage", "(", ")", ")", ";", "}", "}" ]
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 in API-A. @return html packaged as a MIMETypedStream @throws ServerException
[ "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", "in", "API", "-", "A", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/access/defaultdisseminator/DefaultDisseminatorImpl.java#L102-L145
9,238
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/access/defaultdisseminator/DefaultDisseminatorImpl.java
DefaultDisseminatorImpl.viewMethodIndex
public MIMETypedStream viewMethodIndex() throws ServerException { // sdp: the dissemination index is disabled for service definition and deployment objects // so send back a message saying so. if (reader.hasContentModel(Models.SERVICE_DEFINITION_3_0) || reader.hasContentModel(Models.SERVICE_DEPLOYMENT_3_0)) { return noMethodIndexMsg(); } // get xml expression of method definitions ObjectMethodsDef[] methods = m_access.listMethods(context, reader.GetObjectPID(), asOfDateTime); ReadableCharArrayWriter buffer = new ReadableCharArrayWriter(1024); ObjectInfoAsXML .getMethodIndex(reposBaseURL, reader.GetObjectPID(), methods, asOfDateTime, buffer); buffer.close(); Reader in = buffer.toReader(); // transform the method definitions xml to an html view try { ReadableByteArrayOutputStream bytes = new ReadableByteArrayOutputStream(2048); PrintWriter out = new PrintWriter( new OutputStreamWriter(bytes, Charset.forName("UTF-8"))); File xslFile = new File(reposHomeDir, "access/listMethods.xslt"); Templates template = XmlTransformUtility.getTemplates(xslFile); Transformer transformer = template.newTransformer(); transformer.setParameter("fedora", context .getEnvironmentValue(Constants.FEDORA_APP_CONTEXT_NAME)); transformer.transform(new StreamSource(in), new StreamResult(out)); out.close(); return new MIMETypedStream("text/html", bytes.toInputStream(), null, bytes.length()); } catch (Exception e) { throw new DisseminationException("[DefaultDisseminatorImpl] had an error " + "in transforming xml for viewItemIndex. " + "Underlying exception was: " + e.getMessage()); } }
java
public MIMETypedStream viewMethodIndex() throws ServerException { // sdp: the dissemination index is disabled for service definition and deployment objects // so send back a message saying so. if (reader.hasContentModel(Models.SERVICE_DEFINITION_3_0) || reader.hasContentModel(Models.SERVICE_DEPLOYMENT_3_0)) { return noMethodIndexMsg(); } // get xml expression of method definitions ObjectMethodsDef[] methods = m_access.listMethods(context, reader.GetObjectPID(), asOfDateTime); ReadableCharArrayWriter buffer = new ReadableCharArrayWriter(1024); ObjectInfoAsXML .getMethodIndex(reposBaseURL, reader.GetObjectPID(), methods, asOfDateTime, buffer); buffer.close(); Reader in = buffer.toReader(); // transform the method definitions xml to an html view try { ReadableByteArrayOutputStream bytes = new ReadableByteArrayOutputStream(2048); PrintWriter out = new PrintWriter( new OutputStreamWriter(bytes, Charset.forName("UTF-8"))); File xslFile = new File(reposHomeDir, "access/listMethods.xslt"); Templates template = XmlTransformUtility.getTemplates(xslFile); Transformer transformer = template.newTransformer(); transformer.setParameter("fedora", context .getEnvironmentValue(Constants.FEDORA_APP_CONTEXT_NAME)); transformer.transform(new StreamSource(in), new StreamResult(out)); out.close(); return new MIMETypedStream("text/html", bytes.toInputStream(), null, bytes.length()); } catch (Exception e) { throw new DisseminationException("[DefaultDisseminatorImpl] had an error " + "in transforming xml for viewItemIndex. " + "Underlying exception was: " + e.getMessage()); } }
[ "public", "MIMETypedStream", "viewMethodIndex", "(", ")", "throws", "ServerException", "{", "// sdp: the dissemination index is disabled for service definition and deployment objects", "// so send back a message saying so.", "if", "(", "reader", ".", "hasContentModel", "(", "Models", ".", "SERVICE_DEFINITION_3_0", ")", "||", "reader", ".", "hasContentModel", "(", "Models", ".", "SERVICE_DEPLOYMENT_3_0", ")", ")", "{", "return", "noMethodIndexMsg", "(", ")", ";", "}", "// get xml expression of method definitions", "ObjectMethodsDef", "[", "]", "methods", "=", "m_access", ".", "listMethods", "(", "context", ",", "reader", ".", "GetObjectPID", "(", ")", ",", "asOfDateTime", ")", ";", "ReadableCharArrayWriter", "buffer", "=", "new", "ReadableCharArrayWriter", "(", "1024", ")", ";", "ObjectInfoAsXML", ".", "getMethodIndex", "(", "reposBaseURL", ",", "reader", ".", "GetObjectPID", "(", ")", ",", "methods", ",", "asOfDateTime", ",", "buffer", ")", ";", "buffer", ".", "close", "(", ")", ";", "Reader", "in", "=", "buffer", ".", "toReader", "(", ")", ";", "// transform the method definitions xml to an html view", "try", "{", "ReadableByteArrayOutputStream", "bytes", "=", "new", "ReadableByteArrayOutputStream", "(", "2048", ")", ";", "PrintWriter", "out", "=", "new", "PrintWriter", "(", "new", "OutputStreamWriter", "(", "bytes", ",", "Charset", ".", "forName", "(", "\"UTF-8\"", ")", ")", ")", ";", "File", "xslFile", "=", "new", "File", "(", "reposHomeDir", ",", "\"access/listMethods.xslt\"", ")", ";", "Templates", "template", "=", "XmlTransformUtility", ".", "getTemplates", "(", "xslFile", ")", ";", "Transformer", "transformer", "=", "template", ".", "newTransformer", "(", ")", ";", "transformer", ".", "setParameter", "(", "\"fedora\"", ",", "context", ".", "getEnvironmentValue", "(", "Constants", ".", "FEDORA_APP_CONTEXT_NAME", ")", ")", ";", "transformer", ".", "transform", "(", "new", "StreamSource", "(", "in", ")", ",", "new", "StreamResult", "(", "out", ")", ")", ";", "out", ".", "close", "(", ")", ";", "return", "new", "MIMETypedStream", "(", "\"text/html\"", ",", "bytes", ".", "toInputStream", "(", ")", ",", "null", ",", "bytes", ".", "length", "(", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "DisseminationException", "(", "\"[DefaultDisseminatorImpl] had an error \"", "+", "\"in transforming xml for viewItemIndex. \"", "+", "\"Underlying exception was: \"", "+", "e", ".", "getMessage", "(", ")", ")", ";", "}", "}" ]
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 the XML that is obtained from listMethods in API-A. @return html packaged as a MIMETypedStream @throws ServerException
[ "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", "the", "XML", "that", "is", "obtained", "from", "listMethods", "in", "API", "-", "A", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/access/defaultdisseminator/DefaultDisseminatorImpl.java#L158-L203
9,239
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/access/defaultdisseminator/DefaultDisseminatorImpl.java
DefaultDisseminatorImpl.viewItemIndex
public MIMETypedStream viewItemIndex() throws ServerException { // get the item index as xml Reader in = null; try { ReadableCharArrayWriter out = new ReadableCharArrayWriter(4096); ObjectInfoAsXML .getItemIndex(reposBaseURL, context .getEnvironmentValue(Constants.FEDORA_APP_CONTEXT_NAME), reader, asOfDateTime, out); out.close(); in = out.toReader(); } catch (Exception e) { throw new GeneralException("[DefaultDisseminatorImpl] An error has occurred. " + "The error was a \"" + e.getClass().getName() + "\" . The " + "Reason was \"" + e.getMessage() + "\" ."); } // convert the xml to an html view try { //InputStream in = getItemIndex().getStream(); ReadableByteArrayOutputStream bytes = new ReadableByteArrayOutputStream(2048); PrintWriter out = new PrintWriter( new OutputStreamWriter(bytes, Charset.forName("UTF-8"))); File xslFile = new File(reposHomeDir, "access/viewItemIndex.xslt"); Templates template = XmlTransformUtility.getTemplates(xslFile); Transformer transformer = template.newTransformer(); transformer.setParameter("fedora", context .getEnvironmentValue(Constants.FEDORA_APP_CONTEXT_NAME)); transformer.transform(new StreamSource(in), new StreamResult(out)); out.close(); return new MIMETypedStream("text/html", bytes.toInputStream(), null, bytes.length()); } catch (Exception e) { throw new DisseminationException("[DefaultDisseminatorImpl] had an error " + "in transforming xml for viewItemIndex. " + "Underlying exception was: " + e.getMessage()); } }
java
public MIMETypedStream viewItemIndex() throws ServerException { // get the item index as xml Reader in = null; try { ReadableCharArrayWriter out = new ReadableCharArrayWriter(4096); ObjectInfoAsXML .getItemIndex(reposBaseURL, context .getEnvironmentValue(Constants.FEDORA_APP_CONTEXT_NAME), reader, asOfDateTime, out); out.close(); in = out.toReader(); } catch (Exception e) { throw new GeneralException("[DefaultDisseminatorImpl] An error has occurred. " + "The error was a \"" + e.getClass().getName() + "\" . The " + "Reason was \"" + e.getMessage() + "\" ."); } // convert the xml to an html view try { //InputStream in = getItemIndex().getStream(); ReadableByteArrayOutputStream bytes = new ReadableByteArrayOutputStream(2048); PrintWriter out = new PrintWriter( new OutputStreamWriter(bytes, Charset.forName("UTF-8"))); File xslFile = new File(reposHomeDir, "access/viewItemIndex.xslt"); Templates template = XmlTransformUtility.getTemplates(xslFile); Transformer transformer = template.newTransformer(); transformer.setParameter("fedora", context .getEnvironmentValue(Constants.FEDORA_APP_CONTEXT_NAME)); transformer.transform(new StreamSource(in), new StreamResult(out)); out.close(); return new MIMETypedStream("text/html", bytes.toInputStream(), null, bytes.length()); } catch (Exception e) { throw new DisseminationException("[DefaultDisseminatorImpl] had an error " + "in transforming xml for viewItemIndex. " + "Underlying exception was: " + e.getMessage()); } }
[ "public", "MIMETypedStream", "viewItemIndex", "(", ")", "throws", "ServerException", "{", "// get the item index as xml", "Reader", "in", "=", "null", ";", "try", "{", "ReadableCharArrayWriter", "out", "=", "new", "ReadableCharArrayWriter", "(", "4096", ")", ";", "ObjectInfoAsXML", ".", "getItemIndex", "(", "reposBaseURL", ",", "context", ".", "getEnvironmentValue", "(", "Constants", ".", "FEDORA_APP_CONTEXT_NAME", ")", ",", "reader", ",", "asOfDateTime", ",", "out", ")", ";", "out", ".", "close", "(", ")", ";", "in", "=", "out", ".", "toReader", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "GeneralException", "(", "\"[DefaultDisseminatorImpl] An error has occurred. \"", "+", "\"The error was a \\\"\"", "+", "e", ".", "getClass", "(", ")", ".", "getName", "(", ")", "+", "\"\\\" . The \"", "+", "\"Reason was \\\"\"", "+", "e", ".", "getMessage", "(", ")", "+", "\"\\\" .\"", ")", ";", "}", "// convert the xml to an html view", "try", "{", "//InputStream in = getItemIndex().getStream();", "ReadableByteArrayOutputStream", "bytes", "=", "new", "ReadableByteArrayOutputStream", "(", "2048", ")", ";", "PrintWriter", "out", "=", "new", "PrintWriter", "(", "new", "OutputStreamWriter", "(", "bytes", ",", "Charset", ".", "forName", "(", "\"UTF-8\"", ")", ")", ")", ";", "File", "xslFile", "=", "new", "File", "(", "reposHomeDir", ",", "\"access/viewItemIndex.xslt\"", ")", ";", "Templates", "template", "=", "XmlTransformUtility", ".", "getTemplates", "(", "xslFile", ")", ";", "Transformer", "transformer", "=", "template", ".", "newTransformer", "(", ")", ";", "transformer", ".", "setParameter", "(", "\"fedora\"", ",", "context", ".", "getEnvironmentValue", "(", "Constants", ".", "FEDORA_APP_CONTEXT_NAME", ")", ")", ";", "transformer", ".", "transform", "(", "new", "StreamSource", "(", "in", ")", ",", "new", "StreamResult", "(", "out", ")", ")", ";", "out", ".", "close", "(", ")", ";", "return", "new", "MIMETypedStream", "(", "\"text/html\"", ",", "bytes", ".", "toInputStream", "(", ")", ",", "null", ",", "bytes", ".", "length", "(", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "DisseminationException", "(", "\"[DefaultDisseminatorImpl] had an error \"", "+", "\"in transforming xml for viewItemIndex. \"", "+", "\"Underlying exception was: \"", "+", "e", ".", "getMessage", "(", ")", ")", ";", "}", "}" ]
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 from listDatastreams in API-A. @return html packaged as a MIMETypedStream @throws ServerException
[ "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", "from", "listDatastreams", "in", "API", "-", "A", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/access/defaultdisseminator/DefaultDisseminatorImpl.java#L215-L258
9,240
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/access/defaultdisseminator/DefaultDisseminatorImpl.java
DefaultDisseminatorImpl.viewDublinCore
public MIMETypedStream viewDublinCore() throws ServerException { // get dublin core record as xml 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.toReader(); } catch (ClassCastException cce) { throw new ObjectIntegrityException("Object " + reader.GetObjectPID() + " has a DC datastream, but it's not inline XML."); } // convert the dublin core xml to an html view try { //InputStream in = getDublinCore().getStream(); ReadableByteArrayOutputStream bytes = new ReadableByteArrayOutputStream(1024); PrintWriter out = new PrintWriter( new OutputStreamWriter(bytes, Charset.forName("UTF-8"))); File xslFile = new File(reposHomeDir, "access/viewDublinCore.xslt"); Templates template = XmlTransformUtility.getTemplates(xslFile); Transformer transformer = template.newTransformer(); transformer.setParameter("fedora", context .getEnvironmentValue(Constants.FEDORA_APP_CONTEXT_NAME)); transformer.transform(new StreamSource(in), new StreamResult(out)); out.close(); return new MIMETypedStream("text/html", bytes.toInputStream(), null, bytes.length()); } catch (Exception e) { throw new DisseminationException("[DefaultDisseminatorImpl] had an error " + "in transforming xml for viewDublinCore. " + "Underlying exception was: " + e.getMessage()); } }
java
public MIMETypedStream viewDublinCore() throws ServerException { // get dublin core record as xml 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.toReader(); } catch (ClassCastException cce) { throw new ObjectIntegrityException("Object " + reader.GetObjectPID() + " has a DC datastream, but it's not inline XML."); } // convert the dublin core xml to an html view try { //InputStream in = getDublinCore().getStream(); ReadableByteArrayOutputStream bytes = new ReadableByteArrayOutputStream(1024); PrintWriter out = new PrintWriter( new OutputStreamWriter(bytes, Charset.forName("UTF-8"))); File xslFile = new File(reposHomeDir, "access/viewDublinCore.xslt"); Templates template = XmlTransformUtility.getTemplates(xslFile); Transformer transformer = template.newTransformer(); transformer.setParameter("fedora", context .getEnvironmentValue(Constants.FEDORA_APP_CONTEXT_NAME)); transformer.transform(new StreamSource(in), new StreamResult(out)); out.close(); return new MIMETypedStream("text/html", bytes.toInputStream(), null, bytes.length()); } catch (Exception e) { throw new DisseminationException("[DefaultDisseminatorImpl] had an error " + "in transforming xml for viewDublinCore. " + "Underlying exception was: " + e.getMessage()); } }
[ "public", "MIMETypedStream", "viewDublinCore", "(", ")", "throws", "ServerException", "{", "// get dublin core record as xml", "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", ".", "toReader", "(", ")", ";", "}", "catch", "(", "ClassCastException", "cce", ")", "{", "throw", "new", "ObjectIntegrityException", "(", "\"Object \"", "+", "reader", ".", "GetObjectPID", "(", ")", "+", "\" has a DC datastream, but it's not inline XML.\"", ")", ";", "}", "// convert the dublin core xml to an html view", "try", "{", "//InputStream in = getDublinCore().getStream();", "ReadableByteArrayOutputStream", "bytes", "=", "new", "ReadableByteArrayOutputStream", "(", "1024", ")", ";", "PrintWriter", "out", "=", "new", "PrintWriter", "(", "new", "OutputStreamWriter", "(", "bytes", ",", "Charset", ".", "forName", "(", "\"UTF-8\"", ")", ")", ")", ";", "File", "xslFile", "=", "new", "File", "(", "reposHomeDir", ",", "\"access/viewDublinCore.xslt\"", ")", ";", "Templates", "template", "=", "XmlTransformUtility", ".", "getTemplates", "(", "xslFile", ")", ";", "Transformer", "transformer", "=", "template", ".", "newTransformer", "(", ")", ";", "transformer", ".", "setParameter", "(", "\"fedora\"", ",", "context", ".", "getEnvironmentValue", "(", "Constants", ".", "FEDORA_APP_CONTEXT_NAME", ")", ")", ";", "transformer", ".", "transform", "(", "new", "StreamSource", "(", "in", ")", ",", "new", "StreamResult", "(", "out", ")", ")", ";", "out", ".", "close", "(", ")", ";", "return", "new", "MIMETypedStream", "(", "\"text/html\"", ",", "bytes", ".", "toInputStream", "(", ")", ",", "null", ",", "bytes", ".", "length", "(", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "DisseminationException", "(", "\"[DefaultDisseminatorImpl] had an error \"", "+", "\"in transforming xml for viewDublinCore. \"", "+", "\"Underlying exception was: \"", "+", "e", ".", "getMessage", "(", ")", ")", ";", "}", "}" ]
Returns the Dublin Core record for the object, if one exists. The record is returned as HTML in a presentation-oriented format. @return html packaged as a MIMETypedStream @throws ServerException
[ "Returns", "the", "Dublin", "Core", "record", "for", "the", "object", "if", "one", "exists", ".", "The", "record", "is", "returned", "as", "HTML", "in", "a", "presentation", "-", "oriented", "format", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/access/defaultdisseminator/DefaultDisseminatorImpl.java#L267-L309
9,241
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/access/defaultdisseminator/DefaultDisseminatorImpl.java
DefaultDisseminatorImpl.reflectMethods
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[0]; methodList.add(method); method = new MethodDef(); method.methodName = "viewMethodIndex"; method.methodLabel = "View a list of dissemination methods in the object"; method.methodParms = new MethodParmDef[0]; methodList.add(method); method = new MethodDef(); method.methodName = "viewItemIndex"; method.methodLabel = "View a list of items in the object"; method.methodParms = new MethodParmDef[0]; methodList.add(method); method = new MethodDef(); method.methodName = "viewDublinCore"; method.methodLabel = "View the Dublin Core record for the object"; method.methodParms = new MethodParmDef[0]; methodList.add(method); return methodList.toArray(new MethodDef[0]); }
java
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[0]; methodList.add(method); method = new MethodDef(); method.methodName = "viewMethodIndex"; method.methodLabel = "View a list of dissemination methods in the object"; method.methodParms = new MethodParmDef[0]; methodList.add(method); method = new MethodDef(); method.methodName = "viewItemIndex"; method.methodLabel = "View a list of items in the object"; method.methodParms = new MethodParmDef[0]; methodList.add(method); method = new MethodDef(); method.methodName = "viewDublinCore"; method.methodLabel = "View the Dublin Core record for the object"; method.methodParms = new MethodParmDef[0]; methodList.add(method); return methodList.toArray(new MethodDef[0]); }
[ "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", "[", "0", "]", ";", "methodList", ".", "add", "(", "method", ")", ";", "method", "=", "new", "MethodDef", "(", ")", ";", "method", ".", "methodName", "=", "\"viewMethodIndex\"", ";", "method", ".", "methodLabel", "=", "\"View a list of dissemination methods in the object\"", ";", "method", ".", "methodParms", "=", "new", "MethodParmDef", "[", "0", "]", ";", "methodList", ".", "add", "(", "method", ")", ";", "method", "=", "new", "MethodDef", "(", ")", ";", "method", ".", "methodName", "=", "\"viewItemIndex\"", ";", "method", ".", "methodLabel", "=", "\"View a list of items in the object\"", ";", "method", ".", "methodParms", "=", "new", "MethodParmDef", "[", "0", "]", ";", "methodList", ".", "add", "(", "method", ")", ";", "method", "=", "new", "MethodDef", "(", ")", ";", "method", ".", "methodName", "=", "\"viewDublinCore\"", ";", "method", ".", "methodLabel", "=", "\"View the Dublin Core record for the object\"", ";", "method", ".", "methodParms", "=", "new", "MethodParmDef", "[", "0", "]", ";", "methodList", ".", "add", "(", "method", ")", ";", "return", "methodList", ".", "toArray", "(", "new", "MethodDef", "[", "0", "]", ")", ";", "}" ]
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. @return an array of method defintions
[ "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", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/access/defaultdisseminator/DefaultDisseminatorImpl.java#L347-L377
9,242
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/utilities/SQLUtility.java
SQLUtility.getDefaultConnection
public static Connection getDefaultConnection(ServerConfiguration serverConfig) { ModuleConfiguration poolConfig = serverConfig .getModuleConfiguration("org.fcrepo.server.storage.ConnectionPoolManager"); String datastoreID = poolConfig.getParameter("defaultPoolName",Parameter.class).getValue(); DatastoreConfiguration dbConfig = serverConfig.getDatastoreConfiguration(datastoreID); return getConnection(dbConfig.getParameter("jdbcDriverClass",Parameter.class) .getValue(), dbConfig.getParameter("jdbcURL",Parameter.class).getValue(), dbConfig.getParameter("dbUsername",Parameter.class).getValue(), dbConfig.getParameter("dbPassword",Parameter.class).getValue()); }
java
public static Connection getDefaultConnection(ServerConfiguration serverConfig) { ModuleConfiguration poolConfig = serverConfig .getModuleConfiguration("org.fcrepo.server.storage.ConnectionPoolManager"); String datastoreID = poolConfig.getParameter("defaultPoolName",Parameter.class).getValue(); DatastoreConfiguration dbConfig = serverConfig.getDatastoreConfiguration(datastoreID); return getConnection(dbConfig.getParameter("jdbcDriverClass",Parameter.class) .getValue(), dbConfig.getParameter("jdbcURL",Parameter.class).getValue(), dbConfig.getParameter("dbUsername",Parameter.class).getValue(), dbConfig.getParameter("dbPassword",Parameter.class).getValue()); }
[ "public", "static", "Connection", "getDefaultConnection", "(", "ServerConfiguration", "serverConfig", ")", "{", "ModuleConfiguration", "poolConfig", "=", "serverConfig", ".", "getModuleConfiguration", "(", "\"org.fcrepo.server.storage.ConnectionPoolManager\"", ")", ";", "String", "datastoreID", "=", "poolConfig", ".", "getParameter", "(", "\"defaultPoolName\"", ",", "Parameter", ".", "class", ")", ".", "getValue", "(", ")", ";", "DatastoreConfiguration", "dbConfig", "=", "serverConfig", ".", "getDatastoreConfiguration", "(", "datastoreID", ")", ";", "return", "getConnection", "(", "dbConfig", ".", "getParameter", "(", "\"jdbcDriverClass\"", ",", "Parameter", ".", "class", ")", ".", "getValue", "(", ")", ",", "dbConfig", ".", "getParameter", "(", "\"jdbcURL\"", ",", "Parameter", ".", "class", ")", ".", "getValue", "(", ")", ",", "dbConfig", ".", "getParameter", "(", "\"dbUsername\"", ",", "Parameter", ".", "class", ")", ".", "getValue", "(", ")", ",", "dbConfig", ".", "getParameter", "(", "\"dbPassword\"", ",", "Parameter", ".", "class", ")", ".", "getValue", "(", ")", ")", ";", "}" ]
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.
[ "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", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/utilities/SQLUtility.java#L171-L184
9,243
fcrepo3/fcrepo
fcrepo-security/fcrepo-security-pdp/src/main/java/org/fcrepo/server/security/xacml/pdp/data/DbXmlManager.java
DbXmlManager.close
public void close() { // getting a read lock will ensure all writes have finished // if we are really closing assume that we don't care about reads 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 = null; log.info("Closed manager"); } catch (XmlException e) { log.warn("close failed: " + e.getMessage(), e); } } } finally { readLock.unlock(); } }
java
public void close() { // getting a read lock will ensure all writes have finished // if we are really closing assume that we don't care about reads 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 = null; log.info("Closed manager"); } catch (XmlException e) { log.warn("close failed: " + e.getMessage(), e); } } } finally { readLock.unlock(); } }
[ "public", "void", "close", "(", ")", "{", "// getting a read lock will ensure all writes have finished", "// if we are really closing assume that we don't care about reads", "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", "=", "null", ";", "log", ".", "info", "(", "\"Closed manager\"", ")", ";", "}", "catch", "(", "XmlException", "e", ")", "{", "log", ".", "warn", "(", "\"close failed: \"", "+", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "}", "}", "finally", "{", "readLock", ".", "unlock", "(", ")", ";", "}", "}" ]
Closes the dbxml container and manager.
[ "Closes", "the", "dbxml", "container", "and", "manager", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-security/fcrepo-security-pdp/src/main/java/org/fcrepo/server/security/xacml/pdp/data/DbXmlManager.java#L72-L99
9,244
fcrepo3/fcrepo
fcrepo-common/src/main/java/org/fcrepo/utilities/NamespaceContextImpl.java
NamespaceContextImpl.addNamespace
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 " + XMLConstants.XML_NS_URI + "not allowed."); } else if (namespaceURI.equals(XMLConstants.XMLNS_ATTRIBUTE_NS_URI)) { throw new IllegalArgumentException("Adding a new namespace for " + XMLConstants.XMLNS_ATTRIBUTE_NS_URI + "not allowed."); } prefix2ns.put(prefix, namespaceURI); }
java
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 " + XMLConstants.XML_NS_URI + "not allowed."); } else if (namespaceURI.equals(XMLConstants.XMLNS_ATTRIBUTE_NS_URI)) { throw new IllegalArgumentException("Adding a new namespace for " + XMLConstants.XMLNS_ATTRIBUTE_NS_URI + "not allowed."); } prefix2ns.put(prefix, namespaceURI); }
[ "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 \"", "+", "XMLConstants", ".", "XML_NS_URI", "+", "\"not allowed.\"", ")", ";", "}", "else", "if", "(", "namespaceURI", ".", "equals", "(", "XMLConstants", ".", "XMLNS_ATTRIBUTE_NS_URI", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Adding a new namespace for \"", "+", "XMLConstants", ".", "XMLNS_ATTRIBUTE_NS_URI", "+", "\"not allowed.\"", ")", ";", "}", "prefix2ns", ".", "put", "(", "prefix", ",", "namespaceURI", ")", ";", "}" ]
Add a prefix to namespace mapping. @param prefix @param namespaceURI @throws IllegalArgumentException if namespaceURI is one of {@value XMLConstants#XML_NS_URI} or {@value XMLConstants#XMLNS_ATTRIBUTE_NS_URI}
[ "Add", "a", "prefix", "to", "namespace", "mapping", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-common/src/main/java/org/fcrepo/utilities/NamespaceContextImpl.java#L107-L119
9,245
fcrepo3/fcrepo
fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/utility/validate/ObjectValidator.java
ObjectValidator.validate
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){ result.addNote(ValidationResultNotation.noContentModel()); return result; } for (String contentmodel:contentmodels){ validateAgainstContentModel(result, contentmodel, object); } return result; }
java
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){ result.addNote(ValidationResultNotation.noContentModel()); return result; } for (String contentmodel:contentmodels){ validateAgainstContentModel(result, contentmodel, object); } return result; }
[ "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", ")", "{", "result", ".", "addNote", "(", "ValidationResultNotation", ".", "noContentModel", "(", ")", ")", ";", "return", "result", ";", "}", "for", "(", "String", "contentmodel", ":", "contentmodels", ")", "{", "validateAgainstContentModel", "(", "result", ",", "contentmodel", ",", "object", ")", ";", "}", "return", "result", ";", "}" ]
Each object is expected to have at least one content model. Validate each of the content models.
[ "Each", "object", "is", "expected", "to", "have", "at", "least", "one", "content", "model", ".", "Validate", "each", "of", "the", "content", "models", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/utility/validate/ObjectValidator.java#L70-L88
9,246
fcrepo3/fcrepo
fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/utility/validate/ObjectValidator.java
ObjectValidator.confirmMatchForDsTypeModel
private void confirmMatchForDsTypeModel(ValidationResult result, DsTypeModel typeModel, String contentModelPid, ObjectInfo object) { String id = typeModel.getId(); DatastreamInfo dsInfo = object.getDatastreamInfo(id); if (dsInfo == null) { // If there is no datastream by that name, nothing to check. result.addNote(ValidationResultNotation .noMatchingDatastreamId(contentModelPid, id)); return; } Collection<Form> forms = typeModel.getForms(); if (forms.isEmpty()) { // If the type model has no forms, it's an automatic match. return; } // Otherwise, the datastream must meet the constraints of at least one form. for (Form form : forms) { if (meetsConstraint(dsInfo.getMimeType(), form.getMimeType()) && meetsConstraint(dsInfo.getFormatUri(), form .getFormatUri())) { return; } } result.addNote(ValidationResultNotation .datastreamDoesNotMatchForms(contentModelPid, id)); }
java
private void confirmMatchForDsTypeModel(ValidationResult result, DsTypeModel typeModel, String contentModelPid, ObjectInfo object) { String id = typeModel.getId(); DatastreamInfo dsInfo = object.getDatastreamInfo(id); if (dsInfo == null) { // If there is no datastream by that name, nothing to check. result.addNote(ValidationResultNotation .noMatchingDatastreamId(contentModelPid, id)); return; } Collection<Form> forms = typeModel.getForms(); if (forms.isEmpty()) { // If the type model has no forms, it's an automatic match. return; } // Otherwise, the datastream must meet the constraints of at least one form. for (Form form : forms) { if (meetsConstraint(dsInfo.getMimeType(), form.getMimeType()) && meetsConstraint(dsInfo.getFormatUri(), form .getFormatUri())) { return; } } result.addNote(ValidationResultNotation .datastreamDoesNotMatchForms(contentModelPid, id)); }
[ "private", "void", "confirmMatchForDsTypeModel", "(", "ValidationResult", "result", ",", "DsTypeModel", "typeModel", ",", "String", "contentModelPid", ",", "ObjectInfo", "object", ")", "{", "String", "id", "=", "typeModel", ".", "getId", "(", ")", ";", "DatastreamInfo", "dsInfo", "=", "object", ".", "getDatastreamInfo", "(", "id", ")", ";", "if", "(", "dsInfo", "==", "null", ")", "{", "// If there is no datastream by that name, nothing to check.", "result", ".", "addNote", "(", "ValidationResultNotation", ".", "noMatchingDatastreamId", "(", "contentModelPid", ",", "id", ")", ")", ";", "return", ";", "}", "Collection", "<", "Form", ">", "forms", "=", "typeModel", ".", "getForms", "(", ")", ";", "if", "(", "forms", ".", "isEmpty", "(", ")", ")", "{", "// If the type model has no forms, it's an automatic match.", "return", ";", "}", "// Otherwise, the datastream must meet the constraints of at least one form.", "for", "(", "Form", "form", ":", "forms", ")", "{", "if", "(", "meetsConstraint", "(", "dsInfo", ".", "getMimeType", "(", ")", ",", "form", ".", "getMimeType", "(", ")", ")", "&&", "meetsConstraint", "(", "dsInfo", ".", "getFormatUri", "(", ")", ",", "form", ".", "getFormatUri", "(", ")", ")", ")", "{", "return", ";", "}", "}", "result", ".", "addNote", "(", "ValidationResultNotation", ".", "datastreamDoesNotMatchForms", "(", "contentModelPid", ",", "id", ")", ")", ";", "}" ]
The object must have a datastream to match each dsTypeModel in the content model. Matching a dsTypeModel means equal IDs and an acceptable form.
[ "The", "object", "must", "have", "a", "datastream", "to", "match", "each", "dsTypeModel", "in", "the", "content", "model", ".", "Matching", "a", "dsTypeModel", "means", "equal", "IDs", "and", "an", "acceptable", "form", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/utility/validate/ObjectValidator.java#L143-L172
9,247
fcrepo3/fcrepo
fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/utility/validate/ObjectValidator.java
ObjectValidator.meetsConstraint
private boolean meetsConstraint(String value, String constraint) { return (constraint == null) || constraint.equals(value); }
java
private boolean meetsConstraint(String value, String constraint) { return (constraint == null) || constraint.equals(value); }
[ "private", "boolean", "meetsConstraint", "(", "String", "value", ",", "String", "constraint", ")", "{", "return", "(", "constraint", "==", "null", ")", "||", "constraint", ".", "equals", "(", "value", ")", ";", "}" ]
If the constraint is not null, the value must match it.
[ "If", "the", "constraint", "is", "not", "null", "the", "value", "must", "match", "it", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/utility/validate/ObjectValidator.java#L177-L179
9,248
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/journal/helpers/FileMovingUtil.java
FileMovingUtil.createTempFile
private static File createTempFile(File baseFile) { File parentDirectory = baseFile.getParentFile(); String filename = baseFile.getName(); return new File(parentDirectory, '_' + filename); }
java
private static File createTempFile(File baseFile) { File parentDirectory = baseFile.getParentFile(); String filename = baseFile.getName(); return new File(parentDirectory, '_' + filename); }
[ "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.
[ "Create", "a", "temporary", "File", "object", ".", "Prefix", "the", "name", "of", "the", "base", "file", "with", "an", "underscore", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/helpers/FileMovingUtil.java#L108-L112
9,249
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/access/WSDLServlet.java
WSDLServlet.doGet
@Override 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 { response.setContentType("text/xml; charset=UTF-8"); getWSDL(api.toUpperCase(), request.getRequestURL() .toString(), response.getWriter()); } response.flushBuffer(); }
java
@Override 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 { response.setContentType("text/xml; charset=UTF-8"); getWSDL(api.toUpperCase(), request.getRequestURL() .toString(), response.getWriter()); } response.flushBuffer(); }
[ "@", "Override", "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", "{", "response", ".", "setContentType", "(", "\"text/xml; charset=UTF-8\"", ")", ";", "getWSDL", "(", "api", ".", "toUpperCase", "(", ")", ",", "request", ".", "getRequestURL", "(", ")", ".", "toString", "(", ")", ",", "response", ".", "getWriter", "(", ")", ")", ";", "}", "response", ".", "flushBuffer", "(", ")", ";", "}" ]
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.
[ "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", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/access/WSDLServlet.java#L75-L91
9,250
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/access/WSDLServlet.java
WSDLServlet.getIndex
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.append("</ul></body></html>"); }
java
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.append("</ul></body></html>"); }
[ "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", ".", "append", "(", "\"</ul></body></html>\"", ")", ";", "}" ]
Get a simple HTML index pointing to each WSDL file provided by the servlet.
[ "Get", "a", "simple", "HTML", "index", "pointing", "to", "each", "WSDL", "file", "provided", "by", "the", "servlet", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/access/WSDLServlet.java#L97-L106
9,251
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/access/WSDLServlet.java
WSDLServlet.getWSDL
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 baseURL = getFedoraBaseURL(requestURL); String svcPath = (String) _SERVICE_PATHS.get(api); RuntimeWSDL wsdl = new RuntimeWSDL(schemaFile, sourceWSDL, baseURL + "/" + svcPath); wsdl.serialize(out); } else { throw new ServletException("No such api: '" + api + "'"); } }
java
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 baseURL = getFedoraBaseURL(requestURL); String svcPath = (String) _SERVICE_PATHS.get(api); RuntimeWSDL wsdl = new RuntimeWSDL(schemaFile, sourceWSDL, baseURL + "/" + svcPath); wsdl.serialize(out); } else { throw new ServletException("No such api: '" + api + "'"); } }
[ "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", "baseURL", "=", "getFedoraBaseURL", "(", "requestURL", ")", ";", "String", "svcPath", "=", "(", "String", ")", "_SERVICE_PATHS", ".", "get", "(", "api", ")", ";", "RuntimeWSDL", "wsdl", "=", "new", "RuntimeWSDL", "(", "schemaFile", ",", "sourceWSDL", ",", "baseURL", "+", "\"/\"", "+", "svcPath", ")", ";", "wsdl", ".", "serialize", "(", "out", ")", ";", "}", "else", "{", "throw", "new", "ServletException", "(", "\"No such api: '\"", "+", "api", "+", "\"'\"", ")", ";", "}", "}" ]
Get the self-contained WSDL given the api name and request URL.
[ "Get", "the", "self", "-", "contained", "WSDL", "given", "the", "api", "name", "and", "request", "URL", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/access/WSDLServlet.java#L111-L132
9,252
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/access/WSDLServlet.java
WSDLServlet.getFedoraBaseURL
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 the " + "string '" + _SERVLET_PATH + "', as expected."); } }
java
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 the " + "string '" + _SERVLET_PATH + "', as expected."); } }
[ "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 the \"", "+", "\"string '\"", "+", "_SERVLET_PATH", "+", "\"', as expected.\"", ")", ";", "}", "}" ]
Determine the base URL of the Fedora webapp given the request URL to this servlet.
[ "Determine", "the", "base", "URL", "of", "the", "Fedora", "webapp", "given", "the", "request", "URL", "to", "this", "servlet", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/access/WSDLServlet.java#L138-L147
9,253
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/access/WSDLServlet.java
WSDLServlet.init
@Override 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()) { throw new ServletException("No such directory: " + _serverDir.getPath()); } } }
java
@Override 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()) { throw new ServletException("No such directory: " + _serverDir.getPath()); } } }
[ "@", "Override", "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", "(", ")", ")", "{", "throw", "new", "ServletException", "(", "\"No such directory: \"", "+", "_serverDir", ".", "getPath", "(", ")", ")", ";", "}", "}", "}" ]
Initialize by setting serverDir based on FEDORA_HOME.
[ "Initialize", "by", "setting", "serverDir", "based", "on", "FEDORA_HOME", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/access/WSDLServlet.java#L152-L167
9,254
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/security/impl/InputParser.java
InputParser.parseInput
static Node parseInput(InputStream input, String rootTag) throws ParsingException { NodeList nodes = null; try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setIgnoringComments(true); DocumentBuilder builder = null; // as of 1.2, we always are namespace aware factory.setNamespaceAware(true); if (ipReference == null) { // we're not validating factory.setValidating(false); builder = factory.newDocumentBuilder(); } else { // we are validating factory.setValidating(true); factory.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA); factory.setAttribute(JAXP_SCHEMA_SOURCE, ipReference.schemaFile); builder = factory.newDocumentBuilder(); builder.setErrorHandler(ipReference); } Document doc = builder.parse(input); nodes = doc.getElementsByTagName(rootTag); } catch (Exception e) { throw new ParsingException("Error tring to parse " + rootTag + "Type", e); } if (nodes.getLength() != 1) throw new ParsingException("Only one " + rootTag + "Type allowed " + "at the root of a Context doc"); return nodes.item(0); }
java
static Node parseInput(InputStream input, String rootTag) throws ParsingException { NodeList nodes = null; try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setIgnoringComments(true); DocumentBuilder builder = null; // as of 1.2, we always are namespace aware factory.setNamespaceAware(true); if (ipReference == null) { // we're not validating factory.setValidating(false); builder = factory.newDocumentBuilder(); } else { // we are validating factory.setValidating(true); factory.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA); factory.setAttribute(JAXP_SCHEMA_SOURCE, ipReference.schemaFile); builder = factory.newDocumentBuilder(); builder.setErrorHandler(ipReference); } Document doc = builder.parse(input); nodes = doc.getElementsByTagName(rootTag); } catch (Exception e) { throw new ParsingException("Error tring to parse " + rootTag + "Type", e); } if (nodes.getLength() != 1) throw new ParsingException("Only one " + rootTag + "Type allowed " + "at the root of a Context doc"); return nodes.item(0); }
[ "static", "Node", "parseInput", "(", "InputStream", "input", ",", "String", "rootTag", ")", "throws", "ParsingException", "{", "NodeList", "nodes", "=", "null", ";", "try", "{", "DocumentBuilderFactory", "factory", "=", "DocumentBuilderFactory", ".", "newInstance", "(", ")", ";", "factory", ".", "setIgnoringComments", "(", "true", ")", ";", "DocumentBuilder", "builder", "=", "null", ";", "// as of 1.2, we always are namespace aware", "factory", ".", "setNamespaceAware", "(", "true", ")", ";", "if", "(", "ipReference", "==", "null", ")", "{", "// we're not validating", "factory", ".", "setValidating", "(", "false", ")", ";", "builder", "=", "factory", ".", "newDocumentBuilder", "(", ")", ";", "}", "else", "{", "// we are validating", "factory", ".", "setValidating", "(", "true", ")", ";", "factory", ".", "setAttribute", "(", "JAXP_SCHEMA_LANGUAGE", ",", "W3C_XML_SCHEMA", ")", ";", "factory", ".", "setAttribute", "(", "JAXP_SCHEMA_SOURCE", ",", "ipReference", ".", "schemaFile", ")", ";", "builder", "=", "factory", ".", "newDocumentBuilder", "(", ")", ";", "builder", ".", "setErrorHandler", "(", "ipReference", ")", ";", "}", "Document", "doc", "=", "builder", ".", "parse", "(", "input", ")", ";", "nodes", "=", "doc", ".", "getElementsByTagName", "(", "rootTag", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "ParsingException", "(", "\"Error tring to parse \"", "+", "rootTag", "+", "\"Type\"", ",", "e", ")", ";", "}", "if", "(", "nodes", ".", "getLength", "(", ")", "!=", "1", ")", "throw", "new", "ParsingException", "(", "\"Only one \"", "+", "rootTag", "+", "\"Type allowed \"", "+", "\"at the root of a Context doc\"", ")", ";", "return", "nodes", ".", "item", "(", "0", ")", ";", "}" ]
Tries to Parse the given output as a Context document. @param input the stream to parse @param rootTage either "Request" or "Response" @return the root node of the request/response @throws ParsingException if a problem occurred parsing the document
[ "Tries", "to", "Parse", "the", "given", "output", "as", "a", "Context", "document", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/security/impl/InputParser.java#L122-L166
9,255
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/storage/SimpleServiceDeploymentReader.java
SimpleServiceDeploymentReader.getParms
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 service deployment object, " + m_obj.getPid() + ", does not have a service method named '" + methodName); }
java
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 service deployment object, " + m_obj.getPid() + ", does not have a service method named '" + methodName); }
[ "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 service deployment object, \"", "+", "m_obj", ".", "getPid", "(", ")", "+", "\", does not have a service method named '\"", "+", "methodName", ")", ";", "}" ]
Get the parms out of a particular service method definition. @param methods @return
[ "Get", "the", "parms", "out", "of", "a", "particular", "service", "method", "definition", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/storage/SimpleServiceDeploymentReader.java#L115-L126
9,256
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/config/ServerConfiguration.java
ServerConfiguration.copy
public ServerConfiguration copy() throws IOException { ReadableByteArrayOutputStream out = new ReadableByteArrayOutputStream(); serialize(out); return new ServerConfigurationParser(out.toInputStream()).parse(); }
java
public ServerConfiguration copy() throws IOException { ReadableByteArrayOutputStream out = new ReadableByteArrayOutputStream(); serialize(out); return new ServerConfigurationParser(out.toInputStream()).parse(); }
[ "public", "ServerConfiguration", "copy", "(", ")", "throws", "IOException", "{", "ReadableByteArrayOutputStream", "out", "=", "new", "ReadableByteArrayOutputStream", "(", ")", ";", "serialize", "(", "out", ")", ";", "return", "new", "ServerConfigurationParser", "(", "out", ".", "toInputStream", "(", ")", ")", ".", "parse", "(", ")", ";", "}" ]
Make an exact copy of this ServerConfiguration.
[ "Make", "an", "exact", "copy", "of", "this", "ServerConfiguration", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/config/ServerConfiguration.java#L64-L68
9,257
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/config/ServerConfiguration.java
ServerConfiguration.applyProperties
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.length() > 0) { String name = fullName.substring(fullName.lastIndexOf(":") + 1); if (fullName.startsWith("server:")) { if (name.endsWith(".class")) { m_className = value; } else { setParameterValue(name, value, true); } } else if (fullName.startsWith("module.")) { String role = fullName.substring(7, fullName.lastIndexOf(":")); ModuleConfiguration module = getModuleConfiguration(role); if (module == null) { module = new ModuleConfiguration(new ArrayList<Parameter>(), role, null, null); m_moduleConfigurations.add(module); } if (name.endsWith(".class")) { module.setClassName(value); } else { module.setParameterValue(name, value, true); } } else if (fullName.startsWith("datastore.")) { String id = fullName.substring(10, fullName.lastIndexOf(":")); DatastoreConfiguration datastore = getDatastoreConfiguration(id); if (datastore == null) { datastore = new DatastoreConfiguration(new ArrayList<Parameter>(), id, null); m_datastoreConfigurations.add(datastore); } datastore.setParameterValue(name, value, true); } } } }
java
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.length() > 0) { String name = fullName.substring(fullName.lastIndexOf(":") + 1); if (fullName.startsWith("server:")) { if (name.endsWith(".class")) { m_className = value; } else { setParameterValue(name, value, true); } } else if (fullName.startsWith("module.")) { String role = fullName.substring(7, fullName.lastIndexOf(":")); ModuleConfiguration module = getModuleConfiguration(role); if (module == null) { module = new ModuleConfiguration(new ArrayList<Parameter>(), role, null, null); m_moduleConfigurations.add(module); } if (name.endsWith(".class")) { module.setClassName(value); } else { module.setParameterValue(name, value, true); } } else if (fullName.startsWith("datastore.")) { String id = fullName.substring(10, fullName.lastIndexOf(":")); DatastoreConfiguration datastore = getDatastoreConfiguration(id); if (datastore == null) { datastore = new DatastoreConfiguration(new ArrayList<Parameter>(), id, null); m_datastoreConfigurations.add(datastore); } datastore.setParameterValue(name, value, true); } } } }
[ "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", ".", "length", "(", ")", ">", "0", ")", "{", "String", "name", "=", "fullName", ".", "substring", "(", "fullName", ".", "lastIndexOf", "(", "\":\"", ")", "+", "1", ")", ";", "if", "(", "fullName", ".", "startsWith", "(", "\"server:\"", ")", ")", "{", "if", "(", "name", ".", "endsWith", "(", "\".class\"", ")", ")", "{", "m_className", "=", "value", ";", "}", "else", "{", "setParameterValue", "(", "name", ",", "value", ",", "true", ")", ";", "}", "}", "else", "if", "(", "fullName", ".", "startsWith", "(", "\"module.\"", ")", ")", "{", "String", "role", "=", "fullName", ".", "substring", "(", "7", ",", "fullName", ".", "lastIndexOf", "(", "\":\"", ")", ")", ";", "ModuleConfiguration", "module", "=", "getModuleConfiguration", "(", "role", ")", ";", "if", "(", "module", "==", "null", ")", "{", "module", "=", "new", "ModuleConfiguration", "(", "new", "ArrayList", "<", "Parameter", ">", "(", ")", ",", "role", ",", "null", ",", "null", ")", ";", "m_moduleConfigurations", ".", "add", "(", "module", ")", ";", "}", "if", "(", "name", ".", "endsWith", "(", "\".class\"", ")", ")", "{", "module", ".", "setClassName", "(", "value", ")", ";", "}", "else", "{", "module", ".", "setParameterValue", "(", "name", ",", "value", ",", "true", ")", ";", "}", "}", "else", "if", "(", "fullName", ".", "startsWith", "(", "\"datastore.\"", ")", ")", "{", "String", "id", "=", "fullName", ".", "substring", "(", "10", ",", "fullName", ".", "lastIndexOf", "(", "\":\"", ")", ")", ";", "DatastoreConfiguration", "datastore", "=", "getDatastoreConfiguration", "(", "id", ")", ";", "if", "(", "datastore", "==", "null", ")", "{", "datastore", "=", "new", "DatastoreConfiguration", "(", "new", "ArrayList", "<", "Parameter", ">", "(", ")", ",", "id", ",", "null", ")", ";", "m_datastoreConfigurations", ".", "add", "(", "datastore", ")", ";", "}", "datastore", ".", "setParameterValue", "(", "name", ",", "value", ",", "true", ")", ";", "}", "}", "}", "}" ]
Apply the given properties to this ServerConfiguration. Trims leading and trailing spaces from the property values before applying them.
[ "Apply", "the", "given", "properties", "to", "this", "ServerConfiguration", ".", "Trims", "leading", "and", "trailing", "spaces", "from", "the", "property", "values", "before", "applying", "them", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/config/ServerConfiguration.java#L74-L121
9,258
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/config/ServerConfiguration.java
ServerConfiguration.strip
private static String strip(String in) { if (in == null) { return null; } String out = in.trim(); if (out.length() == 0) { return null; } else { return out; } }
java
private static String strip(String in) { if (in == null) { return null; } String out = in.trim(); if (out.length() == 0) { return null; } else { return out; } }
[ "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.
[ "resulting", "string", "is", "empty", "in", "incoming", "string", "is", "null", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/config/ServerConfiguration.java#L215-L225
9,259
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/config/ServerConfiguration.java
ServerConfiguration.main
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 == 2) { Properties props = new Properties(); props.load(new FileInputStream(new File(args[1]))); config.applyProperties(props); } ByteArrayOutputStream out = new ByteArrayOutputStream(); config.serialize(out); String content = new String(out.toByteArray(), "UTF-8"); System.out.println(content); }
java
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 == 2) { Properties props = new Properties(); props.load(new FileInputStream(new File(args[1]))); config.applyProperties(props); } ByteArrayOutputStream out = new ByteArrayOutputStream(); config.serialize(out); String content = new String(out.toByteArray(), "UTF-8"); System.out.println(content); }
[ "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", "==", "2", ")", "{", "Properties", "props", "=", "new", "Properties", "(", ")", ";", "props", ".", "load", "(", "new", "FileInputStream", "(", "new", "File", "(", "args", "[", "1", "]", ")", ")", ")", ";", "config", ".", "applyProperties", "(", "props", ")", ";", "}", "ByteArrayOutputStream", "out", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "config", ".", "serialize", "(", "out", ")", ";", "String", "content", "=", "new", "String", "(", "out", ".", "toByteArray", "(", ")", ",", "\"UTF-8\"", ")", ";", "System", ".", "out", ".", "println", "(", "content", ")", ";", "}" ]
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.
[ "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", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/config/ServerConfiguration.java#L264-L280
9,260
fcrepo3/fcrepo
fcrepo-webapp/fcrepo-webapp-fop/src/main/java/org/fcrepo/localservices/fop/RepositoryURIResolver.java
RepositoryURIResolver.resolveRepositoryURI
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 TransformerException("Resource does not exist. \"" + path + "\" is not accessible."); } } catch (MalformedURLException mfue) { throw new TransformerException("Error accessing resource using servlet context: " + path, mfue); } catch (IOException ioe) { throw new TransformerException("Unable to access resource at: " + path, ioe); } return resolvedSource; }
java
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 TransformerException("Resource does not exist. \"" + path + "\" is not accessible."); } } catch (MalformedURLException mfue) { throw new TransformerException("Error accessing resource using servlet context: " + path, mfue); } catch (IOException ioe) { throw new TransformerException("Unable to access resource at: " + path, ioe); } return resolvedSource; }
[ "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", "TransformerException", "(", "\"Resource does not exist. \\\"\"", "+", "path", "+", "\"\\\" is not accessible.\"", ")", ";", "}", "}", "catch", "(", "MalformedURLException", "mfue", ")", "{", "throw", "new", "TransformerException", "(", "\"Error accessing resource using servlet context: \"", "+", "path", ",", "mfue", ")", ";", "}", "catch", "(", "IOException", "ioe", ")", "{", "throw", "new", "TransformerException", "(", "\"Unable to access resource at: \"", "+", "path", ",", "ioe", ")", ";", "}", "return", "resolvedSource", ";", "}" ]
Resolves the "repository" URI. @param path the href to the resource @return the resolved Source or null if the resource was not found @throws TransformerException if no URL can be constructed from the path
[ "Resolves", "the", "repository", "URI", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-webapp/fcrepo-webapp-fop/src/main/java/org/fcrepo/localservices/fop/RepositoryURIResolver.java#L42-L68
9,261
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/journal/readerwriter/multicast/TransportOutputFile.java
TransportOutputFile.open
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: // READY state = State.OPEN; tempFile.createNewFile(); fileWriter = new FileWriter(tempFile); return fileWriter; } }
java
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: // READY state = State.OPEN; tempFile.createNewFile(); fileWriter = new FileWriter(tempFile); return fileWriter; } }
[ "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", ":", "// READY", "state", "=", "State", ".", "OPEN", ";", "tempFile", ".", "createNewFile", "(", ")", ";", "fileWriter", "=", "new", "FileWriter", "(", "tempFile", ")", ";", "return", "fileWriter", ";", "}", "}" ]
Create the file with its "in progress" filename. @return a Writer on the new file.
[ "Create", "the", "file", "with", "its", "in", "progress", "filename", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/readerwriter/multicast/TransportOutputFile.java#L76-L90
9,262
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/journal/readerwriter/multicast/TransportOutputFile.java
TransportOutputFile.close
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: // OPEN fileWriter.close(); tempFile.renameTo(file); state = State.CLOSED; } }
java
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: // OPEN fileWriter.close(); tempFile.renameTo(file); state = State.CLOSED; } }
[ "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", ":", "// OPEN", "fileWriter", ".", "close", "(", ")", ";", "tempFile", ".", "renameTo", "(", "file", ")", ";", "state", "=", "State", ".", "CLOSED", ";", "}", "}" ]
Close the writer and rename the file. @throws IOException
[ "Close", "the", "writer", "and", "rename", "the", "file", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/readerwriter/multicast/TransportOutputFile.java#L97-L110
9,263
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/security/DefaultBackendSecurity.java
DefaultBackendSecurity.parseBeSecurity
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("[DefaultBackendSecurity] " + "An error has occured in parsing the backend security " + "configuration file located at \"" + m_beSecurityPath + "\". " + "The underlying error was a " + th.getClass().getName() + "The message was \"" + th.getMessage() + "\"."); } }
java
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("[DefaultBackendSecurity] " + "An error has occured in parsing the backend security " + "configuration file located at \"" + m_beSecurityPath + "\". " + "The underlying error was a " + th.getClass().getName() + "The message was \"" + th.getMessage() + "\"."); } }
[ "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", "(", "\"[DefaultBackendSecurity] \"", "+", "\"An error has occured in parsing the backend security \"", "+", "\"configuration file located at \\\"\"", "+", "m_beSecurityPath", "+", "\"\\\". \"", "+", "\"The underlying error was a \"", "+", "th", ".", "getClass", "(", ")", ".", "getName", "(", ")", "+", "\"The message was \\\"\"", "+", "th", ".", "getMessage", "(", ")", "+", "\"\\\".\"", ")", ";", "}", "}" ]
Parses the beSecurity configuration file. @throws BackendSecurityParserException If an error occurs in attempting to parse the beSecurity configuration file.
[ "Parses", "the", "beSecurity", "configuration", "file", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/security/DefaultBackendSecurity.java#L139-L158
9,264
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/storage/types/BasicDigitalObject.java
BasicDigitalObject.setExtProperty
public void setExtProperty(String propName, String propValue) { if (m_extProperties == null) { m_extProperties = new HashMap<String, String>(); } m_extProperties.put(propName, propValue); }
java
public void setExtProperty(String propName, String propValue) { if (m_extProperties == null) { m_extProperties = new HashMap<String, String>(); } m_extProperties.put(propName, propValue); }
[ "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. @param propName The extended property name, either a string, or URI as string.
[ "Sets", "an", "extended", "property", "on", "the", "object", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/storage/types/BasicDigitalObject.java#L271-L277
9,265
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/storage/types/BasicDigitalObject.java
BasicDigitalObject.getExtProperty
public String getExtProperty(String propName) { if (m_extProperties == null) { return null; } return m_extProperties.get(propName); }
java
public String getExtProperty(String propName) { if (m_extProperties == null) { return null; } return m_extProperties.get(propName); }
[ "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. @return The property value.
[ "Gets", "an", "extended", "property", "value", "given", "the", "property", "name", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/storage/types/BasicDigitalObject.java#L284-L289
9,266
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/storage/types/BasicDigitalObject.java
BasicDigitalObject.hasRelationship
public boolean hasRelationship(PredicateNode predicate, ObjectNode object) { return hasRelationship(PID.toURIReference(m_pid), predicate, object); }
java
public boolean hasRelationship(PredicateNode predicate, ObjectNode object) { return hasRelationship(PID.toURIReference(m_pid), predicate, object); }
[ "public", "boolean", "hasRelationship", "(", "PredicateNode", "predicate", ",", "ObjectNode", "object", ")", "{", "return", "hasRelationship", "(", "PID", ".", "toURIReference", "(", "m_pid", ")", ",", "predicate", ",", "object", ")", ";", "}" ]
assumes m_pid as subject; ie RELS-EXT only
[ "assumes", "m_pid", "as", "subject", ";", "ie", "RELS", "-", "EXT", "only" ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/storage/types/BasicDigitalObject.java#L305-L307
9,267
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/storage/types/BasicDigitalObject.java
BasicDigitalObject.getRelationships
public Set<RelationshipTuple> getRelationships(PredicateNode predicate, ObjectNode object) { return getRelationships(PID.toURIReference(m_pid), predicate, object); }
java
public Set<RelationshipTuple> getRelationships(PredicateNode predicate, ObjectNode object) { return getRelationships(PID.toURIReference(m_pid), predicate, object); }
[ "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
[ "assume", "m_pid", "as", "subject", ";", "ie", "RELS", "-", "EXT", "only" ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/storage/types/BasicDigitalObject.java#L369-L372
9,268
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/storage/types/BasicDigitalObject.java
BasicDigitalObject.getRels
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 = relsDatastreamVersions.get(0); for (Datastream v : relsDatastreamVersions) { if (v.DSCreateDT == null){ latestRels = v; break; } if (v.DSCreateDT.getTime() > latestRels.DSCreateDT.getTime()) { latestRels = v; } } try { return RDFRelationshipReader.readRelationships(latestRels); } catch (ServerException e) { throw new RuntimeException("Error reading object relationships in " + relsDatastreamName, e); } }
java
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 = relsDatastreamVersions.get(0); for (Datastream v : relsDatastreamVersions) { if (v.DSCreateDT == null){ latestRels = v; break; } if (v.DSCreateDT.getTime() > latestRels.DSCreateDT.getTime()) { latestRels = v; } } try { return RDFRelationshipReader.readRelationships(latestRels); } catch (ServerException e) { throw new RuntimeException("Error reading object relationships in " + relsDatastreamName, e); } }
[ "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", "=", "relsDatastreamVersions", ".", "get", "(", "0", ")", ";", "for", "(", "Datastream", "v", ":", "relsDatastreamVersions", ")", "{", "if", "(", "v", ".", "DSCreateDT", "==", "null", ")", "{", "latestRels", "=", "v", ";", "break", ";", "}", "if", "(", "v", ".", "DSCreateDT", ".", "getTime", "(", ")", ">", "latestRels", ".", "DSCreateDT", ".", "getTime", "(", ")", ")", "{", "latestRels", "=", "v", ";", "}", "}", "try", "{", "return", "RDFRelationshipReader", ".", "readRelationships", "(", "latestRels", ")", ";", "}", "catch", "(", "ServerException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Error reading object relationships in \"", "+", "relsDatastreamName", ",", "e", ")", ";", "}", "}" ]
Given a relationships datastream name, return the relationships contained in that datastream
[ "Given", "a", "relationships", "datastream", "name", "return", "the", "relationships", "contained", "in", "that", "datastream" ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/storage/types/BasicDigitalObject.java#L494-L518
9,269
fcrepo3/fcrepo
fcrepo-common/src/main/java/org/fcrepo/common/http/ProxyConfiguration.java
ProxyConfiguration.isHostProxyable
public boolean isHostProxyable(String host) { return getProxyHost() != null && getProxyPort() > 0 && (nonProxyPattern == null || !nonProxyPattern.matcher(host) .matches()); }
java
public boolean isHostProxyable(String host) { return getProxyHost() != null && getProxyPort() > 0 && (nonProxyPattern == null || !nonProxyPattern.matcher(host) .matches()); }
[ "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. @param host the host to be matched @return true if the host satifies the above stated condition, otherwise false.
[ "Checks", "whether", "a", "proxy", "has", "been", "configured", "and", "the", "given", "host", "is", "not", "in", "the", "nonProxyHost", "list", "or", "the", "nonProxyList", "is", "empty", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-common/src/main/java/org/fcrepo/common/http/ProxyConfiguration.java#L143-L148
9,270
fcrepo3/fcrepo
fcrepo-common/src/main/java/org/fcrepo/utilities/MimeTypeUtils.java
MimeTypeUtils.fileExtensionForMIMEType
public static String fileExtensionForMIMEType(String mimeType) { loadMappings(); String ext = mimeTypeToExtensionMap.get(mimeType); if (ext == null) ext = "dat"; return ext; }
java
public static String fileExtensionForMIMEType(String mimeType) { loadMappings(); String ext = mimeTypeToExtensionMap.get(mimeType); if (ext == null) ext = "dat"; return ext; }
[ "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. @param mimeType the String MIME type @return the appropriate file name extension, or a default extension if not found. The extension will not have the leading "." character.
[ "Get", "an", "appropriate", "extension", "for", "a", "MIME", "type", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-common/src/main/java/org/fcrepo/utilities/MimeTypeUtils.java#L86-L94
9,271
fcrepo3/fcrepo
fcrepo-common/src/main/java/org/fcrepo/utilities/MimeTypeUtils.java
MimeTypeUtils.loadMappings
private static HashMap<String, String> loadMappings() { HashMap<String, String> mimeTypeToExtensionMap = new HashMap<String, String>(); // First, check the user's home directory. String fileSep = System.getProperty("file.separator"); StringBuffer buf = new StringBuffer(); buf.append(System.getProperty("user.home")); buf.append(fileSep); buf.append(".mime.types"); loadMIMETypesFile(buf.toString()); // Now, check every directory in the classpath. String pathSep = System.getProperty("path.separator"); String[] pathComponents = pathSep.split(" "); int i; for (i = 0; i < pathComponents.length; i++) { buf.setLength(0); buf.append(pathComponents[i]); buf.append(fileSep); buf.append("mime.types"); loadMIMETypesFile(buf.toString()); } // Finally, load the resource bundle. ResourceBundle bundle = ResourceBundle.getBundle(MIME_MAPPINGS_BUNDLE); for (Enumeration<?> e = bundle.getKeys(); e.hasMoreElements();) { String type = (String) e.nextElement(); try { String[] extensions = bundle.getString(type).split(" "); if (mimeTypeToExtensionMap.get(type) == null) { logger.debug("Internal: " + type + " -> \"" + extensions[0] + "\""); mimeTypeToExtensionMap.put(type, extensions[0]); } } catch (MissingResourceException ex) { logger.error("While reading internal bundle \"" + MIME_MAPPINGS_BUNDLE + "\", got unexpected error on key \"" + type + "\"", ex); } } return mimeTypeToExtensionMap; }
java
private static HashMap<String, String> loadMappings() { HashMap<String, String> mimeTypeToExtensionMap = new HashMap<String, String>(); // First, check the user's home directory. String fileSep = System.getProperty("file.separator"); StringBuffer buf = new StringBuffer(); buf.append(System.getProperty("user.home")); buf.append(fileSep); buf.append(".mime.types"); loadMIMETypesFile(buf.toString()); // Now, check every directory in the classpath. String pathSep = System.getProperty("path.separator"); String[] pathComponents = pathSep.split(" "); int i; for (i = 0; i < pathComponents.length; i++) { buf.setLength(0); buf.append(pathComponents[i]); buf.append(fileSep); buf.append("mime.types"); loadMIMETypesFile(buf.toString()); } // Finally, load the resource bundle. ResourceBundle bundle = ResourceBundle.getBundle(MIME_MAPPINGS_BUNDLE); for (Enumeration<?> e = bundle.getKeys(); e.hasMoreElements();) { String type = (String) e.nextElement(); try { String[] extensions = bundle.getString(type).split(" "); if (mimeTypeToExtensionMap.get(type) == null) { logger.debug("Internal: " + type + " -> \"" + extensions[0] + "\""); mimeTypeToExtensionMap.put(type, extensions[0]); } } catch (MissingResourceException ex) { logger.error("While reading internal bundle \"" + MIME_MAPPINGS_BUNDLE + "\", got unexpected error on key \"" + type + "\"", ex); } } return mimeTypeToExtensionMap; }
[ "private", "static", "HashMap", "<", "String", ",", "String", ">", "loadMappings", "(", ")", "{", "HashMap", "<", "String", ",", "String", ">", "mimeTypeToExtensionMap", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "// First, check the user's home directory.", "String", "fileSep", "=", "System", ".", "getProperty", "(", "\"file.separator\"", ")", ";", "StringBuffer", "buf", "=", "new", "StringBuffer", "(", ")", ";", "buf", ".", "append", "(", "System", ".", "getProperty", "(", "\"user.home\"", ")", ")", ";", "buf", ".", "append", "(", "fileSep", ")", ";", "buf", ".", "append", "(", "\".mime.types\"", ")", ";", "loadMIMETypesFile", "(", "buf", ".", "toString", "(", ")", ")", ";", "// Now, check every directory in the classpath.", "String", "pathSep", "=", "System", ".", "getProperty", "(", "\"path.separator\"", ")", ";", "String", "[", "]", "pathComponents", "=", "pathSep", ".", "split", "(", "\" \"", ")", ";", "int", "i", ";", "for", "(", "i", "=", "0", ";", "i", "<", "pathComponents", ".", "length", ";", "i", "++", ")", "{", "buf", ".", "setLength", "(", "0", ")", ";", "buf", ".", "append", "(", "pathComponents", "[", "i", "]", ")", ";", "buf", ".", "append", "(", "fileSep", ")", ";", "buf", ".", "append", "(", "\"mime.types\"", ")", ";", "loadMIMETypesFile", "(", "buf", ".", "toString", "(", ")", ")", ";", "}", "// Finally, load the resource bundle.", "ResourceBundle", "bundle", "=", "ResourceBundle", ".", "getBundle", "(", "MIME_MAPPINGS_BUNDLE", ")", ";", "for", "(", "Enumeration", "<", "?", ">", "e", "=", "bundle", ".", "getKeys", "(", ")", ";", "e", ".", "hasMoreElements", "(", ")", ";", ")", "{", "String", "type", "=", "(", "String", ")", "e", ".", "nextElement", "(", ")", ";", "try", "{", "String", "[", "]", "extensions", "=", "bundle", ".", "getString", "(", "type", ")", ".", "split", "(", "\" \"", ")", ";", "if", "(", "mimeTypeToExtensionMap", ".", "get", "(", "type", ")", "==", "null", ")", "{", "logger", ".", "debug", "(", "\"Internal: \"", "+", "type", "+", "\" -> \\\"\"", "+", "extensions", "[", "0", "]", "+", "\"\\\"\"", ")", ";", "mimeTypeToExtensionMap", ".", "put", "(", "type", ",", "extensions", "[", "0", "]", ")", ";", "}", "}", "catch", "(", "MissingResourceException", "ex", ")", "{", "logger", ".", "error", "(", "\"While reading internal bundle \\\"\"", "+", "MIME_MAPPINGS_BUNDLE", "+", "\"\\\", got unexpected error on key \\\"\"", "+", "type", "+", "\"\\\"\"", ",", "ex", ")", ";", "}", "}", "return", "mimeTypeToExtensionMap", ";", "}" ]
Load the MIME type mappings into memory.
[ "Load", "the", "MIME", "type", "mappings", "into", "memory", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-common/src/main/java/org/fcrepo/utilities/MimeTypeUtils.java#L99-L154
9,272
fcrepo3/fcrepo
fcrepo-common/src/main/java/org/fcrepo/utilities/MimeTypeUtils.java
MimeTypeUtils.loadMIMETypesFile
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 LineNumberReader(new FileReader(f)); String line; while ((line = r.readLine()) != null) { line = line.trim(); if ((line.length() == 0) || (line.startsWith("#"))) continue; String[] fields = line.split(" "); // Skip lines without at least two tokens. if (fields.length < 2) continue; // Special case: Scan the extensions, and make sure we // have at least one valid extension. Some .mime.types // files have entries like this: // // mime/type desc="xxx" exts="jnlp" // // We don't handle those. List<String> extensions = new ArrayList<String>(); for (int i = 1; i < fields.length; i++) { if (fields[i].indexOf('=') != -1) continue; if (fields[i].indexOf('"') != -1) continue; // Treat as valid. Remove any leading "." if (fields[i].startsWith(".")) { if (fields[i].length() == 1) continue; fields[i] = fields[i].substring(1); } extensions.add(fields[i]); } if (extensions.size() == 0) continue; // If the MIME type doesn't have a "/", skip it String mimeType = fields[0]; String extension; if (mimeType.indexOf('/') == -1) continue; // The first field is the preferred extension. Keep any // existing mapping for the MIME type. if (mimeTypeToExtensionMap.get(mimeType) == null) { extension = extensions.get(0); logger.debug("File \"" + path + "\": " + mimeType + " -> \"" + extension + "\""); mimeTypeToExtensionMap.put(mimeType, extension); } } r.close(); } } catch (IOException ex) { logger.debug("Error reading \"" + path + "\"", ex); } }
java
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 LineNumberReader(new FileReader(f)); String line; while ((line = r.readLine()) != null) { line = line.trim(); if ((line.length() == 0) || (line.startsWith("#"))) continue; String[] fields = line.split(" "); // Skip lines without at least two tokens. if (fields.length < 2) continue; // Special case: Scan the extensions, and make sure we // have at least one valid extension. Some .mime.types // files have entries like this: // // mime/type desc="xxx" exts="jnlp" // // We don't handle those. List<String> extensions = new ArrayList<String>(); for (int i = 1; i < fields.length; i++) { if (fields[i].indexOf('=') != -1) continue; if (fields[i].indexOf('"') != -1) continue; // Treat as valid. Remove any leading "." if (fields[i].startsWith(".")) { if (fields[i].length() == 1) continue; fields[i] = fields[i].substring(1); } extensions.add(fields[i]); } if (extensions.size() == 0) continue; // If the MIME type doesn't have a "/", skip it String mimeType = fields[0]; String extension; if (mimeType.indexOf('/') == -1) continue; // The first field is the preferred extension. Keep any // existing mapping for the MIME type. if (mimeTypeToExtensionMap.get(mimeType) == null) { extension = extensions.get(0); logger.debug("File \"" + path + "\": " + mimeType + " -> \"" + extension + "\""); mimeTypeToExtensionMap.put(mimeType, extension); } } r.close(); } } catch (IOException ex) { logger.debug("Error reading \"" + path + "\"", ex); } }
[ "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", "LineNumberReader", "(", "new", "FileReader", "(", "f", ")", ")", ";", "String", "line", ";", "while", "(", "(", "line", "=", "r", ".", "readLine", "(", ")", ")", "!=", "null", ")", "{", "line", "=", "line", ".", "trim", "(", ")", ";", "if", "(", "(", "line", ".", "length", "(", ")", "==", "0", ")", "||", "(", "line", ".", "startsWith", "(", "\"#\"", ")", ")", ")", "continue", ";", "String", "[", "]", "fields", "=", "line", ".", "split", "(", "\" \"", ")", ";", "// Skip lines without at least two tokens.", "if", "(", "fields", ".", "length", "<", "2", ")", "continue", ";", "// Special case: Scan the extensions, and make sure we", "// have at least one valid extension. Some .mime.types", "// files have entries like this:", "//", "// mime/type desc=\"xxx\" exts=\"jnlp\"", "//", "// We don't handle those.", "List", "<", "String", ">", "extensions", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "fields", ".", "length", ";", "i", "++", ")", "{", "if", "(", "fields", "[", "i", "]", ".", "indexOf", "(", "'", "'", ")", "!=", "-", "1", ")", "continue", ";", "if", "(", "fields", "[", "i", "]", ".", "indexOf", "(", "'", "'", ")", "!=", "-", "1", ")", "continue", ";", "// Treat as valid. Remove any leading \".\"", "if", "(", "fields", "[", "i", "]", ".", "startsWith", "(", "\".\"", ")", ")", "{", "if", "(", "fields", "[", "i", "]", ".", "length", "(", ")", "==", "1", ")", "continue", ";", "fields", "[", "i", "]", "=", "fields", "[", "i", "]", ".", "substring", "(", "1", ")", ";", "}", "extensions", ".", "add", "(", "fields", "[", "i", "]", ")", ";", "}", "if", "(", "extensions", ".", "size", "(", ")", "==", "0", ")", "continue", ";", "// If the MIME type doesn't have a \"/\", skip it", "String", "mimeType", "=", "fields", "[", "0", "]", ";", "String", "extension", ";", "if", "(", "mimeType", ".", "indexOf", "(", "'", "'", ")", "==", "-", "1", ")", "continue", ";", "// The first field is the preferred extension. Keep any", "// existing mapping for the MIME type.", "if", "(", "mimeTypeToExtensionMap", ".", "get", "(", "mimeType", ")", "==", "null", ")", "{", "extension", "=", "extensions", ".", "get", "(", "0", ")", ";", "logger", ".", "debug", "(", "\"File \\\"\"", "+", "path", "+", "\"\\\": \"", "+", "mimeType", "+", "\" -> \\\"\"", "+", "extension", "+", "\"\\\"\"", ")", ";", "mimeTypeToExtensionMap", ".", "put", "(", "mimeType", ",", "extension", ")", ";", "}", "}", "r", ".", "close", "(", ")", ";", "}", "}", "catch", "(", "IOException", "ex", ")", "{", "logger", ".", "debug", "(", "\"Error reading \\\"\"", "+", "path", "+", "\"\\\"\"", ",", "ex", ")", ";", "}", "}" ]
Attempt to load a MIME types file. Throws no exceptions. @param path path to the file
[ "Attempt", "to", "load", "a", "MIME", "types", "file", ".", "Throws", "no", "exceptions", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-common/src/main/java/org/fcrepo/utilities/MimeTypeUtils.java#L162-L237
9,273
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/journal/readerwriter/multicast/rmi/RmiJournalReceiverHelper.java
RmiJournalReceiverHelper.figureIndexedHash
public static String figureIndexedHash(String repositoryHash, long entryIndex) { return String.valueOf((entryIndex + repositoryHash).hashCode()); }
java
public static String figureIndexedHash(String repositoryHash, long entryIndex) { return String.valueOf((entryIndex + repositoryHash).hashCode()); }
[ "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.
[ "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", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/readerwriter/multicast/rmi/RmiJournalReceiverHelper.java#L27-L30
9,274
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/journal/JournalCreator.java
JournalCreator.ingest
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.addArgument(ARGUMENT_NAME_LOG_MESSAGE, logMessage); cje.addArgument(ARGUMENT_NAME_FORMAT, format); cje.addArgument(ARGUMENT_NAME_ENCODING, encoding); cje.addArgument(ARGUMENT_NAME_NEW_PID, pid); return (String) cje.invokeAndClose(delegate, writer); } catch (JournalException e) { throw new GeneralException("Problem creating the Journal", e); } }
java
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.addArgument(ARGUMENT_NAME_LOG_MESSAGE, logMessage); cje.addArgument(ARGUMENT_NAME_FORMAT, format); cje.addArgument(ARGUMENT_NAME_ENCODING, encoding); cje.addArgument(ARGUMENT_NAME_NEW_PID, pid); return (String) cje.invokeAndClose(delegate, writer); } catch (JournalException e) { throw new GeneralException("Problem creating the Journal", e); } }
[ "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", ".", "addArgument", "(", "ARGUMENT_NAME_LOG_MESSAGE", ",", "logMessage", ")", ";", "cje", ".", "addArgument", "(", "ARGUMENT_NAME_FORMAT", ",", "format", ")", ";", "cje", ".", "addArgument", "(", "ARGUMENT_NAME_ENCODING", ",", "encoding", ")", ";", "cje", ".", "addArgument", "(", "ARGUMENT_NAME_NEW_PID", ",", "pid", ")", ";", "return", "(", "String", ")", "cje", ".", "invokeAndClose", "(", "delegate", ",", "writer", ")", ";", "}", "catch", "(", "JournalException", "e", ")", "{", "throw", "new", "GeneralException", "(", "\"Problem creating the Journal\"", ",", "e", ")", ";", "}", "}" ]
Let the delegate do it, and then write a journal entry.
[ "Let", "the", "delegate", "do", "it", "and", "then", "write", "a", "journal", "entry", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/JournalCreator.java#L100-L118
9,275
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/resourceIndex/FedoraObjectTripleGenerator_3_0.java
FedoraObjectTripleGenerator_3_0.addCommonTriples
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.GetDatastreams(null, null); for (Datastream ds : datastreams) { addCoreDatastreamTriples(ds, objURI, set); if (ds.DatastreamID.equals("DC")) { addDCTriples(ds, objURI, set); } } addRelationshipTriples(reader, objURI, set); return objURI; } catch (ResourceIndexException e) { throw e; } catch (Exception e) { throw new ResourceIndexException("Error generating triples", e); } }
java
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.GetDatastreams(null, null); for (Datastream ds : datastreams) { addCoreDatastreamTriples(ds, objURI, set); if (ds.DatastreamID.equals("DC")) { addDCTriples(ds, objURI, set); } } addRelationshipTriples(reader, objURI, set); return objURI; } catch (ResourceIndexException e) { throw e; } catch (Exception e) { throw new ResourceIndexException("Error generating triples", e); } }
[ "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", ".", "GetDatastreams", "(", "null", ",", "null", ")", ";", "for", "(", "Datastream", "ds", ":", "datastreams", ")", "{", "addCoreDatastreamTriples", "(", "ds", ",", "objURI", ",", "set", ")", ";", "if", "(", "ds", ".", "DatastreamID", ".", "equals", "(", "\"DC\"", ")", ")", "{", "addDCTriples", "(", "ds", ",", "objURI", ",", "set", ")", ";", "}", "}", "addRelationshipTriples", "(", "reader", ",", "objURI", ",", "set", ")", ";", "return", "objURI", ";", "}", "catch", "(", "ResourceIndexException", "e", ")", "{", "throw", "e", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "ResourceIndexException", "(", "\"Error generating triples\"", ",", "e", ")", ";", "}", "}" ]
Add the common core and datastream triples for the given object.
[ "Add", "the", "common", "core", "and", "datastream", "triples", "for", "the", "given", "object", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/resourceIndex/FedoraObjectTripleGenerator_3_0.java#L56-L82
9,276
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/resourceIndex/FedoraObjectTripleGenerator_3_0.java
FedoraObjectTripleGenerator_3_0.addDCTriples
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)) { String lang = dcField.getLang(); if (lang == null) { add(objURI, predicate, dcField.getValue(), set); } else { add(objURI, predicate, dcField.getValue(), lang, set); } } } }
java
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)) { String lang = dcField.getLang(); if (lang == null) { add(objURI, predicate, dcField.getValue(), set); } else { add(objURI, predicate, dcField.getValue(), lang, set); } } } }
[ "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", ")", ")", "{", "String", "lang", "=", "dcField", ".", "getLang", "(", ")", ";", "if", "(", "lang", "==", "null", ")", "{", "add", "(", "objURI", ",", "predicate", ",", "dcField", ".", "getValue", "(", ")", ",", "set", ")", ";", "}", "else", "{", "add", "(", "objURI", ",", "predicate", ",", "dcField", ".", "getValue", "(", ")", ",", "lang", ",", "set", ")", ";", "}", "}", "}", "}" ]
Add a statement about the object for each predicate, value pair expressed in the DC datastream.
[ "Add", "a", "statement", "about", "the", "object", "for", "each", "predicate", "value", "pair", "expressed", "in", "the", "DC", "datastream", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/resourceIndex/FedoraObjectTripleGenerator_3_0.java#L146-L161
9,277
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/security/servletfilters/FilterRestApiFlash.java
FilterRestApiFlash.doFilter
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException { if (logger.isDebugEnabled()) { logger.debug("Entering FilterRestApiFlash.doThisSubclass()"); } HttpServletRequest httpRequest = (HttpServletRequest)request; HttpServletResponse httpResponse = (HttpServletResponse)response; String queryString = httpRequest.getQueryString(); if(queryString != null && queryString.contains("flash=true")) { StatusHttpServletResponseWrapper sHttpResponse = new StatusHttpServletResponseWrapper(httpResponse); filterChain.doFilter(request, sHttpResponse); if(sHttpResponse.status != sHttpResponse.realStatus) { // Append the error indicator with real status try { ServletOutputStream out = sHttpResponse.getOutputStream(); out.print("::ERROR("+sHttpResponse.realStatus+")"); } catch(IllegalStateException ise) { PrintWriter out = sHttpResponse.getWriter(); out.print("::ERROR("+sHttpResponse.realStatus+")"); } } } else { filterChain.doFilter(request, response); } }
java
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException { if (logger.isDebugEnabled()) { logger.debug("Entering FilterRestApiFlash.doThisSubclass()"); } HttpServletRequest httpRequest = (HttpServletRequest)request; HttpServletResponse httpResponse = (HttpServletResponse)response; String queryString = httpRequest.getQueryString(); if(queryString != null && queryString.contains("flash=true")) { StatusHttpServletResponseWrapper sHttpResponse = new StatusHttpServletResponseWrapper(httpResponse); filterChain.doFilter(request, sHttpResponse); if(sHttpResponse.status != sHttpResponse.realStatus) { // Append the error indicator with real status try { ServletOutputStream out = sHttpResponse.getOutputStream(); out.print("::ERROR("+sHttpResponse.realStatus+")"); } catch(IllegalStateException ise) { PrintWriter out = sHttpResponse.getWriter(); out.print("::ERROR("+sHttpResponse.realStatus+")"); } } } else { filterChain.doFilter(request, response); } }
[ "public", "void", "doFilter", "(", "ServletRequest", "request", ",", "ServletResponse", "response", ",", "FilterChain", "filterChain", ")", "throws", "IOException", ",", "ServletException", "{", "if", "(", "logger", ".", "isDebugEnabled", "(", ")", ")", "{", "logger", ".", "debug", "(", "\"Entering FilterRestApiFlash.doThisSubclass()\"", ")", ";", "}", "HttpServletRequest", "httpRequest", "=", "(", "HttpServletRequest", ")", "request", ";", "HttpServletResponse", "httpResponse", "=", "(", "HttpServletResponse", ")", "response", ";", "String", "queryString", "=", "httpRequest", ".", "getQueryString", "(", ")", ";", "if", "(", "queryString", "!=", "null", "&&", "queryString", ".", "contains", "(", "\"flash=true\"", ")", ")", "{", "StatusHttpServletResponseWrapper", "sHttpResponse", "=", "new", "StatusHttpServletResponseWrapper", "(", "httpResponse", ")", ";", "filterChain", ".", "doFilter", "(", "request", ",", "sHttpResponse", ")", ";", "if", "(", "sHttpResponse", ".", "status", "!=", "sHttpResponse", ".", "realStatus", ")", "{", "// Append the error indicator with real status", "try", "{", "ServletOutputStream", "out", "=", "sHttpResponse", ".", "getOutputStream", "(", ")", ";", "out", ".", "print", "(", "\"::ERROR(\"", "+", "sHttpResponse", ".", "realStatus", "+", "\")\"", ")", ";", "}", "catch", "(", "IllegalStateException", "ise", ")", "{", "PrintWriter", "out", "=", "sHttpResponse", ".", "getWriter", "(", ")", ";", "out", ".", "print", "(", "\"::ERROR(\"", "+", "sHttpResponse", ".", "realStatus", "+", "\")\"", ")", ";", "}", "}", "}", "else", "{", "filterChain", ".", "doFilter", "(", "request", ",", "response", ")", ";", "}", "}" ]
Perform flash client response filtering
[ "Perform", "flash", "client", "response", "filtering" ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/security/servletfilters/FilterRestApiFlash.java#L50-L81
9,278
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/storage/types/Datastream.java
Datastream.copy
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[i]; } } target.DSFormatURI = DSFormatURI; target.DSMIME = DSMIME; target.DSControlGrp = DSControlGrp; target.DSInfoType = DSInfoType; target.DSState = DSState; target.DSVersionable = DSVersionable; target.DSVersionID = DSVersionID; target.DSLabel = DSLabel; target.DSCreateDT = DSCreateDT; target.DSSize = DSSize; target.DSLocation = DSLocation; target.DSLocationType = DSLocationType; target.DSChecksumType = DSChecksumType; target.DSChecksum = DSChecksum; }
java
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[i]; } } target.DSFormatURI = DSFormatURI; target.DSMIME = DSMIME; target.DSControlGrp = DSControlGrp; target.DSInfoType = DSInfoType; target.DSState = DSState; target.DSVersionable = DSVersionable; target.DSVersionID = DSVersionID; target.DSLabel = DSLabel; target.DSCreateDT = DSCreateDT; target.DSSize = DSSize; target.DSLocation = DSLocation; target.DSLocationType = DSLocationType; target.DSChecksumType = DSChecksumType; target.DSChecksum = DSChecksum; }
[ "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", "[", "i", "]", ";", "}", "}", "target", ".", "DSFormatURI", "=", "DSFormatURI", ";", "target", ".", "DSMIME", "=", "DSMIME", ";", "target", ".", "DSControlGrp", "=", "DSControlGrp", ";", "target", ".", "DSInfoType", "=", "DSInfoType", ";", "target", ".", "DSState", "=", "DSState", ";", "target", ".", "DSVersionable", "=", "DSVersionable", ";", "target", ".", "DSVersionID", "=", "DSVersionID", ";", "target", ".", "DSLabel", "=", "DSLabel", ";", "target", ".", "DSCreateDT", "=", "DSCreateDT", ";", "target", ".", "DSSize", "=", "DSSize", ";", "target", ".", "DSLocation", "=", "DSLocation", ";", "target", ".", "DSLocationType", "=", "DSLocationType", ";", "target", ".", "DSChecksumType", "=", "DSChecksumType", ";", "target", ".", "DSChecksum", "=", "DSChecksum", ";", "}" ]
Copy this instance into target
[ "Copy", "this", "instance", "into", "target" ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/storage/types/Datastream.java#L316-L340
9,279
fcrepo3/fcrepo
fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/WatchPrintStream.java
WatchPrintStream.println
@Override 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); } }
java
@Override 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); } }
[ "@", "Override", "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.
[ "Every", "time", "this", "is", "called", "the", "buffer", "is", "cleared", "an", "output", "is", "sent", "to", "the", "JTextArea", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/WatchPrintStream.java#L32-L40
9,280
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/utilities/SQLUtilityImpl.java
SQLUtilityImpl.setNumeric
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 (NumberFormatException e2) { throw new SQLException("Value specified for " + columnName + ", '" + value + "' was" + " specified as numeric, but is not"); } } }
java
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 (NumberFormatException e2) { throw new SQLException("Value specified for " + columnName + ", '" + value + "' was" + " specified as numeric, but is not"); } } }
[ "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", "(", "NumberFormatException", "e2", ")", "{", "throw", "new", "SQLException", "(", "\"Value specified for \"", "+", "columnName", "+", "\", '\"", "+", "value", "+", "\"' was\"", "+", "\" specified as numeric, but is not\"", ")", ";", "}", "}", "}" ]
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.
[ "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", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/utilities/SQLUtilityImpl.java#L436-L451
9,281
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/utilities/SQLUtilityImpl.java
SQLUtilityImpl.getSelector
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 { throw new SQLException("Unique column does not exist in given " + "column array"); } }
java
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 { throw new SQLException("Unique column does not exist in given " + "column array"); } }
[ "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", "{", "throw", "new", "SQLException", "(", "\"Unique column does not exist in given \"", "+", "\"column array\"", ")", ";", "}", "}" ]
Gets the value in the given array whose associated column name matches the given uniqueColumn name. @throws SQLException if the uniqueColumn doesn't exist in the given column array.
[ "Gets", "the", "value", "in", "the", "given", "array", "whose", "associated", "column", "name", "matches", "the", "given", "uniqueColumn", "name", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/utilities/SQLUtilityImpl.java#L460-L475
9,282
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/utilities/ServerUtility.java
ServerUtility.pingServer
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; } }
java
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; } }
[ "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.
[ "Tell", "whether", "the", "server", "is", "running", "by", "pinging", "it", "as", "a", "client", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/utilities/ServerUtility.java#L85-L94
9,283
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/utilities/ServerUtility.java
ServerUtility.reloadPolicies
public static void reloadPolicies(String protocol, String user, String pass) throws IOException { getServerResponse(protocol, user, pass, "/management/control?action=reloadPolicies"); }
java
public static void reloadPolicies(String protocol, String user, String pass) throws IOException { getServerResponse(protocol, user, pass, "/management/control?action=reloadPolicies"); }
[ "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.
[ "Signals", "for", "the", "server", "to", "reload", "its", "policies", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/utilities/ServerUtility.java#L117-L123
9,284
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/utilities/ServerUtility.java
ServerUtility.isURLFedoraServer
public static boolean isURLFedoraServer(String url) { // scheme must be http or https URI uri = URI.create(url); String scheme = uri.getScheme(); if (!scheme.equals("http") && !scheme.equals("https")) { return false; } // host must be configured hostname or localhost String fHost = CONFIG.getParameter(FEDORA_SERVER_HOST,Parameter.class).getValue(); String host = uri.getHost(); if (!host.equals(fHost) && !host.equals("localhost")) { return false; } // path must begin with configured webapp context String path = uri.getPath(); String fedoraContext = CONFIG.getParameter( FEDORA_SERVER_CONTEXT,Parameter.class).getValue(); if (!path.startsWith("/" + fedoraContext + "/")) { return false; } // port specification must match http or https port as appropriate String httpPort = CONFIG.getParameter(FEDORA_SERVER_PORT,Parameter.class).getValue(); String httpsPort = CONFIG.getParameter(FEDORA_REDIRECT_PORT,Parameter.class).getValue(); if (uri.getPort() == -1) { // unspecified, so fedoraPort must be 80 (http), or 443 (https) if (scheme.equals("http")) { return httpPort.equals("80"); } else { return httpsPort.equals("443"); } } else { // specified, so must match appropriate http or https port String port = "" + uri.getPort(); if (scheme.equals("http")) { return port.equals(httpPort); } else { return port.equals(httpsPort); } } }
java
public static boolean isURLFedoraServer(String url) { // scheme must be http or https URI uri = URI.create(url); String scheme = uri.getScheme(); if (!scheme.equals("http") && !scheme.equals("https")) { return false; } // host must be configured hostname or localhost String fHost = CONFIG.getParameter(FEDORA_SERVER_HOST,Parameter.class).getValue(); String host = uri.getHost(); if (!host.equals(fHost) && !host.equals("localhost")) { return false; } // path must begin with configured webapp context String path = uri.getPath(); String fedoraContext = CONFIG.getParameter( FEDORA_SERVER_CONTEXT,Parameter.class).getValue(); if (!path.startsWith("/" + fedoraContext + "/")) { return false; } // port specification must match http or https port as appropriate String httpPort = CONFIG.getParameter(FEDORA_SERVER_PORT,Parameter.class).getValue(); String httpsPort = CONFIG.getParameter(FEDORA_REDIRECT_PORT,Parameter.class).getValue(); if (uri.getPort() == -1) { // unspecified, so fedoraPort must be 80 (http), or 443 (https) if (scheme.equals("http")) { return httpPort.equals("80"); } else { return httpsPort.equals("443"); } } else { // specified, so must match appropriate http or https port String port = "" + uri.getPort(); if (scheme.equals("http")) { return port.equals(httpPort); } else { return port.equals(httpsPort); } } }
[ "public", "static", "boolean", "isURLFedoraServer", "(", "String", "url", ")", "{", "// scheme must be http or https", "URI", "uri", "=", "URI", ".", "create", "(", "url", ")", ";", "String", "scheme", "=", "uri", ".", "getScheme", "(", ")", ";", "if", "(", "!", "scheme", ".", "equals", "(", "\"http\"", ")", "&&", "!", "scheme", ".", "equals", "(", "\"https\"", ")", ")", "{", "return", "false", ";", "}", "// host must be configured hostname or localhost", "String", "fHost", "=", "CONFIG", ".", "getParameter", "(", "FEDORA_SERVER_HOST", ",", "Parameter", ".", "class", ")", ".", "getValue", "(", ")", ";", "String", "host", "=", "uri", ".", "getHost", "(", ")", ";", "if", "(", "!", "host", ".", "equals", "(", "fHost", ")", "&&", "!", "host", ".", "equals", "(", "\"localhost\"", ")", ")", "{", "return", "false", ";", "}", "// path must begin with configured webapp context", "String", "path", "=", "uri", ".", "getPath", "(", ")", ";", "String", "fedoraContext", "=", "CONFIG", ".", "getParameter", "(", "FEDORA_SERVER_CONTEXT", ",", "Parameter", ".", "class", ")", ".", "getValue", "(", ")", ";", "if", "(", "!", "path", ".", "startsWith", "(", "\"/\"", "+", "fedoraContext", "+", "\"/\"", ")", ")", "{", "return", "false", ";", "}", "// port specification must match http or https port as appropriate", "String", "httpPort", "=", "CONFIG", ".", "getParameter", "(", "FEDORA_SERVER_PORT", ",", "Parameter", ".", "class", ")", ".", "getValue", "(", ")", ";", "String", "httpsPort", "=", "CONFIG", ".", "getParameter", "(", "FEDORA_REDIRECT_PORT", ",", "Parameter", ".", "class", ")", ".", "getValue", "(", ")", ";", "if", "(", "uri", ".", "getPort", "(", ")", "==", "-", "1", ")", "{", "// unspecified, so fedoraPort must be 80 (http), or 443 (https)", "if", "(", "scheme", ".", "equals", "(", "\"http\"", ")", ")", "{", "return", "httpPort", ".", "equals", "(", "\"80\"", ")", ";", "}", "else", "{", "return", "httpsPort", ".", "equals", "(", "\"443\"", ")", ";", "}", "}", "else", "{", "// specified, so must match appropriate http or https port", "String", "port", "=", "\"\"", "+", "uri", ".", "getPort", "(", ")", ";", "if", "(", "scheme", ".", "equals", "(", "\"http\"", ")", ")", "{", "return", "port", ".", "equals", "(", "httpPort", ")", ";", "}", "else", "{", "return", "port", ".", "equals", "(", "httpsPort", ")", ";", "}", "}", "}" ]
Tell whether the given URL appears to be referring to somewhere within the Fedora webapp.
[ "Tell", "whether", "the", "given", "URL", "appears", "to", "be", "referring", "to", "somewhere", "within", "the", "Fedora", "webapp", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/utilities/ServerUtility.java#L160-L204
9,285
fcrepo3/fcrepo
fcrepo-server/src/main/java/org/fcrepo/server/utilities/ServerUtility.java
ServerUtility.getArgBoolean
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") || lowerArg.equals("no")) { return false; } else { throw new IllegalArgumentException(args[position] + " not a valid value. Specify true or false"); } } else { return defaultValue; } }
java
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") || lowerArg.equals("no")) { return false; } else { throw new IllegalArgumentException(args[position] + " not a valid value. Specify true or false"); } } else { return defaultValue; } }
[ "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\"", ")", "||", "lowerArg", ".", "equals", "(", "\"no\"", ")", ")", "{", "return", "false", ";", "}", "else", "{", "throw", "new", "IllegalArgumentException", "(", "args", "[", "position", "]", "+", "\" not a valid value. Specify true or false\"", ")", ";", "}", "}", "else", "{", "return", "defaultValue", ";", "}", "}" ]
Get boolean argument from list of arguments at position; use defaultValue if not present @param args @param position @param defaultValue @return
[ "Get", "boolean", "argument", "from", "list", "of", "arguments", "at", "position", ";", "use", "defaultValue", "if", "not", "present" ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/utilities/ServerUtility.java#L355-L368
9,286
fcrepo3/fcrepo
fcrepo-installer/src/main/java/org/fcrepo/utilities/install/container/TomcatServerXML.java
TomcatServerXML.setHTTPPort
public void setHTTPPort() throws InstallationFailedException { // Note this very significant assumption: this xpath will select exactly one connector 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."); } httpConnector.addAttribute("port", options .getValue(InstallOptions.TOMCAT_HTTP_PORT)); httpConnector.addAttribute("enableLookups", "true"); // supports client dns/fqdn in xacml authz policies httpConnector.addAttribute("acceptCount", "100"); httpConnector.addAttribute("maxThreads", "150"); httpConnector.addAttribute("minSpareThreads", "25"); httpConnector.addAttribute("maxSpareThreads", "75"); }
java
public void setHTTPPort() throws InstallationFailedException { // Note this very significant assumption: this xpath will select exactly one connector 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."); } httpConnector.addAttribute("port", options .getValue(InstallOptions.TOMCAT_HTTP_PORT)); httpConnector.addAttribute("enableLookups", "true"); // supports client dns/fqdn in xacml authz policies httpConnector.addAttribute("acceptCount", "100"); httpConnector.addAttribute("maxThreads", "150"); httpConnector.addAttribute("minSpareThreads", "25"); httpConnector.addAttribute("maxSpareThreads", "75"); }
[ "public", "void", "setHTTPPort", "(", ")", "throws", "InstallationFailedException", "{", "// Note this very significant assumption: this xpath will select exactly one connector", "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.\"", ")", ";", "}", "httpConnector", ".", "addAttribute", "(", "\"port\"", ",", "options", ".", "getValue", "(", "InstallOptions", ".", "TOMCAT_HTTP_PORT", ")", ")", ";", "httpConnector", ".", "addAttribute", "(", "\"enableLookups\"", ",", "\"true\"", ")", ";", "// supports client dns/fqdn in xacml authz policies", "httpConnector", ".", "addAttribute", "(", "\"acceptCount\"", ",", "\"100\"", ")", ";", "httpConnector", ".", "addAttribute", "(", "\"maxThreads\"", ",", "\"150\"", ")", ";", "httpConnector", ".", "addAttribute", "(", "\"minSpareThreads\"", ",", "\"25\"", ")", ";", "httpConnector", ".", "addAttribute", "(", "\"maxSpareThreads\"", ",", "\"75\"", ")", ";", "}" ]
Sets the http port and Fedora default http connector options. @see "http://tomcat.apache.org/tomcat-6.0-doc/config/http.html" @throws InstallationFailedException
[ "Sets", "the", "http", "port", "and", "Fedora", "default", "http", "connector", "options", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-installer/src/main/java/org/fcrepo/utilities/install/container/TomcatServerXML.java#L71-L88
9,287
fcrepo3/fcrepo
fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/utility/validate/process/PidfileIterator.java
PidfileIterator.fillNextLine
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) { throw new IllegalStateException(e); } }
java
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) { throw new IllegalStateException(e); } }
[ "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", ")", "{", "throw", "new", "IllegalStateException", "(", "e", ")", ";", "}", "}" ]
Scan through the file until we get an EOF or a good line.
[ "Scan", "through", "the", "file", "until", "we", "get", "an", "EOF", "or", "a", "good", "line", "." ]
37df51b9b857fd12c6ab8269820d406c3c4ad774
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/utility/validate/process/PidfileIterator.java#L70-L88
9,288
termsuite/termsuite-core
src/main/java/fr/univnantes/termsuite/framework/service/TermService.java
TermService.getLemma
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(); }
java
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(); }
[ "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.
[ "Returns", "the", "concatenation", "of", "inner", "words", "lemmas", "." ]
731e5d0bc7c14180713c01a9c7dffe1925f26130
https://github.com/termsuite/termsuite-core/blob/731e5d0bc7c14180713c01a9c7dffe1925f26130/src/main/java/fr/univnantes/termsuite/framework/service/TermService.java#L93-L103
9,289
aerogear/aerogear-crypto-java
src/main/java/org/jboss/aerogear/crypto/BlockCipher.java
BlockCipher.getNewCipher
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"); } }
java
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"); } }
[ "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 @param blockMode block mode name @return instance to the block mode
[ "Retrieve", "a", "new", "instance", "of", "the", "block", "mode", "provided" ]
3a371780f7deff603f5a7a1dd3de1eeb5e147202
https://github.com/aerogear/aerogear-crypto-java/blob/3a371780f7deff603f5a7a1dd3de1eeb5e147202/src/main/java/org/jboss/aerogear/crypto/BlockCipher.java#L43-L54
9,290
aerogear/aerogear-crypto-java
src/main/java/org/jboss/aerogear/crypto/CryptoBox.java
CryptoBox.encrypt
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)); int outputOffset = cipher.processBytes(message, 0, message.length, cipherText, 0); try { cipher.doFinal(cipherText, outputOffset); } catch (InvalidCipherTextException e) { throw new RuntimeException("Error: ", e); } return cipherText; }
java
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)); int outputOffset = cipher.processBytes(message, 0, message.length, cipherText, 0); try { cipher.doFinal(cipherText, outputOffset); } catch (InvalidCipherTextException e) { throw new RuntimeException("Error: ", e); } return cipherText; }
[ "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", ")", ")", ";", "int", "outputOffset", "=", "cipher", ".", "processBytes", "(", "message", ",", "0", ",", "message", ".", "length", ",", "cipherText", ",", "0", ")", ";", "try", "{", "cipher", ".", "doFinal", "(", "cipherText", ",", "outputOffset", ")", ";", "}", "catch", "(", "InvalidCipherTextException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Error: \"", ",", "e", ")", ";", "}", "return", "cipherText", ";", "}" ]
Given the iv, encrypt the provided data @param iv initialization vector @param message data to be encrypted @return byte array with the cipher text @throws RuntimeException
[ "Given", "the", "iv", "encrypt", "the", "provided", "data" ]
3a371780f7deff603f5a7a1dd3de1eeb5e147202
https://github.com/aerogear/aerogear-crypto-java/blob/3a371780f7deff603f5a7a1dd3de1eeb5e147202/src/main/java/org/jboss/aerogear/crypto/CryptoBox.java#L142-L160
9,291
aerogear/aerogear-crypto-java
src/main/java/org/jboss/aerogear/crypto/CryptoBox.java
CryptoBox.encrypt
public byte[] encrypt(String iv, String message, Encoder encoder) { return encrypt(encoder.decode(iv), encoder.decode(message)); }
java
public byte[] encrypt(String iv, String message, Encoder encoder) { return encrypt(encoder.decode(iv), encoder.decode(message)); }
[ "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 @param iv initialization vector @param message data to be encrypted @param encoder encoder provided RAW or HEX @return byte array with the cipher text
[ "Given", "the", "iv", "encrypt", "and", "encode", "the", "provided", "data" ]
3a371780f7deff603f5a7a1dd3de1eeb5e147202
https://github.com/aerogear/aerogear-crypto-java/blob/3a371780f7deff603f5a7a1dd3de1eeb5e147202/src/main/java/org/jboss/aerogear/crypto/CryptoBox.java#L170-L172
9,292
knowm/Datasets
datasets-samples/src/main/java/org/knowm/datasets/samples/HiggsBosonDemo.java
HiggsBosonDemo.addToMap
@Override public void addToMap(Map<String, String> properties, Map<String, List<Float>> rawHistogramData) { // System.out.println(Arrays.toString(properties.entrySet().toArray()));0 for (Entry<String, String> entrySet : properties.entrySet()) { String key = entrySet.getKey(); String value = entrySet.getValue(); try { Float floatValue = Float.parseFloat(value); if (floatValue > -900.0f) { List<Float> rawDataForSingleProperty = rawHistogramData.get(key); if (rawDataForSingleProperty == null) { rawDataForSingleProperty = new ArrayList<Float>(); } rawDataForSingleProperty.add(floatValue); rawHistogramData.put(key, rawDataForSingleProperty); } } catch (NumberFormatException e) { // wasn't a float, skip. } } }
java
@Override public void addToMap(Map<String, String> properties, Map<String, List<Float>> rawHistogramData) { // System.out.println(Arrays.toString(properties.entrySet().toArray()));0 for (Entry<String, String> entrySet : properties.entrySet()) { String key = entrySet.getKey(); String value = entrySet.getValue(); try { Float floatValue = Float.parseFloat(value); if (floatValue > -900.0f) { List<Float> rawDataForSingleProperty = rawHistogramData.get(key); if (rawDataForSingleProperty == null) { rawDataForSingleProperty = new ArrayList<Float>(); } rawDataForSingleProperty.add(floatValue); rawHistogramData.put(key, rawDataForSingleProperty); } } catch (NumberFormatException e) { // wasn't a float, skip. } } }
[ "@", "Override", "public", "void", "addToMap", "(", "Map", "<", "String", ",", "String", ">", "properties", ",", "Map", "<", "String", ",", "List", "<", "Float", ">", ">", "rawHistogramData", ")", "{", "// System.out.println(Arrays.toString(properties.entrySet().toArray()));0", "for", "(", "Entry", "<", "String", ",", "String", ">", "entrySet", ":", "properties", ".", "entrySet", "(", ")", ")", "{", "String", "key", "=", "entrySet", ".", "getKey", "(", ")", ";", "String", "value", "=", "entrySet", ".", "getValue", "(", ")", ";", "try", "{", "Float", "floatValue", "=", "Float", ".", "parseFloat", "(", "value", ")", ";", "if", "(", "floatValue", ">", "-", "900.0f", ")", "{", "List", "<", "Float", ">", "rawDataForSingleProperty", "=", "rawHistogramData", ".", "get", "(", "key", ")", ";", "if", "(", "rawDataForSingleProperty", "==", "null", ")", "{", "rawDataForSingleProperty", "=", "new", "ArrayList", "<", "Float", ">", "(", ")", ";", "}", "rawDataForSingleProperty", ".", "add", "(", "floatValue", ")", ";", "rawHistogramData", ".", "put", "(", "key", ",", "rawDataForSingleProperty", ")", ";", "}", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "// wasn't a float, skip.", "}", "}", "}" ]
Overriding this to weed out the -999.0 values in the dataset
[ "Overriding", "this", "to", "weed", "out", "the", "-", "999", ".", "0", "values", "in", "the", "dataset" ]
4ea16ccda1d4190a551accff78bbbe05c9c38c79
https://github.com/knowm/Datasets/blob/4ea16ccda1d4190a551accff78bbbe05c9c38c79/datasets-samples/src/main/java/org/knowm/datasets/samples/HiggsBosonDemo.java#L93-L117
9,293
termsuite/termsuite-core
src/main/java/fr/univnantes/termsuite/uima/engines/export/AbstractTSVBuilder.java
AbstractTSVBuilder.append
public void append(String firstVal, String... otherVals) throws IOException { output.append(firstVal); for (String v : otherVals) output.append(valSep).append(v); output.append(lineSep); }
java
public void append(String firstVal, String... otherVals) throws IOException { output.append(firstVal); for (String v : otherVals) output.append(valSep).append(v); output.append(lineSep); }
[ "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. @param firstVal The first value of the line @param otherVals The remaining values @throws IOException
[ "Appends", "a", "line", "to", "the", "writer", ".", "The", "values", "are", "separated", "using", "the", "current", "separator", "an", "line", "separator", "is", "appended", "at", "the", "end", "." ]
731e5d0bc7c14180713c01a9c7dffe1925f26130
https://github.com/termsuite/termsuite-core/blob/731e5d0bc7c14180713c01a9c7dffe1925f26130/src/main/java/fr/univnantes/termsuite/uima/engines/export/AbstractTSVBuilder.java#L120-L125
9,294
aerogear/aerogear-crypto-java
src/main/java/org/jboss/aerogear/crypto/Util.java
Util.checkLength
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; }
java
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; }
[ "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 @param data @param size @return data provided if valid
[ "Validate", "the", "length", "of", "the", "data", "provided" ]
3a371780f7deff603f5a7a1dd3de1eeb5e147202
https://github.com/aerogear/aerogear-crypto-java/blob/3a371780f7deff603f5a7a1dd3de1eeb5e147202/src/main/java/org/jboss/aerogear/crypto/Util.java#L50-L58
9,295
aerogear/aerogear-crypto-java
src/main/java/org/jboss/aerogear/crypto/Util.java
Util.newByteArray
public static byte[] newByteArray(byte[] data) { if (data == null) { throw new IllegalArgumentException("Data you want to copy are backed by null object."); } byte[] buffer = new byte[data.length]; System.arraycopy(data, 0, buffer, 0, data.length); return buffer; }
java
public static byte[] newByteArray(byte[] data) { if (data == null) { throw new IllegalArgumentException("Data you want to copy are backed by null object."); } byte[] buffer = new byte[data.length]; System.arraycopy(data, 0, buffer, 0, data.length); return buffer; }
[ "public", "static", "byte", "[", "]", "newByteArray", "(", "byte", "[", "]", "data", ")", "{", "if", "(", "data", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Data you want to copy are backed by null object.\"", ")", ";", "}", "byte", "[", "]", "buffer", "=", "new", "byte", "[", "data", ".", "length", "]", ";", "System", ".", "arraycopy", "(", "data", ",", "0", ",", "buffer", ",", "0", ",", "data", ".", "length", ")", ";", "return", "buffer", ";", "}" ]
Copy the provided data @param data @return byte array
[ "Copy", "the", "provided", "data" ]
3a371780f7deff603f5a7a1dd3de1eeb5e147202
https://github.com/aerogear/aerogear-crypto-java/blob/3a371780f7deff603f5a7a1dd3de1eeb5e147202/src/main/java/org/jboss/aerogear/crypto/Util.java#L111-L118
9,296
knowm/Datasets
datasets-ucsd-anomaly/src/main/java/org/knowm/datasets/ucsdanomaly/RawData2DB.java
RawData2DB.main
public static void main(String[] args) throws IOException, SerialException, SQLException { UCSDAnomalyDAO.init(args); UCSDAnomalyDAO.dropTable(); UCSDAnomalyDAO.createTable(); RawData2DB dp = new RawData2DB(); System.out.println("processing data..."); dp.go("./raw/UCSDped1/Train/", null); dp.go("./raw/UCSDped1/Test/", "UCSDped1.m"); // dp.go("./raw/UCSDped2/Train/"); // dp.go("./raw/UCSDped2/Test/"); System.out.println("done."); UCSDAnomalyDAO.release(); }
java
public static void main(String[] args) throws IOException, SerialException, SQLException { UCSDAnomalyDAO.init(args); UCSDAnomalyDAO.dropTable(); UCSDAnomalyDAO.createTable(); RawData2DB dp = new RawData2DB(); System.out.println("processing data..."); dp.go("./raw/UCSDped1/Train/", null); dp.go("./raw/UCSDped1/Test/", "UCSDped1.m"); // dp.go("./raw/UCSDped2/Train/"); // dp.go("./raw/UCSDped2/Test/"); System.out.println("done."); UCSDAnomalyDAO.release(); }
[ "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "throws", "IOException", ",", "SerialException", ",", "SQLException", "{", "UCSDAnomalyDAO", ".", "init", "(", "args", ")", ";", "UCSDAnomalyDAO", ".", "dropTable", "(", ")", ";", "UCSDAnomalyDAO", ".", "createTable", "(", ")", ";", "RawData2DB", "dp", "=", "new", "RawData2DB", "(", ")", ";", "System", ".", "out", ".", "println", "(", "\"processing data...\"", ")", ";", "dp", ".", "go", "(", "\"./raw/UCSDped1/Train/\"", ",", "null", ")", ";", "dp", ".", "go", "(", "\"./raw/UCSDped1/Test/\"", ",", "\"UCSDped1.m\"", ")", ";", "// dp.go(\"./raw/UCSDped2/Train/\");", "// dp.go(\"./raw/UCSDped2/Test/\");", "System", ".", "out", ".", "println", "(", "\"done.\"", ")", ";", "UCSDAnomalyDAO", ".", "release", "(", ")", ";", "}" ]
one-based index
[ "one", "-", "based", "index" ]
4ea16ccda1d4190a551accff78bbbe05c9c38c79
https://github.com/knowm/Datasets/blob/4ea16ccda1d4190a551accff78bbbe05c9c38c79/datasets-ucsd-anomaly/src/main/java/org/knowm/datasets/ucsdanomaly/RawData2DB.java#L56-L73
9,297
aerogear/aerogear-crypto-java
src/main/java/org/jboss/aerogear/crypto/encoders/Raw.java
Raw.decode
@Override public byte[] decode(final String data) { return data != null ? data.getBytes(CHARSET) : null; }
java
@Override public byte[] decode(final String data) { return data != null ? data.getBytes(CHARSET) : null; }
[ "@", "Override", "public", "byte", "[", "]", "decode", "(", "final", "String", "data", ")", "{", "return", "data", "!=", "null", "?", "data", ".", "getBytes", "(", "CHARSET", ")", ":", "null", ";", "}" ]
Decode the provided string @param data to be decoded @return sequence of bytes
[ "Decode", "the", "provided", "string" ]
3a371780f7deff603f5a7a1dd3de1eeb5e147202
https://github.com/aerogear/aerogear-crypto-java/blob/3a371780f7deff603f5a7a1dd3de1eeb5e147202/src/main/java/org/jboss/aerogear/crypto/encoders/Raw.java#L29-L32
9,298
termsuite/termsuite-core
src/main/java/fr/univnantes/termsuite/tools/CliUtil.java
CliUtil.printUsage
public static void printUsage(ParseException e, String cmdLine, Options options) { System.err.println(e.getMessage()); // automatically generate the help statement HelpFormatter formatter = new HelpFormatter(); PrintWriter pw = new PrintWriter(System.err); formatter.printUsage(pw, cmdLine.length() + 7, cmdLine, options); pw.flush(); }
java
public static void printUsage(ParseException e, String cmdLine, Options options) { System.err.println(e.getMessage()); // automatically generate the help statement HelpFormatter formatter = new HelpFormatter(); PrintWriter pw = new PrintWriter(System.err); formatter.printUsage(pw, cmdLine.length() + 7, cmdLine, options); pw.flush(); }
[ "public", "static", "void", "printUsage", "(", "ParseException", "e", ",", "String", "cmdLine", ",", "Options", "options", ")", "{", "System", ".", "err", ".", "println", "(", "e", ".", "getMessage", "(", ")", ")", ";", "// automatically generate the help statement", "HelpFormatter", "formatter", "=", "new", "HelpFormatter", "(", ")", ";", "PrintWriter", "pw", "=", "new", "PrintWriter", "(", "System", ".", "err", ")", ";", "formatter", ".", "printUsage", "(", "pw", ",", "cmdLine", ".", "length", "(", ")", "+", "7", ",", "cmdLine", ",", "options", ")", ";", "pw", ".", "flush", "(", ")", ";", "}" ]
Prints the command line usage to the std error output @param e The error that raised the help message @param cmdLine The command line usage @param options The options expected
[ "Prints", "the", "command", "line", "usage", "to", "the", "std", "error", "output" ]
731e5d0bc7c14180713c01a9c7dffe1925f26130
https://github.com/termsuite/termsuite-core/blob/731e5d0bc7c14180713c01a9c7dffe1925f26130/src/main/java/fr/univnantes/termsuite/tools/CliUtil.java#L76-L84
9,299
termsuite/termsuite-core
src/main/java/fr/univnantes/termsuite/tools/CliUtil.java
CliUtil.logCommandLineOptions
public static void logCommandLineOptions(Logger logger, CommandLine line) { for (Option myOption : line.getOptions()) { String message; String opt = ""; if(myOption.getOpt() != null) { opt+="-"+myOption.getOpt(); if(myOption.getLongOpt() != null) opt+=" (--"+myOption.getLongOpt()+")"; } else opt+="--"+myOption.getLongOpt()+""; if(myOption.hasArg()) message = opt + " " + myOption.getValue(); else message = opt; logger.info("with option: " + message); } }
java
public static void logCommandLineOptions(Logger logger, CommandLine line) { for (Option myOption : line.getOptions()) { String message; String opt = ""; if(myOption.getOpt() != null) { opt+="-"+myOption.getOpt(); if(myOption.getLongOpt() != null) opt+=" (--"+myOption.getLongOpt()+")"; } else opt+="--"+myOption.getLongOpt()+""; if(myOption.hasArg()) message = opt + " " + myOption.getValue(); else message = opt; logger.info("with option: " + message); } }
[ "public", "static", "void", "logCommandLineOptions", "(", "Logger", "logger", ",", "CommandLine", "line", ")", "{", "for", "(", "Option", "myOption", ":", "line", ".", "getOptions", "(", ")", ")", "{", "String", "message", ";", "String", "opt", "=", "\"\"", ";", "if", "(", "myOption", ".", "getOpt", "(", ")", "!=", "null", ")", "{", "opt", "+=", "\"-\"", "+", "myOption", ".", "getOpt", "(", ")", ";", "if", "(", "myOption", ".", "getLongOpt", "(", ")", "!=", "null", ")", "opt", "+=", "\" (--\"", "+", "myOption", ".", "getLongOpt", "(", ")", "+", "\")\"", ";", "}", "else", "opt", "+=", "\"--\"", "+", "myOption", ".", "getLongOpt", "(", ")", "+", "\"\"", ";", "if", "(", "myOption", ".", "hasArg", "(", ")", ")", "message", "=", "opt", "+", "\" \"", "+", "myOption", ".", "getValue", "(", ")", ";", "else", "message", "=", "opt", ";", "logger", ".", "info", "(", "\"with option: \"", "+", "message", ")", ";", "}", "}" ]
Displays all command line options in log messages. @param line
[ "Displays", "all", "command", "line", "options", "in", "log", "messages", "." ]
731e5d0bc7c14180713c01a9c7dffe1925f26130
https://github.com/termsuite/termsuite-core/blob/731e5d0bc7c14180713c01a9c7dffe1925f26130/src/main/java/fr/univnantes/termsuite/tools/CliUtil.java#L91-L110