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
|
---|---|---|---|---|---|---|---|---|---|---|---|
8,800 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/storage/translation/handlers/METSContentHandler.java
|
METSContentHandler.setRDFAsDatastream
|
private void setRDFAsDatastream(StringBuffer buf) {
DatastreamXMLMetadata ds = new DatastreamXMLMetadata();
// set the attrs common to all datastream versions
ds.DatastreamID = "RELS-INT";
ds.DSVersionable = false;
ds.DSFormatURI = m_dsFormatURI;
ds.DatastreamAltIDs = m_dsAltIDs;
ds.DSVersionID = "RELS-INT.0";
ds.DSLabel =
"DO NOT EDIT: System-generated datastream to preserve METS DMDID/ADMID relationships.";
ds.DSCreateDT = new Date();
ds.DSMIME = "application/rdf+xml";
// set the attrs specific to datastream version
ds.DSControlGrp = "X";
ds.DSState = "A";
ds.DSLocation =
m_obj.getPid() + "+" + ds.DatastreamID + "+" + ds.DSVersionID;
ds.DSLocationType = Datastream.DS_LOCATION_TYPE_INTERNAL;
ds.DSInfoType = "DATA";
ds.DSMDClass = DatastreamXMLMetadata.TECHNICAL;
// now set the xml content stream itself...
try {
ds.xmlContent = buf.toString().getBytes(m_characterEncoding);
ds.DSSize = ds.xmlContent.length;
} catch (UnsupportedEncodingException uee) {
logger.error("Encoding error when creating RELS-INT datastream", uee);
}
// FINALLY! add the RDF and an inline xml datastream in the digital object
m_obj.addDatastreamVersion(ds, true);
}
|
java
|
private void setRDFAsDatastream(StringBuffer buf) {
DatastreamXMLMetadata ds = new DatastreamXMLMetadata();
// set the attrs common to all datastream versions
ds.DatastreamID = "RELS-INT";
ds.DSVersionable = false;
ds.DSFormatURI = m_dsFormatURI;
ds.DatastreamAltIDs = m_dsAltIDs;
ds.DSVersionID = "RELS-INT.0";
ds.DSLabel =
"DO NOT EDIT: System-generated datastream to preserve METS DMDID/ADMID relationships.";
ds.DSCreateDT = new Date();
ds.DSMIME = "application/rdf+xml";
// set the attrs specific to datastream version
ds.DSControlGrp = "X";
ds.DSState = "A";
ds.DSLocation =
m_obj.getPid() + "+" + ds.DatastreamID + "+" + ds.DSVersionID;
ds.DSLocationType = Datastream.DS_LOCATION_TYPE_INTERNAL;
ds.DSInfoType = "DATA";
ds.DSMDClass = DatastreamXMLMetadata.TECHNICAL;
// now set the xml content stream itself...
try {
ds.xmlContent = buf.toString().getBytes(m_characterEncoding);
ds.DSSize = ds.xmlContent.length;
} catch (UnsupportedEncodingException uee) {
logger.error("Encoding error when creating RELS-INT datastream", uee);
}
// FINALLY! add the RDF and an inline xml datastream in the digital object
m_obj.addDatastreamVersion(ds, true);
}
|
[
"private",
"void",
"setRDFAsDatastream",
"(",
"StringBuffer",
"buf",
")",
"{",
"DatastreamXMLMetadata",
"ds",
"=",
"new",
"DatastreamXMLMetadata",
"(",
")",
";",
"// set the attrs common to all datastream versions",
"ds",
".",
"DatastreamID",
"=",
"\"RELS-INT\"",
";",
"ds",
".",
"DSVersionable",
"=",
"false",
";",
"ds",
".",
"DSFormatURI",
"=",
"m_dsFormatURI",
";",
"ds",
".",
"DatastreamAltIDs",
"=",
"m_dsAltIDs",
";",
"ds",
".",
"DSVersionID",
"=",
"\"RELS-INT.0\"",
";",
"ds",
".",
"DSLabel",
"=",
"\"DO NOT EDIT: System-generated datastream to preserve METS DMDID/ADMID relationships.\"",
";",
"ds",
".",
"DSCreateDT",
"=",
"new",
"Date",
"(",
")",
";",
"ds",
".",
"DSMIME",
"=",
"\"application/rdf+xml\"",
";",
"// set the attrs specific to datastream version",
"ds",
".",
"DSControlGrp",
"=",
"\"X\"",
";",
"ds",
".",
"DSState",
"=",
"\"A\"",
";",
"ds",
".",
"DSLocation",
"=",
"m_obj",
".",
"getPid",
"(",
")",
"+",
"\"+\"",
"+",
"ds",
".",
"DatastreamID",
"+",
"\"+\"",
"+",
"ds",
".",
"DSVersionID",
";",
"ds",
".",
"DSLocationType",
"=",
"Datastream",
".",
"DS_LOCATION_TYPE_INTERNAL",
";",
"ds",
".",
"DSInfoType",
"=",
"\"DATA\"",
";",
"ds",
".",
"DSMDClass",
"=",
"DatastreamXMLMetadata",
".",
"TECHNICAL",
";",
"// now set the xml content stream itself...",
"try",
"{",
"ds",
".",
"xmlContent",
"=",
"buf",
".",
"toString",
"(",
")",
".",
"getBytes",
"(",
"m_characterEncoding",
")",
";",
"ds",
".",
"DSSize",
"=",
"ds",
".",
"xmlContent",
".",
"length",
";",
"}",
"catch",
"(",
"UnsupportedEncodingException",
"uee",
")",
"{",
"logger",
".",
"error",
"(",
"\"Encoding error when creating RELS-INT datastream\"",
",",
"uee",
")",
";",
"}",
"// FINALLY! add the RDF and an inline xml datastream in the digital object",
"m_obj",
".",
"addDatastreamVersion",
"(",
"ds",
",",
"true",
")",
";",
"}"
] |
DMDID and ADMID relationships found in the METS file.
|
[
"DMDID",
"and",
"ADMID",
"relationships",
"found",
"in",
"the",
"METS",
"file",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/storage/translation/handlers/METSContentHandler.java#L1124-L1155
|
8,801 |
fcrepo3/fcrepo
|
fcrepo-installer/src/main/java/org/fcrepo/utilities/install/container/Tomcat5ServerXML.java
|
Tomcat5ServerXML.setSSLPort
|
public void setSSLPort() throws InstallationFailedException {
Element httpsConnector =
(Element) getDocument()
.selectSingleNode(HTTPS_CONNECTOR_XPATH);
if (options.getBooleanValue(InstallOptions.SSL_AVAILABLE, true)) {
if (httpsConnector == null) {
Element service =
(Element) getDocument()
.selectSingleNode("/Server/Service[@name='Catalina']");
httpsConnector = service.addElement("Connector");
httpsConnector.addAttribute("maxThreads", "150");
httpsConnector.addAttribute("minSpareThreads", "25");
httpsConnector.addAttribute("maxSpareThreads", "75");
httpsConnector.addAttribute("disableUploadTimeout", "true");
httpsConnector.addAttribute("acceptCount", "100");
httpsConnector.addAttribute("debug", "0");
httpsConnector.addAttribute("scheme", "https");
httpsConnector.addAttribute("secure", "true");
httpsConnector.addAttribute("clientAuth", "false");
httpsConnector.addAttribute("sslProtocol", "TLS");
}
httpsConnector.addAttribute("port", options
.getValue(InstallOptions.TOMCAT_SSL_PORT));
httpsConnector.addAttribute("enableLookups", "true"); // supports client dns/fqdn in xacml authz policies
String keystore = options.getValue(InstallOptions.KEYSTORE_FILE);
if (keystore.equals(InstallOptions.INCLUDED)) {
keystore = KEYSTORE_LOCATION;
}
addAttribute(httpsConnector,
"keystoreFile",
keystore,
InstallOptions.DEFAULT);
addAttribute(httpsConnector,
"keystorePass",
options.getValue(InstallOptions.KEYSTORE_PASSWORD),
KEYSTORE_PASSWORD_DEFAULT);
addAttribute(httpsConnector,
"keystoreType",
options.getValue(InstallOptions.KEYSTORE_TYPE),
KEYSTORE_TYPE_DEFAULT);
// The redirectPort for the non-SSL connector should match the port on
// the SSL connector, per:
// http://tomcat.apache.org/tomcat-5.0-doc/ssl-howto.html
Element httpConnector =
(Element) getDocument()
.selectSingleNode(HTTP_CONNECTOR_XPATH);
if (httpConnector != null) {
httpConnector.addAttribute("redirectPort", options
.getValue(InstallOptions.TOMCAT_SSL_PORT));
} else {
throw new InstallationFailedException("Unable to set server.xml SSL Port. XPath for Connector element failed.");
}
} else if (httpsConnector != null) {
httpsConnector.getParent().remove(httpsConnector);
}
}
|
java
|
public void setSSLPort() throws InstallationFailedException {
Element httpsConnector =
(Element) getDocument()
.selectSingleNode(HTTPS_CONNECTOR_XPATH);
if (options.getBooleanValue(InstallOptions.SSL_AVAILABLE, true)) {
if (httpsConnector == null) {
Element service =
(Element) getDocument()
.selectSingleNode("/Server/Service[@name='Catalina']");
httpsConnector = service.addElement("Connector");
httpsConnector.addAttribute("maxThreads", "150");
httpsConnector.addAttribute("minSpareThreads", "25");
httpsConnector.addAttribute("maxSpareThreads", "75");
httpsConnector.addAttribute("disableUploadTimeout", "true");
httpsConnector.addAttribute("acceptCount", "100");
httpsConnector.addAttribute("debug", "0");
httpsConnector.addAttribute("scheme", "https");
httpsConnector.addAttribute("secure", "true");
httpsConnector.addAttribute("clientAuth", "false");
httpsConnector.addAttribute("sslProtocol", "TLS");
}
httpsConnector.addAttribute("port", options
.getValue(InstallOptions.TOMCAT_SSL_PORT));
httpsConnector.addAttribute("enableLookups", "true"); // supports client dns/fqdn in xacml authz policies
String keystore = options.getValue(InstallOptions.KEYSTORE_FILE);
if (keystore.equals(InstallOptions.INCLUDED)) {
keystore = KEYSTORE_LOCATION;
}
addAttribute(httpsConnector,
"keystoreFile",
keystore,
InstallOptions.DEFAULT);
addAttribute(httpsConnector,
"keystorePass",
options.getValue(InstallOptions.KEYSTORE_PASSWORD),
KEYSTORE_PASSWORD_DEFAULT);
addAttribute(httpsConnector,
"keystoreType",
options.getValue(InstallOptions.KEYSTORE_TYPE),
KEYSTORE_TYPE_DEFAULT);
// The redirectPort for the non-SSL connector should match the port on
// the SSL connector, per:
// http://tomcat.apache.org/tomcat-5.0-doc/ssl-howto.html
Element httpConnector =
(Element) getDocument()
.selectSingleNode(HTTP_CONNECTOR_XPATH);
if (httpConnector != null) {
httpConnector.addAttribute("redirectPort", options
.getValue(InstallOptions.TOMCAT_SSL_PORT));
} else {
throw new InstallationFailedException("Unable to set server.xml SSL Port. XPath for Connector element failed.");
}
} else if (httpsConnector != null) {
httpsConnector.getParent().remove(httpsConnector);
}
}
|
[
"public",
"void",
"setSSLPort",
"(",
")",
"throws",
"InstallationFailedException",
"{",
"Element",
"httpsConnector",
"=",
"(",
"Element",
")",
"getDocument",
"(",
")",
".",
"selectSingleNode",
"(",
"HTTPS_CONNECTOR_XPATH",
")",
";",
"if",
"(",
"options",
".",
"getBooleanValue",
"(",
"InstallOptions",
".",
"SSL_AVAILABLE",
",",
"true",
")",
")",
"{",
"if",
"(",
"httpsConnector",
"==",
"null",
")",
"{",
"Element",
"service",
"=",
"(",
"Element",
")",
"getDocument",
"(",
")",
".",
"selectSingleNode",
"(",
"\"/Server/Service[@name='Catalina']\"",
")",
";",
"httpsConnector",
"=",
"service",
".",
"addElement",
"(",
"\"Connector\"",
")",
";",
"httpsConnector",
".",
"addAttribute",
"(",
"\"maxThreads\"",
",",
"\"150\"",
")",
";",
"httpsConnector",
".",
"addAttribute",
"(",
"\"minSpareThreads\"",
",",
"\"25\"",
")",
";",
"httpsConnector",
".",
"addAttribute",
"(",
"\"maxSpareThreads\"",
",",
"\"75\"",
")",
";",
"httpsConnector",
".",
"addAttribute",
"(",
"\"disableUploadTimeout\"",
",",
"\"true\"",
")",
";",
"httpsConnector",
".",
"addAttribute",
"(",
"\"acceptCount\"",
",",
"\"100\"",
")",
";",
"httpsConnector",
".",
"addAttribute",
"(",
"\"debug\"",
",",
"\"0\"",
")",
";",
"httpsConnector",
".",
"addAttribute",
"(",
"\"scheme\"",
",",
"\"https\"",
")",
";",
"httpsConnector",
".",
"addAttribute",
"(",
"\"secure\"",
",",
"\"true\"",
")",
";",
"httpsConnector",
".",
"addAttribute",
"(",
"\"clientAuth\"",
",",
"\"false\"",
")",
";",
"httpsConnector",
".",
"addAttribute",
"(",
"\"sslProtocol\"",
",",
"\"TLS\"",
")",
";",
"}",
"httpsConnector",
".",
"addAttribute",
"(",
"\"port\"",
",",
"options",
".",
"getValue",
"(",
"InstallOptions",
".",
"TOMCAT_SSL_PORT",
")",
")",
";",
"httpsConnector",
".",
"addAttribute",
"(",
"\"enableLookups\"",
",",
"\"true\"",
")",
";",
"// supports client dns/fqdn in xacml authz policies",
"String",
"keystore",
"=",
"options",
".",
"getValue",
"(",
"InstallOptions",
".",
"KEYSTORE_FILE",
")",
";",
"if",
"(",
"keystore",
".",
"equals",
"(",
"InstallOptions",
".",
"INCLUDED",
")",
")",
"{",
"keystore",
"=",
"KEYSTORE_LOCATION",
";",
"}",
"addAttribute",
"(",
"httpsConnector",
",",
"\"keystoreFile\"",
",",
"keystore",
",",
"InstallOptions",
".",
"DEFAULT",
")",
";",
"addAttribute",
"(",
"httpsConnector",
",",
"\"keystorePass\"",
",",
"options",
".",
"getValue",
"(",
"InstallOptions",
".",
"KEYSTORE_PASSWORD",
")",
",",
"KEYSTORE_PASSWORD_DEFAULT",
")",
";",
"addAttribute",
"(",
"httpsConnector",
",",
"\"keystoreType\"",
",",
"options",
".",
"getValue",
"(",
"InstallOptions",
".",
"KEYSTORE_TYPE",
")",
",",
"KEYSTORE_TYPE_DEFAULT",
")",
";",
"// The redirectPort for the non-SSL connector should match the port on",
"// the SSL connector, per:",
"// http://tomcat.apache.org/tomcat-5.0-doc/ssl-howto.html",
"Element",
"httpConnector",
"=",
"(",
"Element",
")",
"getDocument",
"(",
")",
".",
"selectSingleNode",
"(",
"HTTP_CONNECTOR_XPATH",
")",
";",
"if",
"(",
"httpConnector",
"!=",
"null",
")",
"{",
"httpConnector",
".",
"addAttribute",
"(",
"\"redirectPort\"",
",",
"options",
".",
"getValue",
"(",
"InstallOptions",
".",
"TOMCAT_SSL_PORT",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"InstallationFailedException",
"(",
"\"Unable to set server.xml SSL Port. XPath for Connector element failed.\"",
")",
";",
"}",
"}",
"else",
"if",
"(",
"httpsConnector",
"!=",
"null",
")",
"{",
"httpsConnector",
".",
"getParent",
"(",
")",
".",
"remove",
"(",
"httpsConnector",
")",
";",
"}",
"}"
] |
Sets the port and keystore information on the SSL connector if it already
exists; creates a new SSL connector, otherwise. Also sets the
redirectPort on the non-SSL connector to match.
@throws InstallationFailedException
|
[
"Sets",
"the",
"port",
"and",
"keystore",
"information",
"on",
"the",
"SSL",
"connector",
"if",
"it",
"already",
"exists",
";",
"creates",
"a",
"new",
"SSL",
"connector",
"otherwise",
".",
"Also",
"sets",
"the",
"redirectPort",
"on",
"the",
"non",
"-",
"SSL",
"connector",
"to",
"match",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-installer/src/main/java/org/fcrepo/utilities/install/container/Tomcat5ServerXML.java#L94-L152
|
8,802 |
fcrepo3/fcrepo
|
fcrepo-installer/src/main/java/org/fcrepo/utilities/install/container/Tomcat5ServerXML.java
|
Tomcat5ServerXML.addAttribute
|
private void addAttribute(Element element,
String attributeName,
String attributeValue,
String defaultValue) {
if (attributeValue == null || attributeValue.equals(defaultValue)) {
Attribute attribute =
(Attribute) element.selectSingleNode(attributeName);
if (attribute != null) {
element.remove(attribute);
}
} else {
element.addAttribute(attributeName, attributeValue);
}
}
|
java
|
private void addAttribute(Element element,
String attributeName,
String attributeValue,
String defaultValue) {
if (attributeValue == null || attributeValue.equals(defaultValue)) {
Attribute attribute =
(Attribute) element.selectSingleNode(attributeName);
if (attribute != null) {
element.remove(attribute);
}
} else {
element.addAttribute(attributeName, attributeValue);
}
}
|
[
"private",
"void",
"addAttribute",
"(",
"Element",
"element",
",",
"String",
"attributeName",
",",
"String",
"attributeValue",
",",
"String",
"defaultValue",
")",
"{",
"if",
"(",
"attributeValue",
"==",
"null",
"||",
"attributeValue",
".",
"equals",
"(",
"defaultValue",
")",
")",
"{",
"Attribute",
"attribute",
"=",
"(",
"Attribute",
")",
"element",
".",
"selectSingleNode",
"(",
"attributeName",
")",
";",
"if",
"(",
"attribute",
"!=",
"null",
")",
"{",
"element",
".",
"remove",
"(",
"attribute",
")",
";",
"}",
"}",
"else",
"{",
"element",
".",
"addAttribute",
"(",
"attributeName",
",",
"attributeValue",
")",
";",
"}",
"}"
] |
Adds the attribute to the element if the attributeValue is not equal to
defaultValue. If attributeValue is null or equals defaultValue, remove
the attribute from the element if it is present.
@param element
@param attributeName
@param attributeValue
@param defaultValue
|
[
"Adds",
"the",
"attribute",
"to",
"the",
"element",
"if",
"the",
"attributeValue",
"is",
"not",
"equal",
"to",
"defaultValue",
".",
"If",
"attributeValue",
"is",
"null",
"or",
"equals",
"defaultValue",
"remove",
"the",
"attribute",
"from",
"the",
"element",
"if",
"it",
"is",
"present",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-installer/src/main/java/org/fcrepo/utilities/install/container/Tomcat5ServerXML.java#L190-L203
|
8,803 |
fcrepo3/fcrepo
|
fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/objecteditor/types/DatastreamBindingRule.java
|
DatastreamBindingRule.accepts
|
public boolean accepts(String type) {
if (m_acceptsAll) {
return true;
}
String[] parts = type.split("/");
if (parts.length != 2) {
return false;
}
for (String element : m_types) {
if (element.equals(parts[0] + "/*") || element.equals(type)) {
return true;
}
}
return false;
}
|
java
|
public boolean accepts(String type) {
if (m_acceptsAll) {
return true;
}
String[] parts = type.split("/");
if (parts.length != 2) {
return false;
}
for (String element : m_types) {
if (element.equals(parts[0] + "/*") || element.equals(type)) {
return true;
}
}
return false;
}
|
[
"public",
"boolean",
"accepts",
"(",
"String",
"type",
")",
"{",
"if",
"(",
"m_acceptsAll",
")",
"{",
"return",
"true",
";",
"}",
"String",
"[",
"]",
"parts",
"=",
"type",
".",
"split",
"(",
"\"/\"",
")",
";",
"if",
"(",
"parts",
".",
"length",
"!=",
"2",
")",
"{",
"return",
"false",
";",
"}",
"for",
"(",
"String",
"element",
":",
"m_types",
")",
"{",
"if",
"(",
"element",
".",
"equals",
"(",
"parts",
"[",
"0",
"]",
"+",
"\"/*\"",
")",
"||",
"element",
".",
"equals",
"(",
"type",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Does this rule allow the given type?
|
[
"Does",
"this",
"rule",
"allow",
"the",
"given",
"type?"
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/objecteditor/types/DatastreamBindingRule.java#L60-L74
|
8,804 |
fcrepo3/fcrepo
|
fcrepo-common/src/main/java/org/fcrepo/utilities/DriverShim.java
|
DriverShim.loadAndRegister
|
public static final void loadAndRegister(File driverJarFile,
String driverClassName)
throws Exception {
loadAndRegister(new URL("jar:" + driverJarFile.toURI() + "!/"),
driverClassName);
}
|
java
|
public static final void loadAndRegister(File driverJarFile,
String driverClassName)
throws Exception {
loadAndRegister(new URL("jar:" + driverJarFile.toURI() + "!/"),
driverClassName);
}
|
[
"public",
"static",
"final",
"void",
"loadAndRegister",
"(",
"File",
"driverJarFile",
",",
"String",
"driverClassName",
")",
"throws",
"Exception",
"{",
"loadAndRegister",
"(",
"new",
"URL",
"(",
"\"jar:\"",
"+",
"driverJarFile",
".",
"toURI",
"(",
")",
"+",
"\"!/\"",
")",
",",
"driverClassName",
")",
";",
"}"
] |
Loads the driver from the given jar file and registers it with the driver
manager.
|
[
"Loads",
"the",
"driver",
"from",
"the",
"given",
"jar",
"file",
"and",
"registers",
"it",
"with",
"the",
"driver",
"manager",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-common/src/main/java/org/fcrepo/utilities/DriverShim.java#L49-L54
|
8,805 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/access/DynamicAccessImpl.java
|
DynamicAccessImpl.getServiceDefinitions
|
public String[] getServiceDefinitions(Context context,
String PID,
Date asOfDateTime)
throws ServerException {
// FIXIT! In FUTURE this method might consult some source that tells
// what Service Definitions are appropriate to dynamically associate
// with the object. The rules for association might be based on the
// context or based on something about the particular object (PID).
// There is one rule that is always true - associate the Default
// Service Definition with EVERY object. For now we will just take the
// dynamic Service Definitions that were loaded by DynamicAccessModule.
// NOTE: AT THIS TIME THERE THERE IS JUST ONE LOADED, NAMELY,
// THE DEFAULT DISSEMINATOR SDEF (sDefPID = fedora-system:3)
ArrayList<String> sdefs = new ArrayList<String>();
Iterator<String> iter = dynamicServiceToDeployment.keySet().iterator();
while (iter.hasNext()) {
sdefs.add(iter.next());
}
return sdefs.toArray(EMPTY_STRING_ARRAY);
}
|
java
|
public String[] getServiceDefinitions(Context context,
String PID,
Date asOfDateTime)
throws ServerException {
// FIXIT! In FUTURE this method might consult some source that tells
// what Service Definitions are appropriate to dynamically associate
// with the object. The rules for association might be based on the
// context or based on something about the particular object (PID).
// There is one rule that is always true - associate the Default
// Service Definition with EVERY object. For now we will just take the
// dynamic Service Definitions that were loaded by DynamicAccessModule.
// NOTE: AT THIS TIME THERE THERE IS JUST ONE LOADED, NAMELY,
// THE DEFAULT DISSEMINATOR SDEF (sDefPID = fedora-system:3)
ArrayList<String> sdefs = new ArrayList<String>();
Iterator<String> iter = dynamicServiceToDeployment.keySet().iterator();
while (iter.hasNext()) {
sdefs.add(iter.next());
}
return sdefs.toArray(EMPTY_STRING_ARRAY);
}
|
[
"public",
"String",
"[",
"]",
"getServiceDefinitions",
"(",
"Context",
"context",
",",
"String",
"PID",
",",
"Date",
"asOfDateTime",
")",
"throws",
"ServerException",
"{",
"// FIXIT! In FUTURE this method might consult some source that tells",
"// what Service Definitions are appropriate to dynamically associate",
"// with the object. The rules for association might be based on the",
"// context or based on something about the particular object (PID).",
"// There is one rule that is always true - associate the Default",
"// Service Definition with EVERY object. For now we will just take the",
"// dynamic Service Definitions that were loaded by DynamicAccessModule.",
"// NOTE: AT THIS TIME THERE THERE IS JUST ONE LOADED, NAMELY,",
"// THE DEFAULT DISSEMINATOR SDEF (sDefPID = fedora-system:3)",
"ArrayList",
"<",
"String",
">",
"sdefs",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"Iterator",
"<",
"String",
">",
"iter",
"=",
"dynamicServiceToDeployment",
".",
"keySet",
"(",
")",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"iter",
".",
"hasNext",
"(",
")",
")",
"{",
"sdefs",
".",
"add",
"(",
"iter",
".",
"next",
"(",
")",
")",
";",
"}",
"return",
"sdefs",
".",
"toArray",
"(",
"EMPTY_STRING_ARRAY",
")",
";",
"}"
] |
Get a list of Service Definition identifiers for dynamic disseminators
associated with the digital object.
@param context
@param PID
identifier of digital object being reflected upon
@param asOfDateTime
@return an array of Service Definition PIDs
@throws ServerException
|
[
"Get",
"a",
"list",
"of",
"Service",
"Definition",
"identifiers",
"for",
"dynamic",
"disseminators",
"associated",
"with",
"the",
"digital",
"object",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/access/DynamicAccessImpl.java#L87-L107
|
8,806 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/access/DynamicAccessImpl.java
|
DynamicAccessImpl.listMethods
|
public ObjectMethodsDef[] listMethods(Context context,
String PID,
Date asOfDateTime)
throws ServerException {
String[] sDefPIDs = getServiceDefinitions(context, PID, asOfDateTime);
Date versDateTime = asOfDateTime;
ArrayList<ObjectMethodsDef> objectMethods =
new ArrayList<ObjectMethodsDef>();
for (String element : sDefPIDs) {
MethodDef[] methodDefs =
getMethods(context, PID, element, asOfDateTime);
for (MethodDef element2 : methodDefs) {
ObjectMethodsDef method = new ObjectMethodsDef();
method.PID = PID;
method.asOfDate = versDateTime;
method.sDefPID = element;
method.methodName = element2.methodName;
method.methodParmDefs = element2.methodParms;
objectMethods.add(method);
}
}
return objectMethods
.toArray(OBJ_METHOD_DEF_ARRAY_TYPE);
}
|
java
|
public ObjectMethodsDef[] listMethods(Context context,
String PID,
Date asOfDateTime)
throws ServerException {
String[] sDefPIDs = getServiceDefinitions(context, PID, asOfDateTime);
Date versDateTime = asOfDateTime;
ArrayList<ObjectMethodsDef> objectMethods =
new ArrayList<ObjectMethodsDef>();
for (String element : sDefPIDs) {
MethodDef[] methodDefs =
getMethods(context, PID, element, asOfDateTime);
for (MethodDef element2 : methodDefs) {
ObjectMethodsDef method = new ObjectMethodsDef();
method.PID = PID;
method.asOfDate = versDateTime;
method.sDefPID = element;
method.methodName = element2.methodName;
method.methodParmDefs = element2.methodParms;
objectMethods.add(method);
}
}
return objectMethods
.toArray(OBJ_METHOD_DEF_ARRAY_TYPE);
}
|
[
"public",
"ObjectMethodsDef",
"[",
"]",
"listMethods",
"(",
"Context",
"context",
",",
"String",
"PID",
",",
"Date",
"asOfDateTime",
")",
"throws",
"ServerException",
"{",
"String",
"[",
"]",
"sDefPIDs",
"=",
"getServiceDefinitions",
"(",
"context",
",",
"PID",
",",
"asOfDateTime",
")",
";",
"Date",
"versDateTime",
"=",
"asOfDateTime",
";",
"ArrayList",
"<",
"ObjectMethodsDef",
">",
"objectMethods",
"=",
"new",
"ArrayList",
"<",
"ObjectMethodsDef",
">",
"(",
")",
";",
"for",
"(",
"String",
"element",
":",
"sDefPIDs",
")",
"{",
"MethodDef",
"[",
"]",
"methodDefs",
"=",
"getMethods",
"(",
"context",
",",
"PID",
",",
"element",
",",
"asOfDateTime",
")",
";",
"for",
"(",
"MethodDef",
"element2",
":",
"methodDefs",
")",
"{",
"ObjectMethodsDef",
"method",
"=",
"new",
"ObjectMethodsDef",
"(",
")",
";",
"method",
".",
"PID",
"=",
"PID",
";",
"method",
".",
"asOfDate",
"=",
"versDateTime",
";",
"method",
".",
"sDefPID",
"=",
"element",
";",
"method",
".",
"methodName",
"=",
"element2",
".",
"methodName",
";",
"method",
".",
"methodParmDefs",
"=",
"element2",
".",
"methodParms",
";",
"objectMethods",
".",
"add",
"(",
"method",
")",
";",
"}",
"}",
"return",
"objectMethods",
".",
"toArray",
"(",
"OBJ_METHOD_DEF_ARRAY_TYPE",
")",
";",
"}"
] |
Get the definitions for all dynamic disseminations on the object. This
will return the method definitions for all methods for all of the dynamic
disseminators associated with the object.
@param context
@param PID
identifier of digital object being reflected upon
@param asOfDateTime
@return an array of object method definitions
@throws ServerException
|
[
"Get",
"the",
"definitions",
"for",
"all",
"dynamic",
"disseminations",
"on",
"the",
"object",
".",
"This",
"will",
"return",
"the",
"method",
"definitions",
"for",
"all",
"methods",
"for",
"all",
"of",
"the",
"dynamic",
"disseminators",
"associated",
"with",
"the",
"object",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/access/DynamicAccessImpl.java#L263-L286
|
8,807 |
fcrepo3/fcrepo
|
fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/batch/BatchModify.java
|
BatchModify.getDuration
|
private static String getDuration(long millis) {
long tsec = millis / 1000;
long h = tsec / 60 / 60;
long m = (tsec - h * 60 * 60) / 60;
long s = tsec - h * 60 * 60 - m * 60;
StringBuffer out = new StringBuffer();
if (h > 0) {
out.append(h + " hour");
if (h > 1) {
out.append('s');
}
}
if (m > 0) {
if (h > 0) {
out.append(", ");
}
out.append(m + " minute");
if (m > 1) {
out.append('s');
}
}
if (s > 0 || h == 0 && m == 0) {
if (h > 0 || m > 0) {
out.append(", ");
}
out.append(s + " second");
if (s != 1) {
out.append('s');
}
}
return out.toString();
}
|
java
|
private static String getDuration(long millis) {
long tsec = millis / 1000;
long h = tsec / 60 / 60;
long m = (tsec - h * 60 * 60) / 60;
long s = tsec - h * 60 * 60 - m * 60;
StringBuffer out = new StringBuffer();
if (h > 0) {
out.append(h + " hour");
if (h > 1) {
out.append('s');
}
}
if (m > 0) {
if (h > 0) {
out.append(", ");
}
out.append(m + " minute");
if (m > 1) {
out.append('s');
}
}
if (s > 0 || h == 0 && m == 0) {
if (h > 0 || m > 0) {
out.append(", ");
}
out.append(s + " second");
if (s != 1) {
out.append('s');
}
}
return out.toString();
}
|
[
"private",
"static",
"String",
"getDuration",
"(",
"long",
"millis",
")",
"{",
"long",
"tsec",
"=",
"millis",
"/",
"1000",
";",
"long",
"h",
"=",
"tsec",
"/",
"60",
"/",
"60",
";",
"long",
"m",
"=",
"(",
"tsec",
"-",
"h",
"*",
"60",
"*",
"60",
")",
"/",
"60",
";",
"long",
"s",
"=",
"tsec",
"-",
"h",
"*",
"60",
"*",
"60",
"-",
"m",
"*",
"60",
";",
"StringBuffer",
"out",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"if",
"(",
"h",
">",
"0",
")",
"{",
"out",
".",
"append",
"(",
"h",
"+",
"\" hour\"",
")",
";",
"if",
"(",
"h",
">",
"1",
")",
"{",
"out",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"}",
"if",
"(",
"m",
">",
"0",
")",
"{",
"if",
"(",
"h",
">",
"0",
")",
"{",
"out",
".",
"append",
"(",
"\", \"",
")",
";",
"}",
"out",
".",
"append",
"(",
"m",
"+",
"\" minute\"",
")",
";",
"if",
"(",
"m",
">",
"1",
")",
"{",
"out",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"}",
"if",
"(",
"s",
">",
"0",
"||",
"h",
"==",
"0",
"&&",
"m",
"==",
"0",
")",
"{",
"if",
"(",
"h",
">",
"0",
"||",
"m",
">",
"0",
")",
"{",
"out",
".",
"append",
"(",
"\", \"",
")",
";",
"}",
"out",
".",
"append",
"(",
"s",
"+",
"\" second\"",
")",
";",
"if",
"(",
"s",
"!=",
"1",
")",
"{",
"out",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"}",
"return",
"out",
".",
"toString",
"(",
")",
";",
"}"
] |
Convert the duration time from milliseconds to standard hours, minutes,
and seconds format.
@param millis
The time interval to convert in miliseconds.
@return A string with the converted time.
|
[
"Convert",
"the",
"duration",
"time",
"from",
"milliseconds",
"to",
"standard",
"hours",
"minutes",
"and",
"seconds",
"format",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/batch/BatchModify.java#L208-L239
|
8,808 |
fcrepo3/fcrepo
|
fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/batch/BatchModify.java
|
BatchModify.openLog
|
private static void openLog(String rootName) throws Exception {
s_rootName = rootName;
String fileName =
s_rootName + "-" + System.currentTimeMillis() + ".xml";
File outFile;
String fedoraHome = Constants.FEDORA_HOME;
if (fedoraHome == null) {
// to current dir
outFile = new File(fileName);
} else {
// to client/log
File logDir =
new File(new File(new File(fedoraHome), "client"), "logs");
if (!logDir.exists()) {
logDir.mkdir();
}
outFile = new File(logDir, fileName);
}
s_logPath = outFile.getPath();
s_log = new PrintStream(new FileOutputStream(outFile), true, "UTF-8");
s_log.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
s_log.println("<" + s_rootName + ">");
}
|
java
|
private static void openLog(String rootName) throws Exception {
s_rootName = rootName;
String fileName =
s_rootName + "-" + System.currentTimeMillis() + ".xml";
File outFile;
String fedoraHome = Constants.FEDORA_HOME;
if (fedoraHome == null) {
// to current dir
outFile = new File(fileName);
} else {
// to client/log
File logDir =
new File(new File(new File(fedoraHome), "client"), "logs");
if (!logDir.exists()) {
logDir.mkdir();
}
outFile = new File(logDir, fileName);
}
s_logPath = outFile.getPath();
s_log = new PrintStream(new FileOutputStream(outFile), true, "UTF-8");
s_log.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
s_log.println("<" + s_rootName + ">");
}
|
[
"private",
"static",
"void",
"openLog",
"(",
"String",
"rootName",
")",
"throws",
"Exception",
"{",
"s_rootName",
"=",
"rootName",
";",
"String",
"fileName",
"=",
"s_rootName",
"+",
"\"-\"",
"+",
"System",
".",
"currentTimeMillis",
"(",
")",
"+",
"\".xml\"",
";",
"File",
"outFile",
";",
"String",
"fedoraHome",
"=",
"Constants",
".",
"FEDORA_HOME",
";",
"if",
"(",
"fedoraHome",
"==",
"null",
")",
"{",
"// to current dir",
"outFile",
"=",
"new",
"File",
"(",
"fileName",
")",
";",
"}",
"else",
"{",
"// to client/log",
"File",
"logDir",
"=",
"new",
"File",
"(",
"new",
"File",
"(",
"new",
"File",
"(",
"fedoraHome",
")",
",",
"\"client\"",
")",
",",
"\"logs\"",
")",
";",
"if",
"(",
"!",
"logDir",
".",
"exists",
"(",
")",
")",
"{",
"logDir",
".",
"mkdir",
"(",
")",
";",
"}",
"outFile",
"=",
"new",
"File",
"(",
"logDir",
",",
"fileName",
")",
";",
"}",
"s_logPath",
"=",
"outFile",
".",
"getPath",
"(",
")",
";",
"s_log",
"=",
"new",
"PrintStream",
"(",
"new",
"FileOutputStream",
"(",
"outFile",
")",
",",
"true",
",",
"\"UTF-8\"",
")",
";",
"s_log",
".",
"println",
"(",
"\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\"",
")",
";",
"s_log",
".",
"println",
"(",
"\"<\"",
"+",
"s_rootName",
"+",
"\">\"",
")",
";",
"}"
] |
Initializes the log file for writing.
@param rootName
The name of the root element for the xml log file.
@throws Exception
If any type of error occurs in trying to open the log file for
writing.
|
[
"Initializes",
"the",
"log",
"file",
"for",
"writing",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/batch/BatchModify.java#L250-L273
|
8,809 |
fcrepo3/fcrepo
|
fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/batch/BatchModify.java
|
BatchModify.fileAsString
|
private static String fileAsString(String path) throws Exception {
StringBuffer buffer = new StringBuffer();
InputStream fis = new FileInputStream(path);
InputStreamReader isr = new InputStreamReader(fis, "UTF-8");
Reader in = new BufferedReader(isr);
int ch;
while ((ch = in.read()) > -1) {
buffer.append((char) ch);
}
in.close();
return buffer.toString();
}
|
java
|
private static String fileAsString(String path) throws Exception {
StringBuffer buffer = new StringBuffer();
InputStream fis = new FileInputStream(path);
InputStreamReader isr = new InputStreamReader(fis, "UTF-8");
Reader in = new BufferedReader(isr);
int ch;
while ((ch = in.read()) > -1) {
buffer.append((char) ch);
}
in.close();
return buffer.toString();
}
|
[
"private",
"static",
"String",
"fileAsString",
"(",
"String",
"path",
")",
"throws",
"Exception",
"{",
"StringBuffer",
"buffer",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"InputStream",
"fis",
"=",
"new",
"FileInputStream",
"(",
"path",
")",
";",
"InputStreamReader",
"isr",
"=",
"new",
"InputStreamReader",
"(",
"fis",
",",
"\"UTF-8\"",
")",
";",
"Reader",
"in",
"=",
"new",
"BufferedReader",
"(",
"isr",
")",
";",
"int",
"ch",
";",
"while",
"(",
"(",
"ch",
"=",
"in",
".",
"read",
"(",
")",
")",
">",
"-",
"1",
")",
"{",
"buffer",
".",
"append",
"(",
"(",
"char",
")",
"ch",
")",
";",
"}",
"in",
".",
"close",
"(",
")",
";",
"return",
"buffer",
".",
"toString",
"(",
")",
";",
"}"
] |
Converts file into string.
@param path
The absolute file path of the file.
@return The contents of the file as a string.
@throws Exception
If any type of error occurs during the conversion.
|
[
"Converts",
"file",
"into",
"string",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/batch/BatchModify.java#L295-L306
|
8,810 |
fcrepo3/fcrepo
|
fcrepo-security/fcrepo-security-pdp/src/main/java/org/fcrepo/server/security/xacml/pdp/data/FilePolicyIndex.java
|
FilePolicyIndex.fileToName
|
private String fileToName(File policyFile) throws PolicyIndexException {
try {
if (!policyFile.getName().endsWith(".xml"))
throw new PolicyIndexException("Invalid policy file name. Policy files must end in .xml - " + policyFile.getName());
return PID.fromFilename(policyFile.getName().substring(0, policyFile.getName().lastIndexOf(".xml"))).toString();
} catch (MalformedPIDException e) {
throw new PolicyIndexException("Invalid policy file name. Filename cannot be converted to a valid PID - " + policyFile.getName());
}
}
|
java
|
private String fileToName(File policyFile) throws PolicyIndexException {
try {
if (!policyFile.getName().endsWith(".xml"))
throw new PolicyIndexException("Invalid policy file name. Policy files must end in .xml - " + policyFile.getName());
return PID.fromFilename(policyFile.getName().substring(0, policyFile.getName().lastIndexOf(".xml"))).toString();
} catch (MalformedPIDException e) {
throw new PolicyIndexException("Invalid policy file name. Filename cannot be converted to a valid PID - " + policyFile.getName());
}
}
|
[
"private",
"String",
"fileToName",
"(",
"File",
"policyFile",
")",
"throws",
"PolicyIndexException",
"{",
"try",
"{",
"if",
"(",
"!",
"policyFile",
".",
"getName",
"(",
")",
".",
"endsWith",
"(",
"\".xml\"",
")",
")",
"throw",
"new",
"PolicyIndexException",
"(",
"\"Invalid policy file name. Policy files must end in .xml - \"",
"+",
"policyFile",
".",
"getName",
"(",
")",
")",
";",
"return",
"PID",
".",
"fromFilename",
"(",
"policyFile",
".",
"getName",
"(",
")",
".",
"substring",
"(",
"0",
",",
"policyFile",
".",
"getName",
"(",
")",
".",
"lastIndexOf",
"(",
"\".xml\"",
")",
")",
")",
".",
"toString",
"(",
")",
";",
"}",
"catch",
"(",
"MalformedPIDException",
"e",
")",
"{",
"throw",
"new",
"PolicyIndexException",
"(",
"\"Invalid policy file name. Filename cannot be converted to a valid PID - \"",
"+",
"policyFile",
".",
"getName",
"(",
")",
")",
";",
"}",
"}"
] |
Determine name of policy from file. .xml prefix is removed, and name is converted to a PID.
Policy names must be valid PIDs.
@param policyFile
@return
@throws PolicyIndexException
|
[
"Determine",
"name",
"of",
"policy",
"from",
"file",
".",
".",
"xml",
"prefix",
"is",
"removed",
"and",
"name",
"is",
"converted",
"to",
"a",
"PID",
".",
"Policy",
"names",
"must",
"be",
"valid",
"PIDs",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-security/fcrepo-security-pdp/src/main/java/org/fcrepo/server/security/xacml/pdp/data/FilePolicyIndex.java#L145-L155
|
8,811 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/security/PolicyLoader.java
|
PolicyLoader.loadObjectPolicy
|
protected AbstractPolicy loadObjectPolicy(PolicyParser policyParser, String pid, boolean validate) throws ServerException {
try {
DOReader reader = m_repoReader.getReader(Server.USE_DEFINITIVE_STORE,
ReadOnlyContext.EMPTY,
pid);
Datastream ds = reader.GetDatastream("POLICY", null);
if (ds != null) {
logger.debug("Using POLICY for {}", pid);
return policyParser.parse(ds.getContentStream(), validate);
} else {
return null;
}
} catch (ObjectNotInLowlevelStorageException e) {
return null;
}
}
|
java
|
protected AbstractPolicy loadObjectPolicy(PolicyParser policyParser, String pid, boolean validate) throws ServerException {
try {
DOReader reader = m_repoReader.getReader(Server.USE_DEFINITIVE_STORE,
ReadOnlyContext.EMPTY,
pid);
Datastream ds = reader.GetDatastream("POLICY", null);
if (ds != null) {
logger.debug("Using POLICY for {}", pid);
return policyParser.parse(ds.getContentStream(), validate);
} else {
return null;
}
} catch (ObjectNotInLowlevelStorageException e) {
return null;
}
}
|
[
"protected",
"AbstractPolicy",
"loadObjectPolicy",
"(",
"PolicyParser",
"policyParser",
",",
"String",
"pid",
",",
"boolean",
"validate",
")",
"throws",
"ServerException",
"{",
"try",
"{",
"DOReader",
"reader",
"=",
"m_repoReader",
".",
"getReader",
"(",
"Server",
".",
"USE_DEFINITIVE_STORE",
",",
"ReadOnlyContext",
".",
"EMPTY",
",",
"pid",
")",
";",
"Datastream",
"ds",
"=",
"reader",
".",
"GetDatastream",
"(",
"\"POLICY\"",
",",
"null",
")",
";",
"if",
"(",
"ds",
"!=",
"null",
")",
"{",
"logger",
".",
"debug",
"(",
"\"Using POLICY for {}\"",
",",
"pid",
")",
";",
"return",
"policyParser",
".",
"parse",
"(",
"ds",
".",
"getContentStream",
"(",
")",
",",
"validate",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}",
"catch",
"(",
"ObjectNotInLowlevelStorageException",
"e",
")",
"{",
"return",
"null",
";",
"}",
"}"
] |
the passed parser must be safe to use in this thread
|
[
"the",
"passed",
"parser",
"must",
"be",
"safe",
"to",
"use",
"in",
"this",
"thread"
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/security/PolicyLoader.java#L38-L53
|
8,812 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/validation/RelsValidator.java
|
RelsValidator.isValidDateTime
|
private static boolean isValidDateTime(String lex) {
try {
DateUtility.parseDateStrict(lex);
if (logger.isTraceEnabled()) {
logger.trace("Validated dateTime: " + lex);
}
return true;
} catch (ParseException e) {
logger.warn("Not a valid dateTime: " + lex);
return false;
}
}
|
java
|
private static boolean isValidDateTime(String lex) {
try {
DateUtility.parseDateStrict(lex);
if (logger.isTraceEnabled()) {
logger.trace("Validated dateTime: " + lex);
}
return true;
} catch (ParseException e) {
logger.warn("Not a valid dateTime: " + lex);
return false;
}
}
|
[
"private",
"static",
"boolean",
"isValidDateTime",
"(",
"String",
"lex",
")",
"{",
"try",
"{",
"DateUtility",
".",
"parseDateStrict",
"(",
"lex",
")",
";",
"if",
"(",
"logger",
".",
"isTraceEnabled",
"(",
")",
")",
"{",
"logger",
".",
"trace",
"(",
"\"Validated dateTime: \"",
"+",
"lex",
")",
";",
"}",
"return",
"true",
";",
"}",
"catch",
"(",
"ParseException",
"e",
")",
"{",
"logger",
".",
"warn",
"(",
"\"Not a valid dateTime: \"",
"+",
"lex",
")",
";",
"return",
"false",
";",
"}",
"}"
] |
Tells whether the given string is a valid lexical representation of a
dateTime value. Passing this test will ensure successful indexing later.
|
[
"Tells",
"whether",
"the",
"given",
"string",
"is",
"a",
"valid",
"lexical",
"representation",
"of",
"a",
"dateTime",
"value",
".",
"Passing",
"this",
"test",
"will",
"ensure",
"successful",
"indexing",
"later",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/validation/RelsValidator.java#L527-L538
|
8,813 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/journal/readerwriter/multicast/rmi/RmiTransport.java
|
RmiTransport.openFile
|
@Override
public void openFile(String repositoryHash,
String filename,
Date currentDate) throws JournalException {
try {
super.testStateChange(State.FILE_OPEN);
writer = new RmiTransportWriter(receiver, repositoryHash, filename);
xmlWriter =
new IndentingXMLEventWriter(XMLOutputFactory
.newInstance()
.createXMLEventWriter(new BufferedWriter(writer,
bufferSize)));
parent.writeDocumentHeader(xmlWriter, repositoryHash, currentDate);
super.setState(State.FILE_OPEN);
} catch (XMLStreamException e) {
throw new JournalException(e);
} catch (FactoryConfigurationError e) {
throw new JournalException(e);
}
}
|
java
|
@Override
public void openFile(String repositoryHash,
String filename,
Date currentDate) throws JournalException {
try {
super.testStateChange(State.FILE_OPEN);
writer = new RmiTransportWriter(receiver, repositoryHash, filename);
xmlWriter =
new IndentingXMLEventWriter(XMLOutputFactory
.newInstance()
.createXMLEventWriter(new BufferedWriter(writer,
bufferSize)));
parent.writeDocumentHeader(xmlWriter, repositoryHash, currentDate);
super.setState(State.FILE_OPEN);
} catch (XMLStreamException e) {
throw new JournalException(e);
} catch (FactoryConfigurationError e) {
throw new JournalException(e);
}
}
|
[
"@",
"Override",
"public",
"void",
"openFile",
"(",
"String",
"repositoryHash",
",",
"String",
"filename",
",",
"Date",
"currentDate",
")",
"throws",
"JournalException",
"{",
"try",
"{",
"super",
".",
"testStateChange",
"(",
"State",
".",
"FILE_OPEN",
")",
";",
"writer",
"=",
"new",
"RmiTransportWriter",
"(",
"receiver",
",",
"repositoryHash",
",",
"filename",
")",
";",
"xmlWriter",
"=",
"new",
"IndentingXMLEventWriter",
"(",
"XMLOutputFactory",
".",
"newInstance",
"(",
")",
".",
"createXMLEventWriter",
"(",
"new",
"BufferedWriter",
"(",
"writer",
",",
"bufferSize",
")",
")",
")",
";",
"parent",
".",
"writeDocumentHeader",
"(",
"xmlWriter",
",",
"repositoryHash",
",",
"currentDate",
")",
";",
"super",
".",
"setState",
"(",
"State",
".",
"FILE_OPEN",
")",
";",
"}",
"catch",
"(",
"XMLStreamException",
"e",
")",
"{",
"throw",
"new",
"JournalException",
"(",
"e",
")",
";",
"}",
"catch",
"(",
"FactoryConfigurationError",
"e",
")",
"{",
"throw",
"new",
"JournalException",
"(",
"e",
")",
";",
"}",
"}"
] |
check state, send the open request, open a very special writer, write the
file opening, set state
|
[
"check",
"state",
"send",
"the",
"open",
"request",
"open",
"a",
"very",
"special",
"writer",
"write",
"the",
"file",
"opening",
"set",
"state"
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/readerwriter/multicast/rmi/RmiTransport.java#L169-L191
|
8,814 |
fcrepo3/fcrepo
|
fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/objecteditor/ContentHandlerFactory.java
|
ContentHandlerFactory.hasViewer
|
public static boolean hasViewer(String type) {
return s_viewers.containsKey(type) || type.endsWith("+xml")
&& s_viewers.containsKey("text/xml");
}
|
java
|
public static boolean hasViewer(String type) {
return s_viewers.containsKey(type) || type.endsWith("+xml")
&& s_viewers.containsKey("text/xml");
}
|
[
"public",
"static",
"boolean",
"hasViewer",
"(",
"String",
"type",
")",
"{",
"return",
"s_viewers",
".",
"containsKey",
"(",
"type",
")",
"||",
"type",
".",
"endsWith",
"(",
"\"+xml\"",
")",
"&&",
"s_viewers",
".",
"containsKey",
"(",
"\"text/xml\"",
")",
";",
"}"
] |
Can the factory provide a viewer for the given type?
|
[
"Can",
"the",
"factory",
"provide",
"a",
"viewer",
"for",
"the",
"given",
"type?"
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/objecteditor/ContentHandlerFactory.java#L48-L51
|
8,815 |
fcrepo3/fcrepo
|
fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/objecteditor/ContentHandlerFactory.java
|
ContentHandlerFactory.viewerIsEditor
|
public static boolean viewerIsEditor(String type) {
Object viewer = s_viewers.get(type);
if (viewer != null) {
return viewer instanceof ContentEditor;
} else {
return false;
}
}
|
java
|
public static boolean viewerIsEditor(String type) {
Object viewer = s_viewers.get(type);
if (viewer != null) {
return viewer instanceof ContentEditor;
} else {
return false;
}
}
|
[
"public",
"static",
"boolean",
"viewerIsEditor",
"(",
"String",
"type",
")",
"{",
"Object",
"viewer",
"=",
"s_viewers",
".",
"get",
"(",
"type",
")",
";",
"if",
"(",
"viewer",
"!=",
"null",
")",
"{",
"return",
"viewer",
"instanceof",
"ContentEditor",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
If a viewer would be provided for the given type, is that viewer also an
editor?
|
[
"If",
"a",
"viewer",
"would",
"be",
"provided",
"for",
"the",
"given",
"type",
"is",
"that",
"viewer",
"also",
"an",
"editor?"
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/objecteditor/ContentHandlerFactory.java#L57-L64
|
8,816 |
fcrepo3/fcrepo
|
fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/objecteditor/ContentHandlerFactory.java
|
ContentHandlerFactory.hasEditor
|
public static boolean hasEditor(String type) {
return s_editors.containsKey(type) || type.endsWith("+xml")
&& s_editors.containsKey("text/xml");
}
|
java
|
public static boolean hasEditor(String type) {
return s_editors.containsKey(type) || type.endsWith("+xml")
&& s_editors.containsKey("text/xml");
}
|
[
"public",
"static",
"boolean",
"hasEditor",
"(",
"String",
"type",
")",
"{",
"return",
"s_editors",
".",
"containsKey",
"(",
"type",
")",
"||",
"type",
".",
"endsWith",
"(",
"\"+xml\"",
")",
"&&",
"s_editors",
".",
"containsKey",
"(",
"\"text/xml\"",
")",
";",
"}"
] |
Can the factory provide an editor for the given type?
|
[
"Can",
"the",
"factory",
"provide",
"an",
"editor",
"for",
"the",
"given",
"type?"
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/objecteditor/ContentHandlerFactory.java#L69-L72
|
8,817 |
fcrepo3/fcrepo
|
fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/objecteditor/ContentHandlerFactory.java
|
ContentHandlerFactory.getViewer
|
public static ContentViewer getViewer(String type, InputStream data)
throws IOException {
ContentViewer viewer = (ContentViewer) s_viewers.get(type);
if (viewer == null && type.endsWith("+xml")) {
viewer = (ContentViewer) s_viewers.get("text/xml");
}
return viewer.newInstance(type, data, true);
}
|
java
|
public static ContentViewer getViewer(String type, InputStream data)
throws IOException {
ContentViewer viewer = (ContentViewer) s_viewers.get(type);
if (viewer == null && type.endsWith("+xml")) {
viewer = (ContentViewer) s_viewers.get("text/xml");
}
return viewer.newInstance(type, data, true);
}
|
[
"public",
"static",
"ContentViewer",
"getViewer",
"(",
"String",
"type",
",",
"InputStream",
"data",
")",
"throws",
"IOException",
"{",
"ContentViewer",
"viewer",
"=",
"(",
"ContentViewer",
")",
"s_viewers",
".",
"get",
"(",
"type",
")",
";",
"if",
"(",
"viewer",
"==",
"null",
"&&",
"type",
".",
"endsWith",
"(",
"\"+xml\"",
")",
")",
"{",
"viewer",
"=",
"(",
"ContentViewer",
")",
"s_viewers",
".",
"get",
"(",
"\"text/xml\"",
")",
";",
"}",
"return",
"viewer",
".",
"newInstance",
"(",
"type",
",",
"data",
",",
"true",
")",
";",
"}"
] |
Get a viewer for the given type, initialized with the given data. This
should only be called if the caller knows there is a viewer for the type.
|
[
"Get",
"a",
"viewer",
"for",
"the",
"given",
"type",
"initialized",
"with",
"the",
"given",
"data",
".",
"This",
"should",
"only",
"be",
"called",
"if",
"the",
"caller",
"knows",
"there",
"is",
"a",
"viewer",
"for",
"the",
"type",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/objecteditor/ContentHandlerFactory.java#L78-L85
|
8,818 |
fcrepo3/fcrepo
|
fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/objecteditor/ContentHandlerFactory.java
|
ContentHandlerFactory.getEditor
|
public static ContentEditor getEditor(String type, InputStream data)
throws IOException {
ContentEditor editor = (ContentEditor) s_editors.get(type);
if (editor == null && type.endsWith("+xml")) {
editor = (ContentEditor) s_editors.get("text/xml");
}
return (ContentEditor) editor.newInstance(type, data, false);
}
|
java
|
public static ContentEditor getEditor(String type, InputStream data)
throws IOException {
ContentEditor editor = (ContentEditor) s_editors.get(type);
if (editor == null && type.endsWith("+xml")) {
editor = (ContentEditor) s_editors.get("text/xml");
}
return (ContentEditor) editor.newInstance(type, data, false);
}
|
[
"public",
"static",
"ContentEditor",
"getEditor",
"(",
"String",
"type",
",",
"InputStream",
"data",
")",
"throws",
"IOException",
"{",
"ContentEditor",
"editor",
"=",
"(",
"ContentEditor",
")",
"s_editors",
".",
"get",
"(",
"type",
")",
";",
"if",
"(",
"editor",
"==",
"null",
"&&",
"type",
".",
"endsWith",
"(",
"\"+xml\"",
")",
")",
"{",
"editor",
"=",
"(",
"ContentEditor",
")",
"s_editors",
".",
"get",
"(",
"\"text/xml\"",
")",
";",
"}",
"return",
"(",
"ContentEditor",
")",
"editor",
".",
"newInstance",
"(",
"type",
",",
"data",
",",
"false",
")",
";",
"}"
] |
Get an editor for the given type, initialized with the given data. This
should only be called if the caller knows there is an editor for the
type.
|
[
"Get",
"an",
"editor",
"for",
"the",
"given",
"type",
"initialized",
"with",
"the",
"given",
"data",
".",
"This",
"should",
"only",
"be",
"called",
"if",
"the",
"caller",
"knows",
"there",
"is",
"an",
"editor",
"for",
"the",
"type",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/objecteditor/ContentHandlerFactory.java#L92-L99
|
8,819 |
fcrepo3/fcrepo
|
fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/utility/validate/ValidationResult.java
|
ValidationResult.getSeverityLevel
|
public Level getSeverityLevel() {
Level severity = Level.INFO;
for (ValidationResultNotation note : notes) {
Level noteLevel = note.getLevel();
if (noteLevel.compareTo(severity) > 0) {
severity = noteLevel;
}
}
return severity;
}
|
java
|
public Level getSeverityLevel() {
Level severity = Level.INFO;
for (ValidationResultNotation note : notes) {
Level noteLevel = note.getLevel();
if (noteLevel.compareTo(severity) > 0) {
severity = noteLevel;
}
}
return severity;
}
|
[
"public",
"Level",
"getSeverityLevel",
"(",
")",
"{",
"Level",
"severity",
"=",
"Level",
".",
"INFO",
";",
"for",
"(",
"ValidationResultNotation",
"note",
":",
"notes",
")",
"{",
"Level",
"noteLevel",
"=",
"note",
".",
"getLevel",
"(",
")",
";",
"if",
"(",
"noteLevel",
".",
"compareTo",
"(",
"severity",
")",
">",
"0",
")",
"{",
"severity",
"=",
"noteLevel",
";",
"}",
"}",
"return",
"severity",
";",
"}"
] |
What's the highest severity level of any of the notations on this result?
|
[
"What",
"s",
"the",
"highest",
"severity",
"level",
"of",
"any",
"of",
"the",
"notations",
"on",
"this",
"result?"
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/utility/validate/ValidationResult.java#L67-L76
|
8,820 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/resourceIndex/ResourceIndexModule.java
|
ResourceIndexModule.shutdownModule
|
@Override
public void shutdownModule() throws ModuleShutdownException {
if (_ri != null) {
try {
_ri.close();
} catch (TrippiException e) {
throw new ModuleShutdownException("Error closing RI",
getRole(),
e);
}
}
}
|
java
|
@Override
public void shutdownModule() throws ModuleShutdownException {
if (_ri != null) {
try {
_ri.close();
} catch (TrippiException e) {
throw new ModuleShutdownException("Error closing RI",
getRole(),
e);
}
}
}
|
[
"@",
"Override",
"public",
"void",
"shutdownModule",
"(",
")",
"throws",
"ModuleShutdownException",
"{",
"if",
"(",
"_ri",
"!=",
"null",
")",
"{",
"try",
"{",
"_ri",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"TrippiException",
"e",
")",
"{",
"throw",
"new",
"ModuleShutdownException",
"(",
"\"Error closing RI\"",
",",
"getRole",
"(",
")",
",",
"e",
")",
";",
"}",
"}",
"}"
] |
Shutdown the RI module by closing the wrapped ResourceIndex.
@throws ModuleShutdownException
if any error occurs while closing.
|
[
"Shutdown",
"the",
"RI",
"module",
"by",
"closing",
"the",
"wrapped",
"ResourceIndex",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/resourceIndex/ResourceIndexModule.java#L226-L237
|
8,821 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/config/webxml/WebXML.java
|
WebXML.getInstance
|
public static WebXML getInstance(String webxml) {
WebXML wx = null;
BeanReader reader = new BeanReader();
reader.getXMLIntrospector().getConfiguration()
.setAttributesForPrimitives(false);
reader.getBindingConfiguration().setMapIDs(false);
try {
reader.registerMultiMapping(getBetwixtMapping());
wx = (WebXML) reader.parse(new File(webxml).toURI().toString());
} catch (IntrospectionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return wx;
}
|
java
|
public static WebXML getInstance(String webxml) {
WebXML wx = null;
BeanReader reader = new BeanReader();
reader.getXMLIntrospector().getConfiguration()
.setAttributesForPrimitives(false);
reader.getBindingConfiguration().setMapIDs(false);
try {
reader.registerMultiMapping(getBetwixtMapping());
wx = (WebXML) reader.parse(new File(webxml).toURI().toString());
} catch (IntrospectionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return wx;
}
|
[
"public",
"static",
"WebXML",
"getInstance",
"(",
"String",
"webxml",
")",
"{",
"WebXML",
"wx",
"=",
"null",
";",
"BeanReader",
"reader",
"=",
"new",
"BeanReader",
"(",
")",
";",
"reader",
".",
"getXMLIntrospector",
"(",
")",
".",
"getConfiguration",
"(",
")",
".",
"setAttributesForPrimitives",
"(",
"false",
")",
";",
"reader",
".",
"getBindingConfiguration",
"(",
")",
".",
"setMapIDs",
"(",
"false",
")",
";",
"try",
"{",
"reader",
".",
"registerMultiMapping",
"(",
"getBetwixtMapping",
"(",
")",
")",
";",
"wx",
"=",
"(",
"WebXML",
")",
"reader",
".",
"parse",
"(",
"new",
"File",
"(",
"webxml",
")",
".",
"toURI",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"}",
"catch",
"(",
"IntrospectionException",
"e",
")",
"{",
"// TODO Auto-generated catch block",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"// TODO Auto-generated catch block",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"catch",
"(",
"SAXException",
"e",
")",
"{",
"// TODO Auto-generated catch block",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"return",
"wx",
";",
"}"
] |
Create an instance of WebXML from the specified file.
@param webxml
Path to web.xml file.
@return instance of WebXML
|
[
"Create",
"an",
"instance",
"of",
"WebXML",
"from",
"the",
"specified",
"file",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/config/webxml/WebXML.java#L89-L110
|
8,822 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/BasicServer.java
|
BasicServer.preIngestIfNeeded
|
private void preIngestIfNeeded(boolean firstRun,
DOManager doManager,
RDFName objectName) throws Exception {
PID pid = new PID(objectName.uri.substring("info:fedora/".length()));
boolean exists = doManager.objectExists(pid.toString());
if (exists && firstRun) {
logger.info("Purging old system object: {}", pid);
Context context = ReadOnlyContext.getContext(null,
null,
null,
false);
DOWriter w = doManager.getWriter(USE_DEFINITIVE_STORE,
context,
pid.toString());
w.remove();
try {
w.commit("Purged by Fedora at startup (to be re-ingested)");
exists = false;
} finally {
doManager.releaseWriter(w);
}
}
if (!exists) {
logger.info("Ingesting new system object: {}", pid);
InputStream xml = getStream("org/fcrepo/server/resources/"
+ pid.toFilename() + ".xml");
Context context = ReadOnlyContext.getContext(null,
null,
null,
false);
DOWriter w = doManager.getIngestWriter(USE_DEFINITIVE_STORE,
context,
xml,
Constants.FOXML1_1.uri,
"UTF-8",
null);
try {
w.commit("Pre-ingested by Fedora at startup");
} finally {
doManager.releaseWriter(w);
}
}
}
|
java
|
private void preIngestIfNeeded(boolean firstRun,
DOManager doManager,
RDFName objectName) throws Exception {
PID pid = new PID(objectName.uri.substring("info:fedora/".length()));
boolean exists = doManager.objectExists(pid.toString());
if (exists && firstRun) {
logger.info("Purging old system object: {}", pid);
Context context = ReadOnlyContext.getContext(null,
null,
null,
false);
DOWriter w = doManager.getWriter(USE_DEFINITIVE_STORE,
context,
pid.toString());
w.remove();
try {
w.commit("Purged by Fedora at startup (to be re-ingested)");
exists = false;
} finally {
doManager.releaseWriter(w);
}
}
if (!exists) {
logger.info("Ingesting new system object: {}", pid);
InputStream xml = getStream("org/fcrepo/server/resources/"
+ pid.toFilename() + ".xml");
Context context = ReadOnlyContext.getContext(null,
null,
null,
false);
DOWriter w = doManager.getIngestWriter(USE_DEFINITIVE_STORE,
context,
xml,
Constants.FOXML1_1.uri,
"UTF-8",
null);
try {
w.commit("Pre-ingested by Fedora at startup");
} finally {
doManager.releaseWriter(w);
}
}
}
|
[
"private",
"void",
"preIngestIfNeeded",
"(",
"boolean",
"firstRun",
",",
"DOManager",
"doManager",
",",
"RDFName",
"objectName",
")",
"throws",
"Exception",
"{",
"PID",
"pid",
"=",
"new",
"PID",
"(",
"objectName",
".",
"uri",
".",
"substring",
"(",
"\"info:fedora/\"",
".",
"length",
"(",
")",
")",
")",
";",
"boolean",
"exists",
"=",
"doManager",
".",
"objectExists",
"(",
"pid",
".",
"toString",
"(",
")",
")",
";",
"if",
"(",
"exists",
"&&",
"firstRun",
")",
"{",
"logger",
".",
"info",
"(",
"\"Purging old system object: {}\"",
",",
"pid",
")",
";",
"Context",
"context",
"=",
"ReadOnlyContext",
".",
"getContext",
"(",
"null",
",",
"null",
",",
"null",
",",
"false",
")",
";",
"DOWriter",
"w",
"=",
"doManager",
".",
"getWriter",
"(",
"USE_DEFINITIVE_STORE",
",",
"context",
",",
"pid",
".",
"toString",
"(",
")",
")",
";",
"w",
".",
"remove",
"(",
")",
";",
"try",
"{",
"w",
".",
"commit",
"(",
"\"Purged by Fedora at startup (to be re-ingested)\"",
")",
";",
"exists",
"=",
"false",
";",
"}",
"finally",
"{",
"doManager",
".",
"releaseWriter",
"(",
"w",
")",
";",
"}",
"}",
"if",
"(",
"!",
"exists",
")",
"{",
"logger",
".",
"info",
"(",
"\"Ingesting new system object: {}\"",
",",
"pid",
")",
";",
"InputStream",
"xml",
"=",
"getStream",
"(",
"\"org/fcrepo/server/resources/\"",
"+",
"pid",
".",
"toFilename",
"(",
")",
"+",
"\".xml\"",
")",
";",
"Context",
"context",
"=",
"ReadOnlyContext",
".",
"getContext",
"(",
"null",
",",
"null",
",",
"null",
",",
"false",
")",
";",
"DOWriter",
"w",
"=",
"doManager",
".",
"getIngestWriter",
"(",
"USE_DEFINITIVE_STORE",
",",
"context",
",",
"xml",
",",
"Constants",
".",
"FOXML1_1",
".",
"uri",
",",
"\"UTF-8\"",
",",
"null",
")",
";",
"try",
"{",
"w",
".",
"commit",
"(",
"\"Pre-ingested by Fedora at startup\"",
")",
";",
"}",
"finally",
"{",
"doManager",
".",
"releaseWriter",
"(",
"w",
")",
";",
"}",
"}",
"}"
] |
Ingests the given system object if it doesn't exist, OR if it
exists, but this instance of Fedora has never been started.
This ensures that, upon upgrade, the old system object
is replaced with the new one.
|
[
"Ingests",
"the",
"given",
"system",
"object",
"if",
"it",
"doesn",
"t",
"exist",
"OR",
"if",
"it",
"exists",
"but",
"this",
"instance",
"of",
"Fedora",
"has",
"never",
"been",
"started",
".",
"This",
"ensures",
"that",
"upon",
"upgrade",
"the",
"old",
"system",
"object",
"is",
"replaced",
"with",
"the",
"new",
"one",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/BasicServer.java#L141-L183
|
8,823 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/validation/DOValidatorImpl.java
|
DOValidatorImpl.validateXMLSchema
|
private void validateXMLSchema(InputStream objectAsStream, DOValidatorXMLSchema xsv)
throws ObjectValidityException, GeneralException {
try {
xsv.validate(objectAsStream);
} catch (ObjectValidityException e) {
logger.error("VALIDATE: ERROR - failed XML Schema validation.", e);
throw e;
} catch (Exception e) {
logger.error("VALIDATE: ERROR - failed XML Schema validation.", e);
throw new ObjectValidityException("[DOValidatorImpl]: validateXMLSchema. "
+ e.getMessage());
}
logger.debug("VALIDATE: SUCCESS - passed XML Schema validation.");
}
|
java
|
private void validateXMLSchema(InputStream objectAsStream, DOValidatorXMLSchema xsv)
throws ObjectValidityException, GeneralException {
try {
xsv.validate(objectAsStream);
} catch (ObjectValidityException e) {
logger.error("VALIDATE: ERROR - failed XML Schema validation.", e);
throw e;
} catch (Exception e) {
logger.error("VALIDATE: ERROR - failed XML Schema validation.", e);
throw new ObjectValidityException("[DOValidatorImpl]: validateXMLSchema. "
+ e.getMessage());
}
logger.debug("VALIDATE: SUCCESS - passed XML Schema validation.");
}
|
[
"private",
"void",
"validateXMLSchema",
"(",
"InputStream",
"objectAsStream",
",",
"DOValidatorXMLSchema",
"xsv",
")",
"throws",
"ObjectValidityException",
",",
"GeneralException",
"{",
"try",
"{",
"xsv",
".",
"validate",
"(",
"objectAsStream",
")",
";",
"}",
"catch",
"(",
"ObjectValidityException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"VALIDATE: ERROR - failed XML Schema validation.\"",
",",
"e",
")",
";",
"throw",
"e",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"VALIDATE: ERROR - failed XML Schema validation.\"",
",",
"e",
")",
";",
"throw",
"new",
"ObjectValidityException",
"(",
"\"[DOValidatorImpl]: validateXMLSchema. \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"logger",
".",
"debug",
"(",
"\"VALIDATE: SUCCESS - passed XML Schema validation.\"",
")",
";",
"}"
] |
Do XML Schema validation on the Fedora object.
@param objectAsFile
The digital object provided as a file.
@throws ObjectValidityException
If validation fails for any reason.
@throws GeneralException
If validation fails for any reason.
|
[
"Do",
"XML",
"Schema",
"validation",
"on",
"the",
"Fedora",
"object",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/validation/DOValidatorImpl.java#L357-L371
|
8,824 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/validation/DOValidatorImpl.java
|
DOValidatorImpl.validateByRules
|
private void validateByRules(InputStream objectAsStream,
String ruleSchemaPath,
String preprocessorPath,
String phase) throws ObjectValidityException,
GeneralException {
try {
DOValidatorSchematron schtron =
new DOValidatorSchematron(ruleSchemaPath,
preprocessorPath,
phase);
schtron.validate(objectAsStream);
} catch (ObjectValidityException e) {
logger.error("VALIDATE: ERROR - failed Schematron rules validation.",
e);
throw e;
} catch (Exception e) {
logger.error("VALIDATE: ERROR - failed Schematron rules validation.",
e);
throw new ObjectValidityException("[DOValidatorImpl]: "
+ "failed Schematron rules validation. " + e.getMessage());
}
logger.debug("VALIDATE: SUCCESS - passed Schematron rules validation.");
}
|
java
|
private void validateByRules(InputStream objectAsStream,
String ruleSchemaPath,
String preprocessorPath,
String phase) throws ObjectValidityException,
GeneralException {
try {
DOValidatorSchematron schtron =
new DOValidatorSchematron(ruleSchemaPath,
preprocessorPath,
phase);
schtron.validate(objectAsStream);
} catch (ObjectValidityException e) {
logger.error("VALIDATE: ERROR - failed Schematron rules validation.",
e);
throw e;
} catch (Exception e) {
logger.error("VALIDATE: ERROR - failed Schematron rules validation.",
e);
throw new ObjectValidityException("[DOValidatorImpl]: "
+ "failed Schematron rules validation. " + e.getMessage());
}
logger.debug("VALIDATE: SUCCESS - passed Schematron rules validation.");
}
|
[
"private",
"void",
"validateByRules",
"(",
"InputStream",
"objectAsStream",
",",
"String",
"ruleSchemaPath",
",",
"String",
"preprocessorPath",
",",
"String",
"phase",
")",
"throws",
"ObjectValidityException",
",",
"GeneralException",
"{",
"try",
"{",
"DOValidatorSchematron",
"schtron",
"=",
"new",
"DOValidatorSchematron",
"(",
"ruleSchemaPath",
",",
"preprocessorPath",
",",
"phase",
")",
";",
"schtron",
".",
"validate",
"(",
"objectAsStream",
")",
";",
"}",
"catch",
"(",
"ObjectValidityException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"VALIDATE: ERROR - failed Schematron rules validation.\"",
",",
"e",
")",
";",
"throw",
"e",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"VALIDATE: ERROR - failed Schematron rules validation.\"",
",",
"e",
")",
";",
"throw",
"new",
"ObjectValidityException",
"(",
"\"[DOValidatorImpl]: \"",
"+",
"\"failed Schematron rules validation. \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"logger",
".",
"debug",
"(",
"\"VALIDATE: SUCCESS - passed Schematron rules validation.\"",
")",
";",
"}"
] |
Do Schematron rules validation on the Fedora object. Schematron
validation tests the object against a set of rules expressed using XPATH
in a Schematron schema. These test for things that are beyond what can be
expressed using XML Schema.
@param objectAsFile
The digital object provided as a file.
@param schemaPath
Location of the Schematron rules file.
@param preprocessorPath
Location of Schematron preprocessing stylesheet
@param phase
The workflow phase (ingest, store) for the object.
@throws ObjectValidityException
If validation fails for any reason.
@throws GeneralException
If validation fails for any reason.
|
[
"Do",
"Schematron",
"rules",
"validation",
"on",
"the",
"Fedora",
"object",
".",
"Schematron",
"validation",
"tests",
"the",
"object",
"against",
"a",
"set",
"of",
"rules",
"expressed",
"using",
"XPATH",
"in",
"a",
"Schematron",
"schema",
".",
"These",
"test",
"for",
"things",
"that",
"are",
"beyond",
"what",
"can",
"be",
"expressed",
"using",
"XML",
"Schema",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/validation/DOValidatorImpl.java#L392-L415
|
8,825 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/validation/DOValidatorImpl.java
|
DOValidatorImpl.cleanUp
|
private void cleanUp(File f) {
if (f != null && f.getParentFile() != null) {
if (m_absoluteTempPath.equalsIgnoreCase(f
.getParentFile().getAbsolutePath())) {
f.delete();
}
}
}
|
java
|
private void cleanUp(File f) {
if (f != null && f.getParentFile() != null) {
if (m_absoluteTempPath.equalsIgnoreCase(f
.getParentFile().getAbsolutePath())) {
f.delete();
}
}
}
|
[
"private",
"void",
"cleanUp",
"(",
"File",
"f",
")",
"{",
"if",
"(",
"f",
"!=",
"null",
"&&",
"f",
".",
"getParentFile",
"(",
")",
"!=",
"null",
")",
"{",
"if",
"(",
"m_absoluteTempPath",
".",
"equalsIgnoreCase",
"(",
"f",
".",
"getParentFile",
"(",
")",
".",
"getAbsolutePath",
"(",
")",
")",
")",
"{",
"f",
".",
"delete",
"(",
")",
";",
"}",
"}",
"}"
] |
but it should only blow away files in the temp directory.
|
[
"but",
"it",
"should",
"only",
"blow",
"away",
"files",
"in",
"the",
"temp",
"directory",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/validation/DOValidatorImpl.java#L438-L445
|
8,826 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/security/impl/BasicEvaluationCtx.java
|
BasicEvaluationCtx.setupResource
|
private void setupResource(List resource) throws ParsingException {
mapAttributes(resource, resourceMap);
// make sure there resource-id attribute was included
List<Attribute> resourceId = resourceMap.get(RESOURCE_ID);
if (resourceId == null) {
logger.warn("Resource must contain resource-id attr");
//throw new ParsingException("resource missing resource-id");
} else {
// make sure there's only one value for this
if (resourceId.size() != 1) {
logger.warn("Resource must contain only one resource-id Attribute");
//throw new ParsingException("too many resource-id attrs");
} else {
// keep track of the resource-id attribute
this.resourceId = resourceId.get(0).getValue();
}
}
//SECURITY-162: Relax resource-id requirement
if(this.resourceId == null)
this.resourceId = new StringAttribute("");
List<Attribute> resourceScope = resourceMap.get(RESOURCE_SCOPE);
// see if a resource-scope attribute was included
if (resourceScope != null && !resourceScope.isEmpty()) {
// make sure there's only one value for resource-scope
if (resourceScope.size() > 1) {
System.err.println("Resource may contain only one " +
"resource-scope Attribute");
throw new ParsingException("too many resource-scope attrs");
}
AttributeValue attrValue = resourceScope.get(0).getValue();
// scope must be a string, so throw an exception otherwise
if (! attrValue.getType().toString().
equals(StringAttribute.identifier))
throw new ParsingException("scope attr must be a string");
String value = ((StringAttribute)attrValue).getValue();
if (value.equals("Immediate")) {
scope = SCOPE_IMMEDIATE;
} else if (value.equals("Children")) {
scope = SCOPE_CHILDREN;
} else if (value.equals("Descendants")) {
scope = SCOPE_DESCENDANTS;
} else {
System.err.println("Unknown scope type: " + value);
throw new ParsingException("invalid scope type: " + value);
}
} else {
// by default, the scope is always Immediate
scope = SCOPE_IMMEDIATE;
}
}
|
java
|
private void setupResource(List resource) throws ParsingException {
mapAttributes(resource, resourceMap);
// make sure there resource-id attribute was included
List<Attribute> resourceId = resourceMap.get(RESOURCE_ID);
if (resourceId == null) {
logger.warn("Resource must contain resource-id attr");
//throw new ParsingException("resource missing resource-id");
} else {
// make sure there's only one value for this
if (resourceId.size() != 1) {
logger.warn("Resource must contain only one resource-id Attribute");
//throw new ParsingException("too many resource-id attrs");
} else {
// keep track of the resource-id attribute
this.resourceId = resourceId.get(0).getValue();
}
}
//SECURITY-162: Relax resource-id requirement
if(this.resourceId == null)
this.resourceId = new StringAttribute("");
List<Attribute> resourceScope = resourceMap.get(RESOURCE_SCOPE);
// see if a resource-scope attribute was included
if (resourceScope != null && !resourceScope.isEmpty()) {
// make sure there's only one value for resource-scope
if (resourceScope.size() > 1) {
System.err.println("Resource may contain only one " +
"resource-scope Attribute");
throw new ParsingException("too many resource-scope attrs");
}
AttributeValue attrValue = resourceScope.get(0).getValue();
// scope must be a string, so throw an exception otherwise
if (! attrValue.getType().toString().
equals(StringAttribute.identifier))
throw new ParsingException("scope attr must be a string");
String value = ((StringAttribute)attrValue).getValue();
if (value.equals("Immediate")) {
scope = SCOPE_IMMEDIATE;
} else if (value.equals("Children")) {
scope = SCOPE_CHILDREN;
} else if (value.equals("Descendants")) {
scope = SCOPE_DESCENDANTS;
} else {
System.err.println("Unknown scope type: " + value);
throw new ParsingException("invalid scope type: " + value);
}
} else {
// by default, the scope is always Immediate
scope = SCOPE_IMMEDIATE;
}
}
|
[
"private",
"void",
"setupResource",
"(",
"List",
"resource",
")",
"throws",
"ParsingException",
"{",
"mapAttributes",
"(",
"resource",
",",
"resourceMap",
")",
";",
"// make sure there resource-id attribute was included",
"List",
"<",
"Attribute",
">",
"resourceId",
"=",
"resourceMap",
".",
"get",
"(",
"RESOURCE_ID",
")",
";",
"if",
"(",
"resourceId",
"==",
"null",
")",
"{",
"logger",
".",
"warn",
"(",
"\"Resource must contain resource-id attr\"",
")",
";",
"//throw new ParsingException(\"resource missing resource-id\");",
"}",
"else",
"{",
"// make sure there's only one value for this",
"if",
"(",
"resourceId",
".",
"size",
"(",
")",
"!=",
"1",
")",
"{",
"logger",
".",
"warn",
"(",
"\"Resource must contain only one resource-id Attribute\"",
")",
";",
"//throw new ParsingException(\"too many resource-id attrs\");",
"}",
"else",
"{",
"// keep track of the resource-id attribute",
"this",
".",
"resourceId",
"=",
"resourceId",
".",
"get",
"(",
"0",
")",
".",
"getValue",
"(",
")",
";",
"}",
"}",
"//SECURITY-162: Relax resource-id requirement",
"if",
"(",
"this",
".",
"resourceId",
"==",
"null",
")",
"this",
".",
"resourceId",
"=",
"new",
"StringAttribute",
"(",
"\"\"",
")",
";",
"List",
"<",
"Attribute",
">",
"resourceScope",
"=",
"resourceMap",
".",
"get",
"(",
"RESOURCE_SCOPE",
")",
";",
"// see if a resource-scope attribute was included",
"if",
"(",
"resourceScope",
"!=",
"null",
"&&",
"!",
"resourceScope",
".",
"isEmpty",
"(",
")",
")",
"{",
"// make sure there's only one value for resource-scope",
"if",
"(",
"resourceScope",
".",
"size",
"(",
")",
">",
"1",
")",
"{",
"System",
".",
"err",
".",
"println",
"(",
"\"Resource may contain only one \"",
"+",
"\"resource-scope Attribute\"",
")",
";",
"throw",
"new",
"ParsingException",
"(",
"\"too many resource-scope attrs\"",
")",
";",
"}",
"AttributeValue",
"attrValue",
"=",
"resourceScope",
".",
"get",
"(",
"0",
")",
".",
"getValue",
"(",
")",
";",
"// scope must be a string, so throw an exception otherwise",
"if",
"(",
"!",
"attrValue",
".",
"getType",
"(",
")",
".",
"toString",
"(",
")",
".",
"equals",
"(",
"StringAttribute",
".",
"identifier",
")",
")",
"throw",
"new",
"ParsingException",
"(",
"\"scope attr must be a string\"",
")",
";",
"String",
"value",
"=",
"(",
"(",
"StringAttribute",
")",
"attrValue",
")",
".",
"getValue",
"(",
")",
";",
"if",
"(",
"value",
".",
"equals",
"(",
"\"Immediate\"",
")",
")",
"{",
"scope",
"=",
"SCOPE_IMMEDIATE",
";",
"}",
"else",
"if",
"(",
"value",
".",
"equals",
"(",
"\"Children\"",
")",
")",
"{",
"scope",
"=",
"SCOPE_CHILDREN",
";",
"}",
"else",
"if",
"(",
"value",
".",
"equals",
"(",
"\"Descendants\"",
")",
")",
"{",
"scope",
"=",
"SCOPE_DESCENDANTS",
";",
"}",
"else",
"{",
"System",
".",
"err",
".",
"println",
"(",
"\"Unknown scope type: \"",
"+",
"value",
")",
";",
"throw",
"new",
"ParsingException",
"(",
"\"invalid scope type: \"",
"+",
"value",
")",
";",
"}",
"}",
"else",
"{",
"// by default, the scope is always Immediate",
"scope",
"=",
"SCOPE_IMMEDIATE",
";",
"}",
"}"
] |
This basically does the same thing that the other types need
to do, except that we also look for a resource-id attribute, not
because we're going to use, but only to make sure that it's actually
there, and for the optional scope attribute, to see what the scope
of the attribute is
|
[
"This",
"basically",
"does",
"the",
"same",
"thing",
"that",
"the",
"other",
"types",
"need",
"to",
"do",
"except",
"that",
"we",
"also",
"look",
"for",
"a",
"resource",
"-",
"id",
"attribute",
"not",
"because",
"we",
"re",
"going",
"to",
"use",
"but",
"only",
"to",
"make",
"sure",
"that",
"it",
"s",
"actually",
"there",
"and",
"for",
"the",
"optional",
"scope",
"attribute",
"to",
"see",
"what",
"the",
"scope",
"of",
"the",
"attribute",
"is"
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/security/impl/BasicEvaluationCtx.java#L295-L352
|
8,827 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/security/impl/BasicEvaluationCtx.java
|
BasicEvaluationCtx.mapAttributes
|
private void mapAttributes(List<Attribute> input, Map<String, List<Attribute>> output) {
Iterator<Attribute> it = input.iterator();
while (it.hasNext()) {
Attribute attr = it.next();
String id = attr.getId().toString();
if (output.containsKey(id)) {
List<Attribute> list = output.get(id);
list.add(attr);
} else {
List list = new ArrayList<Attribute>();
list.add(attr);
output.put(id, list);
}
}
}
|
java
|
private void mapAttributes(List<Attribute> input, Map<String, List<Attribute>> output) {
Iterator<Attribute> it = input.iterator();
while (it.hasNext()) {
Attribute attr = it.next();
String id = attr.getId().toString();
if (output.containsKey(id)) {
List<Attribute> list = output.get(id);
list.add(attr);
} else {
List list = new ArrayList<Attribute>();
list.add(attr);
output.put(id, list);
}
}
}
|
[
"private",
"void",
"mapAttributes",
"(",
"List",
"<",
"Attribute",
">",
"input",
",",
"Map",
"<",
"String",
",",
"List",
"<",
"Attribute",
">",
">",
"output",
")",
"{",
"Iterator",
"<",
"Attribute",
">",
"it",
"=",
"input",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"Attribute",
"attr",
"=",
"it",
".",
"next",
"(",
")",
";",
"String",
"id",
"=",
"attr",
".",
"getId",
"(",
")",
".",
"toString",
"(",
")",
";",
"if",
"(",
"output",
".",
"containsKey",
"(",
"id",
")",
")",
"{",
"List",
"<",
"Attribute",
">",
"list",
"=",
"output",
".",
"get",
"(",
"id",
")",
";",
"list",
".",
"add",
"(",
"attr",
")",
";",
"}",
"else",
"{",
"List",
"list",
"=",
"new",
"ArrayList",
"<",
"Attribute",
">",
"(",
")",
";",
"list",
".",
"add",
"(",
"attr",
")",
";",
"output",
".",
"put",
"(",
"id",
",",
"list",
")",
";",
"}",
"}",
"}"
] |
Generic routine for resource, attribute and environment attributes
to build the lookup map for each. The Form is a Map that is indexed
by the String form of the attribute ids, and that contains Sets at
each entry with all attributes that have that id
|
[
"Generic",
"routine",
"for",
"resource",
"attribute",
"and",
"environment",
"attributes",
"to",
"build",
"the",
"lookup",
"map",
"for",
"each",
".",
"The",
"Form",
"is",
"a",
"Map",
"that",
"is",
"indexed",
"by",
"the",
"String",
"form",
"of",
"the",
"attribute",
"ids",
"and",
"that",
"contains",
"Sets",
"at",
"each",
"entry",
"with",
"all",
"attributes",
"that",
"have",
"that",
"id"
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/security/impl/BasicEvaluationCtx.java#L360-L375
|
8,828 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/security/impl/BasicEvaluationCtx.java
|
BasicEvaluationCtx.getGenericAttributes
|
private EvaluationResult getGenericAttributes(URI type, URI id, URI issuer,
Map<String, List<Attribute>> map, URI category,
int designatorType) {
// try to find the id
List<Attribute> attrList = (List)(map.get(id.toString()));
if (attrList == null) {
// the request didn't have an attribute with that id, so we should
// try asking the wrapped context
Attribute contextValue = checkContext(type, id, issuer, category, designatorType);
if (contextValue != null) {
attrList = Collections.singletonList(contextValue);
// cache the context values
map.put(id.toString(), attrList);
} else {
// the context didn't have an attribute with that id, so we should
// try asking the attribute finder
attrList = Collections.emptyList();
}
}
// now go through each, considering each Attribute object
final List<AttributeValue> attributes;
Attribute attr = null;
switch (attrList.size()) {
case 0:
attributes = Collections.emptyList();
break;
case 1:
attr = attrList.get(0);
// make sure the type and issuer are correct
if ((attr.getType().equals(type)) &&
((issuer == null) ||
((attr.getIssuer() != null) &&
(attr.getIssuer().equals(issuer.toString()))))) {
attributes = new ArrayList<AttributeValue>(attrList.get(0).getValues());
} else {
attributes = Collections.emptyList();
}
break;
default:
Iterator it = attrList.iterator();
attributes = new ArrayList<AttributeValue>();
while (it.hasNext()) {
attr = (Attribute)(it.next());
// make sure the type and issuer are correct
if ((attr.getType().equals(type)) &&
((issuer == null) ||
((attr.getIssuer() != null) &&
(attr.getIssuer().equals(issuer.toString()))))) {
// if we got here, then we found a match, so we want to pull
// out the values and put them in out list
attributes.addAll(attr.getValues());
}
}
}
// see if we found any acceptable attributes
if (attributes.size() == 0) {
// we failed to find any that matched the type/issuer, or all the
// Attribute types were empty...so ask the finder
logger.debug("Attribute not in request: {} ... querying AttributeFinder",
id);
return callHelper(type, id, issuer, category, designatorType);
} else {
// if we got here, then we found at least one useful AttributeValue
return new EvaluationResult(new BagAttribute(type, attributes));
}
}
|
java
|
private EvaluationResult getGenericAttributes(URI type, URI id, URI issuer,
Map<String, List<Attribute>> map, URI category,
int designatorType) {
// try to find the id
List<Attribute> attrList = (List)(map.get(id.toString()));
if (attrList == null) {
// the request didn't have an attribute with that id, so we should
// try asking the wrapped context
Attribute contextValue = checkContext(type, id, issuer, category, designatorType);
if (contextValue != null) {
attrList = Collections.singletonList(contextValue);
// cache the context values
map.put(id.toString(), attrList);
} else {
// the context didn't have an attribute with that id, so we should
// try asking the attribute finder
attrList = Collections.emptyList();
}
}
// now go through each, considering each Attribute object
final List<AttributeValue> attributes;
Attribute attr = null;
switch (attrList.size()) {
case 0:
attributes = Collections.emptyList();
break;
case 1:
attr = attrList.get(0);
// make sure the type and issuer are correct
if ((attr.getType().equals(type)) &&
((issuer == null) ||
((attr.getIssuer() != null) &&
(attr.getIssuer().equals(issuer.toString()))))) {
attributes = new ArrayList<AttributeValue>(attrList.get(0).getValues());
} else {
attributes = Collections.emptyList();
}
break;
default:
Iterator it = attrList.iterator();
attributes = new ArrayList<AttributeValue>();
while (it.hasNext()) {
attr = (Attribute)(it.next());
// make sure the type and issuer are correct
if ((attr.getType().equals(type)) &&
((issuer == null) ||
((attr.getIssuer() != null) &&
(attr.getIssuer().equals(issuer.toString()))))) {
// if we got here, then we found a match, so we want to pull
// out the values and put them in out list
attributes.addAll(attr.getValues());
}
}
}
// see if we found any acceptable attributes
if (attributes.size() == 0) {
// we failed to find any that matched the type/issuer, or all the
// Attribute types were empty...so ask the finder
logger.debug("Attribute not in request: {} ... querying AttributeFinder",
id);
return callHelper(type, id, issuer, category, designatorType);
} else {
// if we got here, then we found at least one useful AttributeValue
return new EvaluationResult(new BagAttribute(type, attributes));
}
}
|
[
"private",
"EvaluationResult",
"getGenericAttributes",
"(",
"URI",
"type",
",",
"URI",
"id",
",",
"URI",
"issuer",
",",
"Map",
"<",
"String",
",",
"List",
"<",
"Attribute",
">",
">",
"map",
",",
"URI",
"category",
",",
"int",
"designatorType",
")",
"{",
"// try to find the id",
"List",
"<",
"Attribute",
">",
"attrList",
"=",
"(",
"List",
")",
"(",
"map",
".",
"get",
"(",
"id",
".",
"toString",
"(",
")",
")",
")",
";",
"if",
"(",
"attrList",
"==",
"null",
")",
"{",
"// the request didn't have an attribute with that id, so we should",
"// try asking the wrapped context",
"Attribute",
"contextValue",
"=",
"checkContext",
"(",
"type",
",",
"id",
",",
"issuer",
",",
"category",
",",
"designatorType",
")",
";",
"if",
"(",
"contextValue",
"!=",
"null",
")",
"{",
"attrList",
"=",
"Collections",
".",
"singletonList",
"(",
"contextValue",
")",
";",
"// cache the context values",
"map",
".",
"put",
"(",
"id",
".",
"toString",
"(",
")",
",",
"attrList",
")",
";",
"}",
"else",
"{",
"// the context didn't have an attribute with that id, so we should",
"// try asking the attribute finder",
"attrList",
"=",
"Collections",
".",
"emptyList",
"(",
")",
";",
"}",
"}",
"// now go through each, considering each Attribute object",
"final",
"List",
"<",
"AttributeValue",
">",
"attributes",
";",
"Attribute",
"attr",
"=",
"null",
";",
"switch",
"(",
"attrList",
".",
"size",
"(",
")",
")",
"{",
"case",
"0",
":",
"attributes",
"=",
"Collections",
".",
"emptyList",
"(",
")",
";",
"break",
";",
"case",
"1",
":",
"attr",
"=",
"attrList",
".",
"get",
"(",
"0",
")",
";",
"// make sure the type and issuer are correct",
"if",
"(",
"(",
"attr",
".",
"getType",
"(",
")",
".",
"equals",
"(",
"type",
")",
")",
"&&",
"(",
"(",
"issuer",
"==",
"null",
")",
"||",
"(",
"(",
"attr",
".",
"getIssuer",
"(",
")",
"!=",
"null",
")",
"&&",
"(",
"attr",
".",
"getIssuer",
"(",
")",
".",
"equals",
"(",
"issuer",
".",
"toString",
"(",
")",
")",
")",
")",
")",
")",
"{",
"attributes",
"=",
"new",
"ArrayList",
"<",
"AttributeValue",
">",
"(",
"attrList",
".",
"get",
"(",
"0",
")",
".",
"getValues",
"(",
")",
")",
";",
"}",
"else",
"{",
"attributes",
"=",
"Collections",
".",
"emptyList",
"(",
")",
";",
"}",
"break",
";",
"default",
":",
"Iterator",
"it",
"=",
"attrList",
".",
"iterator",
"(",
")",
";",
"attributes",
"=",
"new",
"ArrayList",
"<",
"AttributeValue",
">",
"(",
")",
";",
"while",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"attr",
"=",
"(",
"Attribute",
")",
"(",
"it",
".",
"next",
"(",
")",
")",
";",
"// make sure the type and issuer are correct",
"if",
"(",
"(",
"attr",
".",
"getType",
"(",
")",
".",
"equals",
"(",
"type",
")",
")",
"&&",
"(",
"(",
"issuer",
"==",
"null",
")",
"||",
"(",
"(",
"attr",
".",
"getIssuer",
"(",
")",
"!=",
"null",
")",
"&&",
"(",
"attr",
".",
"getIssuer",
"(",
")",
".",
"equals",
"(",
"issuer",
".",
"toString",
"(",
")",
")",
")",
")",
")",
")",
"{",
"// if we got here, then we found a match, so we want to pull",
"// out the values and put them in out list",
"attributes",
".",
"addAll",
"(",
"attr",
".",
"getValues",
"(",
")",
")",
";",
"}",
"}",
"}",
"// see if we found any acceptable attributes",
"if",
"(",
"attributes",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"// we failed to find any that matched the type/issuer, or all the",
"// Attribute types were empty...so ask the finder",
"logger",
".",
"debug",
"(",
"\"Attribute not in request: {} ... querying AttributeFinder\"",
",",
"id",
")",
";",
"return",
"callHelper",
"(",
"type",
",",
"id",
",",
"issuer",
",",
"category",
",",
"designatorType",
")",
";",
"}",
"else",
"{",
"// if we got here, then we found at least one useful AttributeValue",
"return",
"new",
"EvaluationResult",
"(",
"new",
"BagAttribute",
"(",
"type",
",",
"attributes",
")",
")",
";",
"}",
"}"
] |
Helper function for the resource, action and environment methods
to get an attribute.
|
[
"Helper",
"function",
"for",
"the",
"resource",
"action",
"and",
"environment",
"methods",
"to",
"get",
"an",
"attribute",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/security/impl/BasicEvaluationCtx.java#L629-L700
|
8,829 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/security/impl/BasicEvaluationCtx.java
|
BasicEvaluationCtx.checkContext
|
private Attribute checkContext(URI type, URI id, URI issuer,
URI category, int designatorType) {
if (!STRING_ATTRIBUTE_TYPE_URI.equals(type)) return null;
String [] values = null;
switch(designatorType){
case AttributeDesignator.SUBJECT_TARGET:
values = context.getSubjectValues(id.toString());
break;
case AttributeDesignator.RESOURCE_TARGET:
values = context.getResourceValues(id);
break;
case AttributeDesignator.ACTION_TARGET:
values = context.getActionValues(id);
break;
case AttributeDesignator.ENVIRONMENT_TARGET:
values = context.getEnvironmentValues(id);
break;
}
if (values == null || values.length == 0) return null;
String iString = (issuer == null) ? null : issuer.toString();
String tString = type.toString();
if (values.length == 1) {
AttributeValue val = stringToValue(values[0], tString);
return (val == null) ? null :
new SingletonAttribute(id, iString, getCurrentDateTime(), val);
} else {
ArrayList<AttributeValue> valCollection = new ArrayList<AttributeValue>(values.length);
for (int i=0;i<values.length;i++) {
AttributeValue val = stringToValue(values[i], tString);
if (val != null) valCollection.add(val);
}
return new BasicAttribute(id, type, iString, getCurrentDateTime(), valCollection);
}
}
|
java
|
private Attribute checkContext(URI type, URI id, URI issuer,
URI category, int designatorType) {
if (!STRING_ATTRIBUTE_TYPE_URI.equals(type)) return null;
String [] values = null;
switch(designatorType){
case AttributeDesignator.SUBJECT_TARGET:
values = context.getSubjectValues(id.toString());
break;
case AttributeDesignator.RESOURCE_TARGET:
values = context.getResourceValues(id);
break;
case AttributeDesignator.ACTION_TARGET:
values = context.getActionValues(id);
break;
case AttributeDesignator.ENVIRONMENT_TARGET:
values = context.getEnvironmentValues(id);
break;
}
if (values == null || values.length == 0) return null;
String iString = (issuer == null) ? null : issuer.toString();
String tString = type.toString();
if (values.length == 1) {
AttributeValue val = stringToValue(values[0], tString);
return (val == null) ? null :
new SingletonAttribute(id, iString, getCurrentDateTime(), val);
} else {
ArrayList<AttributeValue> valCollection = new ArrayList<AttributeValue>(values.length);
for (int i=0;i<values.length;i++) {
AttributeValue val = stringToValue(values[i], tString);
if (val != null) valCollection.add(val);
}
return new BasicAttribute(id, type, iString, getCurrentDateTime(), valCollection);
}
}
|
[
"private",
"Attribute",
"checkContext",
"(",
"URI",
"type",
",",
"URI",
"id",
",",
"URI",
"issuer",
",",
"URI",
"category",
",",
"int",
"designatorType",
")",
"{",
"if",
"(",
"!",
"STRING_ATTRIBUTE_TYPE_URI",
".",
"equals",
"(",
"type",
")",
")",
"return",
"null",
";",
"String",
"[",
"]",
"values",
"=",
"null",
";",
"switch",
"(",
"designatorType",
")",
"{",
"case",
"AttributeDesignator",
".",
"SUBJECT_TARGET",
":",
"values",
"=",
"context",
".",
"getSubjectValues",
"(",
"id",
".",
"toString",
"(",
")",
")",
";",
"break",
";",
"case",
"AttributeDesignator",
".",
"RESOURCE_TARGET",
":",
"values",
"=",
"context",
".",
"getResourceValues",
"(",
"id",
")",
";",
"break",
";",
"case",
"AttributeDesignator",
".",
"ACTION_TARGET",
":",
"values",
"=",
"context",
".",
"getActionValues",
"(",
"id",
")",
";",
"break",
";",
"case",
"AttributeDesignator",
".",
"ENVIRONMENT_TARGET",
":",
"values",
"=",
"context",
".",
"getEnvironmentValues",
"(",
"id",
")",
";",
"break",
";",
"}",
"if",
"(",
"values",
"==",
"null",
"||",
"values",
".",
"length",
"==",
"0",
")",
"return",
"null",
";",
"String",
"iString",
"=",
"(",
"issuer",
"==",
"null",
")",
"?",
"null",
":",
"issuer",
".",
"toString",
"(",
")",
";",
"String",
"tString",
"=",
"type",
".",
"toString",
"(",
")",
";",
"if",
"(",
"values",
".",
"length",
"==",
"1",
")",
"{",
"AttributeValue",
"val",
"=",
"stringToValue",
"(",
"values",
"[",
"0",
"]",
",",
"tString",
")",
";",
"return",
"(",
"val",
"==",
"null",
")",
"?",
"null",
":",
"new",
"SingletonAttribute",
"(",
"id",
",",
"iString",
",",
"getCurrentDateTime",
"(",
")",
",",
"val",
")",
";",
"}",
"else",
"{",
"ArrayList",
"<",
"AttributeValue",
">",
"valCollection",
"=",
"new",
"ArrayList",
"<",
"AttributeValue",
">",
"(",
"values",
".",
"length",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"values",
".",
"length",
";",
"i",
"++",
")",
"{",
"AttributeValue",
"val",
"=",
"stringToValue",
"(",
"values",
"[",
"i",
"]",
",",
"tString",
")",
";",
"if",
"(",
"val",
"!=",
"null",
")",
"valCollection",
".",
"add",
"(",
"val",
")",
";",
"}",
"return",
"new",
"BasicAttribute",
"(",
"id",
",",
"type",
",",
"iString",
",",
"getCurrentDateTime",
"(",
")",
",",
"valCollection",
")",
";",
"}",
"}"
] |
Private helper that checks the request context for an attribute, or else returns
null
|
[
"Private",
"helper",
"that",
"checks",
"the",
"request",
"context",
"for",
"an",
"attribute",
"or",
"else",
"returns",
"null"
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/security/impl/BasicEvaluationCtx.java#L706-L739
|
8,830 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/security/impl/BasicEvaluationCtx.java
|
BasicEvaluationCtx.callHelper
|
private EvaluationResult callHelper(URI type, URI id, URI issuer,
URI category, int adType) {
if (finder != null) {
return finder.findAttribute(type, id, issuer, category,
this, adType);
} else {
logger.warn(NO_FINDER_MSG);
return new EvaluationResult(BagAttribute.createEmptyBag(type));
}
}
|
java
|
private EvaluationResult callHelper(URI type, URI id, URI issuer,
URI category, int adType) {
if (finder != null) {
return finder.findAttribute(type, id, issuer, category,
this, adType);
} else {
logger.warn(NO_FINDER_MSG);
return new EvaluationResult(BagAttribute.createEmptyBag(type));
}
}
|
[
"private",
"EvaluationResult",
"callHelper",
"(",
"URI",
"type",
",",
"URI",
"id",
",",
"URI",
"issuer",
",",
"URI",
"category",
",",
"int",
"adType",
")",
"{",
"if",
"(",
"finder",
"!=",
"null",
")",
"{",
"return",
"finder",
".",
"findAttribute",
"(",
"type",
",",
"id",
",",
"issuer",
",",
"category",
",",
"this",
",",
"adType",
")",
";",
"}",
"else",
"{",
"logger",
".",
"warn",
"(",
"NO_FINDER_MSG",
")",
";",
"return",
"new",
"EvaluationResult",
"(",
"BagAttribute",
".",
"createEmptyBag",
"(",
"type",
")",
")",
";",
"}",
"}"
] |
Private helper that calls the finder if it's non-null, or else returns
an empty bag
|
[
"Private",
"helper",
"that",
"calls",
"the",
"finder",
"if",
"it",
"s",
"non",
"-",
"null",
"or",
"else",
"returns",
"an",
"empty",
"bag"
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/security/impl/BasicEvaluationCtx.java#L744-L754
|
8,831 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/storage/DefaultDOManager.java
|
DefaultDOManager.getReader
|
@Override
public DOReader getReader(boolean cachedObjectRequired, Context context,
String pid) throws ServerException {
long getReaderStartTime = logger.isDebugEnabled() ?
System.currentTimeMillis() : -1;
String source = null;
try {
{
DOReader reader = null;
if (m_readerCache != null) {
reader = m_readerCache.get(pid);
}
if (reader == null) {
reader =
new SimpleDOReader(context, this, m_translator,
m_defaultExportFormat,
m_defaultStorageFormat,
m_storageCharacterEncoding,
m_permanentStore.retrieveObject(pid));
source = "filesystem";
if (m_readerCache != null) {
m_readerCache.put(reader, getReaderStartTime);
}
} else {
source = "memory";
}
return reader;
}
} finally {
if (logger.isDebugEnabled()) {
long dur = System.currentTimeMillis() - getReaderStartTime;
logger.debug("Got DOReader (source={}) for {} in {}ms.",
source, pid, dur);
}
}
}
|
java
|
@Override
public DOReader getReader(boolean cachedObjectRequired, Context context,
String pid) throws ServerException {
long getReaderStartTime = logger.isDebugEnabled() ?
System.currentTimeMillis() : -1;
String source = null;
try {
{
DOReader reader = null;
if (m_readerCache != null) {
reader = m_readerCache.get(pid);
}
if (reader == null) {
reader =
new SimpleDOReader(context, this, m_translator,
m_defaultExportFormat,
m_defaultStorageFormat,
m_storageCharacterEncoding,
m_permanentStore.retrieveObject(pid));
source = "filesystem";
if (m_readerCache != null) {
m_readerCache.put(reader, getReaderStartTime);
}
} else {
source = "memory";
}
return reader;
}
} finally {
if (logger.isDebugEnabled()) {
long dur = System.currentTimeMillis() - getReaderStartTime;
logger.debug("Got DOReader (source={}) for {} in {}ms.",
source, pid, dur);
}
}
}
|
[
"@",
"Override",
"public",
"DOReader",
"getReader",
"(",
"boolean",
"cachedObjectRequired",
",",
"Context",
"context",
",",
"String",
"pid",
")",
"throws",
"ServerException",
"{",
"long",
"getReaderStartTime",
"=",
"logger",
".",
"isDebugEnabled",
"(",
")",
"?",
"System",
".",
"currentTimeMillis",
"(",
")",
":",
"-",
"1",
";",
"String",
"source",
"=",
"null",
";",
"try",
"{",
"{",
"DOReader",
"reader",
"=",
"null",
";",
"if",
"(",
"m_readerCache",
"!=",
"null",
")",
"{",
"reader",
"=",
"m_readerCache",
".",
"get",
"(",
"pid",
")",
";",
"}",
"if",
"(",
"reader",
"==",
"null",
")",
"{",
"reader",
"=",
"new",
"SimpleDOReader",
"(",
"context",
",",
"this",
",",
"m_translator",
",",
"m_defaultExportFormat",
",",
"m_defaultStorageFormat",
",",
"m_storageCharacterEncoding",
",",
"m_permanentStore",
".",
"retrieveObject",
"(",
"pid",
")",
")",
";",
"source",
"=",
"\"filesystem\"",
";",
"if",
"(",
"m_readerCache",
"!=",
"null",
")",
"{",
"m_readerCache",
".",
"put",
"(",
"reader",
",",
"getReaderStartTime",
")",
";",
"}",
"}",
"else",
"{",
"source",
"=",
"\"memory\"",
";",
"}",
"return",
"reader",
";",
"}",
"}",
"finally",
"{",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"long",
"dur",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"getReaderStartTime",
";",
"logger",
".",
"debug",
"(",
"\"Got DOReader (source={}) for {} in {}ms.\"",
",",
"source",
",",
"pid",
",",
"dur",
")",
";",
"}",
"}",
"}"
] |
Gets a reader on an existing digital object.
|
[
"Gets",
"a",
"reader",
"on",
"an",
"existing",
"digital",
"object",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/storage/DefaultDOManager.java#L715-L750
|
8,832 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/storage/DefaultDOManager.java
|
DefaultDOManager.getServiceDeploymentReader
|
@Override
public ServiceDeploymentReader getServiceDeploymentReader(
boolean cachedObjectRequired, Context context, String pid)
throws ServerException {
{
return new SimpleServiceDeploymentReader(context, this,
m_translator, m_defaultExportFormat,
m_defaultStorageFormat, m_storageCharacterEncoding,
m_permanentStore.retrieveObject(pid));
}
}
|
java
|
@Override
public ServiceDeploymentReader getServiceDeploymentReader(
boolean cachedObjectRequired, Context context, String pid)
throws ServerException {
{
return new SimpleServiceDeploymentReader(context, this,
m_translator, m_defaultExportFormat,
m_defaultStorageFormat, m_storageCharacterEncoding,
m_permanentStore.retrieveObject(pid));
}
}
|
[
"@",
"Override",
"public",
"ServiceDeploymentReader",
"getServiceDeploymentReader",
"(",
"boolean",
"cachedObjectRequired",
",",
"Context",
"context",
",",
"String",
"pid",
")",
"throws",
"ServerException",
"{",
"{",
"return",
"new",
"SimpleServiceDeploymentReader",
"(",
"context",
",",
"this",
",",
"m_translator",
",",
"m_defaultExportFormat",
",",
"m_defaultStorageFormat",
",",
"m_storageCharacterEncoding",
",",
"m_permanentStore",
".",
"retrieveObject",
"(",
"pid",
")",
")",
";",
"}",
"}"
] |
Gets a reader on an existing service deployment object.
|
[
"Gets",
"a",
"reader",
"on",
"an",
"existing",
"service",
"deployment",
"object",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/storage/DefaultDOManager.java#L755-L765
|
8,833 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/storage/DefaultDOManager.java
|
DefaultDOManager.getServiceDefinitionReader
|
@Override
public ServiceDefinitionReader getServiceDefinitionReader(
boolean cachedObjectRequired, Context context, String pid)
throws ServerException {
{
return new SimpleServiceDefinitionReader(context, this,
m_translator, m_defaultExportFormat,
m_defaultStorageFormat, m_storageCharacterEncoding,
m_permanentStore.retrieveObject(pid));
}
}
|
java
|
@Override
public ServiceDefinitionReader getServiceDefinitionReader(
boolean cachedObjectRequired, Context context, String pid)
throws ServerException {
{
return new SimpleServiceDefinitionReader(context, this,
m_translator, m_defaultExportFormat,
m_defaultStorageFormat, m_storageCharacterEncoding,
m_permanentStore.retrieveObject(pid));
}
}
|
[
"@",
"Override",
"public",
"ServiceDefinitionReader",
"getServiceDefinitionReader",
"(",
"boolean",
"cachedObjectRequired",
",",
"Context",
"context",
",",
"String",
"pid",
")",
"throws",
"ServerException",
"{",
"{",
"return",
"new",
"SimpleServiceDefinitionReader",
"(",
"context",
",",
"this",
",",
"m_translator",
",",
"m_defaultExportFormat",
",",
"m_defaultStorageFormat",
",",
"m_storageCharacterEncoding",
",",
"m_permanentStore",
".",
"retrieveObject",
"(",
"pid",
")",
")",
";",
"}",
"}"
] |
Gets a reader on an existing service definition object.
|
[
"Gets",
"a",
"reader",
"on",
"an",
"existing",
"service",
"definition",
"object",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/storage/DefaultDOManager.java#L770-L780
|
8,834 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/storage/DefaultDOManager.java
|
DefaultDOManager.getWriter
|
@Override
public DOWriter getWriter(boolean cachedObjectRequired, Context context,
String pid) throws ServerException, ObjectLockedException {
if (cachedObjectRequired) {
throw new InvalidContextException(
"A DOWriter is unavailable in a cached context.");
} else {
BasicDigitalObject obj = new BasicDigitalObject();
getWriteLock(pid);
boolean clean = false;
try {
m_translator.deserialize(m_permanentStore.retrieveObject(pid), obj,
m_defaultStorageFormat, m_storageCharacterEncoding,
DOTranslationUtility.DESERIALIZE_INSTANCE);
DOWriter w =
new SimpleDOWriter(context, this, m_translator,
m_defaultStorageFormat, m_storageCharacterEncoding,
obj);
clean = true;
return w;
} finally {
if (!clean) {
releaseWriteLock(pid);
}
}
}
}
|
java
|
@Override
public DOWriter getWriter(boolean cachedObjectRequired, Context context,
String pid) throws ServerException, ObjectLockedException {
if (cachedObjectRequired) {
throw new InvalidContextException(
"A DOWriter is unavailable in a cached context.");
} else {
BasicDigitalObject obj = new BasicDigitalObject();
getWriteLock(pid);
boolean clean = false;
try {
m_translator.deserialize(m_permanentStore.retrieveObject(pid), obj,
m_defaultStorageFormat, m_storageCharacterEncoding,
DOTranslationUtility.DESERIALIZE_INSTANCE);
DOWriter w =
new SimpleDOWriter(context, this, m_translator,
m_defaultStorageFormat, m_storageCharacterEncoding,
obj);
clean = true;
return w;
} finally {
if (!clean) {
releaseWriteLock(pid);
}
}
}
}
|
[
"@",
"Override",
"public",
"DOWriter",
"getWriter",
"(",
"boolean",
"cachedObjectRequired",
",",
"Context",
"context",
",",
"String",
"pid",
")",
"throws",
"ServerException",
",",
"ObjectLockedException",
"{",
"if",
"(",
"cachedObjectRequired",
")",
"{",
"throw",
"new",
"InvalidContextException",
"(",
"\"A DOWriter is unavailable in a cached context.\"",
")",
";",
"}",
"else",
"{",
"BasicDigitalObject",
"obj",
"=",
"new",
"BasicDigitalObject",
"(",
")",
";",
"getWriteLock",
"(",
"pid",
")",
";",
"boolean",
"clean",
"=",
"false",
";",
"try",
"{",
"m_translator",
".",
"deserialize",
"(",
"m_permanentStore",
".",
"retrieveObject",
"(",
"pid",
")",
",",
"obj",
",",
"m_defaultStorageFormat",
",",
"m_storageCharacterEncoding",
",",
"DOTranslationUtility",
".",
"DESERIALIZE_INSTANCE",
")",
";",
"DOWriter",
"w",
"=",
"new",
"SimpleDOWriter",
"(",
"context",
",",
"this",
",",
"m_translator",
",",
"m_defaultStorageFormat",
",",
"m_storageCharacterEncoding",
",",
"obj",
")",
";",
"clean",
"=",
"true",
";",
"return",
"w",
";",
"}",
"finally",
"{",
"if",
"(",
"!",
"clean",
")",
"{",
"releaseWriteLock",
"(",
"pid",
")",
";",
"}",
"}",
"}",
"}"
] |
Gets a writer on an existing object.
|
[
"Gets",
"a",
"writer",
"on",
"an",
"existing",
"object",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/storage/DefaultDOManager.java#L785-L811
|
8,835 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/storage/DefaultDOManager.java
|
DefaultDOManager.populateDC
|
private static void populateDC(Context ctx, DigitalObject obj, DOWriter w,
Date nowUTC) throws IOException, ServerException {
logger.debug("Adding/Checking default DC datastream");
Datastream dc = w.GetDatastream("DC", null);
DCFields dcf;
XMLDatastreamProcessor dcxml = null;
if (dc == null) {
dcxml = new XMLDatastreamProcessor("DC");
dc = dcxml.getDatastream();
//dc.DSMDClass=DatastreamXMLMetadata.DESCRIPTIVE;
dc.DatastreamID = "DC";
dc.DSVersionID = "DC1.0";
//dc.DSControlGrp = "X"; set by XMLDatastreamProcessor instead
dc.DSCreateDT = nowUTC;
dc.DSLabel = "Dublin Core Record for this object";
dc.DSMIME = "text/xml";
dc.DSFormatURI = OAI_DC2_0.uri;
dc.DSSize = 0;
dc.DSState = "A";
dc.DSVersionable = true;
dcf = new DCFields();
if (obj.getLabel() != null && !obj.getLabel().isEmpty()) {
dcf.titles().add(new DCField(obj.getLabel()));
}
w.addDatastream(dc, dc.DSVersionable);
} else {
dcxml = new XMLDatastreamProcessor(dc);
// note: context may be required to get through authz as content
// could be filesystem file (or URL)
dcf = new DCFields(dc.getContentStream(ctx));
}
// set the value of the dc datastream according to what's in the
// DCFields object
// ensure one of the dc:identifiers is the pid
ByteArrayOutputStream bytes = new ByteArrayOutputStream(512);
PrintWriter out = new PrintWriter(new OutputStreamWriter(bytes, Charset.forName("UTF-8")));
dcf.getAsXML(obj.getPid(), out);
out.close();
dcxml.setXMLContent(bytes.toByteArray());
}
|
java
|
private static void populateDC(Context ctx, DigitalObject obj, DOWriter w,
Date nowUTC) throws IOException, ServerException {
logger.debug("Adding/Checking default DC datastream");
Datastream dc = w.GetDatastream("DC", null);
DCFields dcf;
XMLDatastreamProcessor dcxml = null;
if (dc == null) {
dcxml = new XMLDatastreamProcessor("DC");
dc = dcxml.getDatastream();
//dc.DSMDClass=DatastreamXMLMetadata.DESCRIPTIVE;
dc.DatastreamID = "DC";
dc.DSVersionID = "DC1.0";
//dc.DSControlGrp = "X"; set by XMLDatastreamProcessor instead
dc.DSCreateDT = nowUTC;
dc.DSLabel = "Dublin Core Record for this object";
dc.DSMIME = "text/xml";
dc.DSFormatURI = OAI_DC2_0.uri;
dc.DSSize = 0;
dc.DSState = "A";
dc.DSVersionable = true;
dcf = new DCFields();
if (obj.getLabel() != null && !obj.getLabel().isEmpty()) {
dcf.titles().add(new DCField(obj.getLabel()));
}
w.addDatastream(dc, dc.DSVersionable);
} else {
dcxml = new XMLDatastreamProcessor(dc);
// note: context may be required to get through authz as content
// could be filesystem file (or URL)
dcf = new DCFields(dc.getContentStream(ctx));
}
// set the value of the dc datastream according to what's in the
// DCFields object
// ensure one of the dc:identifiers is the pid
ByteArrayOutputStream bytes = new ByteArrayOutputStream(512);
PrintWriter out = new PrintWriter(new OutputStreamWriter(bytes, Charset.forName("UTF-8")));
dcf.getAsXML(obj.getPid(), out);
out.close();
dcxml.setXMLContent(bytes.toByteArray());
}
|
[
"private",
"static",
"void",
"populateDC",
"(",
"Context",
"ctx",
",",
"DigitalObject",
"obj",
",",
"DOWriter",
"w",
",",
"Date",
"nowUTC",
")",
"throws",
"IOException",
",",
"ServerException",
"{",
"logger",
".",
"debug",
"(",
"\"Adding/Checking default DC datastream\"",
")",
";",
"Datastream",
"dc",
"=",
"w",
".",
"GetDatastream",
"(",
"\"DC\"",
",",
"null",
")",
";",
"DCFields",
"dcf",
";",
"XMLDatastreamProcessor",
"dcxml",
"=",
"null",
";",
"if",
"(",
"dc",
"==",
"null",
")",
"{",
"dcxml",
"=",
"new",
"XMLDatastreamProcessor",
"(",
"\"DC\"",
")",
";",
"dc",
"=",
"dcxml",
".",
"getDatastream",
"(",
")",
";",
"//dc.DSMDClass=DatastreamXMLMetadata.DESCRIPTIVE;",
"dc",
".",
"DatastreamID",
"=",
"\"DC\"",
";",
"dc",
".",
"DSVersionID",
"=",
"\"DC1.0\"",
";",
"//dc.DSControlGrp = \"X\"; set by XMLDatastreamProcessor instead",
"dc",
".",
"DSCreateDT",
"=",
"nowUTC",
";",
"dc",
".",
"DSLabel",
"=",
"\"Dublin Core Record for this object\"",
";",
"dc",
".",
"DSMIME",
"=",
"\"text/xml\"",
";",
"dc",
".",
"DSFormatURI",
"=",
"OAI_DC2_0",
".",
"uri",
";",
"dc",
".",
"DSSize",
"=",
"0",
";",
"dc",
".",
"DSState",
"=",
"\"A\"",
";",
"dc",
".",
"DSVersionable",
"=",
"true",
";",
"dcf",
"=",
"new",
"DCFields",
"(",
")",
";",
"if",
"(",
"obj",
".",
"getLabel",
"(",
")",
"!=",
"null",
"&&",
"!",
"obj",
".",
"getLabel",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"dcf",
".",
"titles",
"(",
")",
".",
"add",
"(",
"new",
"DCField",
"(",
"obj",
".",
"getLabel",
"(",
")",
")",
")",
";",
"}",
"w",
".",
"addDatastream",
"(",
"dc",
",",
"dc",
".",
"DSVersionable",
")",
";",
"}",
"else",
"{",
"dcxml",
"=",
"new",
"XMLDatastreamProcessor",
"(",
"dc",
")",
";",
"// note: context may be required to get through authz as content",
"// could be filesystem file (or URL)",
"dcf",
"=",
"new",
"DCFields",
"(",
"dc",
".",
"getContentStream",
"(",
"ctx",
")",
")",
";",
"}",
"// set the value of the dc datastream according to what's in the",
"// DCFields object",
"// ensure one of the dc:identifiers is the pid",
"ByteArrayOutputStream",
"bytes",
"=",
"new",
"ByteArrayOutputStream",
"(",
"512",
")",
";",
"PrintWriter",
"out",
"=",
"new",
"PrintWriter",
"(",
"new",
"OutputStreamWriter",
"(",
"bytes",
",",
"Charset",
".",
"forName",
"(",
"\"UTF-8\"",
")",
")",
")",
";",
"dcf",
".",
"getAsXML",
"(",
"obj",
".",
"getPid",
"(",
")",
",",
"out",
")",
";",
"out",
".",
"close",
"(",
")",
";",
"dcxml",
".",
"setXMLContent",
"(",
"bytes",
".",
"toByteArray",
"(",
")",
")",
";",
"}"
] |
Adds a minimal DC datastream if one isn't already present.
If there is already a DC datastream, ensure one of the dc:identifier
values is the PID of the object.
|
[
"Adds",
"a",
"minimal",
"DC",
"datastream",
"if",
"one",
"isn",
"t",
"already",
"present",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/storage/DefaultDOManager.java#L1060-L1100
|
8,836 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/storage/DefaultDOManager.java
|
DefaultDOManager.objectExists
|
@Override
public boolean objectExists(String pid) throws StorageDeviceException {
boolean registered = objectExistsInRegistry(pid);
boolean exists = false;
if (!registered && m_checkableStore) {
try {
exists = ((ICheckable)m_permanentStore).objectExists(pid);
} catch (LowlevelStorageException e) {
throw new StorageDeviceException(e.getMessage(), e);
}
}
if (exists && !registered) {
logger.warn("{} was not in the registry, but appears to be in store." +
" Registry db may be in inconsistent state.", pid);
}
return registered || exists;
}
|
java
|
@Override
public boolean objectExists(String pid) throws StorageDeviceException {
boolean registered = objectExistsInRegistry(pid);
boolean exists = false;
if (!registered && m_checkableStore) {
try {
exists = ((ICheckable)m_permanentStore).objectExists(pid);
} catch (LowlevelStorageException e) {
throw new StorageDeviceException(e.getMessage(), e);
}
}
if (exists && !registered) {
logger.warn("{} was not in the registry, but appears to be in store." +
" Registry db may be in inconsistent state.", pid);
}
return registered || exists;
}
|
[
"@",
"Override",
"public",
"boolean",
"objectExists",
"(",
"String",
"pid",
")",
"throws",
"StorageDeviceException",
"{",
"boolean",
"registered",
"=",
"objectExistsInRegistry",
"(",
"pid",
")",
";",
"boolean",
"exists",
"=",
"false",
";",
"if",
"(",
"!",
"registered",
"&&",
"m_checkableStore",
")",
"{",
"try",
"{",
"exists",
"=",
"(",
"(",
"ICheckable",
")",
"m_permanentStore",
")",
".",
"objectExists",
"(",
"pid",
")",
";",
"}",
"catch",
"(",
"LowlevelStorageException",
"e",
")",
"{",
"throw",
"new",
"StorageDeviceException",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}",
"if",
"(",
"exists",
"&&",
"!",
"registered",
")",
"{",
"logger",
".",
"warn",
"(",
"\"{} was not in the registry, but appears to be in store.\"",
"+",
"\" Registry db may be in inconsistent state.\"",
",",
"pid",
")",
";",
"}",
"return",
"registered",
"||",
"exists",
";",
"}"
] |
Checks the object registry for the given object.
|
[
"Checks",
"the",
"object",
"registry",
"for",
"the",
"given",
"object",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/storage/DefaultDOManager.java#L1699-L1715
|
8,837 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/storage/DefaultDOManager.java
|
DefaultDOManager.unregisterObject
|
private void unregisterObject(DigitalObject obj)
throws StorageDeviceException {
String pid = obj.getPid();
Connection conn = null;
PreparedStatement st = null;
try {
conn = m_connectionPool.getReadWriteConnection();
String query = "DELETE FROM doRegistry WHERE doPID=?";
st = conn.prepareStatement(query);
st.setString(1, pid);
st.executeUpdate();
//TODO hasModel
if (obj.hasContentModel(Models.SERVICE_DEPLOYMENT_3_0)) {
updateDeploymentMap(obj, conn, true);
}
} catch (SQLException sqle) {
throw new StorageDeviceException(
"Unexpected error from SQL database while unregistering object: " +
sqle.getMessage(), sqle);
} finally {
try {
if (st != null) {
st.close();
}
if (conn != null) {
m_connectionPool.free(conn);
}
} catch (Exception sqle) {
throw new StorageDeviceException(
"Unexpected error from SQL database while unregistering object: " +
sqle.getMessage(), sqle);
} finally {
st = null;
}
}
}
|
java
|
private void unregisterObject(DigitalObject obj)
throws StorageDeviceException {
String pid = obj.getPid();
Connection conn = null;
PreparedStatement st = null;
try {
conn = m_connectionPool.getReadWriteConnection();
String query = "DELETE FROM doRegistry WHERE doPID=?";
st = conn.prepareStatement(query);
st.setString(1, pid);
st.executeUpdate();
//TODO hasModel
if (obj.hasContentModel(Models.SERVICE_DEPLOYMENT_3_0)) {
updateDeploymentMap(obj, conn, true);
}
} catch (SQLException sqle) {
throw new StorageDeviceException(
"Unexpected error from SQL database while unregistering object: " +
sqle.getMessage(), sqle);
} finally {
try {
if (st != null) {
st.close();
}
if (conn != null) {
m_connectionPool.free(conn);
}
} catch (Exception sqle) {
throw new StorageDeviceException(
"Unexpected error from SQL database while unregistering object: " +
sqle.getMessage(), sqle);
} finally {
st = null;
}
}
}
|
[
"private",
"void",
"unregisterObject",
"(",
"DigitalObject",
"obj",
")",
"throws",
"StorageDeviceException",
"{",
"String",
"pid",
"=",
"obj",
".",
"getPid",
"(",
")",
";",
"Connection",
"conn",
"=",
"null",
";",
"PreparedStatement",
"st",
"=",
"null",
";",
"try",
"{",
"conn",
"=",
"m_connectionPool",
".",
"getReadWriteConnection",
"(",
")",
";",
"String",
"query",
"=",
"\"DELETE FROM doRegistry WHERE doPID=?\"",
";",
"st",
"=",
"conn",
".",
"prepareStatement",
"(",
"query",
")",
";",
"st",
".",
"setString",
"(",
"1",
",",
"pid",
")",
";",
"st",
".",
"executeUpdate",
"(",
")",
";",
"//TODO hasModel",
"if",
"(",
"obj",
".",
"hasContentModel",
"(",
"Models",
".",
"SERVICE_DEPLOYMENT_3_0",
")",
")",
"{",
"updateDeploymentMap",
"(",
"obj",
",",
"conn",
",",
"true",
")",
";",
"}",
"}",
"catch",
"(",
"SQLException",
"sqle",
")",
"{",
"throw",
"new",
"StorageDeviceException",
"(",
"\"Unexpected error from SQL database while unregistering object: \"",
"+",
"sqle",
".",
"getMessage",
"(",
")",
",",
"sqle",
")",
";",
"}",
"finally",
"{",
"try",
"{",
"if",
"(",
"st",
"!=",
"null",
")",
"{",
"st",
".",
"close",
"(",
")",
";",
"}",
"if",
"(",
"conn",
"!=",
"null",
")",
"{",
"m_connectionPool",
".",
"free",
"(",
"conn",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"sqle",
")",
"{",
"throw",
"new",
"StorageDeviceException",
"(",
"\"Unexpected error from SQL database while unregistering object: \"",
"+",
"sqle",
".",
"getMessage",
"(",
")",
",",
"sqle",
")",
";",
"}",
"finally",
"{",
"st",
"=",
"null",
";",
"}",
"}",
"}"
] |
Removes an object from the object registry.
|
[
"Removes",
"an",
"object",
"from",
"the",
"object",
"registry",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/storage/DefaultDOManager.java#L1805-L1841
|
8,838 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/storage/DefaultDOManager.java
|
DefaultDOManager.getPIDs
|
private String[] getPIDs(String whereClause) throws StorageDeviceException {
Connection conn = null;
PreparedStatement s = null;
ResultSet results = null;
try {
conn = m_connectionPool.getReadOnlyConnection();
String query = "SELECT doPID FROM doRegistry " + whereClause;
s = conn.prepareStatement(query);
logger.debug("Executing db query: {}", query);
results = s.executeQuery();
if (results.next()){
ArrayList<String> pidList = new ArrayList<String>();
do {
pidList.add(results.getString("doPID"));
} while (results.next());
return pidList.toArray(EMPTY_STRING_ARRAY);
} else {
return EMPTY_STRING_ARRAY;
}
} catch (SQLException sqle) {
throw new StorageDeviceException(
"Unexpected error from SQL database: " + sqle.getMessage(),
sqle);
} finally {
try {
if (results != null) {
results.close();
}
if (s != null) {
s.close();
}
if (conn != null) {
m_connectionPool.free(conn);
}
} catch (SQLException sqle) {
throw new StorageDeviceException(
"Unexpected error from SQL database: " +
sqle.getMessage(), sqle);
} finally {
results = null;
s = null;
}
}
}
|
java
|
private String[] getPIDs(String whereClause) throws StorageDeviceException {
Connection conn = null;
PreparedStatement s = null;
ResultSet results = null;
try {
conn = m_connectionPool.getReadOnlyConnection();
String query = "SELECT doPID FROM doRegistry " + whereClause;
s = conn.prepareStatement(query);
logger.debug("Executing db query: {}", query);
results = s.executeQuery();
if (results.next()){
ArrayList<String> pidList = new ArrayList<String>();
do {
pidList.add(results.getString("doPID"));
} while (results.next());
return pidList.toArray(EMPTY_STRING_ARRAY);
} else {
return EMPTY_STRING_ARRAY;
}
} catch (SQLException sqle) {
throw new StorageDeviceException(
"Unexpected error from SQL database: " + sqle.getMessage(),
sqle);
} finally {
try {
if (results != null) {
results.close();
}
if (s != null) {
s.close();
}
if (conn != null) {
m_connectionPool.free(conn);
}
} catch (SQLException sqle) {
throw new StorageDeviceException(
"Unexpected error from SQL database: " +
sqle.getMessage(), sqle);
} finally {
results = null;
s = null;
}
}
}
|
[
"private",
"String",
"[",
"]",
"getPIDs",
"(",
"String",
"whereClause",
")",
"throws",
"StorageDeviceException",
"{",
"Connection",
"conn",
"=",
"null",
";",
"PreparedStatement",
"s",
"=",
"null",
";",
"ResultSet",
"results",
"=",
"null",
";",
"try",
"{",
"conn",
"=",
"m_connectionPool",
".",
"getReadOnlyConnection",
"(",
")",
";",
"String",
"query",
"=",
"\"SELECT doPID FROM doRegistry \"",
"+",
"whereClause",
";",
"s",
"=",
"conn",
".",
"prepareStatement",
"(",
"query",
")",
";",
"logger",
".",
"debug",
"(",
"\"Executing db query: {}\"",
",",
"query",
")",
";",
"results",
"=",
"s",
".",
"executeQuery",
"(",
")",
";",
"if",
"(",
"results",
".",
"next",
"(",
")",
")",
"{",
"ArrayList",
"<",
"String",
">",
"pidList",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"do",
"{",
"pidList",
".",
"add",
"(",
"results",
".",
"getString",
"(",
"\"doPID\"",
")",
")",
";",
"}",
"while",
"(",
"results",
".",
"next",
"(",
")",
")",
";",
"return",
"pidList",
".",
"toArray",
"(",
"EMPTY_STRING_ARRAY",
")",
";",
"}",
"else",
"{",
"return",
"EMPTY_STRING_ARRAY",
";",
"}",
"}",
"catch",
"(",
"SQLException",
"sqle",
")",
"{",
"throw",
"new",
"StorageDeviceException",
"(",
"\"Unexpected error from SQL database: \"",
"+",
"sqle",
".",
"getMessage",
"(",
")",
",",
"sqle",
")",
";",
"}",
"finally",
"{",
"try",
"{",
"if",
"(",
"results",
"!=",
"null",
")",
"{",
"results",
".",
"close",
"(",
")",
";",
"}",
"if",
"(",
"s",
"!=",
"null",
")",
"{",
"s",
".",
"close",
"(",
")",
";",
"}",
"if",
"(",
"conn",
"!=",
"null",
")",
"{",
"m_connectionPool",
".",
"free",
"(",
"conn",
")",
";",
"}",
"}",
"catch",
"(",
"SQLException",
"sqle",
")",
"{",
"throw",
"new",
"StorageDeviceException",
"(",
"\"Unexpected error from SQL database: \"",
"+",
"sqle",
".",
"getMessage",
"(",
")",
",",
"sqle",
")",
";",
"}",
"finally",
"{",
"results",
"=",
"null",
";",
"s",
"=",
"null",
";",
"}",
"}",
"}"
] |
whereClause is a WHERE clause, starting with "where"
|
[
"whereClause",
"is",
"a",
"WHERE",
"clause",
"starting",
"with",
"where"
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/storage/DefaultDOManager.java#L1957-L2001
|
8,839 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/storage/DefaultDOManager.java
|
DefaultDOManager.getNumObjectsWithVersion
|
private int getNumObjectsWithVersion(Connection conn, int n)
throws SQLException {
PreparedStatement st = null;
try {
String query;
// Because we are dealing with only two Strings, one of which is fixed,
// take advantage of String.concat
if (n > 0) {
query = "SELECT COUNT(*) FROM doRegistry WHERE systemVersion = ".concat(Integer.toString(n));
} else {
query = "SELECT COUNT(*) FROM doRegistry";
}
st = conn.prepareStatement(query);
ResultSet results = st.executeQuery();
results.next();
return results.getInt(1);
} finally {
if (st != null) {
st.close();
}
}
}
|
java
|
private int getNumObjectsWithVersion(Connection conn, int n)
throws SQLException {
PreparedStatement st = null;
try {
String query;
// Because we are dealing with only two Strings, one of which is fixed,
// take advantage of String.concat
if (n > 0) {
query = "SELECT COUNT(*) FROM doRegistry WHERE systemVersion = ".concat(Integer.toString(n));
} else {
query = "SELECT COUNT(*) FROM doRegistry";
}
st = conn.prepareStatement(query);
ResultSet results = st.executeQuery();
results.next();
return results.getInt(1);
} finally {
if (st != null) {
st.close();
}
}
}
|
[
"private",
"int",
"getNumObjectsWithVersion",
"(",
"Connection",
"conn",
",",
"int",
"n",
")",
"throws",
"SQLException",
"{",
"PreparedStatement",
"st",
"=",
"null",
";",
"try",
"{",
"String",
"query",
";",
"// Because we are dealing with only two Strings, one of which is fixed,",
"// take advantage of String.concat",
"if",
"(",
"n",
">",
"0",
")",
"{",
"query",
"=",
"\"SELECT COUNT(*) FROM doRegistry WHERE systemVersion = \"",
".",
"concat",
"(",
"Integer",
".",
"toString",
"(",
"n",
")",
")",
";",
"}",
"else",
"{",
"query",
"=",
"\"SELECT COUNT(*) FROM doRegistry\"",
";",
"}",
"st",
"=",
"conn",
".",
"prepareStatement",
"(",
"query",
")",
";",
"ResultSet",
"results",
"=",
"st",
".",
"executeQuery",
"(",
")",
";",
"results",
".",
"next",
"(",
")",
";",
"return",
"results",
".",
"getInt",
"(",
"1",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"st",
"!=",
"null",
")",
"{",
"st",
".",
"close",
"(",
")",
";",
"}",
"}",
"}"
] |
Get the number of objects in the registry whose system version is equal
to the given value. If n is less than one, return the total number of
objects in the registry.
|
[
"Get",
"the",
"number",
"of",
"objects",
"in",
"the",
"registry",
"whose",
"system",
"version",
"is",
"equal",
"to",
"the",
"given",
"value",
".",
"If",
"n",
"is",
"less",
"than",
"one",
"return",
"the",
"total",
"number",
"of",
"objects",
"in",
"the",
"registry",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/storage/DefaultDOManager.java#L2104-L2126
|
8,840 |
fcrepo3/fcrepo
|
fcrepo-common/src/main/java/org/fcrepo/utilities/XmlTransformUtility.java
|
XmlTransformUtility.getTemplates
|
public static Templates getTemplates(File src) throws TransformerException {
String key = src.getAbsolutePath();
TimestampedCacheEntry<Templates> entry = TEMPLATES_CACHE.get(key);
// check to see if it is null or has changed
if (entry == null || entry.timestamp() < src.lastModified()) {
TransformerFactory factory = null;
try {
factory = borrowTransformerFactory();
Templates template = factory.newTemplates(new StreamSource(src));
entry = new TimestampedCacheEntry<Templates>(src.lastModified(), template);
} catch (Exception e) {
throw new TransformerException(e.getMessage(), e);
} finally {
if (factory != null) returnTransformerFactory(factory);
}
TEMPLATES_CACHE.put(key, entry);
}
return entry.value();
}
|
java
|
public static Templates getTemplates(File src) throws TransformerException {
String key = src.getAbsolutePath();
TimestampedCacheEntry<Templates> entry = TEMPLATES_CACHE.get(key);
// check to see if it is null or has changed
if (entry == null || entry.timestamp() < src.lastModified()) {
TransformerFactory factory = null;
try {
factory = borrowTransformerFactory();
Templates template = factory.newTemplates(new StreamSource(src));
entry = new TimestampedCacheEntry<Templates>(src.lastModified(), template);
} catch (Exception e) {
throw new TransformerException(e.getMessage(), e);
} finally {
if (factory != null) returnTransformerFactory(factory);
}
TEMPLATES_CACHE.put(key, entry);
}
return entry.value();
}
|
[
"public",
"static",
"Templates",
"getTemplates",
"(",
"File",
"src",
")",
"throws",
"TransformerException",
"{",
"String",
"key",
"=",
"src",
".",
"getAbsolutePath",
"(",
")",
";",
"TimestampedCacheEntry",
"<",
"Templates",
">",
"entry",
"=",
"TEMPLATES_CACHE",
".",
"get",
"(",
"key",
")",
";",
"// check to see if it is null or has changed",
"if",
"(",
"entry",
"==",
"null",
"||",
"entry",
".",
"timestamp",
"(",
")",
"<",
"src",
".",
"lastModified",
"(",
")",
")",
"{",
"TransformerFactory",
"factory",
"=",
"null",
";",
"try",
"{",
"factory",
"=",
"borrowTransformerFactory",
"(",
")",
";",
"Templates",
"template",
"=",
"factory",
".",
"newTemplates",
"(",
"new",
"StreamSource",
"(",
"src",
")",
")",
";",
"entry",
"=",
"new",
"TimestampedCacheEntry",
"<",
"Templates",
">",
"(",
"src",
".",
"lastModified",
"(",
")",
",",
"template",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"TransformerException",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"factory",
"!=",
"null",
")",
"returnTransformerFactory",
"(",
"factory",
")",
";",
"}",
"TEMPLATES_CACHE",
".",
"put",
"(",
"key",
",",
"entry",
")",
";",
"}",
"return",
"entry",
".",
"value",
"(",
")",
";",
"}"
] |
Try to cache parsed Templates, but check for changes on disk
@param src
@return Templates
|
[
"Try",
"to",
"cache",
"parsed",
"Templates",
"but",
"check",
"for",
"changes",
"on",
"disk"
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-common/src/main/java/org/fcrepo/utilities/XmlTransformUtility.java#L110-L128
|
8,841 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/storage/translation/AtomDOSerializer.java
|
AtomDOSerializer.addAuditDatastream
|
private void addAuditDatastream(Feed feed, DigitalObject obj, ZipOutputStream zout, String encoding) throws ObjectIntegrityException, StreamIOException {
if (obj.getAuditRecords().size() == 0) {
return;
}
String dsId = PID.toURI(obj.getPid()) + "/AUDIT";
String dsvId =
dsId
+ "/"
+ DateUtility
.convertDateToString(obj.getCreateDate());
Entry dsEntry = feed.addEntry();
dsEntry.setId(dsId);
dsEntry.setTitle("AUDIT");
dsEntry.setUpdated(obj.getCreateDate()); // create date?
dsEntry.addCategory(MODEL.STATE.uri, "A", null);
dsEntry.addCategory(MODEL.CONTROL_GROUP.uri, "X", null);
dsEntry.addCategory(MODEL.VERSIONABLE.uri, "false", null);
dsEntry.addLink(dsvId, Link.REL_ALTERNATE);
Entry dsvEntry = feed.addEntry();
dsvEntry.setId(dsvId);
dsvEntry.setTitle("AUDIT.0");
dsvEntry.setUpdated(obj.getCreateDate());
ThreadHelper.addInReplyTo(dsvEntry, PID.toURI(obj.getPid()) + "/AUDIT");
dsvEntry.addCategory(MODEL.FORMAT_URI.uri, AUDIT1_0.uri, null);
dsvEntry
.addCategory(MODEL.LABEL.uri, "Audit Trail for this object", null);
if (m_format.equals(ATOM_ZIP1_1)) {
String name = "AUDIT.0.xml";
try {
zout.putNextEntry(new ZipEntry(name));
ReadableCharArrayWriter buf =
new ReadableCharArrayWriter(512);
PrintWriter pw = new PrintWriter(buf);
DOTranslationUtility.appendAuditTrail(obj, pw);
pw.close();
IOUtils.copy(buf.toReader(), zout, encoding);
zout.closeEntry();
} catch(IOException e) {
throw new StreamIOException(e.getMessage(), e);
}
IRI iri = new IRI(name);
dsvEntry.setSummary("AUDIT.0");
dsvEntry.setContent(iri, "text/xml");
} else {
dsvEntry.setContent(DOTranslationUtility.getAuditTrail(obj),
"text/xml");
}
}
|
java
|
private void addAuditDatastream(Feed feed, DigitalObject obj, ZipOutputStream zout, String encoding) throws ObjectIntegrityException, StreamIOException {
if (obj.getAuditRecords().size() == 0) {
return;
}
String dsId = PID.toURI(obj.getPid()) + "/AUDIT";
String dsvId =
dsId
+ "/"
+ DateUtility
.convertDateToString(obj.getCreateDate());
Entry dsEntry = feed.addEntry();
dsEntry.setId(dsId);
dsEntry.setTitle("AUDIT");
dsEntry.setUpdated(obj.getCreateDate()); // create date?
dsEntry.addCategory(MODEL.STATE.uri, "A", null);
dsEntry.addCategory(MODEL.CONTROL_GROUP.uri, "X", null);
dsEntry.addCategory(MODEL.VERSIONABLE.uri, "false", null);
dsEntry.addLink(dsvId, Link.REL_ALTERNATE);
Entry dsvEntry = feed.addEntry();
dsvEntry.setId(dsvId);
dsvEntry.setTitle("AUDIT.0");
dsvEntry.setUpdated(obj.getCreateDate());
ThreadHelper.addInReplyTo(dsvEntry, PID.toURI(obj.getPid()) + "/AUDIT");
dsvEntry.addCategory(MODEL.FORMAT_URI.uri, AUDIT1_0.uri, null);
dsvEntry
.addCategory(MODEL.LABEL.uri, "Audit Trail for this object", null);
if (m_format.equals(ATOM_ZIP1_1)) {
String name = "AUDIT.0.xml";
try {
zout.putNextEntry(new ZipEntry(name));
ReadableCharArrayWriter buf =
new ReadableCharArrayWriter(512);
PrintWriter pw = new PrintWriter(buf);
DOTranslationUtility.appendAuditTrail(obj, pw);
pw.close();
IOUtils.copy(buf.toReader(), zout, encoding);
zout.closeEntry();
} catch(IOException e) {
throw new StreamIOException(e.getMessage(), e);
}
IRI iri = new IRI(name);
dsvEntry.setSummary("AUDIT.0");
dsvEntry.setContent(iri, "text/xml");
} else {
dsvEntry.setContent(DOTranslationUtility.getAuditTrail(obj),
"text/xml");
}
}
|
[
"private",
"void",
"addAuditDatastream",
"(",
"Feed",
"feed",
",",
"DigitalObject",
"obj",
",",
"ZipOutputStream",
"zout",
",",
"String",
"encoding",
")",
"throws",
"ObjectIntegrityException",
",",
"StreamIOException",
"{",
"if",
"(",
"obj",
".",
"getAuditRecords",
"(",
")",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"return",
";",
"}",
"String",
"dsId",
"=",
"PID",
".",
"toURI",
"(",
"obj",
".",
"getPid",
"(",
")",
")",
"+",
"\"/AUDIT\"",
";",
"String",
"dsvId",
"=",
"dsId",
"+",
"\"/\"",
"+",
"DateUtility",
".",
"convertDateToString",
"(",
"obj",
".",
"getCreateDate",
"(",
")",
")",
";",
"Entry",
"dsEntry",
"=",
"feed",
".",
"addEntry",
"(",
")",
";",
"dsEntry",
".",
"setId",
"(",
"dsId",
")",
";",
"dsEntry",
".",
"setTitle",
"(",
"\"AUDIT\"",
")",
";",
"dsEntry",
".",
"setUpdated",
"(",
"obj",
".",
"getCreateDate",
"(",
")",
")",
";",
"// create date?",
"dsEntry",
".",
"addCategory",
"(",
"MODEL",
".",
"STATE",
".",
"uri",
",",
"\"A\"",
",",
"null",
")",
";",
"dsEntry",
".",
"addCategory",
"(",
"MODEL",
".",
"CONTROL_GROUP",
".",
"uri",
",",
"\"X\"",
",",
"null",
")",
";",
"dsEntry",
".",
"addCategory",
"(",
"MODEL",
".",
"VERSIONABLE",
".",
"uri",
",",
"\"false\"",
",",
"null",
")",
";",
"dsEntry",
".",
"addLink",
"(",
"dsvId",
",",
"Link",
".",
"REL_ALTERNATE",
")",
";",
"Entry",
"dsvEntry",
"=",
"feed",
".",
"addEntry",
"(",
")",
";",
"dsvEntry",
".",
"setId",
"(",
"dsvId",
")",
";",
"dsvEntry",
".",
"setTitle",
"(",
"\"AUDIT.0\"",
")",
";",
"dsvEntry",
".",
"setUpdated",
"(",
"obj",
".",
"getCreateDate",
"(",
")",
")",
";",
"ThreadHelper",
".",
"addInReplyTo",
"(",
"dsvEntry",
",",
"PID",
".",
"toURI",
"(",
"obj",
".",
"getPid",
"(",
")",
")",
"+",
"\"/AUDIT\"",
")",
";",
"dsvEntry",
".",
"addCategory",
"(",
"MODEL",
".",
"FORMAT_URI",
".",
"uri",
",",
"AUDIT1_0",
".",
"uri",
",",
"null",
")",
";",
"dsvEntry",
".",
"addCategory",
"(",
"MODEL",
".",
"LABEL",
".",
"uri",
",",
"\"Audit Trail for this object\"",
",",
"null",
")",
";",
"if",
"(",
"m_format",
".",
"equals",
"(",
"ATOM_ZIP1_1",
")",
")",
"{",
"String",
"name",
"=",
"\"AUDIT.0.xml\"",
";",
"try",
"{",
"zout",
".",
"putNextEntry",
"(",
"new",
"ZipEntry",
"(",
"name",
")",
")",
";",
"ReadableCharArrayWriter",
"buf",
"=",
"new",
"ReadableCharArrayWriter",
"(",
"512",
")",
";",
"PrintWriter",
"pw",
"=",
"new",
"PrintWriter",
"(",
"buf",
")",
";",
"DOTranslationUtility",
".",
"appendAuditTrail",
"(",
"obj",
",",
"pw",
")",
";",
"pw",
".",
"close",
"(",
")",
";",
"IOUtils",
".",
"copy",
"(",
"buf",
".",
"toReader",
"(",
")",
",",
"zout",
",",
"encoding",
")",
";",
"zout",
".",
"closeEntry",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"StreamIOException",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"IRI",
"iri",
"=",
"new",
"IRI",
"(",
"name",
")",
";",
"dsvEntry",
".",
"setSummary",
"(",
"\"AUDIT.0\"",
")",
";",
"dsvEntry",
".",
"setContent",
"(",
"iri",
",",
"\"text/xml\"",
")",
";",
"}",
"else",
"{",
"dsvEntry",
".",
"setContent",
"(",
"DOTranslationUtility",
".",
"getAuditTrail",
"(",
"obj",
")",
",",
"\"text/xml\"",
")",
";",
"}",
"}"
] |
AUDIT datastream is rebuilt from the latest in-memory audit trail which
is a separate array list in the DigitalObject class. Audit trail
datastream re-created from audit records. There is only ONE version of
the audit trail datastream
@throws ObjectIntegrityException
@throws StreamIOException
|
[
"AUDIT",
"datastream",
"is",
"rebuilt",
"from",
"the",
"latest",
"in",
"-",
"memory",
"audit",
"trail",
"which",
"is",
"a",
"separate",
"array",
"list",
"in",
"the",
"DigitalObject",
"class",
".",
"Audit",
"trail",
"datastream",
"re",
"-",
"created",
"from",
"audit",
"records",
".",
"There",
"is",
"only",
"ONE",
"version",
"of",
"the",
"audit",
"trail",
"datastream"
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/storage/translation/AtomDOSerializer.java#L270-L321
|
8,842 |
fcrepo3/fcrepo
|
fcrepo-security/fcrepo-security-http/src/main/java/org/fcrepo/security/http/AuthZHttpRequestAttributesFilter.java
|
AuthZHttpRequestAttributesFilter.setNames
|
public void setNames(String names) {
this.names = new HashSet<String>(Arrays.asList(names.split(" ")));
}
|
java
|
public void setNames(String names) {
this.names = new HashSet<String>(Arrays.asList(names.split(" ")));
}
|
[
"public",
"void",
"setNames",
"(",
"String",
"names",
")",
"{",
"this",
".",
"names",
"=",
"new",
"HashSet",
"<",
"String",
">",
"(",
"Arrays",
".",
"asList",
"(",
"names",
".",
"split",
"(",
"\" \"",
")",
")",
")",
";",
"}"
] |
setNames set the list of attribute names to look for
@param names
contains space separated attribute names
|
[
"setNames",
"set",
"the",
"list",
"of",
"attribute",
"names",
"to",
"look",
"for"
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-security/fcrepo-security-http/src/main/java/org/fcrepo/security/http/AuthZHttpRequestAttributesFilter.java#L49-L51
|
8,843 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/storage/DefaultExternalContentManager.java
|
DefaultExternalContentManager.getFromWeb
|
private MIMETypedStream getFromWeb(ContentManagerParams params)
throws ModuleInitializationException, GeneralException, RangeNotSatisfiableException {
String username = params.getUsername();
String password = params.getPassword();
boolean backendSSL = false;
String url = params.getUrl();
// in case host is 'local.fedora.server', and has not been normalized (e.g. on validating datastream add)
url = params.getTranslator().makeAbsoluteURLs(url);
if (ServerUtility.isURLFedoraServer(url) && !params.isBypassBackend()) {
BackendSecuritySpec m_beSS;
BackendSecurity m_beSecurity =
(BackendSecurity) getServer()
.getModule("org.fcrepo.server.security.BackendSecurity");
try {
m_beSS = m_beSecurity.getBackendSecuritySpec();
} catch (Exception e) {
throw new ModuleInitializationException(
"Can't intitialize BackendSecurity module (in default access) from Server.getModule",
getRole());
}
Hashtable<String, String> beHash =
m_beSS.getSecuritySpec(BackendPolicies.FEDORA_INTERNAL_CALL);
username = beHash.get("callUsername");
password = beHash.get("callPassword");
backendSSL =
Boolean.parseBoolean(beHash.get("callSSL"));
if (backendSSL) {
if (params.getProtocol().equals("http")) {
url = url.replaceFirst("http:", "https:");
}
url =
url.replaceFirst(":" + fedoraServerPort + "/",
":" + fedoraServerRedirectPort
+ "/");
}
if (logger.isDebugEnabled()) {
logger.debug("************************* backendUsername: "
+ username + " backendPassword: "
+ password + " backendSSL: " + backendSSL);
logger.debug("************************* doAuthnGetURL: " + url);
}
}
return getFromWeb(url, username, password, params.getMimeType(),
isHEADRequest(params), params.getContext());
}
|
java
|
private MIMETypedStream getFromWeb(ContentManagerParams params)
throws ModuleInitializationException, GeneralException, RangeNotSatisfiableException {
String username = params.getUsername();
String password = params.getPassword();
boolean backendSSL = false;
String url = params.getUrl();
// in case host is 'local.fedora.server', and has not been normalized (e.g. on validating datastream add)
url = params.getTranslator().makeAbsoluteURLs(url);
if (ServerUtility.isURLFedoraServer(url) && !params.isBypassBackend()) {
BackendSecuritySpec m_beSS;
BackendSecurity m_beSecurity =
(BackendSecurity) getServer()
.getModule("org.fcrepo.server.security.BackendSecurity");
try {
m_beSS = m_beSecurity.getBackendSecuritySpec();
} catch (Exception e) {
throw new ModuleInitializationException(
"Can't intitialize BackendSecurity module (in default access) from Server.getModule",
getRole());
}
Hashtable<String, String> beHash =
m_beSS.getSecuritySpec(BackendPolicies.FEDORA_INTERNAL_CALL);
username = beHash.get("callUsername");
password = beHash.get("callPassword");
backendSSL =
Boolean.parseBoolean(beHash.get("callSSL"));
if (backendSSL) {
if (params.getProtocol().equals("http")) {
url = url.replaceFirst("http:", "https:");
}
url =
url.replaceFirst(":" + fedoraServerPort + "/",
":" + fedoraServerRedirectPort
+ "/");
}
if (logger.isDebugEnabled()) {
logger.debug("************************* backendUsername: "
+ username + " backendPassword: "
+ password + " backendSSL: " + backendSSL);
logger.debug("************************* doAuthnGetURL: " + url);
}
}
return getFromWeb(url, username, password, params.getMimeType(),
isHEADRequest(params), params.getContext());
}
|
[
"private",
"MIMETypedStream",
"getFromWeb",
"(",
"ContentManagerParams",
"params",
")",
"throws",
"ModuleInitializationException",
",",
"GeneralException",
",",
"RangeNotSatisfiableException",
"{",
"String",
"username",
"=",
"params",
".",
"getUsername",
"(",
")",
";",
"String",
"password",
"=",
"params",
".",
"getPassword",
"(",
")",
";",
"boolean",
"backendSSL",
"=",
"false",
";",
"String",
"url",
"=",
"params",
".",
"getUrl",
"(",
")",
";",
"// in case host is 'local.fedora.server', and has not been normalized (e.g. on validating datastream add)",
"url",
"=",
"params",
".",
"getTranslator",
"(",
")",
".",
"makeAbsoluteURLs",
"(",
"url",
")",
";",
"if",
"(",
"ServerUtility",
".",
"isURLFedoraServer",
"(",
"url",
")",
"&&",
"!",
"params",
".",
"isBypassBackend",
"(",
")",
")",
"{",
"BackendSecuritySpec",
"m_beSS",
";",
"BackendSecurity",
"m_beSecurity",
"=",
"(",
"BackendSecurity",
")",
"getServer",
"(",
")",
".",
"getModule",
"(",
"\"org.fcrepo.server.security.BackendSecurity\"",
")",
";",
"try",
"{",
"m_beSS",
"=",
"m_beSecurity",
".",
"getBackendSecuritySpec",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"ModuleInitializationException",
"(",
"\"Can't intitialize BackendSecurity module (in default access) from Server.getModule\"",
",",
"getRole",
"(",
")",
")",
";",
"}",
"Hashtable",
"<",
"String",
",",
"String",
">",
"beHash",
"=",
"m_beSS",
".",
"getSecuritySpec",
"(",
"BackendPolicies",
".",
"FEDORA_INTERNAL_CALL",
")",
";",
"username",
"=",
"beHash",
".",
"get",
"(",
"\"callUsername\"",
")",
";",
"password",
"=",
"beHash",
".",
"get",
"(",
"\"callPassword\"",
")",
";",
"backendSSL",
"=",
"Boolean",
".",
"parseBoolean",
"(",
"beHash",
".",
"get",
"(",
"\"callSSL\"",
")",
")",
";",
"if",
"(",
"backendSSL",
")",
"{",
"if",
"(",
"params",
".",
"getProtocol",
"(",
")",
".",
"equals",
"(",
"\"http\"",
")",
")",
"{",
"url",
"=",
"url",
".",
"replaceFirst",
"(",
"\"http:\"",
",",
"\"https:\"",
")",
";",
"}",
"url",
"=",
"url",
".",
"replaceFirst",
"(",
"\":\"",
"+",
"fedoraServerPort",
"+",
"\"/\"",
",",
"\":\"",
"+",
"fedoraServerRedirectPort",
"+",
"\"/\"",
")",
";",
"}",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"logger",
".",
"debug",
"(",
"\"************************* backendUsername: \"",
"+",
"username",
"+",
"\" backendPassword: \"",
"+",
"password",
"+",
"\" backendSSL: \"",
"+",
"backendSSL",
")",
";",
"logger",
".",
"debug",
"(",
"\"************************* doAuthnGetURL: \"",
"+",
"url",
")",
";",
"}",
"}",
"return",
"getFromWeb",
"(",
"url",
",",
"username",
",",
"password",
",",
"params",
".",
"getMimeType",
"(",
")",
",",
"isHEADRequest",
"(",
"params",
")",
",",
"params",
".",
"getContext",
"(",
")",
")",
";",
"}"
] |
Retrieves external content via http or https.
@return A MIMETypedStream
@throws ModuleInitializationException
@throws GeneralException
@throws RangeNotSatisfiableException
|
[
"Retrieves",
"external",
"content",
"via",
"http",
"or",
"https",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/storage/DefaultExternalContentManager.java#L352-L397
|
8,844 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/storage/DefaultExternalContentManager.java
|
DefaultExternalContentManager.determineMimeType
|
private String determineMimeType(File file){
String mimeType = MIME_MAP.getContentType(file);
// if mimeType detection failed, fall back to the default
if (mimeType == null || mimeType.equalsIgnoreCase("")){
mimeType = DEFAULT_MIMETYPE;
}
return mimeType;
}
|
java
|
private String determineMimeType(File file){
String mimeType = MIME_MAP.getContentType(file);
// if mimeType detection failed, fall back to the default
if (mimeType == null || mimeType.equalsIgnoreCase("")){
mimeType = DEFAULT_MIMETYPE;
}
return mimeType;
}
|
[
"private",
"String",
"determineMimeType",
"(",
"File",
"file",
")",
"{",
"String",
"mimeType",
"=",
"MIME_MAP",
".",
"getContentType",
"(",
"file",
")",
";",
"// if mimeType detection failed, fall back to the default",
"if",
"(",
"mimeType",
"==",
"null",
"||",
"mimeType",
".",
"equalsIgnoreCase",
"(",
"\"\"",
")",
")",
"{",
"mimeType",
"=",
"DEFAULT_MIMETYPE",
";",
"}",
"return",
"mimeType",
";",
"}"
] |
Determines the mime type of a given file
@param file for which the mime type needs to be detected
@return the detected mime type
|
[
"Determines",
"the",
"mime",
"type",
"of",
"a",
"given",
"file"
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/storage/DefaultExternalContentManager.java#L405-L412
|
8,845 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/storage/DefaultExternalContentManager.java
|
DefaultExternalContentManager.isHEADRequest
|
private static boolean isHEADRequest(ContentManagerParams params) {
Context context = params.getContext();
if (context != null) {
String method =
context.getEnvironmentValue(
Constants.HTTP_REQUEST.METHOD.attributeId);
return "HEAD".equalsIgnoreCase(method);
}
return false;
}
|
java
|
private static boolean isHEADRequest(ContentManagerParams params) {
Context context = params.getContext();
if (context != null) {
String method =
context.getEnvironmentValue(
Constants.HTTP_REQUEST.METHOD.attributeId);
return "HEAD".equalsIgnoreCase(method);
}
return false;
}
|
[
"private",
"static",
"boolean",
"isHEADRequest",
"(",
"ContentManagerParams",
"params",
")",
"{",
"Context",
"context",
"=",
"params",
".",
"getContext",
"(",
")",
";",
"if",
"(",
"context",
"!=",
"null",
")",
"{",
"String",
"method",
"=",
"context",
".",
"getEnvironmentValue",
"(",
"Constants",
".",
"HTTP_REQUEST",
".",
"METHOD",
".",
"attributeId",
")",
";",
"return",
"\"HEAD\"",
".",
"equalsIgnoreCase",
"(",
"method",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
determine whether the context is a HEAD http request
|
[
"determine",
"whether",
"the",
"context",
"is",
"a",
"HEAD",
"http",
"request"
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/storage/DefaultExternalContentManager.java#L417-L426
|
8,846 |
fcrepo3/fcrepo
|
fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/utility/validate/process/ValidatorProcess.java
|
ValidatorProcess.openObjectSource
|
private static RemoteObjectSource openObjectSource(ServiceInfo serviceInfo) {
try {
return new RemoteObjectSource(serviceInfo);
} catch (ServiceException e) {
throw new IllegalStateException("Failed to initialize "
+ "the ValidatorProcess: ", e);
} catch (IOException e) {
throw new IllegalStateException("Failed to initialize "
+ "the ValidatorProcess: ", e);
}
}
|
java
|
private static RemoteObjectSource openObjectSource(ServiceInfo serviceInfo) {
try {
return new RemoteObjectSource(serviceInfo);
} catch (ServiceException e) {
throw new IllegalStateException("Failed to initialize "
+ "the ValidatorProcess: ", e);
} catch (IOException e) {
throw new IllegalStateException("Failed to initialize "
+ "the ValidatorProcess: ", e);
}
}
|
[
"private",
"static",
"RemoteObjectSource",
"openObjectSource",
"(",
"ServiceInfo",
"serviceInfo",
")",
"{",
"try",
"{",
"return",
"new",
"RemoteObjectSource",
"(",
"serviceInfo",
")",
";",
"}",
"catch",
"(",
"ServiceException",
"e",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Failed to initialize \"",
"+",
"\"the ValidatorProcess: \"",
",",
"e",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Failed to initialize \"",
"+",
"\"the ValidatorProcess: \"",
",",
"e",
")",
";",
"}",
"}"
] |
Open the connection to the Fedora server.
|
[
"Open",
"the",
"connection",
"to",
"the",
"Fedora",
"server",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/utility/validate/process/ValidatorProcess.java#L34-L44
|
8,847 |
fcrepo3/fcrepo
|
fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/utility/validate/process/ValidatorProcess.java
|
ValidatorProcess.getPidIterator
|
private static Iterator<String> getPidIterator(ValidatorProcessParameters parms,
RemoteObjectSource objectSource)
throws ObjectSourceException {
if (parms.getIteratorType() == IteratorType.FS_QUERY) {
return objectSource.findObjectPids(parms.getQuery());
} else {
return new PidfileIterator(parms.getPidfile());
}
}
|
java
|
private static Iterator<String> getPidIterator(ValidatorProcessParameters parms,
RemoteObjectSource objectSource)
throws ObjectSourceException {
if (parms.getIteratorType() == IteratorType.FS_QUERY) {
return objectSource.findObjectPids(parms.getQuery());
} else {
return new PidfileIterator(parms.getPidfile());
}
}
|
[
"private",
"static",
"Iterator",
"<",
"String",
">",
"getPidIterator",
"(",
"ValidatorProcessParameters",
"parms",
",",
"RemoteObjectSource",
"objectSource",
")",
"throws",
"ObjectSourceException",
"{",
"if",
"(",
"parms",
".",
"getIteratorType",
"(",
")",
"==",
"IteratorType",
".",
"FS_QUERY",
")",
"{",
"return",
"objectSource",
".",
"findObjectPids",
"(",
"parms",
".",
"getQuery",
"(",
")",
")",
";",
"}",
"else",
"{",
"return",
"new",
"PidfileIterator",
"(",
"parms",
".",
"getPidfile",
"(",
")",
")",
";",
"}",
"}"
] |
The list of PIDs may come from a file, or from a query against the object
source.
|
[
"The",
"list",
"of",
"PIDs",
"may",
"come",
"from",
"a",
"file",
"or",
"from",
"a",
"query",
"against",
"the",
"object",
"source",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/utility/validate/process/ValidatorProcess.java#L50-L58
|
8,848 |
fcrepo3/fcrepo
|
fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/objecteditor/ServiceDescriptionPanel.java
|
ServiceDescriptionPanel.makePanel
|
private JPanel makePanel(String sDefPID) throws IOException {
JTextArea supportsMethodsTextArea = new JTextArea(" defines method");
supportsMethodsTextArea.setLineWrap(false);
supportsMethodsTextArea.setEditable(false);
supportsMethodsTextArea.setBackground(Administrator.BACKGROUND_COLOR);
JTextArea methodParametersTextArea = new JTextArea(" with parm(s)");
methodParametersTextArea.setLineWrap(false);
methodParametersTextArea.setEditable(false);
methodParametersTextArea.setBackground(Administrator.BACKGROUND_COLOR);
JComponent[] left =
new JComponent[] {supportsMethodsTextArea,
methodParametersTextArea};
//
// Methods
//
List<MethodDefinition> methodDefs = Util.getMethodDefinitions(sDefPID);
String[] methodSelections = new String[methodDefs.size()];
for (int i = 0; i < methodDefs.size(); i++) {
MethodDefinition def = (MethodDefinition) methodDefs.get(i);
StringBuffer buf = new StringBuffer();
buf.append(def.getName());
if (def.getLabel() != null) {
buf.append(" - ");
buf.append(def.getLabel());
}
methodSelections[i] = buf.toString();
}
final JComboBox<String> methodComboBox =
new JComboBox<String>(methodSelections);
Administrator.constrainHeight(methodComboBox);
//
// Parameters... ParameterPanel handles the switching and displaying
//
final ParameterPanel parameterPanel = new ParameterPanel(methodDefs);
methodComboBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
String[] parts =
((String) methodComboBox.getSelectedItem())
.split(" - ");
parameterPanel.show(parts[0]);
parameterPanel.revalidate();
}
});
JComponent[] right = new JComponent[] {methodComboBox, parameterPanel};
GridBagLayout gb = new GridBagLayout();
JPanel panel = new JPanel(gb);
panel.setBorder(BorderFactory.createEmptyBorder(4, 0, 0, 0));
Util.addRows(left, right, gb, panel, true, false);
return panel;
}
|
java
|
private JPanel makePanel(String sDefPID) throws IOException {
JTextArea supportsMethodsTextArea = new JTextArea(" defines method");
supportsMethodsTextArea.setLineWrap(false);
supportsMethodsTextArea.setEditable(false);
supportsMethodsTextArea.setBackground(Administrator.BACKGROUND_COLOR);
JTextArea methodParametersTextArea = new JTextArea(" with parm(s)");
methodParametersTextArea.setLineWrap(false);
methodParametersTextArea.setEditable(false);
methodParametersTextArea.setBackground(Administrator.BACKGROUND_COLOR);
JComponent[] left =
new JComponent[] {supportsMethodsTextArea,
methodParametersTextArea};
//
// Methods
//
List<MethodDefinition> methodDefs = Util.getMethodDefinitions(sDefPID);
String[] methodSelections = new String[methodDefs.size()];
for (int i = 0; i < methodDefs.size(); i++) {
MethodDefinition def = (MethodDefinition) methodDefs.get(i);
StringBuffer buf = new StringBuffer();
buf.append(def.getName());
if (def.getLabel() != null) {
buf.append(" - ");
buf.append(def.getLabel());
}
methodSelections[i] = buf.toString();
}
final JComboBox<String> methodComboBox =
new JComboBox<String>(methodSelections);
Administrator.constrainHeight(methodComboBox);
//
// Parameters... ParameterPanel handles the switching and displaying
//
final ParameterPanel parameterPanel = new ParameterPanel(methodDefs);
methodComboBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
String[] parts =
((String) methodComboBox.getSelectedItem())
.split(" - ");
parameterPanel.show(parts[0]);
parameterPanel.revalidate();
}
});
JComponent[] right = new JComponent[] {methodComboBox, parameterPanel};
GridBagLayout gb = new GridBagLayout();
JPanel panel = new JPanel(gb);
panel.setBorder(BorderFactory.createEmptyBorder(4, 0, 0, 0));
Util.addRows(left, right, gb, panel, true, false);
return panel;
}
|
[
"private",
"JPanel",
"makePanel",
"(",
"String",
"sDefPID",
")",
"throws",
"IOException",
"{",
"JTextArea",
"supportsMethodsTextArea",
"=",
"new",
"JTextArea",
"(",
"\" defines method\"",
")",
";",
"supportsMethodsTextArea",
".",
"setLineWrap",
"(",
"false",
")",
";",
"supportsMethodsTextArea",
".",
"setEditable",
"(",
"false",
")",
";",
"supportsMethodsTextArea",
".",
"setBackground",
"(",
"Administrator",
".",
"BACKGROUND_COLOR",
")",
";",
"JTextArea",
"methodParametersTextArea",
"=",
"new",
"JTextArea",
"(",
"\" with parm(s)\"",
")",
";",
"methodParametersTextArea",
".",
"setLineWrap",
"(",
"false",
")",
";",
"methodParametersTextArea",
".",
"setEditable",
"(",
"false",
")",
";",
"methodParametersTextArea",
".",
"setBackground",
"(",
"Administrator",
".",
"BACKGROUND_COLOR",
")",
";",
"JComponent",
"[",
"]",
"left",
"=",
"new",
"JComponent",
"[",
"]",
"{",
"supportsMethodsTextArea",
",",
"methodParametersTextArea",
"}",
";",
"//",
"// Methods",
"//",
"List",
"<",
"MethodDefinition",
">",
"methodDefs",
"=",
"Util",
".",
"getMethodDefinitions",
"(",
"sDefPID",
")",
";",
"String",
"[",
"]",
"methodSelections",
"=",
"new",
"String",
"[",
"methodDefs",
".",
"size",
"(",
")",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"methodDefs",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"MethodDefinition",
"def",
"=",
"(",
"MethodDefinition",
")",
"methodDefs",
".",
"get",
"(",
"i",
")",
";",
"StringBuffer",
"buf",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"buf",
".",
"append",
"(",
"def",
".",
"getName",
"(",
")",
")",
";",
"if",
"(",
"def",
".",
"getLabel",
"(",
")",
"!=",
"null",
")",
"{",
"buf",
".",
"append",
"(",
"\" - \"",
")",
";",
"buf",
".",
"append",
"(",
"def",
".",
"getLabel",
"(",
")",
")",
";",
"}",
"methodSelections",
"[",
"i",
"]",
"=",
"buf",
".",
"toString",
"(",
")",
";",
"}",
"final",
"JComboBox",
"<",
"String",
">",
"methodComboBox",
"=",
"new",
"JComboBox",
"<",
"String",
">",
"(",
"methodSelections",
")",
";",
"Administrator",
".",
"constrainHeight",
"(",
"methodComboBox",
")",
";",
"//",
"// Parameters... ParameterPanel handles the switching and displaying",
"//",
"final",
"ParameterPanel",
"parameterPanel",
"=",
"new",
"ParameterPanel",
"(",
"methodDefs",
")",
";",
"methodComboBox",
".",
"addActionListener",
"(",
"new",
"ActionListener",
"(",
")",
"{",
"public",
"void",
"actionPerformed",
"(",
"ActionEvent",
"evt",
")",
"{",
"String",
"[",
"]",
"parts",
"=",
"(",
"(",
"String",
")",
"methodComboBox",
".",
"getSelectedItem",
"(",
")",
")",
".",
"split",
"(",
"\" - \"",
")",
";",
"parameterPanel",
".",
"show",
"(",
"parts",
"[",
"0",
"]",
")",
";",
"parameterPanel",
".",
"revalidate",
"(",
")",
";",
"}",
"}",
")",
";",
"JComponent",
"[",
"]",
"right",
"=",
"new",
"JComponent",
"[",
"]",
"{",
"methodComboBox",
",",
"parameterPanel",
"}",
";",
"GridBagLayout",
"gb",
"=",
"new",
"GridBagLayout",
"(",
")",
";",
"JPanel",
"panel",
"=",
"new",
"JPanel",
"(",
"gb",
")",
";",
"panel",
".",
"setBorder",
"(",
"BorderFactory",
".",
"createEmptyBorder",
"(",
"4",
",",
"0",
",",
"0",
",",
"0",
")",
")",
";",
"Util",
".",
"addRows",
"(",
"left",
",",
"right",
",",
"gb",
",",
"panel",
",",
"true",
",",
"false",
")",
";",
"return",
"panel",
";",
"}"
] |
Create and return a new panel describing the service definition. Methods
dropdown "methodName - descriptionIfExists" Parameters "None." |
tabbedPane
|
[
"Create",
"and",
"return",
"a",
"new",
"panel",
"describing",
"the",
"service",
"definition",
".",
"Methods",
"dropdown",
"methodName",
"-",
"descriptionIfExists",
"Parameters",
"None",
".",
"|",
"tabbedPane"
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/objecteditor/ServiceDescriptionPanel.java#L87-L145
|
8,849 |
fcrepo3/fcrepo
|
fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/utility/validate/types/DsCompositeModelDoc.java
|
DsCompositeModelDoc.parseBytesToDocument
|
private Document parseBytesToDocument(String pid, byte[] bytes)
throws InvalidContentModelException {
try {
DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
return builder.parse(new ByteArrayInputStream(bytes));
} catch (ParserConfigurationException e) {
throw new InvalidContentModelException(pid, "Failed to parse "
+ DS_COMPOSITE_MODEL, e);
} catch (SAXException e) {
throw new InvalidContentModelException(pid, "Failed to parse "
+ DS_COMPOSITE_MODEL, e);
} catch (IOException e) {
throw new InvalidContentModelException(pid, "Failed to parse "
+ DS_COMPOSITE_MODEL, e);
}
}
|
java
|
private Document parseBytesToDocument(String pid, byte[] bytes)
throws InvalidContentModelException {
try {
DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
return builder.parse(new ByteArrayInputStream(bytes));
} catch (ParserConfigurationException e) {
throw new InvalidContentModelException(pid, "Failed to parse "
+ DS_COMPOSITE_MODEL, e);
} catch (SAXException e) {
throw new InvalidContentModelException(pid, "Failed to parse "
+ DS_COMPOSITE_MODEL, e);
} catch (IOException e) {
throw new InvalidContentModelException(pid, "Failed to parse "
+ DS_COMPOSITE_MODEL, e);
}
}
|
[
"private",
"Document",
"parseBytesToDocument",
"(",
"String",
"pid",
",",
"byte",
"[",
"]",
"bytes",
")",
"throws",
"InvalidContentModelException",
"{",
"try",
"{",
"DocumentBuilderFactory",
"factory",
"=",
"DocumentBuilderFactory",
".",
"newInstance",
"(",
")",
";",
"factory",
".",
"setNamespaceAware",
"(",
"true",
")",
";",
"DocumentBuilder",
"builder",
"=",
"factory",
".",
"newDocumentBuilder",
"(",
")",
";",
"return",
"builder",
".",
"parse",
"(",
"new",
"ByteArrayInputStream",
"(",
"bytes",
")",
")",
";",
"}",
"catch",
"(",
"ParserConfigurationException",
"e",
")",
"{",
"throw",
"new",
"InvalidContentModelException",
"(",
"pid",
",",
"\"Failed to parse \"",
"+",
"DS_COMPOSITE_MODEL",
",",
"e",
")",
";",
"}",
"catch",
"(",
"SAXException",
"e",
")",
"{",
"throw",
"new",
"InvalidContentModelException",
"(",
"pid",
",",
"\"Failed to parse \"",
"+",
"DS_COMPOSITE_MODEL",
",",
"e",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"InvalidContentModelException",
"(",
"pid",
",",
"\"Failed to parse \"",
"+",
"DS_COMPOSITE_MODEL",
",",
"e",
")",
";",
"}",
"}"
] |
Create a DOM document from the original XML.
|
[
"Create",
"a",
"DOM",
"document",
"from",
"the",
"original",
"XML",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/utility/validate/types/DsCompositeModelDoc.java#L76-L94
|
8,850 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/storage/types/DatastreamManagedContent.java
|
DatastreamManagedContent.putContentStream
|
public void putContentStream(MIMETypedStream stream) throws StreamIOException {
// TODO: refactor to use proper temp file management - FCREPO-718
// for now, write to new temp file, clean up existing location
String oldDSLocation = DSLocation;
try {
// note: don't use temp upload dir, use (container's) temp dir (upload dir is for uploads)
File tempFile = File.createTempFile("managedcontentupdate", null);
OutputStream os = new FileOutputStream(tempFile);
StreamUtility.pipeStream(stream.getStream(), os, 32768);
DSLocation = TEMP_SCHEME + tempFile.getAbsolutePath();
} catch (Exception e) {
throw new StreamIOException("Error creating new temp file for updated managed content (existing content is:" + oldDSLocation + ")", e);
}
// if old location was a temp location, clean it up
// (if old location was uploaded, DefaultManagement should do this, but refactor up as part of FCREPO-718)
if (oldDSLocation != null && oldDSLocation.startsWith(TEMP_SCHEME)) {
File oldFile;
try {
oldFile = new File(oldDSLocation.substring(TEMP_SCHEME.length()));
} catch (Exception e) {
throw new StreamIOException("Error removing old temp file while updating managed content (location: " + oldDSLocation + ")", e);
}
if (oldFile.exists()) {
if (!oldFile.delete()) {
logger.warn("Failed to delete temp file, marked for deletion when VM closes " + oldFile.getAbsolutePath());
oldFile.deleteOnExit();
}
} else
logger.warn("Cannot delete temp file as it no longer exists " + oldFile.getAbsolutePath());
}
}
|
java
|
public void putContentStream(MIMETypedStream stream) throws StreamIOException {
// TODO: refactor to use proper temp file management - FCREPO-718
// for now, write to new temp file, clean up existing location
String oldDSLocation = DSLocation;
try {
// note: don't use temp upload dir, use (container's) temp dir (upload dir is for uploads)
File tempFile = File.createTempFile("managedcontentupdate", null);
OutputStream os = new FileOutputStream(tempFile);
StreamUtility.pipeStream(stream.getStream(), os, 32768);
DSLocation = TEMP_SCHEME + tempFile.getAbsolutePath();
} catch (Exception e) {
throw new StreamIOException("Error creating new temp file for updated managed content (existing content is:" + oldDSLocation + ")", e);
}
// if old location was a temp location, clean it up
// (if old location was uploaded, DefaultManagement should do this, but refactor up as part of FCREPO-718)
if (oldDSLocation != null && oldDSLocation.startsWith(TEMP_SCHEME)) {
File oldFile;
try {
oldFile = new File(oldDSLocation.substring(TEMP_SCHEME.length()));
} catch (Exception e) {
throw new StreamIOException("Error removing old temp file while updating managed content (location: " + oldDSLocation + ")", e);
}
if (oldFile.exists()) {
if (!oldFile.delete()) {
logger.warn("Failed to delete temp file, marked for deletion when VM closes " + oldFile.getAbsolutePath());
oldFile.deleteOnExit();
}
} else
logger.warn("Cannot delete temp file as it no longer exists " + oldFile.getAbsolutePath());
}
}
|
[
"public",
"void",
"putContentStream",
"(",
"MIMETypedStream",
"stream",
")",
"throws",
"StreamIOException",
"{",
"// TODO: refactor to use proper temp file management - FCREPO-718",
"// for now, write to new temp file, clean up existing location",
"String",
"oldDSLocation",
"=",
"DSLocation",
";",
"try",
"{",
"// note: don't use temp upload dir, use (container's) temp dir (upload dir is for uploads)",
"File",
"tempFile",
"=",
"File",
".",
"createTempFile",
"(",
"\"managedcontentupdate\"",
",",
"null",
")",
";",
"OutputStream",
"os",
"=",
"new",
"FileOutputStream",
"(",
"tempFile",
")",
";",
"StreamUtility",
".",
"pipeStream",
"(",
"stream",
".",
"getStream",
"(",
")",
",",
"os",
",",
"32768",
")",
";",
"DSLocation",
"=",
"TEMP_SCHEME",
"+",
"tempFile",
".",
"getAbsolutePath",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"StreamIOException",
"(",
"\"Error creating new temp file for updated managed content (existing content is:\"",
"+",
"oldDSLocation",
"+",
"\")\"",
",",
"e",
")",
";",
"}",
"// if old location was a temp location, clean it up",
"// (if old location was uploaded, DefaultManagement should do this, but refactor up as part of FCREPO-718)",
"if",
"(",
"oldDSLocation",
"!=",
"null",
"&&",
"oldDSLocation",
".",
"startsWith",
"(",
"TEMP_SCHEME",
")",
")",
"{",
"File",
"oldFile",
";",
"try",
"{",
"oldFile",
"=",
"new",
"File",
"(",
"oldDSLocation",
".",
"substring",
"(",
"TEMP_SCHEME",
".",
"length",
"(",
")",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"StreamIOException",
"(",
"\"Error removing old temp file while updating managed content (location: \"",
"+",
"oldDSLocation",
"+",
"\")\"",
",",
"e",
")",
";",
"}",
"if",
"(",
"oldFile",
".",
"exists",
"(",
")",
")",
"{",
"if",
"(",
"!",
"oldFile",
".",
"delete",
"(",
")",
")",
"{",
"logger",
".",
"warn",
"(",
"\"Failed to delete temp file, marked for deletion when VM closes \"",
"+",
"oldFile",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"oldFile",
".",
"deleteOnExit",
"(",
")",
";",
"}",
"}",
"else",
"logger",
".",
"warn",
"(",
"\"Cannot delete temp file as it no longer exists \"",
"+",
"oldFile",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"}",
"}"
] |
Set the contents of this managed datastream by storing as a temp file. If the previous content
was stored in a temp file, clean up this file.
@param stream - the data to store in this datastream
@throws StreamIOException
|
[
"Set",
"the",
"contents",
"of",
"this",
"managed",
"datastream",
"by",
"storing",
"as",
"a",
"temp",
"file",
".",
"If",
"the",
"previous",
"content",
"was",
"stored",
"in",
"a",
"temp",
"file",
"clean",
"up",
"this",
"file",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/storage/types/DatastreamManagedContent.java#L271-L303
|
8,851 |
fcrepo3/fcrepo
|
fcrepo-installer/src/main/java/org/fcrepo/utilities/install/Database.java
|
Database.usesDOTable
|
protected boolean usesDOTable() throws Exception {
Connection conn = getConnection();
DatabaseMetaData dmd = conn.getMetaData();
// check if we need to update old table
ResultSet rs = dmd.getTables(null, null, "do%", null);
while (rs.next()) {
if (rs.getString("TABLE_NAME").equals("do")) {
rs.close();
return true;
}
}
rs.close();
return false;
}
|
java
|
protected boolean usesDOTable() throws Exception {
Connection conn = getConnection();
DatabaseMetaData dmd = conn.getMetaData();
// check if we need to update old table
ResultSet rs = dmd.getTables(null, null, "do%", null);
while (rs.next()) {
if (rs.getString("TABLE_NAME").equals("do")) {
rs.close();
return true;
}
}
rs.close();
return false;
}
|
[
"protected",
"boolean",
"usesDOTable",
"(",
")",
"throws",
"Exception",
"{",
"Connection",
"conn",
"=",
"getConnection",
"(",
")",
";",
"DatabaseMetaData",
"dmd",
"=",
"conn",
".",
"getMetaData",
"(",
")",
";",
"// check if we need to update old table",
"ResultSet",
"rs",
"=",
"dmd",
".",
"getTables",
"(",
"null",
",",
"null",
",",
"\"do%\"",
",",
"null",
")",
";",
"while",
"(",
"rs",
".",
"next",
"(",
")",
")",
"{",
"if",
"(",
"rs",
".",
"getString",
"(",
"\"TABLE_NAME\"",
")",
".",
"equals",
"(",
"\"do\"",
")",
")",
"{",
"rs",
".",
"close",
"(",
")",
";",
"return",
"true",
";",
"}",
"}",
"rs",
".",
"close",
"(",
")",
";",
"return",
"false",
";",
"}"
] |
Determines whether or not the database has a table named "do".
@return true if the database contains a table with the name "do".
@throws Exception
|
[
"Determines",
"whether",
"or",
"not",
"the",
"database",
"has",
"a",
"table",
"named",
"do",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-installer/src/main/java/org/fcrepo/utilities/install/Database.java#L139-L153
|
8,852 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/journal/xmlhelpers/AbstractXmlReader.java
|
AbstractXmlReader.readStartTag
|
protected XMLEvent readStartTag(XMLEventReader reader, QName tagName)
throws XMLStreamException, JournalException {
XMLEvent event = reader.nextTag();
if (!isStartTagEvent(event, tagName)) {
throw getNotStartTagException(tagName, event);
}
return event;
}
|
java
|
protected XMLEvent readStartTag(XMLEventReader reader, QName tagName)
throws XMLStreamException, JournalException {
XMLEvent event = reader.nextTag();
if (!isStartTagEvent(event, tagName)) {
throw getNotStartTagException(tagName, event);
}
return event;
}
|
[
"protected",
"XMLEvent",
"readStartTag",
"(",
"XMLEventReader",
"reader",
",",
"QName",
"tagName",
")",
"throws",
"XMLStreamException",
",",
"JournalException",
"{",
"XMLEvent",
"event",
"=",
"reader",
".",
"nextTag",
"(",
")",
";",
"if",
"(",
"!",
"isStartTagEvent",
"(",
"event",
",",
"tagName",
")",
")",
"{",
"throw",
"getNotStartTagException",
"(",
"tagName",
",",
"event",
")",
";",
"}",
"return",
"event",
";",
"}"
] |
Read the next event and complain if it is not the Start Tag that we
expected.
|
[
"Read",
"the",
"next",
"event",
"and",
"complain",
"if",
"it",
"is",
"not",
"the",
"Start",
"Tag",
"that",
"we",
"expected",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/xmlhelpers/AbstractXmlReader.java#L44-L51
|
8,853 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/journal/xmlhelpers/AbstractXmlReader.java
|
AbstractXmlReader.isStartTagEvent
|
protected boolean isStartTagEvent(XMLEvent event, QName tagName) {
return event.isStartElement()
&& event.asStartElement().getName().equals(tagName);
}
|
java
|
protected boolean isStartTagEvent(XMLEvent event, QName tagName) {
return event.isStartElement()
&& event.asStartElement().getName().equals(tagName);
}
|
[
"protected",
"boolean",
"isStartTagEvent",
"(",
"XMLEvent",
"event",
",",
"QName",
"tagName",
")",
"{",
"return",
"event",
".",
"isStartElement",
"(",
")",
"&&",
"event",
".",
"asStartElement",
"(",
")",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"tagName",
")",
";",
"}"
] |
Test an event to see whether it is an start tag with the expected name.
|
[
"Test",
"an",
"event",
"to",
"see",
"whether",
"it",
"is",
"an",
"start",
"tag",
"with",
"the",
"expected",
"name",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/xmlhelpers/AbstractXmlReader.java#L56-L59
|
8,854 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/journal/xmlhelpers/AbstractXmlReader.java
|
AbstractXmlReader.isEndTagEvent
|
protected boolean isEndTagEvent(XMLEvent event, QName tagName) {
return event.isEndElement()
&& event.asEndElement().getName().equals(tagName);
}
|
java
|
protected boolean isEndTagEvent(XMLEvent event, QName tagName) {
return event.isEndElement()
&& event.asEndElement().getName().equals(tagName);
}
|
[
"protected",
"boolean",
"isEndTagEvent",
"(",
"XMLEvent",
"event",
",",
"QName",
"tagName",
")",
"{",
"return",
"event",
".",
"isEndElement",
"(",
")",
"&&",
"event",
".",
"asEndElement",
"(",
")",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"tagName",
")",
";",
"}"
] |
Test an event to see whether it is an end tag with the expected name.
|
[
"Test",
"an",
"event",
"to",
"see",
"whether",
"it",
"is",
"an",
"end",
"tag",
"with",
"the",
"expected",
"name",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/xmlhelpers/AbstractXmlReader.java#L64-L67
|
8,855 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/journal/xmlhelpers/AbstractXmlReader.java
|
AbstractXmlReader.getRequiredAttributeValue
|
protected String getRequiredAttributeValue(StartElement start,
QName attributeName)
throws JournalException {
Attribute mapNameAttribute = start.getAttributeByName(attributeName);
if (mapNameAttribute == null) {
throw new JournalException("Start tag '" + start
+ "' must contain a '" + attributeName + "' attribute.");
}
return mapNameAttribute.getValue();
}
|
java
|
protected String getRequiredAttributeValue(StartElement start,
QName attributeName)
throws JournalException {
Attribute mapNameAttribute = start.getAttributeByName(attributeName);
if (mapNameAttribute == null) {
throw new JournalException("Start tag '" + start
+ "' must contain a '" + attributeName + "' attribute.");
}
return mapNameAttribute.getValue();
}
|
[
"protected",
"String",
"getRequiredAttributeValue",
"(",
"StartElement",
"start",
",",
"QName",
"attributeName",
")",
"throws",
"JournalException",
"{",
"Attribute",
"mapNameAttribute",
"=",
"start",
".",
"getAttributeByName",
"(",
"attributeName",
")",
";",
"if",
"(",
"mapNameAttribute",
"==",
"null",
")",
"{",
"throw",
"new",
"JournalException",
"(",
"\"Start tag '\"",
"+",
"start",
"+",
"\"' must contain a '\"",
"+",
"attributeName",
"+",
"\"' attribute.\"",
")",
";",
"}",
"return",
"mapNameAttribute",
".",
"getValue",
"(",
")",
";",
"}"
] |
Get the value of a given attribute from this start tag, or complain if
it's not there.
|
[
"Get",
"the",
"value",
"of",
"a",
"given",
"attribute",
"from",
"this",
"start",
"tag",
"or",
"complain",
"if",
"it",
"s",
"not",
"there",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/xmlhelpers/AbstractXmlReader.java#L73-L82
|
8,856 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/journal/xmlhelpers/AbstractXmlReader.java
|
AbstractXmlReader.getOptionalAttributeValue
|
protected String getOptionalAttributeValue(StartElement start,
QName attributeName) {
Attribute mapNameAttribute = start.getAttributeByName(attributeName);
if (mapNameAttribute == null) {
return null;
} else {
return mapNameAttribute.getValue();
}
}
|
java
|
protected String getOptionalAttributeValue(StartElement start,
QName attributeName) {
Attribute mapNameAttribute = start.getAttributeByName(attributeName);
if (mapNameAttribute == null) {
return null;
} else {
return mapNameAttribute.getValue();
}
}
|
[
"protected",
"String",
"getOptionalAttributeValue",
"(",
"StartElement",
"start",
",",
"QName",
"attributeName",
")",
"{",
"Attribute",
"mapNameAttribute",
"=",
"start",
".",
"getAttributeByName",
"(",
"attributeName",
")",
";",
"if",
"(",
"mapNameAttribute",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"else",
"{",
"return",
"mapNameAttribute",
".",
"getValue",
"(",
")",
";",
"}",
"}"
] |
Get the value of a given attribute from this start tag, or null if the
attribute is not there.
|
[
"Get",
"the",
"value",
"of",
"a",
"given",
"attribute",
"from",
"this",
"start",
"tag",
"or",
"null",
"if",
"the",
"attribute",
"is",
"not",
"there",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/xmlhelpers/AbstractXmlReader.java#L88-L96
|
8,857 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/journal/xmlhelpers/AbstractXmlReader.java
|
AbstractXmlReader.getNotNextMemberOrEndOfGroupException
|
protected JournalException getNotNextMemberOrEndOfGroupException(QName groupTagName,
QName memberTagName,
XMLEvent event) {
return new JournalException("Expecting either '" + memberTagName
+ "' start tag, or '" + groupTagName
+ "' end tag, but event was '" + event + "'");
}
|
java
|
protected JournalException getNotNextMemberOrEndOfGroupException(QName groupTagName,
QName memberTagName,
XMLEvent event) {
return new JournalException("Expecting either '" + memberTagName
+ "' start tag, or '" + groupTagName
+ "' end tag, but event was '" + event + "'");
}
|
[
"protected",
"JournalException",
"getNotNextMemberOrEndOfGroupException",
"(",
"QName",
"groupTagName",
",",
"QName",
"memberTagName",
",",
"XMLEvent",
"event",
")",
"{",
"return",
"new",
"JournalException",
"(",
"\"Expecting either '\"",
"+",
"memberTagName",
"+",
"\"' start tag, or '\"",
"+",
"groupTagName",
"+",
"\"' end tag, but event was '\"",
"+",
"event",
"+",
"\"'\"",
")",
";",
"}"
] |
While traversing a group of member tags, we expected either the start of
another member tag, or the end of the group.
|
[
"While",
"traversing",
"a",
"group",
"of",
"member",
"tags",
"we",
"expected",
"either",
"the",
"start",
"of",
"another",
"member",
"tag",
"or",
"the",
"end",
"of",
"the",
"group",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/xmlhelpers/AbstractXmlReader.java#L154-L160
|
8,858 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/access/defaultdisseminator/ServiceMethodDispatcher.java
|
ServiceMethodDispatcher.invokeMethod
|
public Object invokeMethod(Object service_object,
String methodName,
Property[] userParms) throws ServerException {
Method method = null;
if (userParms == null) {
userParms = new Property[0];
}
Object[] parmValues = new Object[userParms.length];
Class<?>[] parmClassTypes = new Class[userParms.length];
for (int i = 0; i < userParms.length; i++) {
// Get parm value. Always treat the parm value as a string.
parmValues[i] = userParms[i].value == null ? "" : userParms[i].value;
parmClassTypes[i] = parmValues[i].getClass();
}
// Invoke method: using Java Reflection
try {
method =
service_object.getClass().getMethod(methodName,
parmClassTypes);
return method.invoke(service_object, parmValues);
} catch (Exception e) {
throw new MethodNotFoundException("Error executing method: "
+ methodName, e);
}
}
|
java
|
public Object invokeMethod(Object service_object,
String methodName,
Property[] userParms) throws ServerException {
Method method = null;
if (userParms == null) {
userParms = new Property[0];
}
Object[] parmValues = new Object[userParms.length];
Class<?>[] parmClassTypes = new Class[userParms.length];
for (int i = 0; i < userParms.length; i++) {
// Get parm value. Always treat the parm value as a string.
parmValues[i] = userParms[i].value == null ? "" : userParms[i].value;
parmClassTypes[i] = parmValues[i].getClass();
}
// Invoke method: using Java Reflection
try {
method =
service_object.getClass().getMethod(methodName,
parmClassTypes);
return method.invoke(service_object, parmValues);
} catch (Exception e) {
throw new MethodNotFoundException("Error executing method: "
+ methodName, e);
}
}
|
[
"public",
"Object",
"invokeMethod",
"(",
"Object",
"service_object",
",",
"String",
"methodName",
",",
"Property",
"[",
"]",
"userParms",
")",
"throws",
"ServerException",
"{",
"Method",
"method",
"=",
"null",
";",
"if",
"(",
"userParms",
"==",
"null",
")",
"{",
"userParms",
"=",
"new",
"Property",
"[",
"0",
"]",
";",
"}",
"Object",
"[",
"]",
"parmValues",
"=",
"new",
"Object",
"[",
"userParms",
".",
"length",
"]",
";",
"Class",
"<",
"?",
">",
"[",
"]",
"parmClassTypes",
"=",
"new",
"Class",
"[",
"userParms",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"userParms",
".",
"length",
";",
"i",
"++",
")",
"{",
"// Get parm value. Always treat the parm value as a string.",
"parmValues",
"[",
"i",
"]",
"=",
"userParms",
"[",
"i",
"]",
".",
"value",
"==",
"null",
"?",
"\"\"",
":",
"userParms",
"[",
"i",
"]",
".",
"value",
";",
"parmClassTypes",
"[",
"i",
"]",
"=",
"parmValues",
"[",
"i",
"]",
".",
"getClass",
"(",
")",
";",
"}",
"// Invoke method: using Java Reflection",
"try",
"{",
"method",
"=",
"service_object",
".",
"getClass",
"(",
")",
".",
"getMethod",
"(",
"methodName",
",",
"parmClassTypes",
")",
";",
"return",
"method",
".",
"invoke",
"(",
"service_object",
",",
"parmValues",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"MethodNotFoundException",
"(",
"\"Error executing method: \"",
"+",
"methodName",
",",
"e",
")",
";",
"}",
"}"
] |
Invoke a method on an internal service. This is done using Java
reflection where the service is the target object of a dynamic method
request.
@param service_object
the target object of the service request
@param methodName
the method to invoke on the target object
@param userParms
parameters to the method to invoke on target object
@return Object product of the method
@throws ServerException
|
[
"Invoke",
"a",
"method",
"on",
"an",
"internal",
"service",
".",
"This",
"is",
"done",
"using",
"Java",
"reflection",
"where",
"the",
"service",
"is",
"the",
"target",
"object",
"of",
"a",
"dynamic",
"method",
"request",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/access/defaultdisseminator/ServiceMethodDispatcher.java#L38-L62
|
8,859 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/management/ManagementModule.java
|
ManagementModule.getProxyChain
|
private Management getProxyChain(Management m)
throws ModuleInitializationException {
try {
invocationHandlers = getInvocationHandlers();
return (Management) ProxyFactory.getProxy(m, invocationHandlers);
} catch (Exception e) {
throw new ModuleInitializationException(e.getMessage(), getRole());
}
}
|
java
|
private Management getProxyChain(Management m)
throws ModuleInitializationException {
try {
invocationHandlers = getInvocationHandlers();
return (Management) ProxyFactory.getProxy(m, invocationHandlers);
} catch (Exception e) {
throw new ModuleInitializationException(e.getMessage(), getRole());
}
}
|
[
"private",
"Management",
"getProxyChain",
"(",
"Management",
"m",
")",
"throws",
"ModuleInitializationException",
"{",
"try",
"{",
"invocationHandlers",
"=",
"getInvocationHandlers",
"(",
")",
";",
"return",
"(",
"Management",
")",
"ProxyFactory",
".",
"getProxy",
"(",
"m",
",",
"invocationHandlers",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"ModuleInitializationException",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"getRole",
"(",
")",
")",
";",
"}",
"}"
] |
Build a proxy chain as configured by the module parameters.
@param m The concrete Management implementation to wrap.
@return A proxy chain for Management
@throws ModuleInitializationException
|
[
"Build",
"a",
"proxy",
"chain",
"as",
"configured",
"by",
"the",
"module",
"parameters",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/management/ManagementModule.java#L575-L583
|
8,860 |
fcrepo3/fcrepo
|
fcrepo-security/fcrepo-security-pdp/src/main/java/org/fcrepo/server/security/xacml/util/Attribute.java
|
Attribute.put
|
public String put(String optionName, String optionValue) {
options.put(optionName, optionValue);
return optionValue;
}
|
java
|
public String put(String optionName, String optionValue) {
options.put(optionName, optionValue);
return optionValue;
}
|
[
"public",
"String",
"put",
"(",
"String",
"optionName",
",",
"String",
"optionValue",
")",
"{",
"options",
".",
"put",
"(",
"optionName",
",",
"optionValue",
")",
";",
"return",
"optionValue",
";",
"}"
] |
Add or update a config item for this attribute
@param optionName
@param optionValue
@return String option value
|
[
"Add",
"or",
"update",
"a",
"config",
"item",
"for",
"this",
"attribute"
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-security/fcrepo-security-pdp/src/main/java/org/fcrepo/server/security/xacml/util/Attribute.java#L37-L40
|
8,861 |
fcrepo3/fcrepo
|
fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/utility/validate/remote/RemotePidIterator.java
|
RemotePidIterator.refreshStash
|
private void refreshStash() throws ObjectSourceException {
if (!stash.isEmpty()) {
return;
}
try {
if (SEARCH_NOT_STARTED.equals(token)) {
beginSearch();
} else if (token != null) {
resumeSearch();
}
} catch (RemoteException e) {
throw new ObjectSourceException(e);
}
}
|
java
|
private void refreshStash() throws ObjectSourceException {
if (!stash.isEmpty()) {
return;
}
try {
if (SEARCH_NOT_STARTED.equals(token)) {
beginSearch();
} else if (token != null) {
resumeSearch();
}
} catch (RemoteException e) {
throw new ObjectSourceException(e);
}
}
|
[
"private",
"void",
"refreshStash",
"(",
")",
"throws",
"ObjectSourceException",
"{",
"if",
"(",
"!",
"stash",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
";",
"}",
"try",
"{",
"if",
"(",
"SEARCH_NOT_STARTED",
".",
"equals",
"(",
"token",
")",
")",
"{",
"beginSearch",
"(",
")",
";",
"}",
"else",
"if",
"(",
"token",
"!=",
"null",
")",
"{",
"resumeSearch",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"RemoteException",
"e",
")",
"{",
"throw",
"new",
"ObjectSourceException",
"(",
"e",
")",
";",
"}",
"}"
] |
Does the stash have anything in it? If it's empty, try to fill it.
|
[
"Does",
"the",
"stash",
"have",
"anything",
"in",
"it?",
"If",
"it",
"s",
"empty",
"try",
"to",
"fill",
"it",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/utility/validate/remote/RemotePidIterator.java#L110-L123
|
8,862 |
fcrepo3/fcrepo
|
fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/utility/validate/remote/RemotePidIterator.java
|
RemotePidIterator.beginSearch
|
private void beginSearch() throws RemoteException {
org.fcrepo.server.types.gen.FieldSearchQuery genFieldSearchQuery =
TypeUtility.convertFieldSearchQueryToGenFieldSearchQuery(query);
org.fcrepo.server.types.gen.FieldSearchResult searchResult =
apia.findObjects(org.fcrepo.server.utilities.TypeUtility.convertStringtoAOS(OBJECT_RESULT_FIELDS),
MAX_FIND_RESULTS,
genFieldSearchQuery);
FieldSearchResult fsr =
TypeUtility
.convertGenFieldSearchResultToFieldSearchResult(searchResult);
for (ObjectFields fields : fsr.objectFieldsList()) {
stash.add(fields.getPid());
}
token = fsr.getToken();
}
|
java
|
private void beginSearch() throws RemoteException {
org.fcrepo.server.types.gen.FieldSearchQuery genFieldSearchQuery =
TypeUtility.convertFieldSearchQueryToGenFieldSearchQuery(query);
org.fcrepo.server.types.gen.FieldSearchResult searchResult =
apia.findObjects(org.fcrepo.server.utilities.TypeUtility.convertStringtoAOS(OBJECT_RESULT_FIELDS),
MAX_FIND_RESULTS,
genFieldSearchQuery);
FieldSearchResult fsr =
TypeUtility
.convertGenFieldSearchResultToFieldSearchResult(searchResult);
for (ObjectFields fields : fsr.objectFieldsList()) {
stash.add(fields.getPid());
}
token = fsr.getToken();
}
|
[
"private",
"void",
"beginSearch",
"(",
")",
"throws",
"RemoteException",
"{",
"org",
".",
"fcrepo",
".",
"server",
".",
"types",
".",
"gen",
".",
"FieldSearchQuery",
"genFieldSearchQuery",
"=",
"TypeUtility",
".",
"convertFieldSearchQueryToGenFieldSearchQuery",
"(",
"query",
")",
";",
"org",
".",
"fcrepo",
".",
"server",
".",
"types",
".",
"gen",
".",
"FieldSearchResult",
"searchResult",
"=",
"apia",
".",
"findObjects",
"(",
"org",
".",
"fcrepo",
".",
"server",
".",
"utilities",
".",
"TypeUtility",
".",
"convertStringtoAOS",
"(",
"OBJECT_RESULT_FIELDS",
")",
",",
"MAX_FIND_RESULTS",
",",
"genFieldSearchQuery",
")",
";",
"FieldSearchResult",
"fsr",
"=",
"TypeUtility",
".",
"convertGenFieldSearchResultToFieldSearchResult",
"(",
"searchResult",
")",
";",
"for",
"(",
"ObjectFields",
"fields",
":",
"fsr",
".",
"objectFieldsList",
"(",
")",
")",
"{",
"stash",
".",
"add",
"(",
"fields",
".",
"getPid",
"(",
")",
")",
";",
"}",
"token",
"=",
"fsr",
".",
"getToken",
"(",
")",
";",
"}"
] |
We haven't tried searching yet. Do so, and set the stash and token from
the results.
|
[
"We",
"haven",
"t",
"tried",
"searching",
"yet",
".",
"Do",
"so",
"and",
"set",
"the",
"stash",
"and",
"token",
"from",
"the",
"results",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/utility/validate/remote/RemotePidIterator.java#L129-L143
|
8,863 |
fcrepo3/fcrepo
|
fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/utility/validate/remote/RemotePidIterator.java
|
RemotePidIterator.resumeSearch
|
private void resumeSearch() throws RemoteException {
org.fcrepo.server.types.gen.FieldSearchResult searchResult =
apia.resumeFindObjects(token);
FieldSearchResult fsr =
TypeUtility
.convertGenFieldSearchResultToFieldSearchResult(searchResult);
for (ObjectFields fields : fsr.objectFieldsList()) {
stash.add(fields.getPid());
}
token = fsr.getToken();
}
|
java
|
private void resumeSearch() throws RemoteException {
org.fcrepo.server.types.gen.FieldSearchResult searchResult =
apia.resumeFindObjects(token);
FieldSearchResult fsr =
TypeUtility
.convertGenFieldSearchResultToFieldSearchResult(searchResult);
for (ObjectFields fields : fsr.objectFieldsList()) {
stash.add(fields.getPid());
}
token = fsr.getToken();
}
|
[
"private",
"void",
"resumeSearch",
"(",
")",
"throws",
"RemoteException",
"{",
"org",
".",
"fcrepo",
".",
"server",
".",
"types",
".",
"gen",
".",
"FieldSearchResult",
"searchResult",
"=",
"apia",
".",
"resumeFindObjects",
"(",
"token",
")",
";",
"FieldSearchResult",
"fsr",
"=",
"TypeUtility",
".",
"convertGenFieldSearchResultToFieldSearchResult",
"(",
"searchResult",
")",
";",
"for",
"(",
"ObjectFields",
"fields",
":",
"fsr",
".",
"objectFieldsList",
"(",
")",
")",
"{",
"stash",
".",
"add",
"(",
"fields",
".",
"getPid",
"(",
")",
")",
";",
"}",
"token",
"=",
"fsr",
".",
"getToken",
"(",
")",
";",
"}"
] |
We are already searching. Use the stored token to continue the search,
and set the stash and token from the results.
|
[
"We",
"are",
"already",
"searching",
".",
"Use",
"the",
"stored",
"token",
"to",
"continue",
"the",
"search",
"and",
"set",
"the",
"stash",
"and",
"token",
"from",
"the",
"results",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/utility/validate/remote/RemotePidIterator.java#L149-L159
|
8,864 |
fcrepo3/fcrepo
|
fcrepo-common/src/main/java/org/fcrepo/utilities/xml/XercesXmlSerializers.java
|
XercesXmlSerializers.writeXmlNoSpace
|
public static void writeXmlNoSpace(Document doc, String encoding, Writer out)
throws IOException {
XMLSerializer ser = new XMLSerializer(out, getXmlNoSpace(encoding));
ser.serialize(doc);
out.close();
}
|
java
|
public static void writeXmlNoSpace(Document doc, String encoding, Writer out)
throws IOException {
XMLSerializer ser = new XMLSerializer(out, getXmlNoSpace(encoding));
ser.serialize(doc);
out.close();
}
|
[
"public",
"static",
"void",
"writeXmlNoSpace",
"(",
"Document",
"doc",
",",
"String",
"encoding",
",",
"Writer",
"out",
")",
"throws",
"IOException",
"{",
"XMLSerializer",
"ser",
"=",
"new",
"XMLSerializer",
"(",
"out",
",",
"getXmlNoSpace",
"(",
"encoding",
")",
")",
";",
"ser",
".",
"serialize",
"(",
"doc",
")",
";",
"out",
".",
"close",
"(",
")",
";",
"}"
] |
Serialize the dom Document with no preserved space between elements,
but without indenting, line wrapping, omission of XML declaration, or
omission of doctype
@param doc
@param encoding
@param out
@throws IOException
|
[
"Serialize",
"the",
"dom",
"Document",
"with",
"no",
"preserved",
"space",
"between",
"elements",
"but",
"without",
"indenting",
"line",
"wrapping",
"omission",
"of",
"XML",
"declaration",
"or",
"omission",
"of",
"doctype"
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-common/src/main/java/org/fcrepo/utilities/xml/XercesXmlSerializers.java#L31-L37
|
8,865 |
fcrepo3/fcrepo
|
fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/FedoraClient.java
|
FedoraClient.uploadFile
|
public String uploadFile(File file) throws IOException {
HttpPost post = null;
try {
// prepare the post method
post = new HttpPost(getUploadURL());
post.getParams().setParameter("Connection", "Keep-Alive");
// add the file part
MultipartEntity entity = new MultipartEntity();
entity.addPart("file", new FileBody(file));
post.setEntity(entity);
// execute and get the response
HttpResponse response = getHttpClient().execute(post);
int responseCode = response.getStatusLine().getStatusCode();
String body = null;
try {
if (response.getEntity() != null) {
body = EntityUtils.toString(response.getEntity());
}
} catch (Exception e) {
logger.warn("Error reading response body", e);
}
if (body == null) {
body = "[empty response body]";
}
body = body.trim();
if (responseCode != HttpStatus.SC_CREATED) {
throw new IOException("Upload failed: "
+ response.getStatusLine().getReasonPhrase()
+ ": " + replaceNewlines(body, " "));
} else {
return replaceNewlines(body, "");
}
} finally {
if (post != null) {
post.releaseConnection();
}
}
}
|
java
|
public String uploadFile(File file) throws IOException {
HttpPost post = null;
try {
// prepare the post method
post = new HttpPost(getUploadURL());
post.getParams().setParameter("Connection", "Keep-Alive");
// add the file part
MultipartEntity entity = new MultipartEntity();
entity.addPart("file", new FileBody(file));
post.setEntity(entity);
// execute and get the response
HttpResponse response = getHttpClient().execute(post);
int responseCode = response.getStatusLine().getStatusCode();
String body = null;
try {
if (response.getEntity() != null) {
body = EntityUtils.toString(response.getEntity());
}
} catch (Exception e) {
logger.warn("Error reading response body", e);
}
if (body == null) {
body = "[empty response body]";
}
body = body.trim();
if (responseCode != HttpStatus.SC_CREATED) {
throw new IOException("Upload failed: "
+ response.getStatusLine().getReasonPhrase()
+ ": " + replaceNewlines(body, " "));
} else {
return replaceNewlines(body, "");
}
} finally {
if (post != null) {
post.releaseConnection();
}
}
}
|
[
"public",
"String",
"uploadFile",
"(",
"File",
"file",
")",
"throws",
"IOException",
"{",
"HttpPost",
"post",
"=",
"null",
";",
"try",
"{",
"// prepare the post method",
"post",
"=",
"new",
"HttpPost",
"(",
"getUploadURL",
"(",
")",
")",
";",
"post",
".",
"getParams",
"(",
")",
".",
"setParameter",
"(",
"\"Connection\"",
",",
"\"Keep-Alive\"",
")",
";",
"// add the file part",
"MultipartEntity",
"entity",
"=",
"new",
"MultipartEntity",
"(",
")",
";",
"entity",
".",
"addPart",
"(",
"\"file\"",
",",
"new",
"FileBody",
"(",
"file",
")",
")",
";",
"post",
".",
"setEntity",
"(",
"entity",
")",
";",
"// execute and get the response",
"HttpResponse",
"response",
"=",
"getHttpClient",
"(",
")",
".",
"execute",
"(",
"post",
")",
";",
"int",
"responseCode",
"=",
"response",
".",
"getStatusLine",
"(",
")",
".",
"getStatusCode",
"(",
")",
";",
"String",
"body",
"=",
"null",
";",
"try",
"{",
"if",
"(",
"response",
".",
"getEntity",
"(",
")",
"!=",
"null",
")",
"{",
"body",
"=",
"EntityUtils",
".",
"toString",
"(",
"response",
".",
"getEntity",
"(",
")",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"warn",
"(",
"\"Error reading response body\"",
",",
"e",
")",
";",
"}",
"if",
"(",
"body",
"==",
"null",
")",
"{",
"body",
"=",
"\"[empty response body]\"",
";",
"}",
"body",
"=",
"body",
".",
"trim",
"(",
")",
";",
"if",
"(",
"responseCode",
"!=",
"HttpStatus",
".",
"SC_CREATED",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Upload failed: \"",
"+",
"response",
".",
"getStatusLine",
"(",
")",
".",
"getReasonPhrase",
"(",
")",
"+",
"\": \"",
"+",
"replaceNewlines",
"(",
"body",
",",
"\" \"",
")",
")",
";",
"}",
"else",
"{",
"return",
"replaceNewlines",
"(",
"body",
",",
"\"\"",
")",
";",
"}",
"}",
"finally",
"{",
"if",
"(",
"post",
"!=",
"null",
")",
"{",
"post",
".",
"releaseConnection",
"(",
")",
";",
"}",
"}",
"}"
] |
Upload the given file to Fedora's upload interface via HTTP POST.
@return the temporary id which can then be passed to API-M requests as a
URL. It will look like uploaded://123
|
[
"Upload",
"the",
"given",
"file",
"to",
"Fedora",
"s",
"upload",
"interface",
"via",
"HTTP",
"POST",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/FedoraClient.java#L232-L271
|
8,866 |
fcrepo3/fcrepo
|
fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/FedoraClient.java
|
FedoraClient.replaceNewlines
|
private static String replaceNewlines(String in, String replaceWith) {
return in.replaceAll("\r", replaceWith).replaceAll("\n", replaceWith);
}
|
java
|
private static String replaceNewlines(String in, String replaceWith) {
return in.replaceAll("\r", replaceWith).replaceAll("\n", replaceWith);
}
|
[
"private",
"static",
"String",
"replaceNewlines",
"(",
"String",
"in",
",",
"String",
"replaceWith",
")",
"{",
"return",
"in",
".",
"replaceAll",
"(",
"\"\\r\"",
",",
"replaceWith",
")",
".",
"replaceAll",
"(",
"\"\\n\"",
",",
"replaceWith",
")",
";",
"}"
] |
Replace newlines with the given string.
|
[
"Replace",
"newlines",
"with",
"the",
"given",
"string",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/FedoraClient.java#L276-L278
|
8,867 |
fcrepo3/fcrepo
|
fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/FedoraClient.java
|
FedoraClient.getUploadURL
|
public synchronized String getUploadURL() throws IOException {
if (m_uploadURL != null) {
return m_uploadURL;
} else {
m_uploadURL = m_baseURL + "management/upload";
if (m_uploadURL.startsWith("http:")) {
URL redirectURL = getRedirectURL(m_uploadURL);
if (redirectURL != null) {
m_uploadURL = redirectURL.toString();
}
}
return m_uploadURL;
}
}
|
java
|
public synchronized String getUploadURL() throws IOException {
if (m_uploadURL != null) {
return m_uploadURL;
} else {
m_uploadURL = m_baseURL + "management/upload";
if (m_uploadURL.startsWith("http:")) {
URL redirectURL = getRedirectURL(m_uploadURL);
if (redirectURL != null) {
m_uploadURL = redirectURL.toString();
}
}
return m_uploadURL;
}
}
|
[
"public",
"synchronized",
"String",
"getUploadURL",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"m_uploadURL",
"!=",
"null",
")",
"{",
"return",
"m_uploadURL",
";",
"}",
"else",
"{",
"m_uploadURL",
"=",
"m_baseURL",
"+",
"\"management/upload\"",
";",
"if",
"(",
"m_uploadURL",
".",
"startsWith",
"(",
"\"http:\"",
")",
")",
"{",
"URL",
"redirectURL",
"=",
"getRedirectURL",
"(",
"m_uploadURL",
")",
";",
"if",
"(",
"redirectURL",
"!=",
"null",
")",
"{",
"m_uploadURL",
"=",
"redirectURL",
".",
"toString",
"(",
")",
";",
"}",
"}",
"return",
"m_uploadURL",
";",
"}",
"}"
] |
Get the URL to which API-M upload requests will be sent.
|
[
"Get",
"the",
"URL",
"to",
"which",
"API",
"-",
"M",
"upload",
"requests",
"will",
"be",
"sent",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/FedoraClient.java#L283-L296
|
8,868 |
fcrepo3/fcrepo
|
fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/FedoraClient.java
|
FedoraClient.getServerVersion
|
public String getServerVersion() throws IOException {
// only do this once -- future invocations will use the known value
if (m_serverVersion == null) {
// Make the APIA call for describe repository
// and make sure that HTTP 302 status is handled.
String desc = getResponseAsString("/describe?xml=true", true, true);
logger.debug("describeRepository response:\n" + desc);
String[] parts = desc.split("<repositoryVersion>");
if (parts.length < 2) {
throw new IOException("Could not find repositoryVersion element in content of /describe?xml=true");
}
int i = parts[1].indexOf("<");
if (i == -1) {
throw new IOException("Could not find end of repositoryVersion element in content of /describe?xml=true");
}
m_serverVersion = parts[1].substring(0, i).trim();
logger.debug("Server version is " + m_serverVersion);
}
return m_serverVersion;
}
|
java
|
public String getServerVersion() throws IOException {
// only do this once -- future invocations will use the known value
if (m_serverVersion == null) {
// Make the APIA call for describe repository
// and make sure that HTTP 302 status is handled.
String desc = getResponseAsString("/describe?xml=true", true, true);
logger.debug("describeRepository response:\n" + desc);
String[] parts = desc.split("<repositoryVersion>");
if (parts.length < 2) {
throw new IOException("Could not find repositoryVersion element in content of /describe?xml=true");
}
int i = parts[1].indexOf("<");
if (i == -1) {
throw new IOException("Could not find end of repositoryVersion element in content of /describe?xml=true");
}
m_serverVersion = parts[1].substring(0, i).trim();
logger.debug("Server version is " + m_serverVersion);
}
return m_serverVersion;
}
|
[
"public",
"String",
"getServerVersion",
"(",
")",
"throws",
"IOException",
"{",
"// only do this once -- future invocations will use the known value",
"if",
"(",
"m_serverVersion",
"==",
"null",
")",
"{",
"// Make the APIA call for describe repository",
"// and make sure that HTTP 302 status is handled.",
"String",
"desc",
"=",
"getResponseAsString",
"(",
"\"/describe?xml=true\"",
",",
"true",
",",
"true",
")",
";",
"logger",
".",
"debug",
"(",
"\"describeRepository response:\\n\"",
"+",
"desc",
")",
";",
"String",
"[",
"]",
"parts",
"=",
"desc",
".",
"split",
"(",
"\"<repositoryVersion>\"",
")",
";",
"if",
"(",
"parts",
".",
"length",
"<",
"2",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Could not find repositoryVersion element in content of /describe?xml=true\"",
")",
";",
"}",
"int",
"i",
"=",
"parts",
"[",
"1",
"]",
".",
"indexOf",
"(",
"\"<\"",
")",
";",
"if",
"(",
"i",
"==",
"-",
"1",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Could not find end of repositoryVersion element in content of /describe?xml=true\"",
")",
";",
"}",
"m_serverVersion",
"=",
"parts",
"[",
"1",
"]",
".",
"substring",
"(",
"0",
",",
"i",
")",
".",
"trim",
"(",
")",
";",
"logger",
".",
"debug",
"(",
"\"Server version is \"",
"+",
"m_serverVersion",
")",
";",
"}",
"return",
"m_serverVersion",
";",
"}"
] |
Get the version reported by the remote Fedora server.
|
[
"Get",
"the",
"version",
"reported",
"by",
"the",
"remote",
"Fedora",
"server",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/FedoraClient.java#L673-L692
|
8,869 |
fcrepo3/fcrepo
|
fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/FedoraClient.java
|
FedoraClient.getServerDate
|
public Date getServerDate() throws IOException {
HttpInputStream in = get("/describe", false, false);
String dateString = null;
try {
Header header = in.getResponseHeader("Date");
if (header == null) {
throw new IOException("Date was not supplied in HTTP response "
+ "header for " + m_baseURL + "describe");
}
dateString = header.getValue();
// This is the date format recommended by RFC2616
SimpleDateFormat format =
new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z",
Locale.US);
format.setTimeZone(TimeZone.getTimeZone("UTC"));
return format.parse(dateString);
} catch (ParseException e) {
throw new IOException("Unparsable date (" + dateString
+ ") in HTTP response header for " + m_baseURL + "describe");
} finally {
in.close();
}
}
|
java
|
public Date getServerDate() throws IOException {
HttpInputStream in = get("/describe", false, false);
String dateString = null;
try {
Header header = in.getResponseHeader("Date");
if (header == null) {
throw new IOException("Date was not supplied in HTTP response "
+ "header for " + m_baseURL + "describe");
}
dateString = header.getValue();
// This is the date format recommended by RFC2616
SimpleDateFormat format =
new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z",
Locale.US);
format.setTimeZone(TimeZone.getTimeZone("UTC"));
return format.parse(dateString);
} catch (ParseException e) {
throw new IOException("Unparsable date (" + dateString
+ ") in HTTP response header for " + m_baseURL + "describe");
} finally {
in.close();
}
}
|
[
"public",
"Date",
"getServerDate",
"(",
")",
"throws",
"IOException",
"{",
"HttpInputStream",
"in",
"=",
"get",
"(",
"\"/describe\"",
",",
"false",
",",
"false",
")",
";",
"String",
"dateString",
"=",
"null",
";",
"try",
"{",
"Header",
"header",
"=",
"in",
".",
"getResponseHeader",
"(",
"\"Date\"",
")",
";",
"if",
"(",
"header",
"==",
"null",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Date was not supplied in HTTP response \"",
"+",
"\"header for \"",
"+",
"m_baseURL",
"+",
"\"describe\"",
")",
";",
"}",
"dateString",
"=",
"header",
".",
"getValue",
"(",
")",
";",
"// This is the date format recommended by RFC2616",
"SimpleDateFormat",
"format",
"=",
"new",
"SimpleDateFormat",
"(",
"\"EEE, dd MMM yyyy HH:mm:ss z\"",
",",
"Locale",
".",
"US",
")",
";",
"format",
".",
"setTimeZone",
"(",
"TimeZone",
".",
"getTimeZone",
"(",
"\"UTC\"",
")",
")",
";",
"return",
"format",
".",
"parse",
"(",
"dateString",
")",
";",
"}",
"catch",
"(",
"ParseException",
"e",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Unparsable date (\"",
"+",
"dateString",
"+",
"\") in HTTP response header for \"",
"+",
"m_baseURL",
"+",
"\"describe\"",
")",
";",
"}",
"finally",
"{",
"in",
".",
"close",
"(",
")",
";",
"}",
"}"
] |
Return the current date as reported by the Fedora server.
@throws IOException
if the HTTP Date header is not provided by the server for any
reason, or it is in the wrong format.
|
[
"Return",
"the",
"current",
"date",
"as",
"reported",
"by",
"the",
"Fedora",
"server",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/FedoraClient.java#L701-L725
|
8,870 |
fcrepo3/fcrepo
|
fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/FedoraClient.java
|
FedoraClient.getRedirectURL
|
private URL getRedirectURL(String location) throws IOException {
HttpInputStream in = get(location, false, false);
try {
if (in.getStatusCode() == 302) {
Header h = in.getResponseHeader("location");
if (h != null) {
return new URL(h.getValue());
}
}
return null;
} finally {
try {
in.close();
} catch (Exception e) {
}
}
}
|
java
|
private URL getRedirectURL(String location) throws IOException {
HttpInputStream in = get(location, false, false);
try {
if (in.getStatusCode() == 302) {
Header h = in.getResponseHeader("location");
if (h != null) {
return new URL(h.getValue());
}
}
return null;
} finally {
try {
in.close();
} catch (Exception e) {
}
}
}
|
[
"private",
"URL",
"getRedirectURL",
"(",
"String",
"location",
")",
"throws",
"IOException",
"{",
"HttpInputStream",
"in",
"=",
"get",
"(",
"location",
",",
"false",
",",
"false",
")",
";",
"try",
"{",
"if",
"(",
"in",
".",
"getStatusCode",
"(",
")",
"==",
"302",
")",
"{",
"Header",
"h",
"=",
"in",
".",
"getResponseHeader",
"(",
"\"location\"",
")",
";",
"if",
"(",
"h",
"!=",
"null",
")",
"{",
"return",
"new",
"URL",
"(",
"h",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}",
"return",
"null",
";",
"}",
"finally",
"{",
"try",
"{",
"in",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"}",
"}",
"}"
] |
Ping the given endpoint to see if an HTTP 302 status code is returned. If
so, return the location given in the HTTP response header. If not, return
null.
|
[
"Ping",
"the",
"given",
"endpoint",
"to",
"see",
"if",
"an",
"HTTP",
"302",
"status",
"code",
"is",
"returned",
".",
"If",
"so",
"return",
"the",
"location",
"given",
"in",
"the",
"HTTP",
"response",
"header",
".",
"If",
"not",
"return",
"null",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/FedoraClient.java#L863-L879
|
8,871 |
fcrepo3/fcrepo
|
fcrepo-security/fcrepo-security-pdp/src/main/java/org/fcrepo/server/security/xacml/pdp/data/XPathPolicyIndex.java
|
XPathPolicyIndex.getXpath
|
protected static String getXpath(Map<String, Collection<AttributeBean>> attributeMap) {
StringBuilder sb = new StringBuilder();
getXpath(attributeMap, sb);
return sb.toString();
}
|
java
|
protected static String getXpath(Map<String, Collection<AttributeBean>> attributeMap) {
StringBuilder sb = new StringBuilder();
getXpath(attributeMap, sb);
return sb.toString();
}
|
[
"protected",
"static",
"String",
"getXpath",
"(",
"Map",
"<",
"String",
",",
"Collection",
"<",
"AttributeBean",
">",
">",
"attributeMap",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"getXpath",
"(",
"attributeMap",
",",
"sb",
")",
";",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] |
Creates an XPath query from the attributes
@param attributeMap attributes from request
@return String
|
[
"Creates",
"an",
"XPath",
"query",
"from",
"the",
"attributes"
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-security/fcrepo-security-pdp/src/main/java/org/fcrepo/server/security/xacml/pdp/data/XPathPolicyIndex.java#L119-L123
|
8,872 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/messaging/JMSManager.java
|
JMSManager.createDestination
|
public Destination createDestination(String name,
DestinationType type,
boolean fTransacted,
int ackMode) throws MessagingException {
// If the destination already exists, just return it
JMSDestination jmsDest = jmsDestinations.get(name);
if (jmsDest != null) {
return jmsDest.destination;
}
// Create the new destination and store it
Session session;
try {
session = connection.createSession(fTransacted, ackMode);
} catch (JMSException e) {
throw new MessagingException(e.getMessage(), e);
}
// Look up the destination otherwise create it
Destination destination = null;
try {
destination = (Destination) jndiLookup(name);
} catch (MessagingException me) {
logger.debug("JNDI lookup for destination " + name + " failed. "
+ "Destination must be created.");
destination = null;
}
if (destination == null) {
// Create a topic or queue as specified
try {
if (type.equals(DestinationType.Queue)) {
logger.debug("setupDestination() - creating Queue" + name);
destination = session.createQueue(name);
} else {
logger.debug("setupDestination() - creating Topic " + name);
destination = session.createTopic(name);
}
} catch (JMSException e) {
throw new MessagingException(e.getMessage(), e);
}
}
jmsDest = new JMSDestination(destination, session, null, null);
jmsDestinations.put(name, jmsDest);
return destination;
}
|
java
|
public Destination createDestination(String name,
DestinationType type,
boolean fTransacted,
int ackMode) throws MessagingException {
// If the destination already exists, just return it
JMSDestination jmsDest = jmsDestinations.get(name);
if (jmsDest != null) {
return jmsDest.destination;
}
// Create the new destination and store it
Session session;
try {
session = connection.createSession(fTransacted, ackMode);
} catch (JMSException e) {
throw new MessagingException(e.getMessage(), e);
}
// Look up the destination otherwise create it
Destination destination = null;
try {
destination = (Destination) jndiLookup(name);
} catch (MessagingException me) {
logger.debug("JNDI lookup for destination " + name + " failed. "
+ "Destination must be created.");
destination = null;
}
if (destination == null) {
// Create a topic or queue as specified
try {
if (type.equals(DestinationType.Queue)) {
logger.debug("setupDestination() - creating Queue" + name);
destination = session.createQueue(name);
} else {
logger.debug("setupDestination() - creating Topic " + name);
destination = session.createTopic(name);
}
} catch (JMSException e) {
throw new MessagingException(e.getMessage(), e);
}
}
jmsDest = new JMSDestination(destination, session, null, null);
jmsDestinations.put(name, jmsDest);
return destination;
}
|
[
"public",
"Destination",
"createDestination",
"(",
"String",
"name",
",",
"DestinationType",
"type",
",",
"boolean",
"fTransacted",
",",
"int",
"ackMode",
")",
"throws",
"MessagingException",
"{",
"// If the destination already exists, just return it",
"JMSDestination",
"jmsDest",
"=",
"jmsDestinations",
".",
"get",
"(",
"name",
")",
";",
"if",
"(",
"jmsDest",
"!=",
"null",
")",
"{",
"return",
"jmsDest",
".",
"destination",
";",
"}",
"// Create the new destination and store it",
"Session",
"session",
";",
"try",
"{",
"session",
"=",
"connection",
".",
"createSession",
"(",
"fTransacted",
",",
"ackMode",
")",
";",
"}",
"catch",
"(",
"JMSException",
"e",
")",
"{",
"throw",
"new",
"MessagingException",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"// Look up the destination otherwise create it",
"Destination",
"destination",
"=",
"null",
";",
"try",
"{",
"destination",
"=",
"(",
"Destination",
")",
"jndiLookup",
"(",
"name",
")",
";",
"}",
"catch",
"(",
"MessagingException",
"me",
")",
"{",
"logger",
".",
"debug",
"(",
"\"JNDI lookup for destination \"",
"+",
"name",
"+",
"\" failed. \"",
"+",
"\"Destination must be created.\"",
")",
";",
"destination",
"=",
"null",
";",
"}",
"if",
"(",
"destination",
"==",
"null",
")",
"{",
"// Create a topic or queue as specified",
"try",
"{",
"if",
"(",
"type",
".",
"equals",
"(",
"DestinationType",
".",
"Queue",
")",
")",
"{",
"logger",
".",
"debug",
"(",
"\"setupDestination() - creating Queue\"",
"+",
"name",
")",
";",
"destination",
"=",
"session",
".",
"createQueue",
"(",
"name",
")",
";",
"}",
"else",
"{",
"logger",
".",
"debug",
"(",
"\"setupDestination() - creating Topic \"",
"+",
"name",
")",
";",
"destination",
"=",
"session",
".",
"createTopic",
"(",
"name",
")",
";",
"}",
"}",
"catch",
"(",
"JMSException",
"e",
")",
"{",
"throw",
"new",
"MessagingException",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}",
"jmsDest",
"=",
"new",
"JMSDestination",
"(",
"destination",
",",
"session",
",",
"null",
",",
"null",
")",
";",
"jmsDestinations",
".",
"put",
"(",
"name",
",",
"jmsDest",
")",
";",
"return",
"destination",
";",
"}"
] |
Creates a Destination if the Destination has not already been created.
@param name - the name of the destination to create
@param type - the destination type (topic or queue)
@param fTransacted - determines whether the session will maintain transactions
@param ackMode - determines the session acknowledgment mode
@throws MessagingException
|
[
"Creates",
"a",
"Destination",
"if",
"the",
"Destination",
"has",
"not",
"already",
"been",
"created",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/messaging/JMSManager.java#L182-L229
|
8,873 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/messaging/JMSManager.java
|
JMSManager.send
|
public void send(String destName, Message msg) throws MessagingException {
JMSDestination jmsDest = getJMSDestination(destName);
// Make sure we have a message producer created for this destination
setupProducer(jmsDest);
// Send the message for this destination
try {
jmsDest.producer.send(msg);
} catch (JMSException e) {
throw new MessagingException(e.getMessage(), e);
}
if(logger.isDebugEnabled()) {
logger.debug("send() - message sent to destination " + destName);
}
}
|
java
|
public void send(String destName, Message msg) throws MessagingException {
JMSDestination jmsDest = getJMSDestination(destName);
// Make sure we have a message producer created for this destination
setupProducer(jmsDest);
// Send the message for this destination
try {
jmsDest.producer.send(msg);
} catch (JMSException e) {
throw new MessagingException(e.getMessage(), e);
}
if(logger.isDebugEnabled()) {
logger.debug("send() - message sent to destination " + destName);
}
}
|
[
"public",
"void",
"send",
"(",
"String",
"destName",
",",
"Message",
"msg",
")",
"throws",
"MessagingException",
"{",
"JMSDestination",
"jmsDest",
"=",
"getJMSDestination",
"(",
"destName",
")",
";",
"// Make sure we have a message producer created for this destination",
"setupProducer",
"(",
"jmsDest",
")",
";",
"// Send the message for this destination",
"try",
"{",
"jmsDest",
".",
"producer",
".",
"send",
"(",
"msg",
")",
";",
"}",
"catch",
"(",
"JMSException",
"e",
")",
"{",
"throw",
"new",
"MessagingException",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"logger",
".",
"debug",
"(",
"\"send() - message sent to destination \"",
"+",
"destName",
")",
";",
"}",
"}"
] |
Allows the caller to send a Message object to a named destination
|
[
"Allows",
"the",
"caller",
"to",
"send",
"a",
"Message",
"object",
"to",
"a",
"named",
"destination"
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/messaging/JMSManager.java#L488-L504
|
8,874 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/messaging/JMSManager.java
|
JMSManager.send
|
public void send(Destination dest, Message msg) throws MessagingException {
try {
Session s =
connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer p = s.createProducer(dest);
p.send(msg);
s.close();
} catch (JMSException e) {
throw new MessagingException(e.getMessage(), e);
}
if(logger.isDebugEnabled()) {
logger.debug("send() - message sent to destination " + dest);
}
}
|
java
|
public void send(Destination dest, Message msg) throws MessagingException {
try {
Session s =
connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer p = s.createProducer(dest);
p.send(msg);
s.close();
} catch (JMSException e) {
throw new MessagingException(e.getMessage(), e);
}
if(logger.isDebugEnabled()) {
logger.debug("send() - message sent to destination " + dest);
}
}
|
[
"public",
"void",
"send",
"(",
"Destination",
"dest",
",",
"Message",
"msg",
")",
"throws",
"MessagingException",
"{",
"try",
"{",
"Session",
"s",
"=",
"connection",
".",
"createSession",
"(",
"false",
",",
"Session",
".",
"AUTO_ACKNOWLEDGE",
")",
";",
"MessageProducer",
"p",
"=",
"s",
".",
"createProducer",
"(",
"dest",
")",
";",
"p",
".",
"send",
"(",
"msg",
")",
";",
"s",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"JMSException",
"e",
")",
"{",
"throw",
"new",
"MessagingException",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"logger",
".",
"debug",
"(",
"\"send() - message sent to destination \"",
"+",
"dest",
")",
";",
"}",
"}"
] |
Allows the caller to send a Message object to a destination
|
[
"Allows",
"the",
"caller",
"to",
"send",
"a",
"Message",
"object",
"to",
"a",
"destination"
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/messaging/JMSManager.java#L509-L523
|
8,875 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/messaging/JMSManager.java
|
JMSManager.send
|
public void send(String destName, String messageText)
throws MessagingException {
this.send(destName, (Serializable) messageText);
}
|
java
|
public void send(String destName, String messageText)
throws MessagingException {
this.send(destName, (Serializable) messageText);
}
|
[
"public",
"void",
"send",
"(",
"String",
"destName",
",",
"String",
"messageText",
")",
"throws",
"MessagingException",
"{",
"this",
".",
"send",
"(",
"destName",
",",
"(",
"Serializable",
")",
"messageText",
")",
";",
"}"
] |
Allows the caller to send text to a destination
|
[
"Allows",
"the",
"caller",
"to",
"send",
"text",
"to",
"a",
"destination"
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/messaging/JMSManager.java#L551-L554
|
8,876 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/messaging/JMSManager.java
|
JMSManager.stop
|
public void stop(String destName) throws MessagingException {
try {
// Look for an existing destination for the given destination
//
JMSDestination jmsDest =
jmsDestinations.get(destName);
if (jmsDest != null) {
// Close out all JMS related state
//
if (jmsDest.producer != null) {
jmsDest.producer.close();
logger.debug("Closed producer for " + destName);
}
if (jmsDest.consumer != null) {
jmsDest.consumer.close();
logger.debug("Closed consumer for " + destName);
}
if (jmsDest.session != null) {
jmsDest.session.close();
logger.debug("Closed session for " + destName);
}
jmsDest.destination = null;
jmsDest.session = null;
jmsDest.producer = null;
jmsDest.consumer = null;
// Remove the JMS client entry
//
jmsDestinations.remove(destName);
jmsDest = null;
}
} catch (JMSException e) {
throw new MessagingException(e.getMessage(), e);
}
}
|
java
|
public void stop(String destName) throws MessagingException {
try {
// Look for an existing destination for the given destination
//
JMSDestination jmsDest =
jmsDestinations.get(destName);
if (jmsDest != null) {
// Close out all JMS related state
//
if (jmsDest.producer != null) {
jmsDest.producer.close();
logger.debug("Closed producer for " + destName);
}
if (jmsDest.consumer != null) {
jmsDest.consumer.close();
logger.debug("Closed consumer for " + destName);
}
if (jmsDest.session != null) {
jmsDest.session.close();
logger.debug("Closed session for " + destName);
}
jmsDest.destination = null;
jmsDest.session = null;
jmsDest.producer = null;
jmsDest.consumer = null;
// Remove the JMS client entry
//
jmsDestinations.remove(destName);
jmsDest = null;
}
} catch (JMSException e) {
throw new MessagingException(e.getMessage(), e);
}
}
|
[
"public",
"void",
"stop",
"(",
"String",
"destName",
")",
"throws",
"MessagingException",
"{",
"try",
"{",
"// Look for an existing destination for the given destination",
"//",
"JMSDestination",
"jmsDest",
"=",
"jmsDestinations",
".",
"get",
"(",
"destName",
")",
";",
"if",
"(",
"jmsDest",
"!=",
"null",
")",
"{",
"// Close out all JMS related state",
"//",
"if",
"(",
"jmsDest",
".",
"producer",
"!=",
"null",
")",
"{",
"jmsDest",
".",
"producer",
".",
"close",
"(",
")",
";",
"logger",
".",
"debug",
"(",
"\"Closed producer for \"",
"+",
"destName",
")",
";",
"}",
"if",
"(",
"jmsDest",
".",
"consumer",
"!=",
"null",
")",
"{",
"jmsDest",
".",
"consumer",
".",
"close",
"(",
")",
";",
"logger",
".",
"debug",
"(",
"\"Closed consumer for \"",
"+",
"destName",
")",
";",
"}",
"if",
"(",
"jmsDest",
".",
"session",
"!=",
"null",
")",
"{",
"jmsDest",
".",
"session",
".",
"close",
"(",
")",
";",
"logger",
".",
"debug",
"(",
"\"Closed session for \"",
"+",
"destName",
")",
";",
"}",
"jmsDest",
".",
"destination",
"=",
"null",
";",
"jmsDest",
".",
"session",
"=",
"null",
";",
"jmsDest",
".",
"producer",
"=",
"null",
";",
"jmsDest",
".",
"consumer",
"=",
"null",
";",
"// Remove the JMS client entry",
"//",
"jmsDestinations",
".",
"remove",
"(",
"destName",
")",
";",
"jmsDest",
"=",
"null",
";",
"}",
"}",
"catch",
"(",
"JMSException",
"e",
")",
"{",
"throw",
"new",
"MessagingException",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}"
] |
Stops producers and consumers on a given destination.
This has no effect on durable subscriptions.
@param destName
@throws MessagingException
|
[
"Stops",
"producers",
"and",
"consumers",
"on",
"a",
"given",
"destination",
".",
"This",
"has",
"no",
"effect",
"on",
"durable",
"subscriptions",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/messaging/JMSManager.java#L563-L598
|
8,877 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/messaging/JMSManager.java
|
JMSManager.stopDurable
|
public void stopDurable(String subscriptionName) throws MessagingException {
try {
MessageConsumer durableSubscriber =
durableSubscriptions.get(subscriptionName);
if (durableSubscriber != null) {
durableSubscriber.close();
}
} catch (JMSException jmse) {
throw new MessagingException("Exception encountered attempting to "
+ "stop durable subscription with name: "
+ subscriptionName + ". Exception message: "
+ jmse.getMessage(), jmse);
}
}
|
java
|
public void stopDurable(String subscriptionName) throws MessagingException {
try {
MessageConsumer durableSubscriber =
durableSubscriptions.get(subscriptionName);
if (durableSubscriber != null) {
durableSubscriber.close();
}
} catch (JMSException jmse) {
throw new MessagingException("Exception encountered attempting to "
+ "stop durable subscription with name: "
+ subscriptionName + ". Exception message: "
+ jmse.getMessage(), jmse);
}
}
|
[
"public",
"void",
"stopDurable",
"(",
"String",
"subscriptionName",
")",
"throws",
"MessagingException",
"{",
"try",
"{",
"MessageConsumer",
"durableSubscriber",
"=",
"durableSubscriptions",
".",
"get",
"(",
"subscriptionName",
")",
";",
"if",
"(",
"durableSubscriber",
"!=",
"null",
")",
"{",
"durableSubscriber",
".",
"close",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"JMSException",
"jmse",
")",
"{",
"throw",
"new",
"MessagingException",
"(",
"\"Exception encountered attempting to \"",
"+",
"\"stop durable subscription with name: \"",
"+",
"subscriptionName",
"+",
"\". Exception message: \"",
"+",
"jmse",
".",
"getMessage",
"(",
")",
",",
"jmse",
")",
";",
"}",
"}"
] |
Stops a durable message consumer. Note that this is not
the same as unsubscribing. When a durable message consumer is
restarted all messages received since it was stopped will be
delivered.
@param subscriptionName - the name of the subscription
@throws MessagingException
|
[
"Stops",
"a",
"durable",
"message",
"consumer",
".",
"Note",
"that",
"this",
"is",
"not",
"the",
"same",
"as",
"unsubscribing",
".",
"When",
"a",
"durable",
"message",
"consumer",
"is",
"restarted",
"all",
"messages",
"received",
"since",
"it",
"was",
"stopped",
"will",
"be",
"delivered",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/messaging/JMSManager.java#L609-L622
|
8,878 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/messaging/JMSManager.java
|
JMSManager.unsubscribeDurable
|
public void unsubscribeDurable(String subscriptionName)
throws MessagingException {
try {
Session session =
connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageConsumer consumer = durableSubscriptions.get(subscriptionName);
if(consumer != null) {
consumer.close();
}
session.unsubscribe(subscriptionName);
} catch (JMSException jmse) {
String errMsg = "Unable to unsubscribe from subscription with name: "
+ subscriptionName + " due to exception: "
+ jmse.getMessage();
logger.debug(errMsg, jmse);
throw new MessagingException(errMsg, jmse);
}
}
|
java
|
public void unsubscribeDurable(String subscriptionName)
throws MessagingException {
try {
Session session =
connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageConsumer consumer = durableSubscriptions.get(subscriptionName);
if(consumer != null) {
consumer.close();
}
session.unsubscribe(subscriptionName);
} catch (JMSException jmse) {
String errMsg = "Unable to unsubscribe from subscription with name: "
+ subscriptionName + " due to exception: "
+ jmse.getMessage();
logger.debug(errMsg, jmse);
throw new MessagingException(errMsg, jmse);
}
}
|
[
"public",
"void",
"unsubscribeDurable",
"(",
"String",
"subscriptionName",
")",
"throws",
"MessagingException",
"{",
"try",
"{",
"Session",
"session",
"=",
"connection",
".",
"createSession",
"(",
"false",
",",
"Session",
".",
"AUTO_ACKNOWLEDGE",
")",
";",
"MessageConsumer",
"consumer",
"=",
"durableSubscriptions",
".",
"get",
"(",
"subscriptionName",
")",
";",
"if",
"(",
"consumer",
"!=",
"null",
")",
"{",
"consumer",
".",
"close",
"(",
")",
";",
"}",
"session",
".",
"unsubscribe",
"(",
"subscriptionName",
")",
";",
"}",
"catch",
"(",
"JMSException",
"jmse",
")",
"{",
"String",
"errMsg",
"=",
"\"Unable to unsubscribe from subscription with name: \"",
"+",
"subscriptionName",
"+",
"\" due to exception: \"",
"+",
"jmse",
".",
"getMessage",
"(",
")",
";",
"logger",
".",
"debug",
"(",
"errMsg",
",",
"jmse",
")",
";",
"throw",
"new",
"MessagingException",
"(",
"errMsg",
",",
"jmse",
")",
";",
"}",
"}"
] |
Removes the durable subscription with the given name.
@param subscriptionName - name of the durable subscription
@throws MessagingException
|
[
"Removes",
"the",
"durable",
"subscription",
"with",
"the",
"given",
"name",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/messaging/JMSManager.java#L630-L647
|
8,879 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/messaging/JMSManager.java
|
JMSManager.getDestination
|
public Destination getDestination(String destName)
throws MessagingException {
Destination destination = null;
JMSDestination jmsDest = getJMSDestination(destName);
if(jmsDest != null) {
destination = jmsDest.destination;
}
return destination;
}
|
java
|
public Destination getDestination(String destName)
throws MessagingException {
Destination destination = null;
JMSDestination jmsDest = getJMSDestination(destName);
if(jmsDest != null) {
destination = jmsDest.destination;
}
return destination;
}
|
[
"public",
"Destination",
"getDestination",
"(",
"String",
"destName",
")",
"throws",
"MessagingException",
"{",
"Destination",
"destination",
"=",
"null",
";",
"JMSDestination",
"jmsDest",
"=",
"getJMSDestination",
"(",
"destName",
")",
";",
"if",
"(",
"jmsDest",
"!=",
"null",
")",
"{",
"destination",
"=",
"jmsDest",
".",
"destination",
";",
"}",
"return",
"destination",
";",
"}"
] |
Gets the named Destination if it has been created.
@param destName
@return the Destination object for the specified destination
name or null if the destination does not exist
@throws MessagingException
|
[
"Gets",
"the",
"named",
"Destination",
"if",
"it",
"has",
"been",
"created",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/messaging/JMSManager.java#L738-L746
|
8,880 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/messaging/JMSManager.java
|
JMSManager.getDestinations
|
public List<Destination> getDestinations() {
List<Destination> destinations = new ArrayList<Destination>();
Iterator<JMSDestination> destinationIterator =
jmsDestinations.values().iterator();
while(destinationIterator.hasNext()) {
destinations.add(destinationIterator.next().destination);
}
return destinations;
}
|
java
|
public List<Destination> getDestinations() {
List<Destination> destinations = new ArrayList<Destination>();
Iterator<JMSDestination> destinationIterator =
jmsDestinations.values().iterator();
while(destinationIterator.hasNext()) {
destinations.add(destinationIterator.next().destination);
}
return destinations;
}
|
[
"public",
"List",
"<",
"Destination",
">",
"getDestinations",
"(",
")",
"{",
"List",
"<",
"Destination",
">",
"destinations",
"=",
"new",
"ArrayList",
"<",
"Destination",
">",
"(",
")",
";",
"Iterator",
"<",
"JMSDestination",
">",
"destinationIterator",
"=",
"jmsDestinations",
".",
"values",
"(",
")",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"destinationIterator",
".",
"hasNext",
"(",
")",
")",
"{",
"destinations",
".",
"add",
"(",
"destinationIterator",
".",
"next",
"(",
")",
".",
"destination",
")",
";",
"}",
"return",
"destinations",
";",
"}"
] |
Provides a listing of the currently available destinations
@return destination list
|
[
"Provides",
"a",
"listing",
"of",
"the",
"currently",
"available",
"destinations"
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/messaging/JMSManager.java#L752-L760
|
8,881 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/messaging/JMSManager.java
|
JMSManager.connectToJMS
|
protected void connectToJMS(String clientId) throws MessagingException {
// Check to see if already connected
//
if (connected == true) return;
try {
// Get a JMS Connection
//
connection = getConnection();
if(clientId != null) {
connection.setClientID(clientId);
}
connection.start();
connected = true;
logger.debug("connectToJMS - connected");
} catch (JMSException e) {
connected = false;
logger.error("JMSManager.connectToJMS - Exception occurred:");
throw new MessagingException(e.getMessage(), e);
}
}
|
java
|
protected void connectToJMS(String clientId) throws MessagingException {
// Check to see if already connected
//
if (connected == true) return;
try {
// Get a JMS Connection
//
connection = getConnection();
if(clientId != null) {
connection.setClientID(clientId);
}
connection.start();
connected = true;
logger.debug("connectToJMS - connected");
} catch (JMSException e) {
connected = false;
logger.error("JMSManager.connectToJMS - Exception occurred:");
throw new MessagingException(e.getMessage(), e);
}
}
|
[
"protected",
"void",
"connectToJMS",
"(",
"String",
"clientId",
")",
"throws",
"MessagingException",
"{",
"// Check to see if already connected",
"//",
"if",
"(",
"connected",
"==",
"true",
")",
"return",
";",
"try",
"{",
"// Get a JMS Connection",
"//",
"connection",
"=",
"getConnection",
"(",
")",
";",
"if",
"(",
"clientId",
"!=",
"null",
")",
"{",
"connection",
".",
"setClientID",
"(",
"clientId",
")",
";",
"}",
"connection",
".",
"start",
"(",
")",
";",
"connected",
"=",
"true",
";",
"logger",
".",
"debug",
"(",
"\"connectToJMS - connected\"",
")",
";",
"}",
"catch",
"(",
"JMSException",
"e",
")",
"{",
"connected",
"=",
"false",
";",
"logger",
".",
"error",
"(",
"\"JMSManager.connectToJMS - Exception occurred:\"",
")",
";",
"throw",
"new",
"MessagingException",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}"
] |
Internal worker methods
|
[
"Internal",
"worker",
"methods"
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/messaging/JMSManager.java#L803-L823
|
8,882 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/journal/helpers/PasswordCipher.java
|
PasswordCipher.encipher
|
public static String encipher(String key, String clearText) {
if (key == null) {
throw new NullPointerException("key may not be null");
}
if (key == "") {
return clearText;
}
if (clearText == null) {
return null;
}
byte[] keyBytes = convertKeyToByteArray(key);
byte[] clearTextBytes = convertClearTextToByteArray(clearText);
byte[] cipherBytes = applyCipher(keyBytes, clearTextBytes);
return Base64.encodeToString(cipherBytes);
}
|
java
|
public static String encipher(String key, String clearText) {
if (key == null) {
throw new NullPointerException("key may not be null");
}
if (key == "") {
return clearText;
}
if (clearText == null) {
return null;
}
byte[] keyBytes = convertKeyToByteArray(key);
byte[] clearTextBytes = convertClearTextToByteArray(clearText);
byte[] cipherBytes = applyCipher(keyBytes, clearTextBytes);
return Base64.encodeToString(cipherBytes);
}
|
[
"public",
"static",
"String",
"encipher",
"(",
"String",
"key",
",",
"String",
"clearText",
")",
"{",
"if",
"(",
"key",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"key may not be null\"",
")",
";",
"}",
"if",
"(",
"key",
"==",
"\"\"",
")",
"{",
"return",
"clearText",
";",
"}",
"if",
"(",
"clearText",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"byte",
"[",
"]",
"keyBytes",
"=",
"convertKeyToByteArray",
"(",
"key",
")",
";",
"byte",
"[",
"]",
"clearTextBytes",
"=",
"convertClearTextToByteArray",
"(",
"clearText",
")",
";",
"byte",
"[",
"]",
"cipherBytes",
"=",
"applyCipher",
"(",
"keyBytes",
",",
"clearTextBytes",
")",
";",
"return",
"Base64",
".",
"encodeToString",
"(",
"cipherBytes",
")",
";",
"}"
] |
Use the key to produce a ciphered String from the clearText.
|
[
"Use",
"the",
"key",
"to",
"produce",
"a",
"ciphered",
"String",
"from",
"the",
"clearText",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/helpers/PasswordCipher.java#L36-L53
|
8,883 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/journal/helpers/PasswordCipher.java
|
PasswordCipher.decipher
|
public static String decipher(String key,
String cipherText,
String cipherType) {
if (key == null || key == "") {
return cipherText;
}
if (cipherText == null) {
return null;
}
if (cipherType == null || cipherType == "") {
return cipherText;
} else if ("1".equalsIgnoreCase(cipherType)) {
byte[] keyBytes = convertKeyToByteArray(key);
byte[] cipherBytes = Base64.decode(cipherText);
sanityCheckOnCipherBytes(cipherText, cipherBytes);
byte[] clearTextBytes = applyCipher(keyBytes, cipherBytes);
return convertByteArrayToClearText(clearTextBytes);
} else {
throw new IllegalArgumentException("Unrecognized cipher type: '"
+ cipherType + "'");
}
}
|
java
|
public static String decipher(String key,
String cipherText,
String cipherType) {
if (key == null || key == "") {
return cipherText;
}
if (cipherText == null) {
return null;
}
if (cipherType == null || cipherType == "") {
return cipherText;
} else if ("1".equalsIgnoreCase(cipherType)) {
byte[] keyBytes = convertKeyToByteArray(key);
byte[] cipherBytes = Base64.decode(cipherText);
sanityCheckOnCipherBytes(cipherText, cipherBytes);
byte[] clearTextBytes = applyCipher(keyBytes, cipherBytes);
return convertByteArrayToClearText(clearTextBytes);
} else {
throw new IllegalArgumentException("Unrecognized cipher type: '"
+ cipherType + "'");
}
}
|
[
"public",
"static",
"String",
"decipher",
"(",
"String",
"key",
",",
"String",
"cipherText",
",",
"String",
"cipherType",
")",
"{",
"if",
"(",
"key",
"==",
"null",
"||",
"key",
"==",
"\"\"",
")",
"{",
"return",
"cipherText",
";",
"}",
"if",
"(",
"cipherText",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"cipherType",
"==",
"null",
"||",
"cipherType",
"==",
"\"\"",
")",
"{",
"return",
"cipherText",
";",
"}",
"else",
"if",
"(",
"\"1\"",
".",
"equalsIgnoreCase",
"(",
"cipherType",
")",
")",
"{",
"byte",
"[",
"]",
"keyBytes",
"=",
"convertKeyToByteArray",
"(",
"key",
")",
";",
"byte",
"[",
"]",
"cipherBytes",
"=",
"Base64",
".",
"decode",
"(",
"cipherText",
")",
";",
"sanityCheckOnCipherBytes",
"(",
"cipherText",
",",
"cipherBytes",
")",
";",
"byte",
"[",
"]",
"clearTextBytes",
"=",
"applyCipher",
"(",
"keyBytes",
",",
"cipherBytes",
")",
";",
"return",
"convertByteArrayToClearText",
"(",
"clearTextBytes",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unrecognized cipher type: '\"",
"+",
"cipherType",
"+",
"\"'\"",
")",
";",
"}",
"}"
] |
Use the key to produce a clear text String from the cipherText. If no key
is provided, or if no type is specified, just return the text as is.
|
[
"Use",
"the",
"key",
"to",
"produce",
"a",
"clear",
"text",
"String",
"from",
"the",
"cipherText",
".",
"If",
"no",
"key",
"is",
"provided",
"or",
"if",
"no",
"type",
"is",
"specified",
"just",
"return",
"the",
"text",
"as",
"is",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/helpers/PasswordCipher.java#L59-L82
|
8,884 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/journal/helpers/PasswordCipher.java
|
PasswordCipher.convertKeyToByteArray
|
private static byte[] convertKeyToByteArray(String key) {
byte[] result = new byte[key.length()];
for (int i = 0; i < result.length; i++) {
char thisChar = key.charAt(i);
result[i] = (byte) (thisChar >>> 8 & 0xFF ^ thisChar & 0xFF);
}
return result;
}
|
java
|
private static byte[] convertKeyToByteArray(String key) {
byte[] result = new byte[key.length()];
for (int i = 0; i < result.length; i++) {
char thisChar = key.charAt(i);
result[i] = (byte) (thisChar >>> 8 & 0xFF ^ thisChar & 0xFF);
}
return result;
}
|
[
"private",
"static",
"byte",
"[",
"]",
"convertKeyToByteArray",
"(",
"String",
"key",
")",
"{",
"byte",
"[",
"]",
"result",
"=",
"new",
"byte",
"[",
"key",
".",
"length",
"(",
")",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"result",
".",
"length",
";",
"i",
"++",
")",
"{",
"char",
"thisChar",
"=",
"key",
".",
"charAt",
"(",
"i",
")",
";",
"result",
"[",
"i",
"]",
"=",
"(",
"byte",
")",
"(",
"thisChar",
">>>",
"8",
"&",
"0xFF",
"^",
"thisChar",
"&",
"0xFF",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Convert the key to a byte array by compressing the 16-bit characters to
bytes. This XOR compression insures that the top 8 bits are still
significant, so a key of "\u0020" yields a different cipher than a key of
"\u0120".
|
[
"Convert",
"the",
"key",
"to",
"a",
"byte",
"array",
"by",
"compressing",
"the",
"16",
"-",
"bit",
"characters",
"to",
"bytes",
".",
"This",
"XOR",
"compression",
"insures",
"that",
"the",
"top",
"8",
"bits",
"are",
"still",
"significant",
"so",
"a",
"key",
"of",
"\\",
"u0020",
"yields",
"a",
"different",
"cipher",
"than",
"a",
"key",
"of",
"\\",
"u0120",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/helpers/PasswordCipher.java#L90-L97
|
8,885 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/journal/helpers/PasswordCipher.java
|
PasswordCipher.convertClearTextToByteArray
|
private static byte[] convertClearTextToByteArray(String clearText) {
byte[] result = new byte[clearText.length() * 2];
for (int i = 0; i < clearText.length(); i++) {
char thisChar = clearText.charAt(i);
int pos = i * 2;
result[pos] = (byte) (thisChar >>> 8 & 0xFF);
result[pos + 1] = (byte) (thisChar & 0xFF);
}
return result;
}
|
java
|
private static byte[] convertClearTextToByteArray(String clearText) {
byte[] result = new byte[clearText.length() * 2];
for (int i = 0; i < clearText.length(); i++) {
char thisChar = clearText.charAt(i);
int pos = i * 2;
result[pos] = (byte) (thisChar >>> 8 & 0xFF);
result[pos + 1] = (byte) (thisChar & 0xFF);
}
return result;
}
|
[
"private",
"static",
"byte",
"[",
"]",
"convertClearTextToByteArray",
"(",
"String",
"clearText",
")",
"{",
"byte",
"[",
"]",
"result",
"=",
"new",
"byte",
"[",
"clearText",
".",
"length",
"(",
")",
"*",
"2",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"clearText",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"char",
"thisChar",
"=",
"clearText",
".",
"charAt",
"(",
"i",
")",
";",
"int",
"pos",
"=",
"i",
"*",
"2",
";",
"result",
"[",
"pos",
"]",
"=",
"(",
"byte",
")",
"(",
"thisChar",
">>>",
"8",
"&",
"0xFF",
")",
";",
"result",
"[",
"pos",
"+",
"1",
"]",
"=",
"(",
"byte",
")",
"(",
"thisChar",
"&",
"0xFF",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Convert the clear text to a byte array by splitting each 16-bit character
into 2 bytes. This insures that no data is lost.
|
[
"Convert",
"the",
"clear",
"text",
"to",
"a",
"byte",
"array",
"by",
"splitting",
"each",
"16",
"-",
"bit",
"character",
"into",
"2",
"bytes",
".",
"This",
"insures",
"that",
"no",
"data",
"is",
"lost",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/helpers/PasswordCipher.java#L103-L112
|
8,886 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/journal/helpers/PasswordCipher.java
|
PasswordCipher.sanityCheckOnCipherBytes
|
private static void sanityCheckOnCipherBytes(String cipherText,
byte[] cipherBytes) {
if (cipherBytes.length % 2 != 0) {
throw new IllegalStateException("Ciphered text decodes to an odd number of bytes! Text='"
+ cipherText
+ "', decodes to "
+ cipherBytes.length
+ " bytes.");
}
}
|
java
|
private static void sanityCheckOnCipherBytes(String cipherText,
byte[] cipherBytes) {
if (cipherBytes.length % 2 != 0) {
throw new IllegalStateException("Ciphered text decodes to an odd number of bytes! Text='"
+ cipherText
+ "', decodes to "
+ cipherBytes.length
+ " bytes.");
}
}
|
[
"private",
"static",
"void",
"sanityCheckOnCipherBytes",
"(",
"String",
"cipherText",
",",
"byte",
"[",
"]",
"cipherBytes",
")",
"{",
"if",
"(",
"cipherBytes",
".",
"length",
"%",
"2",
"!=",
"0",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Ciphered text decodes to an odd number of bytes! Text='\"",
"+",
"cipherText",
"+",
"\"', decodes to \"",
"+",
"cipherBytes",
".",
"length",
"+",
"\" bytes.\"",
")",
";",
"}",
"}"
] |
If the cipher text decodes to an odd number of bytes, we can't go on!
|
[
"If",
"the",
"cipher",
"text",
"decodes",
"to",
"an",
"odd",
"number",
"of",
"bytes",
"we",
"can",
"t",
"go",
"on!"
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/helpers/PasswordCipher.java#L117-L126
|
8,887 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/journal/helpers/PasswordCipher.java
|
PasswordCipher.convertByteArrayToClearText
|
private static String convertByteArrayToClearText(byte[] bytes) {
StringBuffer result = new StringBuffer();
for (int i = 0; i < bytes.length; i += 2) {
char thisChar = (char) (bytes[i] << 8 | bytes[i + 1]);
result.append(thisChar);
}
return result.toString();
}
|
java
|
private static String convertByteArrayToClearText(byte[] bytes) {
StringBuffer result = new StringBuffer();
for (int i = 0; i < bytes.length; i += 2) {
char thisChar = (char) (bytes[i] << 8 | bytes[i + 1]);
result.append(thisChar);
}
return result.toString();
}
|
[
"private",
"static",
"String",
"convertByteArrayToClearText",
"(",
"byte",
"[",
"]",
"bytes",
")",
"{",
"StringBuffer",
"result",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"bytes",
".",
"length",
";",
"i",
"+=",
"2",
")",
"{",
"char",
"thisChar",
"=",
"(",
"char",
")",
"(",
"bytes",
"[",
"i",
"]",
"<<",
"8",
"|",
"bytes",
"[",
"i",
"+",
"1",
"]",
")",
";",
"result",
".",
"append",
"(",
"thisChar",
")",
";",
"}",
"return",
"result",
".",
"toString",
"(",
")",
";",
"}"
] |
Convert a byte array to text by joining each two bytes into a 16-bit
character.
|
[
"Convert",
"a",
"byte",
"array",
"to",
"text",
"by",
"joining",
"each",
"two",
"bytes",
"into",
"a",
"16",
"-",
"bit",
"character",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/helpers/PasswordCipher.java#L132-L139
|
8,888 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/journal/helpers/PasswordCipher.java
|
PasswordCipher.applyCipher
|
private static byte[] applyCipher(byte[] keyBytes, byte[] textBytes) {
byte[] result = new byte[textBytes.length];
for (int i = 0; i < result.length; i++) {
int keyPos = i % keyBytes.length;
result[i] = (byte) (textBytes[i] ^ keyBytes[keyPos]);
}
return result;
}
|
java
|
private static byte[] applyCipher(byte[] keyBytes, byte[] textBytes) {
byte[] result = new byte[textBytes.length];
for (int i = 0; i < result.length; i++) {
int keyPos = i % keyBytes.length;
result[i] = (byte) (textBytes[i] ^ keyBytes[keyPos]);
}
return result;
}
|
[
"private",
"static",
"byte",
"[",
"]",
"applyCipher",
"(",
"byte",
"[",
"]",
"keyBytes",
",",
"byte",
"[",
"]",
"textBytes",
")",
"{",
"byte",
"[",
"]",
"result",
"=",
"new",
"byte",
"[",
"textBytes",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"result",
".",
"length",
";",
"i",
"++",
")",
"{",
"int",
"keyPos",
"=",
"i",
"%",
"keyBytes",
".",
"length",
";",
"result",
"[",
"i",
"]",
"=",
"(",
"byte",
")",
"(",
"textBytes",
"[",
"i",
"]",
"^",
"keyBytes",
"[",
"keyPos",
"]",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
The same algorithm applies for enciphering or deciphering. Go through the
text, XORing with successive bytes of the key. If you apply it twice, you
get the original text back.
|
[
"The",
"same",
"algorithm",
"applies",
"for",
"enciphering",
"or",
"deciphering",
".",
"Go",
"through",
"the",
"text",
"XORing",
"with",
"successive",
"bytes",
"of",
"the",
"key",
".",
"If",
"you",
"apply",
"it",
"twice",
"you",
"get",
"the",
"original",
"text",
"back",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/helpers/PasswordCipher.java#L146-L153
|
8,889 |
fcrepo3/fcrepo
|
fcrepo-security/fcrepo-security-jaas/src/main/java/org/fcrepo/server/security/jaas/auth/module/XmlUsersFileModule.java
|
XmlUsersFileModule.getUserDocument
|
private static Document getUserDocument() throws Exception {
if (userDoc == null || userFileParsed != userFile.lastModified() || userFileBytesLoaded != userFile.length()) {
synchronized(XmlUsersFileModule.class) {
if (userDoc == null || userFileParsed != userFile.lastModified() || userFileBytesLoaded != userFile.length()) {
userDoc = DataUtils.getDocumentFromFile(userFile);
userFileParsed = userFile.lastModified();
userFileBytesLoaded = userFile.length();
}
}
}
return userDoc;
}
|
java
|
private static Document getUserDocument() throws Exception {
if (userDoc == null || userFileParsed != userFile.lastModified() || userFileBytesLoaded != userFile.length()) {
synchronized(XmlUsersFileModule.class) {
if (userDoc == null || userFileParsed != userFile.lastModified() || userFileBytesLoaded != userFile.length()) {
userDoc = DataUtils.getDocumentFromFile(userFile);
userFileParsed = userFile.lastModified();
userFileBytesLoaded = userFile.length();
}
}
}
return userDoc;
}
|
[
"private",
"static",
"Document",
"getUserDocument",
"(",
")",
"throws",
"Exception",
"{",
"if",
"(",
"userDoc",
"==",
"null",
"||",
"userFileParsed",
"!=",
"userFile",
".",
"lastModified",
"(",
")",
"||",
"userFileBytesLoaded",
"!=",
"userFile",
".",
"length",
"(",
")",
")",
"{",
"synchronized",
"(",
"XmlUsersFileModule",
".",
"class",
")",
"{",
"if",
"(",
"userDoc",
"==",
"null",
"||",
"userFileParsed",
"!=",
"userFile",
".",
"lastModified",
"(",
")",
"||",
"userFileBytesLoaded",
"!=",
"userFile",
".",
"length",
"(",
")",
")",
"{",
"userDoc",
"=",
"DataUtils",
".",
"getDocumentFromFile",
"(",
"userFile",
")",
";",
"userFileParsed",
"=",
"userFile",
".",
"lastModified",
"(",
")",
";",
"userFileBytesLoaded",
"=",
"userFile",
".",
"length",
"(",
")",
";",
"}",
"}",
"}",
"return",
"userDoc",
";",
"}"
] |
Quick and dirty caching.
@return DOM of a parsed user file
@throws Exception
|
[
"Quick",
"and",
"dirty",
"caching",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-security/fcrepo-security-jaas/src/main/java/org/fcrepo/server/security/jaas/auth/module/XmlUsersFileModule.java#L258-L269
|
8,890 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/journal/readerwriter/multifile/MultiFileJournalHelper.java
|
MultiFileJournalHelper.getRequiredParameter
|
static String getRequiredParameter(Map<String, String> parameters,
String parameterName)
throws JournalException {
String value = parameters.get(parameterName);
if (value == null) {
throw new JournalException("'" + parameterName + "' is required.");
}
return value;
}
|
java
|
static String getRequiredParameter(Map<String, String> parameters,
String parameterName)
throws JournalException {
String value = parameters.get(parameterName);
if (value == null) {
throw new JournalException("'" + parameterName + "' is required.");
}
return value;
}
|
[
"static",
"String",
"getRequiredParameter",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"parameters",
",",
"String",
"parameterName",
")",
"throws",
"JournalException",
"{",
"String",
"value",
"=",
"parameters",
".",
"get",
"(",
"parameterName",
")",
";",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"throw",
"new",
"JournalException",
"(",
"\"'\"",
"+",
"parameterName",
"+",
"\"' is required.\"",
")",
";",
"}",
"return",
"value",
";",
"}"
] |
Get the requested parameter, or throw an exception if it is not found.
|
[
"Get",
"the",
"requested",
"parameter",
"or",
"throw",
"an",
"exception",
"if",
"it",
"is",
"not",
"found",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/readerwriter/multifile/MultiFileJournalHelper.java#L36-L44
|
8,891 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/journal/readerwriter/multifile/MultiFileJournalHelper.java
|
MultiFileJournalHelper.parseParametersForPollingInterval
|
static long parseParametersForPollingInterval(Map<String, String> parameters)
throws JournalException {
String intervalString =
parameters.get(PARAMETER_FOLLOW_POLLING_INTERVAL);
if (intervalString == null) {
intervalString = DEFAULT_FOLLOW_POLLING_INTERVAL;
}
Pattern p = Pattern.compile("([0-9]+)([HM]?)");
Matcher m = p.matcher(intervalString);
if (!m.matches()) {
throw new JournalException("Parameter '"
+ PARAMETER_FOLLOW_POLLING_INTERVAL
+ "' must be an positive integer number of seconds, "
+ "optionally followed by 'H'(hours), or 'M'(minutes)");
}
long interval = Long.parseLong(m.group(1)) * 1000;
String factor = m.group(2);
if ("H".equals(factor)) {
interval *= 60 * 60;
} else if ("M".equals(factor)) {
interval *= 60;
}
return interval;
}
|
java
|
static long parseParametersForPollingInterval(Map<String, String> parameters)
throws JournalException {
String intervalString =
parameters.get(PARAMETER_FOLLOW_POLLING_INTERVAL);
if (intervalString == null) {
intervalString = DEFAULT_FOLLOW_POLLING_INTERVAL;
}
Pattern p = Pattern.compile("([0-9]+)([HM]?)");
Matcher m = p.matcher(intervalString);
if (!m.matches()) {
throw new JournalException("Parameter '"
+ PARAMETER_FOLLOW_POLLING_INTERVAL
+ "' must be an positive integer number of seconds, "
+ "optionally followed by 'H'(hours), or 'M'(minutes)");
}
long interval = Long.parseLong(m.group(1)) * 1000;
String factor = m.group(2);
if ("H".equals(factor)) {
interval *= 60 * 60;
} else if ("M".equals(factor)) {
interval *= 60;
}
return interval;
}
|
[
"static",
"long",
"parseParametersForPollingInterval",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"parameters",
")",
"throws",
"JournalException",
"{",
"String",
"intervalString",
"=",
"parameters",
".",
"get",
"(",
"PARAMETER_FOLLOW_POLLING_INTERVAL",
")",
";",
"if",
"(",
"intervalString",
"==",
"null",
")",
"{",
"intervalString",
"=",
"DEFAULT_FOLLOW_POLLING_INTERVAL",
";",
"}",
"Pattern",
"p",
"=",
"Pattern",
".",
"compile",
"(",
"\"([0-9]+)([HM]?)\"",
")",
";",
"Matcher",
"m",
"=",
"p",
".",
"matcher",
"(",
"intervalString",
")",
";",
"if",
"(",
"!",
"m",
".",
"matches",
"(",
")",
")",
"{",
"throw",
"new",
"JournalException",
"(",
"\"Parameter '\"",
"+",
"PARAMETER_FOLLOW_POLLING_INTERVAL",
"+",
"\"' must be an positive integer number of seconds, \"",
"+",
"\"optionally followed by 'H'(hours), or 'M'(minutes)\"",
")",
";",
"}",
"long",
"interval",
"=",
"Long",
".",
"parseLong",
"(",
"m",
".",
"group",
"(",
"1",
")",
")",
"*",
"1000",
";",
"String",
"factor",
"=",
"m",
".",
"group",
"(",
"2",
")",
";",
"if",
"(",
"\"H\"",
".",
"equals",
"(",
"factor",
")",
")",
"{",
"interval",
"*=",
"60",
"*",
"60",
";",
"}",
"else",
"if",
"(",
"\"M\"",
".",
"equals",
"(",
"factor",
")",
")",
"{",
"interval",
"*=",
"60",
";",
"}",
"return",
"interval",
";",
"}"
] |
Find the polling interval that we will choose when checking for new
journal files to appear.
|
[
"Find",
"the",
"polling",
"interval",
"that",
"we",
"will",
"choose",
"when",
"checking",
"for",
"new",
"journal",
"files",
"to",
"appear",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/readerwriter/multifile/MultiFileJournalHelper.java#L50-L73
|
8,892 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/journal/readerwriter/multifile/MultiFileJournalHelper.java
|
MultiFileJournalHelper.getSortedArrayOfJournalFiles
|
static File[] getSortedArrayOfJournalFiles(File journalDirectory,
String filenamePrefix) {
JournalFileFilter filter = new JournalFileFilter(filenamePrefix);
File[] journalFiles = journalDirectory.listFiles(filter);
Arrays.sort(journalFiles, new FilenameComparator());
return journalFiles;
}
|
java
|
static File[] getSortedArrayOfJournalFiles(File journalDirectory,
String filenamePrefix) {
JournalFileFilter filter = new JournalFileFilter(filenamePrefix);
File[] journalFiles = journalDirectory.listFiles(filter);
Arrays.sort(journalFiles, new FilenameComparator());
return journalFiles;
}
|
[
"static",
"File",
"[",
"]",
"getSortedArrayOfJournalFiles",
"(",
"File",
"journalDirectory",
",",
"String",
"filenamePrefix",
")",
"{",
"JournalFileFilter",
"filter",
"=",
"new",
"JournalFileFilter",
"(",
"filenamePrefix",
")",
";",
"File",
"[",
"]",
"journalFiles",
"=",
"journalDirectory",
".",
"listFiles",
"(",
"filter",
")",
";",
"Arrays",
".",
"sort",
"(",
"journalFiles",
",",
"new",
"FilenameComparator",
"(",
")",
")",
";",
"return",
"journalFiles",
";",
"}"
] |
Get the Journal Files that exist the Journal Directory, sorted by name.
|
[
"Get",
"the",
"Journal",
"Files",
"that",
"exist",
"the",
"Journal",
"Directory",
"sorted",
"by",
"name",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/readerwriter/multifile/MultiFileJournalHelper.java#L78-L84
|
8,893 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/security/servletfilters/CacheElement.java
|
CacheElement.populate
|
public final void populate(Boolean authenticated,
Set<?> predicates,
Map<String, Set<?>> map,
String errorMessage) {
String m = m_cacheabbrev + " populate() ";
logger.debug("{}>", m);
try {
if (predicates != null) {
logger.warn(m + " predicates are deprecated; will be ignored");
}
assertInvalid();
if (errorMessage != null) {
logger.error(m + "errorMessage==" + errorMessage);
throw new Exception(errorMessage);
} else {
validate(authenticated, map);
// can't set expiration here -- don't have cache reference
// can't set pwd here, don't have it
}
} catch (Throwable t) {
logger.error(m + "invalidating to be sure");
this.invalidate(errorMessage);
} finally {
logger.debug("{}<", m);
}
}
|
java
|
public final void populate(Boolean authenticated,
Set<?> predicates,
Map<String, Set<?>> map,
String errorMessage) {
String m = m_cacheabbrev + " populate() ";
logger.debug("{}>", m);
try {
if (predicates != null) {
logger.warn(m + " predicates are deprecated; will be ignored");
}
assertInvalid();
if (errorMessage != null) {
logger.error(m + "errorMessage==" + errorMessage);
throw new Exception(errorMessage);
} else {
validate(authenticated, map);
// can't set expiration here -- don't have cache reference
// can't set pwd here, don't have it
}
} catch (Throwable t) {
logger.error(m + "invalidating to be sure");
this.invalidate(errorMessage);
} finally {
logger.debug("{}<", m);
}
}
|
[
"public",
"final",
"void",
"populate",
"(",
"Boolean",
"authenticated",
",",
"Set",
"<",
"?",
">",
"predicates",
",",
"Map",
"<",
"String",
",",
"Set",
"<",
"?",
">",
">",
"map",
",",
"String",
"errorMessage",
")",
"{",
"String",
"m",
"=",
"m_cacheabbrev",
"+",
"\" populate() \"",
";",
"logger",
".",
"debug",
"(",
"\"{}>\"",
",",
"m",
")",
";",
"try",
"{",
"if",
"(",
"predicates",
"!=",
"null",
")",
"{",
"logger",
".",
"warn",
"(",
"m",
"+",
"\" predicates are deprecated; will be ignored\"",
")",
";",
"}",
"assertInvalid",
"(",
")",
";",
"if",
"(",
"errorMessage",
"!=",
"null",
")",
"{",
"logger",
".",
"error",
"(",
"m",
"+",
"\"errorMessage==\"",
"+",
"errorMessage",
")",
";",
"throw",
"new",
"Exception",
"(",
"errorMessage",
")",
";",
"}",
"else",
"{",
"validate",
"(",
"authenticated",
",",
"map",
")",
";",
"// can't set expiration here -- don't have cache reference",
"// can't set pwd here, don't have it",
"}",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"logger",
".",
"error",
"(",
"m",
"+",
"\"invalidating to be sure\"",
")",
";",
"this",
".",
"invalidate",
"(",
"errorMessage",
")",
";",
"}",
"finally",
"{",
"logger",
".",
"debug",
"(",
"\"{}<\"",
",",
"m",
")",
";",
"}",
"}"
] |
Populates this cache element with the given authenticated state
and named values, then puts it in the valid state.
Note: Prior to the call, the element must be in the invalid state.
TODO: The predicates parameter is deprecated and should be removed.
For now, callers can avoid a warning by giving it as null.
|
[
"Populates",
"this",
"cache",
"element",
"with",
"the",
"given",
"authenticated",
"state",
"and",
"named",
"values",
"then",
"puts",
"it",
"in",
"the",
"valid",
"state",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/security/servletfilters/CacheElement.java#L80-L105
|
8,894 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/journal/recoverylog/JournalRecoveryLog.java
|
JournalRecoveryLog.getInstance
|
public static JournalRecoveryLog getInstance(Map<String, String> parameters,
String role,
ServerInterface server)
throws ModuleInitializationException {
try {
Object recoveryLog =
JournalHelper
.createInstanceAccordingToParameter(PARAMETER_JOURNAL_RECOVERY_LOG_CLASSNAME,
new Class[] {
Map.class,
String.class,
ServerInterface.class},
new Object[] {
parameters,
role,
server},
parameters);
logger.info("JournalRecoveryLog is " + recoveryLog.toString());
return (JournalRecoveryLog) recoveryLog;
} catch (JournalException e) {
throw new ModuleInitializationException("Can't create JournalRecoveryLog",
role,
e);
}
}
|
java
|
public static JournalRecoveryLog getInstance(Map<String, String> parameters,
String role,
ServerInterface server)
throws ModuleInitializationException {
try {
Object recoveryLog =
JournalHelper
.createInstanceAccordingToParameter(PARAMETER_JOURNAL_RECOVERY_LOG_CLASSNAME,
new Class[] {
Map.class,
String.class,
ServerInterface.class},
new Object[] {
parameters,
role,
server},
parameters);
logger.info("JournalRecoveryLog is " + recoveryLog.toString());
return (JournalRecoveryLog) recoveryLog;
} catch (JournalException e) {
throw new ModuleInitializationException("Can't create JournalRecoveryLog",
role,
e);
}
}
|
[
"public",
"static",
"JournalRecoveryLog",
"getInstance",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"parameters",
",",
"String",
"role",
",",
"ServerInterface",
"server",
")",
"throws",
"ModuleInitializationException",
"{",
"try",
"{",
"Object",
"recoveryLog",
"=",
"JournalHelper",
".",
"createInstanceAccordingToParameter",
"(",
"PARAMETER_JOURNAL_RECOVERY_LOG_CLASSNAME",
",",
"new",
"Class",
"[",
"]",
"{",
"Map",
".",
"class",
",",
"String",
".",
"class",
",",
"ServerInterface",
".",
"class",
"}",
",",
"new",
"Object",
"[",
"]",
"{",
"parameters",
",",
"role",
",",
"server",
"}",
",",
"parameters",
")",
";",
"logger",
".",
"info",
"(",
"\"JournalRecoveryLog is \"",
"+",
"recoveryLog",
".",
"toString",
"(",
")",
")",
";",
"return",
"(",
"JournalRecoveryLog",
")",
"recoveryLog",
";",
"}",
"catch",
"(",
"JournalException",
"e",
")",
"{",
"throw",
"new",
"ModuleInitializationException",
"(",
"\"Can't create JournalRecoveryLog\"",
",",
"role",
",",
"e",
")",
";",
"}",
"}"
] |
Create an instance of the proper JournalRecoveryLog child class, as
determined by the server parameters.
|
[
"Create",
"an",
"instance",
"of",
"the",
"proper",
"JournalRecoveryLog",
"child",
"class",
"as",
"determined",
"by",
"the",
"server",
"parameters",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/recoverylog/JournalRecoveryLog.java#L50-L75
|
8,895 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/journal/recoverylog/JournalRecoveryLog.java
|
JournalRecoveryLog.logHeaderInfo
|
public void logHeaderInfo(Map<String, String> parameters) {
StringBuffer buffer = new StringBuffer("Recovery parameters:");
for (Iterator<String> keys = parameters.keySet().iterator(); keys
.hasNext();) {
Object key = keys.next();
Object value = parameters.get(key);
buffer.append("\n ").append(key).append("=").append(value);
}
log(buffer.toString());
}
|
java
|
public void logHeaderInfo(Map<String, String> parameters) {
StringBuffer buffer = new StringBuffer("Recovery parameters:");
for (Iterator<String> keys = parameters.keySet().iterator(); keys
.hasNext();) {
Object key = keys.next();
Object value = parameters.get(key);
buffer.append("\n ").append(key).append("=").append(value);
}
log(buffer.toString());
}
|
[
"public",
"void",
"logHeaderInfo",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"parameters",
")",
"{",
"StringBuffer",
"buffer",
"=",
"new",
"StringBuffer",
"(",
"\"Recovery parameters:\"",
")",
";",
"for",
"(",
"Iterator",
"<",
"String",
">",
"keys",
"=",
"parameters",
".",
"keySet",
"(",
")",
".",
"iterator",
"(",
")",
";",
"keys",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"Object",
"key",
"=",
"keys",
".",
"next",
"(",
")",
";",
"Object",
"value",
"=",
"parameters",
".",
"get",
"(",
"key",
")",
";",
"buffer",
".",
"append",
"(",
"\"\\n \"",
")",
".",
"append",
"(",
"key",
")",
".",
"append",
"(",
"\"=\"",
")",
".",
"append",
"(",
"value",
")",
";",
"}",
"log",
"(",
"buffer",
".",
"toString",
"(",
")",
")",
";",
"}"
] |
Concrete sub-classes should call this method from their constructor, or
as soon as the log is ready for writing.
|
[
"Concrete",
"sub",
"-",
"classes",
"should",
"call",
"this",
"method",
"from",
"their",
"constructor",
"or",
"as",
"soon",
"as",
"the",
"log",
"is",
"ready",
"for",
"writing",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/recoverylog/JournalRecoveryLog.java#L129-L138
|
8,896 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/journal/recoverylog/JournalRecoveryLog.java
|
JournalRecoveryLog.log
|
public void log(ConsumerJournalEntry journalEntry) {
StringBuffer buffer = new StringBuffer();
buffer.append("Event: method='").append(journalEntry.getMethodName())
.append("', ").append(journalEntry.getIdentifier())
.append("\n");
if (logLevel == LEVEL_HIGH) {
JournalEntryContext context = journalEntry.getContext();
buffer.append(" context=").append(context.getClass().getName())
.append("\n");
buffer.append(writeMapValues("environmentAttributes", context
.getEnvironmentAttributes()));
buffer.append(writeMapValues("subjectAttributes", context
.getSubjectAttributes()));
buffer.append(writeMapValues("actionAttributes", context
.getActionAttributes()));
buffer.append(writeMapValues("resourceAttributes", context
.getResourceAttributes()));
buffer.append(writeMapValues("recoveryAttributes", context
.getRecoveryAttributes()));
buffer.append(" password='*********'\n");
buffer.append(" noOp=").append(context.getNoOp())
.append("\n");
}
if (logLevel == LEVEL_HIGH || logLevel == LEVEL_MEDIUM) {
buffer.append(" now=" + journalEntry.getContext().getNoOp()
+ "\n");
buffer.append(" arguments\n");
Map<String, Object> argumentsMap = journalEntry.getArgumentsMap();
for (Iterator<String> names = argumentsMap.keySet().iterator(); names
.hasNext();) {
String name = names.next();
Object value = argumentsMap.get(name);
if (value instanceof String[]) {
buffer.append(writeStringArray(name, (String[]) value));
} else {
buffer.append(" " + name + "='" + value + "'\n");
}
}
}
log(buffer.toString());
}
|
java
|
public void log(ConsumerJournalEntry journalEntry) {
StringBuffer buffer = new StringBuffer();
buffer.append("Event: method='").append(journalEntry.getMethodName())
.append("', ").append(journalEntry.getIdentifier())
.append("\n");
if (logLevel == LEVEL_HIGH) {
JournalEntryContext context = journalEntry.getContext();
buffer.append(" context=").append(context.getClass().getName())
.append("\n");
buffer.append(writeMapValues("environmentAttributes", context
.getEnvironmentAttributes()));
buffer.append(writeMapValues("subjectAttributes", context
.getSubjectAttributes()));
buffer.append(writeMapValues("actionAttributes", context
.getActionAttributes()));
buffer.append(writeMapValues("resourceAttributes", context
.getResourceAttributes()));
buffer.append(writeMapValues("recoveryAttributes", context
.getRecoveryAttributes()));
buffer.append(" password='*********'\n");
buffer.append(" noOp=").append(context.getNoOp())
.append("\n");
}
if (logLevel == LEVEL_HIGH || logLevel == LEVEL_MEDIUM) {
buffer.append(" now=" + journalEntry.getContext().getNoOp()
+ "\n");
buffer.append(" arguments\n");
Map<String, Object> argumentsMap = journalEntry.getArgumentsMap();
for (Iterator<String> names = argumentsMap.keySet().iterator(); names
.hasNext();) {
String name = names.next();
Object value = argumentsMap.get(name);
if (value instanceof String[]) {
buffer.append(writeStringArray(name, (String[]) value));
} else {
buffer.append(" " + name + "='" + value + "'\n");
}
}
}
log(buffer.toString());
}
|
[
"public",
"void",
"log",
"(",
"ConsumerJournalEntry",
"journalEntry",
")",
"{",
"StringBuffer",
"buffer",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"buffer",
".",
"append",
"(",
"\"Event: method='\"",
")",
".",
"append",
"(",
"journalEntry",
".",
"getMethodName",
"(",
")",
")",
".",
"append",
"(",
"\"', \"",
")",
".",
"append",
"(",
"journalEntry",
".",
"getIdentifier",
"(",
")",
")",
".",
"append",
"(",
"\"\\n\"",
")",
";",
"if",
"(",
"logLevel",
"==",
"LEVEL_HIGH",
")",
"{",
"JournalEntryContext",
"context",
"=",
"journalEntry",
".",
"getContext",
"(",
")",
";",
"buffer",
".",
"append",
"(",
"\" context=\"",
")",
".",
"append",
"(",
"context",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
")",
".",
"append",
"(",
"\"\\n\"",
")",
";",
"buffer",
".",
"append",
"(",
"writeMapValues",
"(",
"\"environmentAttributes\"",
",",
"context",
".",
"getEnvironmentAttributes",
"(",
")",
")",
")",
";",
"buffer",
".",
"append",
"(",
"writeMapValues",
"(",
"\"subjectAttributes\"",
",",
"context",
".",
"getSubjectAttributes",
"(",
")",
")",
")",
";",
"buffer",
".",
"append",
"(",
"writeMapValues",
"(",
"\"actionAttributes\"",
",",
"context",
".",
"getActionAttributes",
"(",
")",
")",
")",
";",
"buffer",
".",
"append",
"(",
"writeMapValues",
"(",
"\"resourceAttributes\"",
",",
"context",
".",
"getResourceAttributes",
"(",
")",
")",
")",
";",
"buffer",
".",
"append",
"(",
"writeMapValues",
"(",
"\"recoveryAttributes\"",
",",
"context",
".",
"getRecoveryAttributes",
"(",
")",
")",
")",
";",
"buffer",
".",
"append",
"(",
"\" password='*********'\\n\"",
")",
";",
"buffer",
".",
"append",
"(",
"\" noOp=\"",
")",
".",
"append",
"(",
"context",
".",
"getNoOp",
"(",
")",
")",
".",
"append",
"(",
"\"\\n\"",
")",
";",
"}",
"if",
"(",
"logLevel",
"==",
"LEVEL_HIGH",
"||",
"logLevel",
"==",
"LEVEL_MEDIUM",
")",
"{",
"buffer",
".",
"append",
"(",
"\" now=\"",
"+",
"journalEntry",
".",
"getContext",
"(",
")",
".",
"getNoOp",
"(",
")",
"+",
"\"\\n\"",
")",
";",
"buffer",
".",
"append",
"(",
"\" arguments\\n\"",
")",
";",
"Map",
"<",
"String",
",",
"Object",
">",
"argumentsMap",
"=",
"journalEntry",
".",
"getArgumentsMap",
"(",
")",
";",
"for",
"(",
"Iterator",
"<",
"String",
">",
"names",
"=",
"argumentsMap",
".",
"keySet",
"(",
")",
".",
"iterator",
"(",
")",
";",
"names",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"String",
"name",
"=",
"names",
".",
"next",
"(",
")",
";",
"Object",
"value",
"=",
"argumentsMap",
".",
"get",
"(",
"name",
")",
";",
"if",
"(",
"value",
"instanceof",
"String",
"[",
"]",
")",
"{",
"buffer",
".",
"append",
"(",
"writeStringArray",
"(",
"name",
",",
"(",
"String",
"[",
"]",
")",
"value",
")",
")",
";",
"}",
"else",
"{",
"buffer",
".",
"append",
"(",
"\" \"",
"+",
"name",
"+",
"\"='\"",
"+",
"value",
"+",
"\"'\\n\"",
")",
";",
"}",
"}",
"}",
"log",
"(",
"buffer",
".",
"toString",
"(",
")",
")",
";",
"}"
] |
Format a journal entry for writing to the logger. Take logging level into
account.
|
[
"Format",
"a",
"journal",
"entry",
"for",
"writing",
"to",
"the",
"logger",
".",
"Take",
"logging",
"level",
"into",
"account",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/recoverylog/JournalRecoveryLog.java#L144-L184
|
8,897 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/journal/recoverylog/JournalRecoveryLog.java
|
JournalRecoveryLog.log
|
protected void log(String message, Writer writer) {
try {
writer.write(JournalHelper.formatDate(new Date()) + ": " + message
+ "\n");
} catch (IOException e) {
logger.error("Error writing journal log entry", e);
}
}
|
java
|
protected void log(String message, Writer writer) {
try {
writer.write(JournalHelper.formatDate(new Date()) + ": " + message
+ "\n");
} catch (IOException e) {
logger.error("Error writing journal log entry", e);
}
}
|
[
"protected",
"void",
"log",
"(",
"String",
"message",
",",
"Writer",
"writer",
")",
"{",
"try",
"{",
"writer",
".",
"write",
"(",
"JournalHelper",
".",
"formatDate",
"(",
"new",
"Date",
"(",
")",
")",
"+",
"\": \"",
"+",
"message",
"+",
"\"\\n\"",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Error writing journal log entry\"",
",",
"e",
")",
";",
"}",
"}"
] |
Concrete sub-classes call this method to perform the final formatting if
a log entry.
|
[
"Concrete",
"sub",
"-",
"classes",
"call",
"this",
"method",
"to",
"perform",
"the",
"final",
"formatting",
"if",
"a",
"log",
"entry",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/recoverylog/JournalRecoveryLog.java#L225-L232
|
8,898 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/rest/DatastreamFilenameHelper.java
|
DatastreamFilenameHelper.getExtension
|
private static final String getExtension(String MIMETYPE) throws Exception {
if (m_extensionMappings == null) {
m_extensionMappings = readExtensionMappings(Server.FEDORA_HOME + "/server/" + Server.CONFIG_DIR + "/" + DATASTREAM_MAPPING_SOURCE_FILE);
}
String extension = m_extensionMappings.get(MIMETYPE);
if (extension != null) {
return extension;
} else {
return "";
}
}
|
java
|
private static final String getExtension(String MIMETYPE) throws Exception {
if (m_extensionMappings == null) {
m_extensionMappings = readExtensionMappings(Server.FEDORA_HOME + "/server/" + Server.CONFIG_DIR + "/" + DATASTREAM_MAPPING_SOURCE_FILE);
}
String extension = m_extensionMappings.get(MIMETYPE);
if (extension != null) {
return extension;
} else {
return "";
}
}
|
[
"private",
"static",
"final",
"String",
"getExtension",
"(",
"String",
"MIMETYPE",
")",
"throws",
"Exception",
"{",
"if",
"(",
"m_extensionMappings",
"==",
"null",
")",
"{",
"m_extensionMappings",
"=",
"readExtensionMappings",
"(",
"Server",
".",
"FEDORA_HOME",
"+",
"\"/server/\"",
"+",
"Server",
".",
"CONFIG_DIR",
"+",
"\"/\"",
"+",
"DATASTREAM_MAPPING_SOURCE_FILE",
")",
";",
"}",
"String",
"extension",
"=",
"m_extensionMappings",
".",
"get",
"(",
"MIMETYPE",
")",
";",
"if",
"(",
"extension",
"!=",
"null",
")",
"{",
"return",
"extension",
";",
"}",
"else",
"{",
"return",
"\"\"",
";",
"}",
"}"
] |
Get the file extension for a given MIMETYPE from the extensions mappings
@param MIMETYPE
@return
@throws Exception
|
[
"Get",
"the",
"file",
"extension",
"for",
"a",
"given",
"MIMETYPE",
"from",
"the",
"extensions",
"mappings"
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/rest/DatastreamFilenameHelper.java#L104-L115
|
8,899 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/rest/DatastreamFilenameHelper.java
|
DatastreamFilenameHelper.readExtensionMappings
|
private static synchronized final HashMap<String, String> readExtensionMappings(String mappingFile) throws Exception {
HashMap<String, String> extensionMappings = new HashMap<String, String>();
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
Document doc = factory.newDocumentBuilder().parse(new File(mappingFile));
Element root = doc.getDocumentElement();
// "mime-mapping" elements are children of root
NodeList mappingNodes = root.getChildNodes();
for (int i = 0; i < mappingNodes.getLength(); i++) {
Node mappingNode = mappingNodes.item(i);
// check it's a mime-mapping element
if (mappingNode.getNodeType() == Node.ELEMENT_NODE && mappingNode.getNodeName().equals("mime-mapping")) {
// look for child elements "extension" and "mime-type" and get values from text nodes
String extension = null;
String mimeType = null;
NodeList nl = mappingNode.getChildNodes();
for (int j = 0; j < nl.getLength(); j++) {
Node n = nl.item(j);
if (n.getNodeType() == Node.ELEMENT_NODE) {
// assuming here that extension and mime-type nodes only have text content (no attrs etc)
if (n.getNodeName().equals("extension")) {
extension = n.getFirstChild().getNodeValue();
} else {
if (n.getNodeName().equals("mime-type")) {
mimeType = n.getFirstChild().getNodeValue();
}
}
}
}
// if we've got an extension and mime-type, and it's not in the list, add it.
if (extension != null && mimeType != null) {
if (!extensionMappings.containsKey(mimeType)) {
extensionMappings.put(mimeType, extension);
} else {
logger.warn("Duplicate extension " + extension + " found for mime-type " + mimeType + " in " + mappingFile);
}
} else {
logger.warn("Element mime-mapping is missing child elements mime-type and/or extension in " + mappingFile);
}
}
}
return extensionMappings;
}
|
java
|
private static synchronized final HashMap<String, String> readExtensionMappings(String mappingFile) throws Exception {
HashMap<String, String> extensionMappings = new HashMap<String, String>();
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
Document doc = factory.newDocumentBuilder().parse(new File(mappingFile));
Element root = doc.getDocumentElement();
// "mime-mapping" elements are children of root
NodeList mappingNodes = root.getChildNodes();
for (int i = 0; i < mappingNodes.getLength(); i++) {
Node mappingNode = mappingNodes.item(i);
// check it's a mime-mapping element
if (mappingNode.getNodeType() == Node.ELEMENT_NODE && mappingNode.getNodeName().equals("mime-mapping")) {
// look for child elements "extension" and "mime-type" and get values from text nodes
String extension = null;
String mimeType = null;
NodeList nl = mappingNode.getChildNodes();
for (int j = 0; j < nl.getLength(); j++) {
Node n = nl.item(j);
if (n.getNodeType() == Node.ELEMENT_NODE) {
// assuming here that extension and mime-type nodes only have text content (no attrs etc)
if (n.getNodeName().equals("extension")) {
extension = n.getFirstChild().getNodeValue();
} else {
if (n.getNodeName().equals("mime-type")) {
mimeType = n.getFirstChild().getNodeValue();
}
}
}
}
// if we've got an extension and mime-type, and it's not in the list, add it.
if (extension != null && mimeType != null) {
if (!extensionMappings.containsKey(mimeType)) {
extensionMappings.put(mimeType, extension);
} else {
logger.warn("Duplicate extension " + extension + " found for mime-type " + mimeType + " in " + mappingFile);
}
} else {
logger.warn("Element mime-mapping is missing child elements mime-type and/or extension in " + mappingFile);
}
}
}
return extensionMappings;
}
|
[
"private",
"static",
"synchronized",
"final",
"HashMap",
"<",
"String",
",",
"String",
">",
"readExtensionMappings",
"(",
"String",
"mappingFile",
")",
"throws",
"Exception",
"{",
"HashMap",
"<",
"String",
",",
"String",
">",
"extensionMappings",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"DocumentBuilderFactory",
"factory",
"=",
"DocumentBuilderFactory",
".",
"newInstance",
"(",
")",
";",
"Document",
"doc",
"=",
"factory",
".",
"newDocumentBuilder",
"(",
")",
".",
"parse",
"(",
"new",
"File",
"(",
"mappingFile",
")",
")",
";",
"Element",
"root",
"=",
"doc",
".",
"getDocumentElement",
"(",
")",
";",
"// \"mime-mapping\" elements are children of root",
"NodeList",
"mappingNodes",
"=",
"root",
".",
"getChildNodes",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"mappingNodes",
".",
"getLength",
"(",
")",
";",
"i",
"++",
")",
"{",
"Node",
"mappingNode",
"=",
"mappingNodes",
".",
"item",
"(",
"i",
")",
";",
"// check it's a mime-mapping element",
"if",
"(",
"mappingNode",
".",
"getNodeType",
"(",
")",
"==",
"Node",
".",
"ELEMENT_NODE",
"&&",
"mappingNode",
".",
"getNodeName",
"(",
")",
".",
"equals",
"(",
"\"mime-mapping\"",
")",
")",
"{",
"// look for child elements \"extension\" and \"mime-type\" and get values from text nodes",
"String",
"extension",
"=",
"null",
";",
"String",
"mimeType",
"=",
"null",
";",
"NodeList",
"nl",
"=",
"mappingNode",
".",
"getChildNodes",
"(",
")",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"nl",
".",
"getLength",
"(",
")",
";",
"j",
"++",
")",
"{",
"Node",
"n",
"=",
"nl",
".",
"item",
"(",
"j",
")",
";",
"if",
"(",
"n",
".",
"getNodeType",
"(",
")",
"==",
"Node",
".",
"ELEMENT_NODE",
")",
"{",
"// assuming here that extension and mime-type nodes only have text content (no attrs etc)",
"if",
"(",
"n",
".",
"getNodeName",
"(",
")",
".",
"equals",
"(",
"\"extension\"",
")",
")",
"{",
"extension",
"=",
"n",
".",
"getFirstChild",
"(",
")",
".",
"getNodeValue",
"(",
")",
";",
"}",
"else",
"{",
"if",
"(",
"n",
".",
"getNodeName",
"(",
")",
".",
"equals",
"(",
"\"mime-type\"",
")",
")",
"{",
"mimeType",
"=",
"n",
".",
"getFirstChild",
"(",
")",
".",
"getNodeValue",
"(",
")",
";",
"}",
"}",
"}",
"}",
"// if we've got an extension and mime-type, and it's not in the list, add it.",
"if",
"(",
"extension",
"!=",
"null",
"&&",
"mimeType",
"!=",
"null",
")",
"{",
"if",
"(",
"!",
"extensionMappings",
".",
"containsKey",
"(",
"mimeType",
")",
")",
"{",
"extensionMappings",
".",
"put",
"(",
"mimeType",
",",
"extension",
")",
";",
"}",
"else",
"{",
"logger",
".",
"warn",
"(",
"\"Duplicate extension \"",
"+",
"extension",
"+",
"\" found for mime-type \"",
"+",
"mimeType",
"+",
"\" in \"",
"+",
"mappingFile",
")",
";",
"}",
"}",
"else",
"{",
"logger",
".",
"warn",
"(",
"\"Element mime-mapping is missing child elements mime-type and/or extension in \"",
"+",
"mappingFile",
")",
";",
"}",
"}",
"}",
"return",
"extensionMappings",
";",
"}"
] |
Read the extensions mappings from config file
@returns new HashMap of mime-types to extensions mappings
@throws Exception
|
[
"Read",
"the",
"extensions",
"mappings",
"from",
"config",
"file"
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/rest/DatastreamFilenameHelper.java#L123-L166
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.