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,900 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/rest/DatastreamFilenameHelper.java
|
DatastreamFilenameHelper.addContentDispositionHeader
|
public final void addContentDispositionHeader(Context context, String pid, String dsID, String download, Date asOfDateTime, MIMETypedStream stream) throws Exception {
String headerValue = null;
String filename = null;
// is downloading requested?
if (download != null && download.equals("true")) {
// generate an "attachment" content disposition header with the filename
filename = getFilename(context, pid, dsID, asOfDateTime, stream.getMIMEType());
headerValue= attachmentHeader(filename);
} else {
// is the content disposition header enabled in the case of not downloading?
if (m_datastreamContentDispositionInlineEnabled.equals("true")) {
// it is... generate the header with "inline"
filename = getFilename(context, pid, dsID, asOfDateTime, stream.getMIMEType());
headerValue= inlineHeader(filename);
}
}
// create content disposition header to add
Property[] header = { new Property ("content-disposition", headerValue) };
// add header to existing headers if present, or set this as the new header if not
if (stream.header != null) {
Property headers[] = new Property[stream.header.length + 1];
System.arraycopy(stream.header, 0, headers, 0, stream.header.length);
headers[headers.length - 1] = header[0];
stream.header = headers;
} else {
stream.header = header;
}
}
|
java
|
public final void addContentDispositionHeader(Context context, String pid, String dsID, String download, Date asOfDateTime, MIMETypedStream stream) throws Exception {
String headerValue = null;
String filename = null;
// is downloading requested?
if (download != null && download.equals("true")) {
// generate an "attachment" content disposition header with the filename
filename = getFilename(context, pid, dsID, asOfDateTime, stream.getMIMEType());
headerValue= attachmentHeader(filename);
} else {
// is the content disposition header enabled in the case of not downloading?
if (m_datastreamContentDispositionInlineEnabled.equals("true")) {
// it is... generate the header with "inline"
filename = getFilename(context, pid, dsID, asOfDateTime, stream.getMIMEType());
headerValue= inlineHeader(filename);
}
}
// create content disposition header to add
Property[] header = { new Property ("content-disposition", headerValue) };
// add header to existing headers if present, or set this as the new header if not
if (stream.header != null) {
Property headers[] = new Property[stream.header.length + 1];
System.arraycopy(stream.header, 0, headers, 0, stream.header.length);
headers[headers.length - 1] = header[0];
stream.header = headers;
} else {
stream.header = header;
}
}
|
[
"public",
"final",
"void",
"addContentDispositionHeader",
"(",
"Context",
"context",
",",
"String",
"pid",
",",
"String",
"dsID",
",",
"String",
"download",
",",
"Date",
"asOfDateTime",
",",
"MIMETypedStream",
"stream",
")",
"throws",
"Exception",
"{",
"String",
"headerValue",
"=",
"null",
";",
"String",
"filename",
"=",
"null",
";",
"// is downloading requested?",
"if",
"(",
"download",
"!=",
"null",
"&&",
"download",
".",
"equals",
"(",
"\"true\"",
")",
")",
"{",
"// generate an \"attachment\" content disposition header with the filename",
"filename",
"=",
"getFilename",
"(",
"context",
",",
"pid",
",",
"dsID",
",",
"asOfDateTime",
",",
"stream",
".",
"getMIMEType",
"(",
")",
")",
";",
"headerValue",
"=",
"attachmentHeader",
"(",
"filename",
")",
";",
"}",
"else",
"{",
"// is the content disposition header enabled in the case of not downloading?",
"if",
"(",
"m_datastreamContentDispositionInlineEnabled",
".",
"equals",
"(",
"\"true\"",
")",
")",
"{",
"// it is... generate the header with \"inline\"",
"filename",
"=",
"getFilename",
"(",
"context",
",",
"pid",
",",
"dsID",
",",
"asOfDateTime",
",",
"stream",
".",
"getMIMEType",
"(",
")",
")",
";",
"headerValue",
"=",
"inlineHeader",
"(",
"filename",
")",
";",
"}",
"}",
"// create content disposition header to add",
"Property",
"[",
"]",
"header",
"=",
"{",
"new",
"Property",
"(",
"\"content-disposition\"",
",",
"headerValue",
")",
"}",
";",
"// add header to existing headers if present, or set this as the new header if not",
"if",
"(",
"stream",
".",
"header",
"!=",
"null",
")",
"{",
"Property",
"headers",
"[",
"]",
"=",
"new",
"Property",
"[",
"stream",
".",
"header",
".",
"length",
"+",
"1",
"]",
";",
"System",
".",
"arraycopy",
"(",
"stream",
".",
"header",
",",
"0",
",",
"headers",
",",
"0",
",",
"stream",
".",
"header",
".",
"length",
")",
";",
"headers",
"[",
"headers",
".",
"length",
"-",
"1",
"]",
"=",
"header",
"[",
"0",
"]",
";",
"stream",
".",
"header",
"=",
"headers",
";",
"}",
"else",
"{",
"stream",
".",
"header",
"=",
"header",
";",
"}",
"}"
] |
Add a content disposition header to a MIMETypedStream based on configuration preferences.
Header by default specifies "inline"; if download=true then "attachment" is specified.
@param context
@param pid
@param dsID
@param download
true if file is to be downloaded
@param asOfDateTime
@param stream
@throws Exception
|
[
"Add",
"a",
"content",
"disposition",
"header",
"to",
"a",
"MIMETypedStream",
"based",
"on",
"configuration",
"preferences",
".",
"Header",
"by",
"default",
"specifies",
"inline",
";",
"if",
"download",
"=",
"true",
"then",
"attachment",
"is",
"specified",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/rest/DatastreamFilenameHelper.java#L181-L210
|
8,901 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/rest/DatastreamFilenameHelper.java
|
DatastreamFilenameHelper.getFilename
|
private final String getFilename(Context context, String pid, String dsid, Date asOfDateTime, String MIMETYPE) throws Exception {
String filename = "";
String extension = "";
// check sources in order
for (String source : m_datastreamFilenameSource.split(" ")) {
// try and get filename and extension from specified source
if (source.equals("rels")) {
filename = getFilenameFromRels(context, pid, dsid, MIMETYPE);
if (!filename.isEmpty())
extension = getExtension(filename, m_datastreamExtensionMappingRels, MIMETYPE);
} else {
if (source.equals("id")) {
filename = getFilenameFromId(pid, dsid, MIMETYPE);
if (!filename.isEmpty())
extension = getExtension(filename, m_datastreamExtensionMappingId, MIMETYPE);
} else {
if (source.equals("label")) {
filename = getFilenameFromLabel(context, pid, dsid, asOfDateTime, MIMETYPE);
if (!filename.isEmpty())
extension = getExtension(filename, m_datastreamExtensionMappingLabel, MIMETYPE);
} else {
logger.warn("Unknown datastream filename source specified in datastreamFilenameSource in fedora.fcfg: " + source + ". Please specify zero or more of: rels id label");
}
}
}
// if we've got one by here, quit loop
if (!filename.isEmpty())
break;
}
// if not determined from above use the default
if (filename.isEmpty()) {
filename = m_datastreamDefaultFilename;
extension = getExtension(m_datastreamDefaultFilename, m_datastreamExtensionMappingDefault, MIMETYPE);
}
// clean up filename - remove illegal chars
if (extension.isEmpty()) {
return ILLEGAL_FILENAME_REGEX.matcher(filename).replaceAll("");
} else {
return ILLEGAL_FILENAME_REGEX.matcher(filename + "." + extension).replaceAll("");
}
}
|
java
|
private final String getFilename(Context context, String pid, String dsid, Date asOfDateTime, String MIMETYPE) throws Exception {
String filename = "";
String extension = "";
// check sources in order
for (String source : m_datastreamFilenameSource.split(" ")) {
// try and get filename and extension from specified source
if (source.equals("rels")) {
filename = getFilenameFromRels(context, pid, dsid, MIMETYPE);
if (!filename.isEmpty())
extension = getExtension(filename, m_datastreamExtensionMappingRels, MIMETYPE);
} else {
if (source.equals("id")) {
filename = getFilenameFromId(pid, dsid, MIMETYPE);
if (!filename.isEmpty())
extension = getExtension(filename, m_datastreamExtensionMappingId, MIMETYPE);
} else {
if (source.equals("label")) {
filename = getFilenameFromLabel(context, pid, dsid, asOfDateTime, MIMETYPE);
if (!filename.isEmpty())
extension = getExtension(filename, m_datastreamExtensionMappingLabel, MIMETYPE);
} else {
logger.warn("Unknown datastream filename source specified in datastreamFilenameSource in fedora.fcfg: " + source + ". Please specify zero or more of: rels id label");
}
}
}
// if we've got one by here, quit loop
if (!filename.isEmpty())
break;
}
// if not determined from above use the default
if (filename.isEmpty()) {
filename = m_datastreamDefaultFilename;
extension = getExtension(m_datastreamDefaultFilename, m_datastreamExtensionMappingDefault, MIMETYPE);
}
// clean up filename - remove illegal chars
if (extension.isEmpty()) {
return ILLEGAL_FILENAME_REGEX.matcher(filename).replaceAll("");
} else {
return ILLEGAL_FILENAME_REGEX.matcher(filename + "." + extension).replaceAll("");
}
}
|
[
"private",
"final",
"String",
"getFilename",
"(",
"Context",
"context",
",",
"String",
"pid",
",",
"String",
"dsid",
",",
"Date",
"asOfDateTime",
",",
"String",
"MIMETYPE",
")",
"throws",
"Exception",
"{",
"String",
"filename",
"=",
"\"\"",
";",
"String",
"extension",
"=",
"\"\"",
";",
"// check sources in order",
"for",
"(",
"String",
"source",
":",
"m_datastreamFilenameSource",
".",
"split",
"(",
"\" \"",
")",
")",
"{",
"// try and get filename and extension from specified source",
"if",
"(",
"source",
".",
"equals",
"(",
"\"rels\"",
")",
")",
"{",
"filename",
"=",
"getFilenameFromRels",
"(",
"context",
",",
"pid",
",",
"dsid",
",",
"MIMETYPE",
")",
";",
"if",
"(",
"!",
"filename",
".",
"isEmpty",
"(",
")",
")",
"extension",
"=",
"getExtension",
"(",
"filename",
",",
"m_datastreamExtensionMappingRels",
",",
"MIMETYPE",
")",
";",
"}",
"else",
"{",
"if",
"(",
"source",
".",
"equals",
"(",
"\"id\"",
")",
")",
"{",
"filename",
"=",
"getFilenameFromId",
"(",
"pid",
",",
"dsid",
",",
"MIMETYPE",
")",
";",
"if",
"(",
"!",
"filename",
".",
"isEmpty",
"(",
")",
")",
"extension",
"=",
"getExtension",
"(",
"filename",
",",
"m_datastreamExtensionMappingId",
",",
"MIMETYPE",
")",
";",
"}",
"else",
"{",
"if",
"(",
"source",
".",
"equals",
"(",
"\"label\"",
")",
")",
"{",
"filename",
"=",
"getFilenameFromLabel",
"(",
"context",
",",
"pid",
",",
"dsid",
",",
"asOfDateTime",
",",
"MIMETYPE",
")",
";",
"if",
"(",
"!",
"filename",
".",
"isEmpty",
"(",
")",
")",
"extension",
"=",
"getExtension",
"(",
"filename",
",",
"m_datastreamExtensionMappingLabel",
",",
"MIMETYPE",
")",
";",
"}",
"else",
"{",
"logger",
".",
"warn",
"(",
"\"Unknown datastream filename source specified in datastreamFilenameSource in fedora.fcfg: \"",
"+",
"source",
"+",
"\". Please specify zero or more of: rels id label\"",
")",
";",
"}",
"}",
"}",
"// if we've got one by here, quit loop",
"if",
"(",
"!",
"filename",
".",
"isEmpty",
"(",
")",
")",
"break",
";",
"}",
"// if not determined from above use the default",
"if",
"(",
"filename",
".",
"isEmpty",
"(",
")",
")",
"{",
"filename",
"=",
"m_datastreamDefaultFilename",
";",
"extension",
"=",
"getExtension",
"(",
"m_datastreamDefaultFilename",
",",
"m_datastreamExtensionMappingDefault",
",",
"MIMETYPE",
")",
";",
"}",
"// clean up filename - remove illegal chars",
"if",
"(",
"extension",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"ILLEGAL_FILENAME_REGEX",
".",
"matcher",
"(",
"filename",
")",
".",
"replaceAll",
"(",
"\"\"",
")",
";",
"}",
"else",
"{",
"return",
"ILLEGAL_FILENAME_REGEX",
".",
"matcher",
"(",
"filename",
"+",
"\".\"",
"+",
"extension",
")",
".",
"replaceAll",
"(",
"\"\"",
")",
";",
"}",
"}"
] |
Generate a filename and extension for a datastream based on configuration preferences.
Filename can be based on a definition in RELS-INT, the datastream label or
the datastream ID. These sources can be specified in order of preference together with
using a default filename. The extension is based on a mime-type-to-extension mapping
configuration file; alternatively if the filename determined already includes an extension
that can be specified instead.
@param context
@param pid
@param dsid
@param asOfDateTime
@param MIMETYPE
@return
@throws Exception
|
[
"Generate",
"a",
"filename",
"and",
"extension",
"for",
"a",
"datastream",
"based",
"on",
"configuration",
"preferences",
".",
"Filename",
"can",
"be",
"based",
"on",
"a",
"definition",
"in",
"RELS",
"-",
"INT",
"the",
"datastream",
"label",
"or",
"the",
"datastream",
"ID",
".",
"These",
"sources",
"can",
"be",
"specified",
"in",
"order",
"of",
"preference",
"together",
"with",
"using",
"a",
"default",
"filename",
".",
"The",
"extension",
"is",
"based",
"on",
"a",
"mime",
"-",
"type",
"-",
"to",
"-",
"extension",
"mapping",
"configuration",
"file",
";",
"alternatively",
"if",
"the",
"filename",
"determined",
"already",
"includes",
"an",
"extension",
"that",
"can",
"be",
"specified",
"instead",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/rest/DatastreamFilenameHelper.java#L240-L284
|
8,902 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/rest/DatastreamFilenameHelper.java
|
DatastreamFilenameHelper.getFilenameFromRels
|
private final String getFilenameFromRels(Context context, String pid, String dsid, String MIMETYPE) throws Exception {
String filename = "";
// read rels directly from RELS-INT - can't use Management.getRelationships as this requires auth
DOReader reader = m_doManager.getReader(false, context, pid);
Datastream relsInt = reader.GetDatastream("RELS-INT", null);
if (relsInt == null) return "";
// try {
// relsInt = m_apiAService.getDatastreamDissemination(context, pid, "RELS-INT", null);
// } catch (DatastreamNotFoundException e) {
// return "";
// }
Set<RelationshipTuple> relsIntTuples = RDFRelationshipReader.readRelationships(relsInt.getContentStream());
if (relsIntTuples.size() == 0) return "";
// find the tuple specifying the filename
int matchingTuples = 0;
String dsSubject = Constants.FEDORA.uri + pid + "/" + dsid;
for ( RelationshipTuple tuple : relsIntTuples ) {
if (tuple.subject.equals(dsSubject) && tuple.predicate.equals(FILENAME_REL)) {
// use the first found relationship by default (report warning later if there are more)
if (matchingTuples == 0) {
if (tuple.isLiteral) {
filename = tuple.object;
} else {
logger.warn("Object " + pid + " datastream " + dsid + " specifies a filename which is not a literal in RELS-INT");
filename = "";
}
}
matchingTuples++;
}
}
if (matchingTuples > 1) {
logger.warn("Object " + pid + " datastream " + dsid + " specifies more than one filename in RELS-INT.");
}
return filename;
}
|
java
|
private final String getFilenameFromRels(Context context, String pid, String dsid, String MIMETYPE) throws Exception {
String filename = "";
// read rels directly from RELS-INT - can't use Management.getRelationships as this requires auth
DOReader reader = m_doManager.getReader(false, context, pid);
Datastream relsInt = reader.GetDatastream("RELS-INT", null);
if (relsInt == null) return "";
// try {
// relsInt = m_apiAService.getDatastreamDissemination(context, pid, "RELS-INT", null);
// } catch (DatastreamNotFoundException e) {
// return "";
// }
Set<RelationshipTuple> relsIntTuples = RDFRelationshipReader.readRelationships(relsInt.getContentStream());
if (relsIntTuples.size() == 0) return "";
// find the tuple specifying the filename
int matchingTuples = 0;
String dsSubject = Constants.FEDORA.uri + pid + "/" + dsid;
for ( RelationshipTuple tuple : relsIntTuples ) {
if (tuple.subject.equals(dsSubject) && tuple.predicate.equals(FILENAME_REL)) {
// use the first found relationship by default (report warning later if there are more)
if (matchingTuples == 0) {
if (tuple.isLiteral) {
filename = tuple.object;
} else {
logger.warn("Object " + pid + " datastream " + dsid + " specifies a filename which is not a literal in RELS-INT");
filename = "";
}
}
matchingTuples++;
}
}
if (matchingTuples > 1) {
logger.warn("Object " + pid + " datastream " + dsid + " specifies more than one filename in RELS-INT.");
}
return filename;
}
|
[
"private",
"final",
"String",
"getFilenameFromRels",
"(",
"Context",
"context",
",",
"String",
"pid",
",",
"String",
"dsid",
",",
"String",
"MIMETYPE",
")",
"throws",
"Exception",
"{",
"String",
"filename",
"=",
"\"\"",
";",
"// read rels directly from RELS-INT - can't use Management.getRelationships as this requires auth",
"DOReader",
"reader",
"=",
"m_doManager",
".",
"getReader",
"(",
"false",
",",
"context",
",",
"pid",
")",
";",
"Datastream",
"relsInt",
"=",
"reader",
".",
"GetDatastream",
"(",
"\"RELS-INT\"",
",",
"null",
")",
";",
"if",
"(",
"relsInt",
"==",
"null",
")",
"return",
"\"\"",
";",
"// try {",
"// relsInt = m_apiAService.getDatastreamDissemination(context, pid, \"RELS-INT\", null);",
"// } catch (DatastreamNotFoundException e) {",
"// return \"\";",
"// }",
"Set",
"<",
"RelationshipTuple",
">",
"relsIntTuples",
"=",
"RDFRelationshipReader",
".",
"readRelationships",
"(",
"relsInt",
".",
"getContentStream",
"(",
")",
")",
";",
"if",
"(",
"relsIntTuples",
".",
"size",
"(",
")",
"==",
"0",
")",
"return",
"\"\"",
";",
"// find the tuple specifying the filename",
"int",
"matchingTuples",
"=",
"0",
";",
"String",
"dsSubject",
"=",
"Constants",
".",
"FEDORA",
".",
"uri",
"+",
"pid",
"+",
"\"/\"",
"+",
"dsid",
";",
"for",
"(",
"RelationshipTuple",
"tuple",
":",
"relsIntTuples",
")",
"{",
"if",
"(",
"tuple",
".",
"subject",
".",
"equals",
"(",
"dsSubject",
")",
"&&",
"tuple",
".",
"predicate",
".",
"equals",
"(",
"FILENAME_REL",
")",
")",
"{",
"// use the first found relationship by default (report warning later if there are more)",
"if",
"(",
"matchingTuples",
"==",
"0",
")",
"{",
"if",
"(",
"tuple",
".",
"isLiteral",
")",
"{",
"filename",
"=",
"tuple",
".",
"object",
";",
"}",
"else",
"{",
"logger",
".",
"warn",
"(",
"\"Object \"",
"+",
"pid",
"+",
"\" datastream \"",
"+",
"dsid",
"+",
"\" specifies a filename which is not a literal in RELS-INT\"",
")",
";",
"filename",
"=",
"\"\"",
";",
"}",
"}",
"matchingTuples",
"++",
";",
"}",
"}",
"if",
"(",
"matchingTuples",
">",
"1",
")",
"{",
"logger",
".",
"warn",
"(",
"\"Object \"",
"+",
"pid",
"+",
"\" datastream \"",
"+",
"dsid",
"+",
"\" specifies more than one filename in RELS-INT.\"",
")",
";",
"}",
"return",
"filename",
";",
"}"
] |
Get datastream filename as defined in RELS-INT
@param context
@param pid
@param dsid
@param MIMETYPE
@return
@throws Exception
|
[
"Get",
"datastream",
"filename",
"as",
"defined",
"in",
"RELS",
"-",
"INT"
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/rest/DatastreamFilenameHelper.java#L295-L332
|
8,903 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/rest/DatastreamFilenameHelper.java
|
DatastreamFilenameHelper.getFilenameFromLabel
|
private final String getFilenameFromLabel(Context context, String pid, String dsid, Date asOfDateTime, String MIMETYPE) throws Exception {
// can't get datastream label directly from datastream as this is an API-M call
// instead get list of datastream defs, as these contain labels
DOReader reader = m_doManager.getReader(false, context, pid);
Datastream ds = reader.GetDatastream(dsid, asOfDateTime);
return (ds == null) ? "" : ds.DSLabel;
}
|
java
|
private final String getFilenameFromLabel(Context context, String pid, String dsid, Date asOfDateTime, String MIMETYPE) throws Exception {
// can't get datastream label directly from datastream as this is an API-M call
// instead get list of datastream defs, as these contain labels
DOReader reader = m_doManager.getReader(false, context, pid);
Datastream ds = reader.GetDatastream(dsid, asOfDateTime);
return (ds == null) ? "" : ds.DSLabel;
}
|
[
"private",
"final",
"String",
"getFilenameFromLabel",
"(",
"Context",
"context",
",",
"String",
"pid",
",",
"String",
"dsid",
",",
"Date",
"asOfDateTime",
",",
"String",
"MIMETYPE",
")",
"throws",
"Exception",
"{",
"// can't get datastream label directly from datastream as this is an API-M call",
"// instead get list of datastream defs, as these contain labels",
"DOReader",
"reader",
"=",
"m_doManager",
".",
"getReader",
"(",
"false",
",",
"context",
",",
"pid",
")",
";",
"Datastream",
"ds",
"=",
"reader",
".",
"GetDatastream",
"(",
"dsid",
",",
"asOfDateTime",
")",
";",
"return",
"(",
"ds",
"==",
"null",
")",
"?",
"\"\"",
":",
"ds",
".",
"DSLabel",
";",
"}"
] |
Get filename based on datastream label
@param context
@param pid
@param dsid
@param asOfDateTime
@param MIMETYPE
@return
@throws Exception
|
[
"Get",
"filename",
"based",
"on",
"datastream",
"label"
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/rest/DatastreamFilenameHelper.java#L344-L352
|
8,904 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/rest/DatastreamFilenameHelper.java
|
DatastreamFilenameHelper.getFilenameFromId
|
private static final String getFilenameFromId(String pid, String dsid, String MIMETYPE) throws Exception {
return dsid;
}
|
java
|
private static final String getFilenameFromId(String pid, String dsid, String MIMETYPE) throws Exception {
return dsid;
}
|
[
"private",
"static",
"final",
"String",
"getFilenameFromId",
"(",
"String",
"pid",
",",
"String",
"dsid",
",",
"String",
"MIMETYPE",
")",
"throws",
"Exception",
"{",
"return",
"dsid",
";",
"}"
] |
Get filename from datastream id
@param pid
@param dsid
@param MIMETYPE
@return
@throws Exception
|
[
"Get",
"filename",
"from",
"datastream",
"id"
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/rest/DatastreamFilenameHelper.java#L362-L364
|
8,905 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/utilities/status/ServerStatusFile.java
|
ServerStatusFile.getMessages
|
public synchronized ServerStatusMessage[] getMessages(ServerStatusMessage afterMessage)
throws Exception {
boolean sawAfterMessage;
String afterMessageString = null;
if (afterMessage == null) {
sawAfterMessage = true;
} else {
sawAfterMessage = false;
afterMessageString = afterMessage.toString();
}
FileInputStream in = null;
try {
in = new FileInputStream(_file);
BufferedReader reader =
new BufferedReader(new InputStreamReader(in));
List<ServerStatusMessage> messages =
new ArrayList<ServerStatusMessage>();
ServerStatusMessage message = getNextMessage(reader);
while (message != null) {
if (!sawAfterMessage) {
if (message.toString().equals(afterMessageString)) {
sawAfterMessage = true;
}
} else {
messages.add(message);
}
message = getNextMessage(reader);
}
return messages.toArray(STATUS_MSG_ARRAY_TYPE);
} catch (IOException ioe) {
throw new Exception("Error opening server status file for reading: "
+ _file.getPath(),
ioe);
} finally {
if (in != null) {
try {
in.close();
} catch (Exception e) {
}
}
}
}
|
java
|
public synchronized ServerStatusMessage[] getMessages(ServerStatusMessage afterMessage)
throws Exception {
boolean sawAfterMessage;
String afterMessageString = null;
if (afterMessage == null) {
sawAfterMessage = true;
} else {
sawAfterMessage = false;
afterMessageString = afterMessage.toString();
}
FileInputStream in = null;
try {
in = new FileInputStream(_file);
BufferedReader reader =
new BufferedReader(new InputStreamReader(in));
List<ServerStatusMessage> messages =
new ArrayList<ServerStatusMessage>();
ServerStatusMessage message = getNextMessage(reader);
while (message != null) {
if (!sawAfterMessage) {
if (message.toString().equals(afterMessageString)) {
sawAfterMessage = true;
}
} else {
messages.add(message);
}
message = getNextMessage(reader);
}
return messages.toArray(STATUS_MSG_ARRAY_TYPE);
} catch (IOException ioe) {
throw new Exception("Error opening server status file for reading: "
+ _file.getPath(),
ioe);
} finally {
if (in != null) {
try {
in.close();
} catch (Exception e) {
}
}
}
}
|
[
"public",
"synchronized",
"ServerStatusMessage",
"[",
"]",
"getMessages",
"(",
"ServerStatusMessage",
"afterMessage",
")",
"throws",
"Exception",
"{",
"boolean",
"sawAfterMessage",
";",
"String",
"afterMessageString",
"=",
"null",
";",
"if",
"(",
"afterMessage",
"==",
"null",
")",
"{",
"sawAfterMessage",
"=",
"true",
";",
"}",
"else",
"{",
"sawAfterMessage",
"=",
"false",
";",
"afterMessageString",
"=",
"afterMessage",
".",
"toString",
"(",
")",
";",
"}",
"FileInputStream",
"in",
"=",
"null",
";",
"try",
"{",
"in",
"=",
"new",
"FileInputStream",
"(",
"_file",
")",
";",
"BufferedReader",
"reader",
"=",
"new",
"BufferedReader",
"(",
"new",
"InputStreamReader",
"(",
"in",
")",
")",
";",
"List",
"<",
"ServerStatusMessage",
">",
"messages",
"=",
"new",
"ArrayList",
"<",
"ServerStatusMessage",
">",
"(",
")",
";",
"ServerStatusMessage",
"message",
"=",
"getNextMessage",
"(",
"reader",
")",
";",
"while",
"(",
"message",
"!=",
"null",
")",
"{",
"if",
"(",
"!",
"sawAfterMessage",
")",
"{",
"if",
"(",
"message",
".",
"toString",
"(",
")",
".",
"equals",
"(",
"afterMessageString",
")",
")",
"{",
"sawAfterMessage",
"=",
"true",
";",
"}",
"}",
"else",
"{",
"messages",
".",
"add",
"(",
"message",
")",
";",
"}",
"message",
"=",
"getNextMessage",
"(",
"reader",
")",
";",
"}",
"return",
"messages",
".",
"toArray",
"(",
"STATUS_MSG_ARRAY_TYPE",
")",
";",
"}",
"catch",
"(",
"IOException",
"ioe",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Error opening server status file for reading: \"",
"+",
"_file",
".",
"getPath",
"(",
")",
",",
"ioe",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"in",
"!=",
"null",
")",
"{",
"try",
"{",
"in",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"}",
"}",
"}",
"}"
] |
Get all messages in the status file, or only those after the given
message if it is non-null. If the status file doesn't exist or can't be
parsed, throw an exception.
|
[
"Get",
"all",
"messages",
"in",
"the",
"status",
"file",
"or",
"only",
"those",
"after",
"the",
"given",
"message",
"if",
"it",
"is",
"non",
"-",
"null",
".",
"If",
"the",
"status",
"file",
"doesn",
"t",
"exist",
"or",
"can",
"t",
"be",
"parsed",
"throw",
"an",
"exception",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/utilities/status/ServerStatusFile.java#L143-L191
|
8,906 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/utilities/status/ServerStatusFile.java
|
ServerStatusFile.getNextMessage
|
private ServerStatusMessage getNextMessage(BufferedReader reader)
throws Exception {
boolean messageStarted = false;
String line = reader.readLine();
while (line != null && !messageStarted) {
if (line.equals(BEGIN_LINE)) {
messageStarted = true;
} else {
line = reader.readLine();
}
}
if (messageStarted) {
// get and parse first two required lines
ServerState state = ServerState.fromString(getNextLine(reader));
Date time = ServerStatusMessage.stringToDate(getNextLine(reader));
String detail = null;
// read optional detail lines till END_LINE
line = getNextLine(reader);
if (!line.equals(END_LINE)) {
StringBuffer buf = new StringBuffer();
while (!line.equals(END_LINE)) {
buf.append(line + "\n");
line = getNextLine(reader);
}
detail = buf.toString();
}
return new ServerStatusMessage(state, time, detail);
} else {
return null;
}
}
|
java
|
private ServerStatusMessage getNextMessage(BufferedReader reader)
throws Exception {
boolean messageStarted = false;
String line = reader.readLine();
while (line != null && !messageStarted) {
if (line.equals(BEGIN_LINE)) {
messageStarted = true;
} else {
line = reader.readLine();
}
}
if (messageStarted) {
// get and parse first two required lines
ServerState state = ServerState.fromString(getNextLine(reader));
Date time = ServerStatusMessage.stringToDate(getNextLine(reader));
String detail = null;
// read optional detail lines till END_LINE
line = getNextLine(reader);
if (!line.equals(END_LINE)) {
StringBuffer buf = new StringBuffer();
while (!line.equals(END_LINE)) {
buf.append(line + "\n");
line = getNextLine(reader);
}
detail = buf.toString();
}
return new ServerStatusMessage(state, time, detail);
} else {
return null;
}
}
|
[
"private",
"ServerStatusMessage",
"getNextMessage",
"(",
"BufferedReader",
"reader",
")",
"throws",
"Exception",
"{",
"boolean",
"messageStarted",
"=",
"false",
";",
"String",
"line",
"=",
"reader",
".",
"readLine",
"(",
")",
";",
"while",
"(",
"line",
"!=",
"null",
"&&",
"!",
"messageStarted",
")",
"{",
"if",
"(",
"line",
".",
"equals",
"(",
"BEGIN_LINE",
")",
")",
"{",
"messageStarted",
"=",
"true",
";",
"}",
"else",
"{",
"line",
"=",
"reader",
".",
"readLine",
"(",
")",
";",
"}",
"}",
"if",
"(",
"messageStarted",
")",
"{",
"// get and parse first two required lines",
"ServerState",
"state",
"=",
"ServerState",
".",
"fromString",
"(",
"getNextLine",
"(",
"reader",
")",
")",
";",
"Date",
"time",
"=",
"ServerStatusMessage",
".",
"stringToDate",
"(",
"getNextLine",
"(",
"reader",
")",
")",
";",
"String",
"detail",
"=",
"null",
";",
"// read optional detail lines till END_LINE",
"line",
"=",
"getNextLine",
"(",
"reader",
")",
";",
"if",
"(",
"!",
"line",
".",
"equals",
"(",
"END_LINE",
")",
")",
"{",
"StringBuffer",
"buf",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"while",
"(",
"!",
"line",
".",
"equals",
"(",
"END_LINE",
")",
")",
"{",
"buf",
".",
"append",
"(",
"line",
"+",
"\"\\n\"",
")",
";",
"line",
"=",
"getNextLine",
"(",
"reader",
")",
";",
"}",
"detail",
"=",
"buf",
".",
"toString",
"(",
")",
";",
"}",
"return",
"new",
"ServerStatusMessage",
"(",
"state",
",",
"time",
",",
"detail",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] |
return the next message, or null if there are no more messages in the file
|
[
"return",
"the",
"next",
"message",
"or",
"null",
"if",
"there",
"are",
"no",
"more",
"messages",
"in",
"the",
"file"
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/utilities/status/ServerStatusFile.java#L210-L248
|
8,907 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/utilities/status/ServerStatusFile.java
|
ServerStatusFile.getNextLine
|
private String getNextLine(BufferedReader reader) throws Exception {
String line = reader.readLine();
if (line != null) {
return line;
} else {
throw new Exception("Error parsing server status file (unexpectedly ended): "
+ _file.getPath());
}
}
|
java
|
private String getNextLine(BufferedReader reader) throws Exception {
String line = reader.readLine();
if (line != null) {
return line;
} else {
throw new Exception("Error parsing server status file (unexpectedly ended): "
+ _file.getPath());
}
}
|
[
"private",
"String",
"getNextLine",
"(",
"BufferedReader",
"reader",
")",
"throws",
"Exception",
"{",
"String",
"line",
"=",
"reader",
".",
"readLine",
"(",
")",
";",
"if",
"(",
"line",
"!=",
"null",
")",
"{",
"return",
"line",
";",
"}",
"else",
"{",
"throw",
"new",
"Exception",
"(",
"\"Error parsing server status file (unexpectedly ended): \"",
"+",
"_file",
".",
"getPath",
"(",
")",
")",
";",
"}",
"}"
] |
get the next line or throw an exception if eof was reached
|
[
"get",
"the",
"next",
"line",
"or",
"throw",
"an",
"exception",
"if",
"eof",
"was",
"reached"
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/utilities/status/ServerStatusFile.java#L251-L259
|
8,908 |
fcrepo3/fcrepo
|
fcrepo-security/fcrepo-security-pep/src/main/java/org/fcrepo/server/security/xacml/pep/ResponseCacheImpl.java
|
ResponseCacheImpl.makeHash
|
private String makeHash(String request) throws CacheException {
RequestCtx reqCtx = null;
try {
reqCtx = m_contextUtil.makeRequestCtx(request);
} catch (MelcoeXacmlException pe) {
throw new CacheException("Error converting request", pe);
}
byte[] hash = null;
// ensure thread safety, don't want concurrent invocations of this method all modifying digest at once
// (alternative is to construct a new digest for each(
synchronized(digest) {
digest.reset();
hashSubjectList(reqCtx.getSubjectsAsList(), digest);
hashAttributeList(reqCtx.getResourceAsList(), digest);
hashAttributeList(reqCtx.getActionAsList(), digest);
hashAttributeList(reqCtx.getEnvironmentAttributesAsList(), digest);
hash = digest.digest();
}
return byte2hex(hash);
}
|
java
|
private String makeHash(String request) throws CacheException {
RequestCtx reqCtx = null;
try {
reqCtx = m_contextUtil.makeRequestCtx(request);
} catch (MelcoeXacmlException pe) {
throw new CacheException("Error converting request", pe);
}
byte[] hash = null;
// ensure thread safety, don't want concurrent invocations of this method all modifying digest at once
// (alternative is to construct a new digest for each(
synchronized(digest) {
digest.reset();
hashSubjectList(reqCtx.getSubjectsAsList(), digest);
hashAttributeList(reqCtx.getResourceAsList(), digest);
hashAttributeList(reqCtx.getActionAsList(), digest);
hashAttributeList(reqCtx.getEnvironmentAttributesAsList(), digest);
hash = digest.digest();
}
return byte2hex(hash);
}
|
[
"private",
"String",
"makeHash",
"(",
"String",
"request",
")",
"throws",
"CacheException",
"{",
"RequestCtx",
"reqCtx",
"=",
"null",
";",
"try",
"{",
"reqCtx",
"=",
"m_contextUtil",
".",
"makeRequestCtx",
"(",
"request",
")",
";",
"}",
"catch",
"(",
"MelcoeXacmlException",
"pe",
")",
"{",
"throw",
"new",
"CacheException",
"(",
"\"Error converting request\"",
",",
"pe",
")",
";",
"}",
"byte",
"[",
"]",
"hash",
"=",
"null",
";",
"// ensure thread safety, don't want concurrent invocations of this method all modifying digest at once",
"// (alternative is to construct a new digest for each(",
"synchronized",
"(",
"digest",
")",
"{",
"digest",
".",
"reset",
"(",
")",
";",
"hashSubjectList",
"(",
"reqCtx",
".",
"getSubjectsAsList",
"(",
")",
",",
"digest",
")",
";",
"hashAttributeList",
"(",
"reqCtx",
".",
"getResourceAsList",
"(",
")",
",",
"digest",
")",
";",
"hashAttributeList",
"(",
"reqCtx",
".",
"getActionAsList",
"(",
")",
",",
"digest",
")",
";",
"hashAttributeList",
"(",
"reqCtx",
".",
"getEnvironmentAttributesAsList",
"(",
")",
",",
"digest",
")",
";",
"hash",
"=",
"digest",
".",
"digest",
"(",
")",
";",
"}",
"return",
"byte2hex",
"(",
"hash",
")",
";",
"}"
] |
Given a request, this method generates a hash.
@param request
the request to hash
@return the hash
@throws CacheException
|
[
"Given",
"a",
"request",
"this",
"method",
"generates",
"a",
"hash",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-security/fcrepo-security-pep/src/main/java/org/fcrepo/server/security/xacml/pep/ResponseCacheImpl.java#L254-L279
|
8,909 |
fcrepo3/fcrepo
|
fcrepo-security/fcrepo-security-pep/src/main/java/org/fcrepo/server/security/xacml/pep/ResponseCacheImpl.java
|
ResponseCacheImpl.hashAttribute
|
private static void hashAttribute(Attribute a, MessageDigest dig) {
dig.update(a.getId().toString().getBytes());
dig.update(a.getType().toString().getBytes());
dig.update(a.getValue().encode().getBytes());
if (a.getIssuer() != null) {
dig.update(a.getIssuer().getBytes());
}
if (a.getIssueInstant() != null) {
dig.update(a.getIssueInstant().encode().getBytes());
}
}
|
java
|
private static void hashAttribute(Attribute a, MessageDigest dig) {
dig.update(a.getId().toString().getBytes());
dig.update(a.getType().toString().getBytes());
dig.update(a.getValue().encode().getBytes());
if (a.getIssuer() != null) {
dig.update(a.getIssuer().getBytes());
}
if (a.getIssueInstant() != null) {
dig.update(a.getIssueInstant().encode().getBytes());
}
}
|
[
"private",
"static",
"void",
"hashAttribute",
"(",
"Attribute",
"a",
",",
"MessageDigest",
"dig",
")",
"{",
"dig",
".",
"update",
"(",
"a",
".",
"getId",
"(",
")",
".",
"toString",
"(",
")",
".",
"getBytes",
"(",
")",
")",
";",
"dig",
".",
"update",
"(",
"a",
".",
"getType",
"(",
")",
".",
"toString",
"(",
")",
".",
"getBytes",
"(",
")",
")",
";",
"dig",
".",
"update",
"(",
"a",
".",
"getValue",
"(",
")",
".",
"encode",
"(",
")",
".",
"getBytes",
"(",
")",
")",
";",
"if",
"(",
"a",
".",
"getIssuer",
"(",
")",
"!=",
"null",
")",
"{",
"dig",
".",
"update",
"(",
"a",
".",
"getIssuer",
"(",
")",
".",
"getBytes",
"(",
")",
")",
";",
"}",
"if",
"(",
"a",
".",
"getIssueInstant",
"(",
")",
"!=",
"null",
")",
"{",
"dig",
".",
"update",
"(",
"a",
".",
"getIssueInstant",
"(",
")",
".",
"encode",
"(",
")",
".",
"getBytes",
"(",
")",
")",
";",
"}",
"}"
] |
Utility function to add an attribute to the hash digest.
@param a
the attribute to hash
|
[
"Utility",
"function",
"to",
"add",
"an",
"attribute",
"to",
"the",
"hash",
"digest",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-security/fcrepo-security-pep/src/main/java/org/fcrepo/server/security/xacml/pep/ResponseCacheImpl.java#L303-L313
|
8,910 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/utilities/status/ServerStatusTool.java
|
ServerStatusTool.watchStartup
|
public void watchStartup(int startingTimeout, int startupTimeout)
throws Exception {
// use this for timeout checks later
long startTime = System.currentTimeMillis();
ServerStatusMessage[] messages = getAllMessages();
ServerStatusMessage lastMessage = messages[messages.length - 1];
boolean starting = false;
boolean started = false;
while (!started) {
showStartup(messages);
// update started and starting flags, and
// throw a startup exception if startup failed
// is encountered
for (ServerStatusMessage element : messages) {
ServerState state = element.getState();
if (state == ServerState.STARTING) {
starting = true;
} else if (state == ServerState.STARTED) {
started = true;
} else if (state == ServerState.STARTUP_FAILED) {
throw new Exception("Fedora startup failed (see above)");
}
}
if (!started) {
// wait half a second
try {
Thread.sleep(500);
} catch (Throwable th) {
}
// throw an exception if either timeout has been
// exceeded
long now = System.currentTimeMillis();
if (!starting) {
if ((now - startTime) / 1000 > startingTimeout) {
throw new Exception("Server startup did not begin within "
+ startingTimeout + " seconds");
}
}
if ((now - startTime) / 1000 > startupTimeout) {
throw new Exception("Server startup did not complete within "
+ startupTimeout + " seconds");
}
// get next batch of messages
messages = _statusFile.getMessages(lastMessage);
if (messages.length > 0) {
lastMessage = messages[messages.length - 1];
}
}
}
}
|
java
|
public void watchStartup(int startingTimeout, int startupTimeout)
throws Exception {
// use this for timeout checks later
long startTime = System.currentTimeMillis();
ServerStatusMessage[] messages = getAllMessages();
ServerStatusMessage lastMessage = messages[messages.length - 1];
boolean starting = false;
boolean started = false;
while (!started) {
showStartup(messages);
// update started and starting flags, and
// throw a startup exception if startup failed
// is encountered
for (ServerStatusMessage element : messages) {
ServerState state = element.getState();
if (state == ServerState.STARTING) {
starting = true;
} else if (state == ServerState.STARTED) {
started = true;
} else if (state == ServerState.STARTUP_FAILED) {
throw new Exception("Fedora startup failed (see above)");
}
}
if (!started) {
// wait half a second
try {
Thread.sleep(500);
} catch (Throwable th) {
}
// throw an exception if either timeout has been
// exceeded
long now = System.currentTimeMillis();
if (!starting) {
if ((now - startTime) / 1000 > startingTimeout) {
throw new Exception("Server startup did not begin within "
+ startingTimeout + " seconds");
}
}
if ((now - startTime) / 1000 > startupTimeout) {
throw new Exception("Server startup did not complete within "
+ startupTimeout + " seconds");
}
// get next batch of messages
messages = _statusFile.getMessages(lastMessage);
if (messages.length > 0) {
lastMessage = messages[messages.length - 1];
}
}
}
}
|
[
"public",
"void",
"watchStartup",
"(",
"int",
"startingTimeout",
",",
"int",
"startupTimeout",
")",
"throws",
"Exception",
"{",
"// use this for timeout checks later",
"long",
"startTime",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"ServerStatusMessage",
"[",
"]",
"messages",
"=",
"getAllMessages",
"(",
")",
";",
"ServerStatusMessage",
"lastMessage",
"=",
"messages",
"[",
"messages",
".",
"length",
"-",
"1",
"]",
";",
"boolean",
"starting",
"=",
"false",
";",
"boolean",
"started",
"=",
"false",
";",
"while",
"(",
"!",
"started",
")",
"{",
"showStartup",
"(",
"messages",
")",
";",
"// update started and starting flags, and",
"// throw a startup exception if startup failed",
"// is encountered",
"for",
"(",
"ServerStatusMessage",
"element",
":",
"messages",
")",
"{",
"ServerState",
"state",
"=",
"element",
".",
"getState",
"(",
")",
";",
"if",
"(",
"state",
"==",
"ServerState",
".",
"STARTING",
")",
"{",
"starting",
"=",
"true",
";",
"}",
"else",
"if",
"(",
"state",
"==",
"ServerState",
".",
"STARTED",
")",
"{",
"started",
"=",
"true",
";",
"}",
"else",
"if",
"(",
"state",
"==",
"ServerState",
".",
"STARTUP_FAILED",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Fedora startup failed (see above)\"",
")",
";",
"}",
"}",
"if",
"(",
"!",
"started",
")",
"{",
"// wait half a second",
"try",
"{",
"Thread",
".",
"sleep",
"(",
"500",
")",
";",
"}",
"catch",
"(",
"Throwable",
"th",
")",
"{",
"}",
"// throw an exception if either timeout has been",
"// exceeded",
"long",
"now",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"if",
"(",
"!",
"starting",
")",
"{",
"if",
"(",
"(",
"now",
"-",
"startTime",
")",
"/",
"1000",
">",
"startingTimeout",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Server startup did not begin within \"",
"+",
"startingTimeout",
"+",
"\" seconds\"",
")",
";",
"}",
"}",
"if",
"(",
"(",
"now",
"-",
"startTime",
")",
"/",
"1000",
">",
"startupTimeout",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Server startup did not complete within \"",
"+",
"startupTimeout",
"+",
"\" seconds\"",
")",
";",
"}",
"// get next batch of messages",
"messages",
"=",
"_statusFile",
".",
"getMessages",
"(",
"lastMessage",
")",
";",
"if",
"(",
"messages",
".",
"length",
">",
"0",
")",
"{",
"lastMessage",
"=",
"messages",
"[",
"messages",
".",
"length",
"-",
"1",
"]",
";",
"}",
"}",
"}",
"}"
] |
Watch the status file and print details to standard output until the
STARTED or STARTUP_FAILED state is encountered. If there are any problems
reading the status file, a timeout is reached, or STARTUP_FAILED is
encountered, this will throw an exception.
|
[
"Watch",
"the",
"status",
"file",
"and",
"print",
"details",
"to",
"standard",
"output",
"until",
"the",
"STARTED",
"or",
"STARTUP_FAILED",
"state",
"is",
"encountered",
".",
"If",
"there",
"are",
"any",
"problems",
"reading",
"the",
"status",
"file",
"a",
"timeout",
"is",
"reached",
"or",
"STARTUP_FAILED",
"is",
"encountered",
"this",
"will",
"throw",
"an",
"exception",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/utilities/status/ServerStatusTool.java#L79-L140
|
8,911 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/utilities/status/ServerStatusTool.java
|
ServerStatusTool.watchShutdown
|
public void watchShutdown(int stoppingTimeout, int shutdownTimeout)
throws Exception {
if (!_statusFile.exists()) {
_statusFile
.append(ServerState.STOPPING,
"WARNING: Server status file did not exist; re-created");
}
// use this for timeout checks later
long startTime = System.currentTimeMillis();
ServerStatusMessage[] messages = getAllMessages();
ServerStatusMessage lastMessage = messages[messages.length - 1];
boolean stopping = false;
boolean stopped = false;
while (!stopped) {
showShutdown(messages);
// update stopping and stopped flags, and
// throw a shutdown exception if STOPPED_WITH_ERR
// is encountered
for (ServerStatusMessage element : messages) {
ServerState state = element.getState();
if (state == ServerState.STOPPING) {
stopping = true;
} else if (state == ServerState.STOPPED) {
stopped = true;
} else if (state == ServerState.STOPPED_WITH_ERR) {
throw new Exception("Fedora shutdown finished with error (see above)");
}
}
if (!stopped) {
// wait half a second
try {
Thread.sleep(500);
} catch (Throwable th) {
}
// throw an exception if either timeout has been
// exceeded
long now = System.currentTimeMillis();
if (!stopping) {
if ((now - startTime) / 1000 > stoppingTimeout) {
throw new Exception("Server shutdown did not begin within "
+ stoppingTimeout + " seconds");
}
}
if ((now - startTime) / 1000 > shutdownTimeout) {
throw new Exception("Server shutdown did not complete within "
+ shutdownTimeout + " seconds");
}
// get next batch of messages
messages = _statusFile.getMessages(lastMessage);
if (messages.length > 0) {
lastMessage = messages[messages.length - 1];
}
}
}
}
|
java
|
public void watchShutdown(int stoppingTimeout, int shutdownTimeout)
throws Exception {
if (!_statusFile.exists()) {
_statusFile
.append(ServerState.STOPPING,
"WARNING: Server status file did not exist; re-created");
}
// use this for timeout checks later
long startTime = System.currentTimeMillis();
ServerStatusMessage[] messages = getAllMessages();
ServerStatusMessage lastMessage = messages[messages.length - 1];
boolean stopping = false;
boolean stopped = false;
while (!stopped) {
showShutdown(messages);
// update stopping and stopped flags, and
// throw a shutdown exception if STOPPED_WITH_ERR
// is encountered
for (ServerStatusMessage element : messages) {
ServerState state = element.getState();
if (state == ServerState.STOPPING) {
stopping = true;
} else if (state == ServerState.STOPPED) {
stopped = true;
} else if (state == ServerState.STOPPED_WITH_ERR) {
throw new Exception("Fedora shutdown finished with error (see above)");
}
}
if (!stopped) {
// wait half a second
try {
Thread.sleep(500);
} catch (Throwable th) {
}
// throw an exception if either timeout has been
// exceeded
long now = System.currentTimeMillis();
if (!stopping) {
if ((now - startTime) / 1000 > stoppingTimeout) {
throw new Exception("Server shutdown did not begin within "
+ stoppingTimeout + " seconds");
}
}
if ((now - startTime) / 1000 > shutdownTimeout) {
throw new Exception("Server shutdown did not complete within "
+ shutdownTimeout + " seconds");
}
// get next batch of messages
messages = _statusFile.getMessages(lastMessage);
if (messages.length > 0) {
lastMessage = messages[messages.length - 1];
}
}
}
}
|
[
"public",
"void",
"watchShutdown",
"(",
"int",
"stoppingTimeout",
",",
"int",
"shutdownTimeout",
")",
"throws",
"Exception",
"{",
"if",
"(",
"!",
"_statusFile",
".",
"exists",
"(",
")",
")",
"{",
"_statusFile",
".",
"append",
"(",
"ServerState",
".",
"STOPPING",
",",
"\"WARNING: Server status file did not exist; re-created\"",
")",
";",
"}",
"// use this for timeout checks later",
"long",
"startTime",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"ServerStatusMessage",
"[",
"]",
"messages",
"=",
"getAllMessages",
"(",
")",
";",
"ServerStatusMessage",
"lastMessage",
"=",
"messages",
"[",
"messages",
".",
"length",
"-",
"1",
"]",
";",
"boolean",
"stopping",
"=",
"false",
";",
"boolean",
"stopped",
"=",
"false",
";",
"while",
"(",
"!",
"stopped",
")",
"{",
"showShutdown",
"(",
"messages",
")",
";",
"// update stopping and stopped flags, and",
"// throw a shutdown exception if STOPPED_WITH_ERR",
"// is encountered",
"for",
"(",
"ServerStatusMessage",
"element",
":",
"messages",
")",
"{",
"ServerState",
"state",
"=",
"element",
".",
"getState",
"(",
")",
";",
"if",
"(",
"state",
"==",
"ServerState",
".",
"STOPPING",
")",
"{",
"stopping",
"=",
"true",
";",
"}",
"else",
"if",
"(",
"state",
"==",
"ServerState",
".",
"STOPPED",
")",
"{",
"stopped",
"=",
"true",
";",
"}",
"else",
"if",
"(",
"state",
"==",
"ServerState",
".",
"STOPPED_WITH_ERR",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Fedora shutdown finished with error (see above)\"",
")",
";",
"}",
"}",
"if",
"(",
"!",
"stopped",
")",
"{",
"// wait half a second",
"try",
"{",
"Thread",
".",
"sleep",
"(",
"500",
")",
";",
"}",
"catch",
"(",
"Throwable",
"th",
")",
"{",
"}",
"// throw an exception if either timeout has been",
"// exceeded",
"long",
"now",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"if",
"(",
"!",
"stopping",
")",
"{",
"if",
"(",
"(",
"now",
"-",
"startTime",
")",
"/",
"1000",
">",
"stoppingTimeout",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Server shutdown did not begin within \"",
"+",
"stoppingTimeout",
"+",
"\" seconds\"",
")",
";",
"}",
"}",
"if",
"(",
"(",
"now",
"-",
"startTime",
")",
"/",
"1000",
">",
"shutdownTimeout",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Server shutdown did not complete within \"",
"+",
"shutdownTimeout",
"+",
"\" seconds\"",
")",
";",
"}",
"// get next batch of messages",
"messages",
"=",
"_statusFile",
".",
"getMessages",
"(",
"lastMessage",
")",
";",
"if",
"(",
"messages",
".",
"length",
">",
"0",
")",
"{",
"lastMessage",
"=",
"messages",
"[",
"messages",
".",
"length",
"-",
"1",
"]",
";",
"}",
"}",
"}",
"}"
] |
Watch the status file and print details to standard output until the
STOPPED or STOPPED_WITH_ERR state is encountered. If there are any
problems reading the status file, a timeout is reached, or
STOPPED_WITH_ERR is encountered, this will throw an exception.
|
[
"Watch",
"the",
"status",
"file",
"and",
"print",
"details",
"to",
"standard",
"output",
"until",
"the",
"STOPPED",
"or",
"STOPPED_WITH_ERR",
"state",
"is",
"encountered",
".",
"If",
"there",
"are",
"any",
"problems",
"reading",
"the",
"status",
"file",
"a",
"timeout",
"is",
"reached",
"or",
"STOPPED_WITH_ERR",
"is",
"encountered",
"this",
"will",
"throw",
"an",
"exception",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/utilities/status/ServerStatusTool.java#L177-L244
|
8,912 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/utilities/status/ServerStatusTool.java
|
ServerStatusTool.showStatus
|
public void showStatus() throws Exception {
ServerStatusMessage message;
if (_statusFile.exists()) {
ServerStatusMessage[] messages = getAllMessages();
message = messages[messages.length - 1];
} else {
message = ServerStatusMessage.NEW_SERVER_MESSAGE;
}
System.out.println(message.toString());
}
|
java
|
public void showStatus() throws Exception {
ServerStatusMessage message;
if (_statusFile.exists()) {
ServerStatusMessage[] messages = getAllMessages();
message = messages[messages.length - 1];
} else {
message = ServerStatusMessage.NEW_SERVER_MESSAGE;
}
System.out.println(message.toString());
}
|
[
"public",
"void",
"showStatus",
"(",
")",
"throws",
"Exception",
"{",
"ServerStatusMessage",
"message",
";",
"if",
"(",
"_statusFile",
".",
"exists",
"(",
")",
")",
"{",
"ServerStatusMessage",
"[",
"]",
"messages",
"=",
"getAllMessages",
"(",
")",
";",
"message",
"=",
"messages",
"[",
"messages",
".",
"length",
"-",
"1",
"]",
";",
"}",
"else",
"{",
"message",
"=",
"ServerStatusMessage",
".",
"NEW_SERVER_MESSAGE",
";",
"}",
"System",
".",
"out",
".",
"println",
"(",
"message",
".",
"toString",
"(",
")",
")",
";",
"}"
] |
Show a human-readable form of the latest message in the server status
file. If the status file doesn't yet exist, this will print a special
status message indicating the server is new. The response will have the
following form.
<pre>
STATE : Some State
AS OF : 2006-03-29 06:44:23AM EST
DETAIL : Detail line 1, if it exists
Detail line 2, if it exists
Detail line 3, etc..
</pre>
|
[
"Show",
"a",
"human",
"-",
"readable",
"form",
"of",
"the",
"latest",
"message",
"in",
"the",
"server",
"status",
"file",
".",
"If",
"the",
"status",
"file",
"doesn",
"t",
"yet",
"exist",
"this",
"will",
"print",
"a",
"special",
"status",
"message",
"indicating",
"the",
"server",
"is",
"new",
".",
"The",
"response",
"will",
"have",
"the",
"following",
"form",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/utilities/status/ServerStatusTool.java#L289-L299
|
8,913 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/utilities/status/ServerStatusTool.java
|
ServerStatusTool.getAllMessages
|
private ServerStatusMessage[] getAllMessages() throws Exception {
ServerStatusMessage[] messages = _statusFile.getMessages(null);
if (messages.length == 0) {
System.out
.println("WARNING: Server status file is empty; re-creating");
init();
messages = _statusFile.getMessages(null);
}
ServerState firstState = messages[0].getState();
if (firstState != ServerState.NOT_STARTING) {
System.out
.println("WARNING: Server status file is missing one or more messages");
}
return messages;
}
|
java
|
private ServerStatusMessage[] getAllMessages() throws Exception {
ServerStatusMessage[] messages = _statusFile.getMessages(null);
if (messages.length == 0) {
System.out
.println("WARNING: Server status file is empty; re-creating");
init();
messages = _statusFile.getMessages(null);
}
ServerState firstState = messages[0].getState();
if (firstState != ServerState.NOT_STARTING) {
System.out
.println("WARNING: Server status file is missing one or more messages");
}
return messages;
}
|
[
"private",
"ServerStatusMessage",
"[",
"]",
"getAllMessages",
"(",
")",
"throws",
"Exception",
"{",
"ServerStatusMessage",
"[",
"]",
"messages",
"=",
"_statusFile",
".",
"getMessages",
"(",
"null",
")",
";",
"if",
"(",
"messages",
".",
"length",
"==",
"0",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"WARNING: Server status file is empty; re-creating\"",
")",
";",
"init",
"(",
")",
";",
"messages",
"=",
"_statusFile",
".",
"getMessages",
"(",
"null",
")",
";",
"}",
"ServerState",
"firstState",
"=",
"messages",
"[",
"0",
"]",
".",
"getState",
"(",
")",
";",
"if",
"(",
"firstState",
"!=",
"ServerState",
".",
"NOT_STARTING",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"WARNING: Server status file is missing one or more messages\"",
")",
";",
"}",
"return",
"messages",
";",
"}"
] |
print a warning
|
[
"print",
"a",
"warning"
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/utilities/status/ServerStatusTool.java#L305-L320
|
8,914 |
fcrepo3/fcrepo
|
fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/swing/mdi/MDIDesktopPane.java
|
MDIDesktopPane.cascadeFrames
|
public void cascadeFrames() {
restoreFrames();
int x = 0;
int y = 0;
JInternalFrame allFrames[] = getAllFrames();
manager.setNormalSize();
int frameHeight =
getBounds().height - 5 - allFrames.length * FRAME_OFFSET;
int frameWidth =
getBounds().width - 5 - allFrames.length * FRAME_OFFSET;
for (int i = allFrames.length - 1; i >= 0; i--) {
allFrames[i].setSize(frameWidth, frameHeight);
allFrames[i].setLocation(x, y);
x = x + FRAME_OFFSET;
y = y + FRAME_OFFSET;
}
}
|
java
|
public void cascadeFrames() {
restoreFrames();
int x = 0;
int y = 0;
JInternalFrame allFrames[] = getAllFrames();
manager.setNormalSize();
int frameHeight =
getBounds().height - 5 - allFrames.length * FRAME_OFFSET;
int frameWidth =
getBounds().width - 5 - allFrames.length * FRAME_OFFSET;
for (int i = allFrames.length - 1; i >= 0; i--) {
allFrames[i].setSize(frameWidth, frameHeight);
allFrames[i].setLocation(x, y);
x = x + FRAME_OFFSET;
y = y + FRAME_OFFSET;
}
}
|
[
"public",
"void",
"cascadeFrames",
"(",
")",
"{",
"restoreFrames",
"(",
")",
";",
"int",
"x",
"=",
"0",
";",
"int",
"y",
"=",
"0",
";",
"JInternalFrame",
"allFrames",
"[",
"]",
"=",
"getAllFrames",
"(",
")",
";",
"manager",
".",
"setNormalSize",
"(",
")",
";",
"int",
"frameHeight",
"=",
"getBounds",
"(",
")",
".",
"height",
"-",
"5",
"-",
"allFrames",
".",
"length",
"*",
"FRAME_OFFSET",
";",
"int",
"frameWidth",
"=",
"getBounds",
"(",
")",
".",
"width",
"-",
"5",
"-",
"allFrames",
".",
"length",
"*",
"FRAME_OFFSET",
";",
"for",
"(",
"int",
"i",
"=",
"allFrames",
".",
"length",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"allFrames",
"[",
"i",
"]",
".",
"setSize",
"(",
"frameWidth",
",",
"frameHeight",
")",
";",
"allFrames",
"[",
"i",
"]",
".",
"setLocation",
"(",
"x",
",",
"y",
")",
";",
"x",
"=",
"x",
"+",
"FRAME_OFFSET",
";",
"y",
"=",
"y",
"+",
"FRAME_OFFSET",
";",
"}",
"}"
] |
Cascade all internal frames, un-iconfying any minimized first
|
[
"Cascade",
"all",
"internal",
"frames",
"un",
"-",
"iconfying",
"any",
"minimized",
"first"
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/swing/mdi/MDIDesktopPane.java#L88-L105
|
8,915 |
fcrepo3/fcrepo
|
fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/swing/mdi/MDIDesktopPane.java
|
MDIDesktopPane.tileFrames
|
public void tileFrames() {
restoreFrames();
java.awt.Component allFrames[] = getAllFrames();
manager.setNormalSize();
int frameHeight = getBounds().height / allFrames.length;
int y = 0;
for (Component element : allFrames) {
element.setSize(getBounds().width, frameHeight);
element.setLocation(0, y);
y = y + frameHeight;
}
}
|
java
|
public void tileFrames() {
restoreFrames();
java.awt.Component allFrames[] = getAllFrames();
manager.setNormalSize();
int frameHeight = getBounds().height / allFrames.length;
int y = 0;
for (Component element : allFrames) {
element.setSize(getBounds().width, frameHeight);
element.setLocation(0, y);
y = y + frameHeight;
}
}
|
[
"public",
"void",
"tileFrames",
"(",
")",
"{",
"restoreFrames",
"(",
")",
";",
"java",
".",
"awt",
".",
"Component",
"allFrames",
"[",
"]",
"=",
"getAllFrames",
"(",
")",
";",
"manager",
".",
"setNormalSize",
"(",
")",
";",
"int",
"frameHeight",
"=",
"getBounds",
"(",
")",
".",
"height",
"/",
"allFrames",
".",
"length",
";",
"int",
"y",
"=",
"0",
";",
"for",
"(",
"Component",
"element",
":",
"allFrames",
")",
"{",
"element",
".",
"setSize",
"(",
"getBounds",
"(",
")",
".",
"width",
",",
"frameHeight",
")",
";",
"element",
".",
"setLocation",
"(",
"0",
",",
"y",
")",
";",
"y",
"=",
"y",
"+",
"frameHeight",
";",
"}",
"}"
] |
Tile all internal frames, un-iconifying any minimized first
|
[
"Tile",
"all",
"internal",
"frames",
"un",
"-",
"iconifying",
"any",
"minimized",
"first"
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/swing/mdi/MDIDesktopPane.java#L110-L121
|
8,916 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/journal/xmlhelpers/ContextXmlReader.java
|
ContextXmlReader.readContext
|
public JournalEntryContext readContext(XMLEventReader reader)
throws JournalException, XMLStreamException {
JournalEntryContext context = new JournalEntryContext();
XMLEvent event = reader.nextTag();
if (!isStartTagEvent(event, QNAME_TAG_CONTEXT)) {
throw getNotStartTagException(QNAME_TAG_CONTEXT, event);
}
context.setPassword(readContextPassword(reader));
context.setNoOp(readContextNoOp(reader));
context.setNow(readContextNow(reader));
context
.setEnvironmentAttributes(convertStringMap(readMultiMap(reader,
CONTEXT_MAPNAME_ENVIRONMENT)));
context.setSubjectAttributes(readMultiMap(reader,
CONTEXT_MAPNAME_SUBJECT));
context
.setActionAttributes(convertStringMap(readMultiMap(reader,
CONTEXT_MAPNAME_ACTION)));
context.setResourceAttributes(convertStringMap(readMultiMap(reader,
CONTEXT_MAPNAME_RESOURCE)));
context.setRecoveryAttributes(convertStringMap(readMultiMap(reader,
CONTEXT_MAPNAME_RECOVERY)));
event = reader.nextTag();
if (!isEndTagEvent(event, QNAME_TAG_CONTEXT)) {
throw getNotEndTagException(QNAME_TAG_CONTEXT, event);
}
decipherPassword(context);
return context;
}
|
java
|
public JournalEntryContext readContext(XMLEventReader reader)
throws JournalException, XMLStreamException {
JournalEntryContext context = new JournalEntryContext();
XMLEvent event = reader.nextTag();
if (!isStartTagEvent(event, QNAME_TAG_CONTEXT)) {
throw getNotStartTagException(QNAME_TAG_CONTEXT, event);
}
context.setPassword(readContextPassword(reader));
context.setNoOp(readContextNoOp(reader));
context.setNow(readContextNow(reader));
context
.setEnvironmentAttributes(convertStringMap(readMultiMap(reader,
CONTEXT_MAPNAME_ENVIRONMENT)));
context.setSubjectAttributes(readMultiMap(reader,
CONTEXT_MAPNAME_SUBJECT));
context
.setActionAttributes(convertStringMap(readMultiMap(reader,
CONTEXT_MAPNAME_ACTION)));
context.setResourceAttributes(convertStringMap(readMultiMap(reader,
CONTEXT_MAPNAME_RESOURCE)));
context.setRecoveryAttributes(convertStringMap(readMultiMap(reader,
CONTEXT_MAPNAME_RECOVERY)));
event = reader.nextTag();
if (!isEndTagEvent(event, QNAME_TAG_CONTEXT)) {
throw getNotEndTagException(QNAME_TAG_CONTEXT, event);
}
decipherPassword(context);
return context;
}
|
[
"public",
"JournalEntryContext",
"readContext",
"(",
"XMLEventReader",
"reader",
")",
"throws",
"JournalException",
",",
"XMLStreamException",
"{",
"JournalEntryContext",
"context",
"=",
"new",
"JournalEntryContext",
"(",
")",
";",
"XMLEvent",
"event",
"=",
"reader",
".",
"nextTag",
"(",
")",
";",
"if",
"(",
"!",
"isStartTagEvent",
"(",
"event",
",",
"QNAME_TAG_CONTEXT",
")",
")",
"{",
"throw",
"getNotStartTagException",
"(",
"QNAME_TAG_CONTEXT",
",",
"event",
")",
";",
"}",
"context",
".",
"setPassword",
"(",
"readContextPassword",
"(",
"reader",
")",
")",
";",
"context",
".",
"setNoOp",
"(",
"readContextNoOp",
"(",
"reader",
")",
")",
";",
"context",
".",
"setNow",
"(",
"readContextNow",
"(",
"reader",
")",
")",
";",
"context",
".",
"setEnvironmentAttributes",
"(",
"convertStringMap",
"(",
"readMultiMap",
"(",
"reader",
",",
"CONTEXT_MAPNAME_ENVIRONMENT",
")",
")",
")",
";",
"context",
".",
"setSubjectAttributes",
"(",
"readMultiMap",
"(",
"reader",
",",
"CONTEXT_MAPNAME_SUBJECT",
")",
")",
";",
"context",
".",
"setActionAttributes",
"(",
"convertStringMap",
"(",
"readMultiMap",
"(",
"reader",
",",
"CONTEXT_MAPNAME_ACTION",
")",
")",
")",
";",
"context",
".",
"setResourceAttributes",
"(",
"convertStringMap",
"(",
"readMultiMap",
"(",
"reader",
",",
"CONTEXT_MAPNAME_RESOURCE",
")",
")",
")",
";",
"context",
".",
"setRecoveryAttributes",
"(",
"convertStringMap",
"(",
"readMultiMap",
"(",
"reader",
",",
"CONTEXT_MAPNAME_RECOVERY",
")",
")",
")",
";",
"event",
"=",
"reader",
".",
"nextTag",
"(",
")",
";",
"if",
"(",
"!",
"isEndTagEvent",
"(",
"event",
",",
"QNAME_TAG_CONTEXT",
")",
")",
"{",
"throw",
"getNotEndTagException",
"(",
"QNAME_TAG_CONTEXT",
",",
"event",
")",
";",
"}",
"decipherPassword",
"(",
"context",
")",
";",
"return",
"context",
";",
"}"
] |
Read the context tax and populate a JournalEntryContext object.
|
[
"Read",
"the",
"context",
"tax",
"and",
"populate",
"a",
"JournalEntryContext",
"object",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/xmlhelpers/ContextXmlReader.java#L38-L71
|
8,917 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/journal/xmlhelpers/ContextXmlReader.java
|
ContextXmlReader.readContextNoOp
|
private boolean readContextNoOp(XMLEventReader reader)
throws XMLStreamException, JournalException {
readStartTag(reader, QNAME_TAG_NOOP);
String value = readCharactersUntilEndTag(reader, QNAME_TAG_NOOP);
return Boolean.valueOf(value).booleanValue();
}
|
java
|
private boolean readContextNoOp(XMLEventReader reader)
throws XMLStreamException, JournalException {
readStartTag(reader, QNAME_TAG_NOOP);
String value = readCharactersUntilEndTag(reader, QNAME_TAG_NOOP);
return Boolean.valueOf(value).booleanValue();
}
|
[
"private",
"boolean",
"readContextNoOp",
"(",
"XMLEventReader",
"reader",
")",
"throws",
"XMLStreamException",
",",
"JournalException",
"{",
"readStartTag",
"(",
"reader",
",",
"QNAME_TAG_NOOP",
")",
";",
"String",
"value",
"=",
"readCharactersUntilEndTag",
"(",
"reader",
",",
"QNAME_TAG_NOOP",
")",
";",
"return",
"Boolean",
".",
"valueOf",
"(",
"value",
")",
".",
"booleanValue",
"(",
")",
";",
"}"
] |
Read the context no-op flag from XML.
|
[
"Read",
"the",
"context",
"no",
"-",
"op",
"flag",
"from",
"XML",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/xmlhelpers/ContextXmlReader.java#L90-L95
|
8,918 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/journal/xmlhelpers/ContextXmlReader.java
|
ContextXmlReader.readContextNow
|
private Date readContextNow(XMLEventReader reader)
throws XMLStreamException, JournalException {
readStartTag(reader, QNAME_TAG_NOW);
String value = readCharactersUntilEndTag(reader, QNAME_TAG_NOW);
return JournalHelper.parseDate(value);
}
|
java
|
private Date readContextNow(XMLEventReader reader)
throws XMLStreamException, JournalException {
readStartTag(reader, QNAME_TAG_NOW);
String value = readCharactersUntilEndTag(reader, QNAME_TAG_NOW);
return JournalHelper.parseDate(value);
}
|
[
"private",
"Date",
"readContextNow",
"(",
"XMLEventReader",
"reader",
")",
"throws",
"XMLStreamException",
",",
"JournalException",
"{",
"readStartTag",
"(",
"reader",
",",
"QNAME_TAG_NOW",
")",
";",
"String",
"value",
"=",
"readCharactersUntilEndTag",
"(",
"reader",
",",
"QNAME_TAG_NOW",
")",
";",
"return",
"JournalHelper",
".",
"parseDate",
"(",
"value",
")",
";",
"}"
] |
Read the context date from XML.
|
[
"Read",
"the",
"context",
"date",
"from",
"XML",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/xmlhelpers/ContextXmlReader.java#L100-L105
|
8,919 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/journal/xmlhelpers/ContextXmlReader.java
|
ContextXmlReader.readMultiMap
|
private MultiValueMap<String> readMultiMap(XMLEventReader reader, String mapName)
throws JournalException, XMLStreamException {
MultiValueMap<String> map = new MultiValueMap<String>();
// must start with a multi-map tag
XMLEvent event = reader.nextTag();
if (!isStartTagEvent(event, QNAME_TAG_MULTI_VALUE_MAP)) {
throw getNotStartTagException(QNAME_TAG_MULTI_VALUE_MAP, event);
}
// the map name must match the expected name
String value =
getRequiredAttributeValue(event.asStartElement(),
QNAME_ATTR_NAME);
if (!mapName.equals(value)) {
throw new JournalException("Expecting a '" + mapName
+ "' multi-map, but found a '" + value
+ "' multi-map instead");
}
// populate the map
readMultiMapKeys(reader, map);
return map;
}
|
java
|
private MultiValueMap<String> readMultiMap(XMLEventReader reader, String mapName)
throws JournalException, XMLStreamException {
MultiValueMap<String> map = new MultiValueMap<String>();
// must start with a multi-map tag
XMLEvent event = reader.nextTag();
if (!isStartTagEvent(event, QNAME_TAG_MULTI_VALUE_MAP)) {
throw getNotStartTagException(QNAME_TAG_MULTI_VALUE_MAP, event);
}
// the map name must match the expected name
String value =
getRequiredAttributeValue(event.asStartElement(),
QNAME_ATTR_NAME);
if (!mapName.equals(value)) {
throw new JournalException("Expecting a '" + mapName
+ "' multi-map, but found a '" + value
+ "' multi-map instead");
}
// populate the map
readMultiMapKeys(reader, map);
return map;
}
|
[
"private",
"MultiValueMap",
"<",
"String",
">",
"readMultiMap",
"(",
"XMLEventReader",
"reader",
",",
"String",
"mapName",
")",
"throws",
"JournalException",
",",
"XMLStreamException",
"{",
"MultiValueMap",
"<",
"String",
">",
"map",
"=",
"new",
"MultiValueMap",
"<",
"String",
">",
"(",
")",
";",
"// must start with a multi-map tag",
"XMLEvent",
"event",
"=",
"reader",
".",
"nextTag",
"(",
")",
";",
"if",
"(",
"!",
"isStartTagEvent",
"(",
"event",
",",
"QNAME_TAG_MULTI_VALUE_MAP",
")",
")",
"{",
"throw",
"getNotStartTagException",
"(",
"QNAME_TAG_MULTI_VALUE_MAP",
",",
"event",
")",
";",
"}",
"// the map name must match the expected name",
"String",
"value",
"=",
"getRequiredAttributeValue",
"(",
"event",
".",
"asStartElement",
"(",
")",
",",
"QNAME_ATTR_NAME",
")",
";",
"if",
"(",
"!",
"mapName",
".",
"equals",
"(",
"value",
")",
")",
"{",
"throw",
"new",
"JournalException",
"(",
"\"Expecting a '\"",
"+",
"mapName",
"+",
"\"' multi-map, but found a '\"",
"+",
"value",
"+",
"\"' multi-map instead\"",
")",
";",
"}",
"// populate the map",
"readMultiMapKeys",
"(",
"reader",
",",
"map",
")",
";",
"return",
"map",
";",
"}"
] |
Read a multi-map, with its nested tags.
|
[
"Read",
"a",
"multi",
"-",
"map",
"with",
"its",
"nested",
"tags",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/xmlhelpers/ContextXmlReader.java#L119-L143
|
8,920 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/journal/xmlhelpers/ContextXmlReader.java
|
ContextXmlReader.readMultiMapKeys
|
private void readMultiMapKeys(XMLEventReader reader, MultiValueMap<String> map)
throws XMLStreamException, JournalException {
while (true) {
XMLEvent event2 = reader.nextTag();
if (isStartTagEvent(event2, QNAME_TAG_MULTI_VALUE_MAP_KEY)) {
// if we find a key tag, get the name
String key =
getRequiredAttributeValue(event2.asStartElement(),
QNAME_ATTR_NAME);
// read as many values as we find.
String[] values = readMultiMapValuesForKey(reader);
// store in the map
storeInMultiMap(map, key, values);
} else if (isEndTagEvent(event2, QNAME_TAG_MULTI_VALUE_MAP)) {
break;
} else {
throw getNotNextMemberOrEndOfGroupException(QNAME_TAG_MULTI_VALUE_MAP,
QNAME_TAG_MULTI_VALUE_MAP_KEY,
event2);
}
}
}
|
java
|
private void readMultiMapKeys(XMLEventReader reader, MultiValueMap<String> map)
throws XMLStreamException, JournalException {
while (true) {
XMLEvent event2 = reader.nextTag();
if (isStartTagEvent(event2, QNAME_TAG_MULTI_VALUE_MAP_KEY)) {
// if we find a key tag, get the name
String key =
getRequiredAttributeValue(event2.asStartElement(),
QNAME_ATTR_NAME);
// read as many values as we find.
String[] values = readMultiMapValuesForKey(reader);
// store in the map
storeInMultiMap(map, key, values);
} else if (isEndTagEvent(event2, QNAME_TAG_MULTI_VALUE_MAP)) {
break;
} else {
throw getNotNextMemberOrEndOfGroupException(QNAME_TAG_MULTI_VALUE_MAP,
QNAME_TAG_MULTI_VALUE_MAP_KEY,
event2);
}
}
}
|
[
"private",
"void",
"readMultiMapKeys",
"(",
"XMLEventReader",
"reader",
",",
"MultiValueMap",
"<",
"String",
">",
"map",
")",
"throws",
"XMLStreamException",
",",
"JournalException",
"{",
"while",
"(",
"true",
")",
"{",
"XMLEvent",
"event2",
"=",
"reader",
".",
"nextTag",
"(",
")",
";",
"if",
"(",
"isStartTagEvent",
"(",
"event2",
",",
"QNAME_TAG_MULTI_VALUE_MAP_KEY",
")",
")",
"{",
"// if we find a key tag, get the name",
"String",
"key",
"=",
"getRequiredAttributeValue",
"(",
"event2",
".",
"asStartElement",
"(",
")",
",",
"QNAME_ATTR_NAME",
")",
";",
"// read as many values as we find.",
"String",
"[",
"]",
"values",
"=",
"readMultiMapValuesForKey",
"(",
"reader",
")",
";",
"// store in the map",
"storeInMultiMap",
"(",
"map",
",",
"key",
",",
"values",
")",
";",
"}",
"else",
"if",
"(",
"isEndTagEvent",
"(",
"event2",
",",
"QNAME_TAG_MULTI_VALUE_MAP",
")",
")",
"{",
"break",
";",
"}",
"else",
"{",
"throw",
"getNotNextMemberOrEndOfGroupException",
"(",
"QNAME_TAG_MULTI_VALUE_MAP",
",",
"QNAME_TAG_MULTI_VALUE_MAP_KEY",
",",
"event2",
")",
";",
"}",
"}",
"}"
] |
Read through the keys of the multi-map, adding to the map as we go.
|
[
"Read",
"through",
"the",
"keys",
"of",
"the",
"multi",
"-",
"map",
"adding",
"to",
"the",
"map",
"as",
"we",
"go",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/xmlhelpers/ContextXmlReader.java#L148-L169
|
8,921 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/journal/xmlhelpers/ContextXmlReader.java
|
ContextXmlReader.readMultiMapValuesForKey
|
private String[] readMultiMapValuesForKey(XMLEventReader reader)
throws XMLStreamException, JournalException {
List<String> values = new ArrayList<String>();
while (true) {
XMLEvent event = reader.nextTag();
if (isStartTagEvent(event, QNAME_TAG_MULTI_VALUE_MAP_VALUE)) {
values
.add(readCharactersUntilEndTag(reader,
QNAME_TAG_MULTI_VALUE_MAP_VALUE));
} else if (isEndTagEvent(event, QNAME_TAG_MULTI_VALUE_MAP_KEY)) {
return values.toArray(new String[values.size()]);
} else {
throw getNotNextMemberOrEndOfGroupException(QNAME_TAG_MULTI_VALUE_MAP_KEY,
QNAME_TAG_MULTI_VALUE_MAP_VALUE,
event);
}
}
}
|
java
|
private String[] readMultiMapValuesForKey(XMLEventReader reader)
throws XMLStreamException, JournalException {
List<String> values = new ArrayList<String>();
while (true) {
XMLEvent event = reader.nextTag();
if (isStartTagEvent(event, QNAME_TAG_MULTI_VALUE_MAP_VALUE)) {
values
.add(readCharactersUntilEndTag(reader,
QNAME_TAG_MULTI_VALUE_MAP_VALUE));
} else if (isEndTagEvent(event, QNAME_TAG_MULTI_VALUE_MAP_KEY)) {
return values.toArray(new String[values.size()]);
} else {
throw getNotNextMemberOrEndOfGroupException(QNAME_TAG_MULTI_VALUE_MAP_KEY,
QNAME_TAG_MULTI_VALUE_MAP_VALUE,
event);
}
}
}
|
[
"private",
"String",
"[",
"]",
"readMultiMapValuesForKey",
"(",
"XMLEventReader",
"reader",
")",
"throws",
"XMLStreamException",
",",
"JournalException",
"{",
"List",
"<",
"String",
">",
"values",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"while",
"(",
"true",
")",
"{",
"XMLEvent",
"event",
"=",
"reader",
".",
"nextTag",
"(",
")",
";",
"if",
"(",
"isStartTagEvent",
"(",
"event",
",",
"QNAME_TAG_MULTI_VALUE_MAP_VALUE",
")",
")",
"{",
"values",
".",
"add",
"(",
"readCharactersUntilEndTag",
"(",
"reader",
",",
"QNAME_TAG_MULTI_VALUE_MAP_VALUE",
")",
")",
";",
"}",
"else",
"if",
"(",
"isEndTagEvent",
"(",
"event",
",",
"QNAME_TAG_MULTI_VALUE_MAP_KEY",
")",
")",
"{",
"return",
"values",
".",
"toArray",
"(",
"new",
"String",
"[",
"values",
".",
"size",
"(",
")",
"]",
")",
";",
"}",
"else",
"{",
"throw",
"getNotNextMemberOrEndOfGroupException",
"(",
"QNAME_TAG_MULTI_VALUE_MAP_KEY",
",",
"QNAME_TAG_MULTI_VALUE_MAP_VALUE",
",",
"event",
")",
";",
"}",
"}",
"}"
] |
Read the list of values for one key of the multi-map.
|
[
"Read",
"the",
"list",
"of",
"values",
"for",
"one",
"key",
"of",
"the",
"multi",
"-",
"map",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/xmlhelpers/ContextXmlReader.java#L174-L191
|
8,922 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/journal/xmlhelpers/ContextXmlReader.java
|
ContextXmlReader.decipherPassword
|
private void decipherPassword(JournalEntryContext context) {
String key = JournalHelper.formatDate(context.now());
String passwordCipher = context.getPassword();
String clearPassword =
PasswordCipher.decipher(key, passwordCipher, passwordType);
context.setPassword(clearPassword);
}
|
java
|
private void decipherPassword(JournalEntryContext context) {
String key = JournalHelper.formatDate(context.now());
String passwordCipher = context.getPassword();
String clearPassword =
PasswordCipher.decipher(key, passwordCipher, passwordType);
context.setPassword(clearPassword);
}
|
[
"private",
"void",
"decipherPassword",
"(",
"JournalEntryContext",
"context",
")",
"{",
"String",
"key",
"=",
"JournalHelper",
".",
"formatDate",
"(",
"context",
".",
"now",
"(",
")",
")",
";",
"String",
"passwordCipher",
"=",
"context",
".",
"getPassword",
"(",
")",
";",
"String",
"clearPassword",
"=",
"PasswordCipher",
".",
"decipher",
"(",
"key",
",",
"passwordCipher",
",",
"passwordType",
")",
";",
"context",
".",
"setPassword",
"(",
"clearPassword",
")",
";",
"}"
] |
The password as read was not correct. It needs to be deciphered.
|
[
"The",
"password",
"as",
"read",
"was",
"not",
"correct",
".",
"It",
"needs",
"to",
"be",
"deciphered",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/xmlhelpers/ContextXmlReader.java#L210-L216
|
8,923 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/access/DynamicAccessModule.java
|
DynamicAccessModule.getServiceDefinitions
|
public String[] getServiceDefinitions(Context context,
String PID,
Date asOfDateTime)
throws ServerException {
//m_ipRestriction.enforce(context);
return da.getServiceDefinitions(context, PID, asOfDateTime);
}
|
java
|
public String[] getServiceDefinitions(Context context,
String PID,
Date asOfDateTime)
throws ServerException {
//m_ipRestriction.enforce(context);
return da.getServiceDefinitions(context, PID, asOfDateTime);
}
|
[
"public",
"String",
"[",
"]",
"getServiceDefinitions",
"(",
"Context",
"context",
",",
"String",
"PID",
",",
"Date",
"asOfDateTime",
")",
"throws",
"ServerException",
"{",
"//m_ipRestriction.enforce(context);",
"return",
"da",
".",
"getServiceDefinitions",
"(",
"context",
",",
"PID",
",",
"asOfDateTime",
")",
";",
"}"
] |
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/DynamicAccessModule.java#L154-L160
|
8,924 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/access/DynamicAccessModule.java
|
DynamicAccessModule.listMethods
|
public ObjectMethodsDef[] listMethods(Context context,
String PID,
Date asOfDateTime)
throws ServerException {
return da.listMethods(context, PID, asOfDateTime);
}
|
java
|
public ObjectMethodsDef[] listMethods(Context context,
String PID,
Date asOfDateTime)
throws ServerException {
return da.listMethods(context, PID, asOfDateTime);
}
|
[
"public",
"ObjectMethodsDef",
"[",
"]",
"listMethods",
"(",
"Context",
"context",
",",
"String",
"PID",
",",
"Date",
"asOfDateTime",
")",
"throws",
"ServerException",
"{",
"return",
"da",
".",
"listMethods",
"(",
"context",
",",
"PID",
",",
"asOfDateTime",
")",
";",
"}"
] |
Get the definitions for all dynamic disseminations on the object.
<p>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",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/access/DynamicAccessModule.java#L270-L275
|
8,925 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/access/DynamicAccessModule.java
|
DynamicAccessModule.getObjectProfile
|
public ObjectProfile getObjectProfile(Context context,
String PID,
Date asOfDateTime)
throws ServerException {
return null;
}
|
java
|
public ObjectProfile getObjectProfile(Context context,
String PID,
Date asOfDateTime)
throws ServerException {
return null;
}
|
[
"public",
"ObjectProfile",
"getObjectProfile",
"(",
"Context",
"context",
",",
"String",
"PID",
",",
"Date",
"asOfDateTime",
")",
"throws",
"ServerException",
"{",
"return",
"null",
";",
"}"
] |
Get the profile information for the digital object. This contain key
metadata and URLs for the Dissemination Index and Item Index of the
object.
@param context
@param PID
identifier of digital object being reflected upon
@param asOfDateTime
@return an object profile data structure
@throws ServerException
|
[
"Get",
"the",
"profile",
"information",
"for",
"the",
"digital",
"object",
".",
"This",
"contain",
"key",
"metadata",
"and",
"URLs",
"for",
"the",
"Dissemination",
"Index",
"and",
"Item",
"Index",
"of",
"the",
"object",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/access/DynamicAccessModule.java#L289-L294
|
8,926 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/storage/lowlevel/akubra/AkubraLowlevelStorage.java
|
AkubraLowlevelStorage.safeOverwrite
|
private static void safeOverwrite(Blob origBlob, InputStream content) {
BlobStoreConnection connection = origBlob.getConnection();
String origId = origBlob.getId().toString();
// write new content to origId/new
Blob newBlob = null;
try {
newBlob = connection.getBlob(new URI(origId + "/new"), null);
copy(content, newBlob.openOutputStream(-1, false));
} catch (Throwable th) {
// any error or exception here is an unrecoverable fault
throw new FaultException(th);
}
// At this point, we have origId (with old content) and origId/new
// rename origId to origId/old
Blob oldBlob = null;
try {
oldBlob = rename(origBlob, origId + "/old");
} finally {
if (oldBlob == null) {
// rename failed; attempt recovery before throwing the fault
try {
delete(newBlob);
} catch (Throwable th) {
logger.error("Failed to delete " + newBlob.getId() + " while"
+ " recovering from rename failure during safe"
+ " overwrite", th);
}
}
}
// At this point, we have origId/old and origId/new
// rename origId/new to origId
boolean successful = false;
try {
rename(newBlob, origId);
successful = true;
} finally {
if (!successful) {
// rename failed; attempt recovery before throwing the fault
try {
rename(oldBlob, origId);
} catch (Throwable th) {
logger.error("Failed to rename " + oldBlob.getId() + " to "
+ origId + " while recovering from rename"
+ " failure during safe overwrite", th);
}
try {
newBlob.delete();
} catch (Throwable th) {
logger.error("Failed to delete " + newBlob.getId()
+ " while recovering from rename"
+ " failure during safe overwrite", th);
}
}
}
// At this point, we have origId (with new content) and origId/old
// remove origId/old; we don't need it anymore
try {
delete(oldBlob);
} catch (Throwable th) {
logger.error("Failed to delete " + oldBlob.getId()
+ " while cleaning up after committed"
+ " safe overwrite", th);
}
}
|
java
|
private static void safeOverwrite(Blob origBlob, InputStream content) {
BlobStoreConnection connection = origBlob.getConnection();
String origId = origBlob.getId().toString();
// write new content to origId/new
Blob newBlob = null;
try {
newBlob = connection.getBlob(new URI(origId + "/new"), null);
copy(content, newBlob.openOutputStream(-1, false));
} catch (Throwable th) {
// any error or exception here is an unrecoverable fault
throw new FaultException(th);
}
// At this point, we have origId (with old content) and origId/new
// rename origId to origId/old
Blob oldBlob = null;
try {
oldBlob = rename(origBlob, origId + "/old");
} finally {
if (oldBlob == null) {
// rename failed; attempt recovery before throwing the fault
try {
delete(newBlob);
} catch (Throwable th) {
logger.error("Failed to delete " + newBlob.getId() + " while"
+ " recovering from rename failure during safe"
+ " overwrite", th);
}
}
}
// At this point, we have origId/old and origId/new
// rename origId/new to origId
boolean successful = false;
try {
rename(newBlob, origId);
successful = true;
} finally {
if (!successful) {
// rename failed; attempt recovery before throwing the fault
try {
rename(oldBlob, origId);
} catch (Throwable th) {
logger.error("Failed to rename " + oldBlob.getId() + " to "
+ origId + " while recovering from rename"
+ " failure during safe overwrite", th);
}
try {
newBlob.delete();
} catch (Throwable th) {
logger.error("Failed to delete " + newBlob.getId()
+ " while recovering from rename"
+ " failure during safe overwrite", th);
}
}
}
// At this point, we have origId (with new content) and origId/old
// remove origId/old; we don't need it anymore
try {
delete(oldBlob);
} catch (Throwable th) {
logger.error("Failed to delete " + oldBlob.getId()
+ " while cleaning up after committed"
+ " safe overwrite", th);
}
}
|
[
"private",
"static",
"void",
"safeOverwrite",
"(",
"Blob",
"origBlob",
",",
"InputStream",
"content",
")",
"{",
"BlobStoreConnection",
"connection",
"=",
"origBlob",
".",
"getConnection",
"(",
")",
";",
"String",
"origId",
"=",
"origBlob",
".",
"getId",
"(",
")",
".",
"toString",
"(",
")",
";",
"// write new content to origId/new",
"Blob",
"newBlob",
"=",
"null",
";",
"try",
"{",
"newBlob",
"=",
"connection",
".",
"getBlob",
"(",
"new",
"URI",
"(",
"origId",
"+",
"\"/new\"",
")",
",",
"null",
")",
";",
"copy",
"(",
"content",
",",
"newBlob",
".",
"openOutputStream",
"(",
"-",
"1",
",",
"false",
")",
")",
";",
"}",
"catch",
"(",
"Throwable",
"th",
")",
"{",
"// any error or exception here is an unrecoverable fault",
"throw",
"new",
"FaultException",
"(",
"th",
")",
";",
"}",
"// At this point, we have origId (with old content) and origId/new",
"// rename origId to origId/old",
"Blob",
"oldBlob",
"=",
"null",
";",
"try",
"{",
"oldBlob",
"=",
"rename",
"(",
"origBlob",
",",
"origId",
"+",
"\"/old\"",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"oldBlob",
"==",
"null",
")",
"{",
"// rename failed; attempt recovery before throwing the fault",
"try",
"{",
"delete",
"(",
"newBlob",
")",
";",
"}",
"catch",
"(",
"Throwable",
"th",
")",
"{",
"logger",
".",
"error",
"(",
"\"Failed to delete \"",
"+",
"newBlob",
".",
"getId",
"(",
")",
"+",
"\" while\"",
"+",
"\" recovering from rename failure during safe\"",
"+",
"\" overwrite\"",
",",
"th",
")",
";",
"}",
"}",
"}",
"// At this point, we have origId/old and origId/new",
"// rename origId/new to origId",
"boolean",
"successful",
"=",
"false",
";",
"try",
"{",
"rename",
"(",
"newBlob",
",",
"origId",
")",
";",
"successful",
"=",
"true",
";",
"}",
"finally",
"{",
"if",
"(",
"!",
"successful",
")",
"{",
"// rename failed; attempt recovery before throwing the fault",
"try",
"{",
"rename",
"(",
"oldBlob",
",",
"origId",
")",
";",
"}",
"catch",
"(",
"Throwable",
"th",
")",
"{",
"logger",
".",
"error",
"(",
"\"Failed to rename \"",
"+",
"oldBlob",
".",
"getId",
"(",
")",
"+",
"\" to \"",
"+",
"origId",
"+",
"\" while recovering from rename\"",
"+",
"\" failure during safe overwrite\"",
",",
"th",
")",
";",
"}",
"try",
"{",
"newBlob",
".",
"delete",
"(",
")",
";",
"}",
"catch",
"(",
"Throwable",
"th",
")",
"{",
"logger",
".",
"error",
"(",
"\"Failed to delete \"",
"+",
"newBlob",
".",
"getId",
"(",
")",
"+",
"\" while recovering from rename\"",
"+",
"\" failure during safe overwrite\"",
",",
"th",
")",
";",
"}",
"}",
"}",
"// At this point, we have origId (with new content) and origId/old",
"// remove origId/old; we don't need it anymore",
"try",
"{",
"delete",
"(",
"oldBlob",
")",
";",
"}",
"catch",
"(",
"Throwable",
"th",
")",
"{",
"logger",
".",
"error",
"(",
"\"Failed to delete \"",
"+",
"oldBlob",
".",
"getId",
"(",
")",
"+",
"\" while cleaning up after committed\"",
"+",
"\" safe overwrite\"",
",",
"th",
")",
";",
"}",
"}"
] |
Overwrites the content of the given blob in a way that guarantees the
original content is not destroyed until the replacement is successfully
put in its place.
|
[
"Overwrites",
"the",
"content",
"of",
"the",
"given",
"blob",
"in",
"a",
"way",
"that",
"guarantees",
"the",
"original",
"content",
"is",
"not",
"destroyed",
"until",
"the",
"replacement",
"is",
"successfully",
"put",
"in",
"its",
"place",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/storage/lowlevel/akubra/AkubraLowlevelStorage.java#L327-L397
|
8,927 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/storage/lowlevel/akubra/AkubraLowlevelStorage.java
|
AkubraLowlevelStorage.getToken
|
private static String getToken(URI blobId) {
String[] parts = blobId.getSchemeSpecificPart().split("/");
if (parts.length == 2) {
return parts[1];
} else if (parts.length == 4) {
return parts[1] + "+" + uriDecode(parts[2]) + "+"
+ uriDecode(parts[3]);
} else {
throw new IllegalArgumentException("Malformed token-as-blobId: "
+ blobId);
}
}
|
java
|
private static String getToken(URI blobId) {
String[] parts = blobId.getSchemeSpecificPart().split("/");
if (parts.length == 2) {
return parts[1];
} else if (parts.length == 4) {
return parts[1] + "+" + uriDecode(parts[2]) + "+"
+ uriDecode(parts[3]);
} else {
throw new IllegalArgumentException("Malformed token-as-blobId: "
+ blobId);
}
}
|
[
"private",
"static",
"String",
"getToken",
"(",
"URI",
"blobId",
")",
"{",
"String",
"[",
"]",
"parts",
"=",
"blobId",
".",
"getSchemeSpecificPart",
"(",
")",
".",
"split",
"(",
"\"/\"",
")",
";",
"if",
"(",
"parts",
".",
"length",
"==",
"2",
")",
"{",
"return",
"parts",
"[",
"1",
"]",
";",
"}",
"else",
"if",
"(",
"parts",
".",
"length",
"==",
"4",
")",
"{",
"return",
"parts",
"[",
"1",
"]",
"+",
"\"+\"",
"+",
"uriDecode",
"(",
"parts",
"[",
"2",
"]",
")",
"+",
"\"+\"",
"+",
"uriDecode",
"(",
"parts",
"[",
"3",
"]",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Malformed token-as-blobId: \"",
"+",
"blobId",
")",
";",
"}",
"}"
] |
Converts a token-as-blobId back to a token.
@param blobId the blobId to convert.
@return the resulting object or datastream token.
|
[
"Converts",
"a",
"token",
"-",
"as",
"-",
"blobId",
"back",
"to",
"a",
"token",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/storage/lowlevel/akubra/AkubraLowlevelStorage.java#L610-L621
|
8,928 |
fcrepo3/fcrepo
|
fcrepo-security/fcrepo-security-pdp/src/main/java/org/fcrepo/server/security/xacml/pdp/data/ExistPolicyIndex.java
|
ExistPolicyIndex.nodeToByte
|
@Deprecated
protected static byte[] nodeToByte(Node node) throws PolicyIndexException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
Writer output = new OutputStreamWriter(out, Charset.forName("UTF-8"));
try {
SunXmlSerializers.writePrettyPrintWithDecl(node, output);
output.close();
} catch (IOException e) {
throw new PolicyIndexException("Failed to serialise node " + e.getMessage(), e);
}
return out.toByteArray();
}
|
java
|
@Deprecated
protected static byte[] nodeToByte(Node node) throws PolicyIndexException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
Writer output = new OutputStreamWriter(out, Charset.forName("UTF-8"));
try {
SunXmlSerializers.writePrettyPrintWithDecl(node, output);
output.close();
} catch (IOException e) {
throw new PolicyIndexException("Failed to serialise node " + e.getMessage(), e);
}
return out.toByteArray();
}
|
[
"@",
"Deprecated",
"protected",
"static",
"byte",
"[",
"]",
"nodeToByte",
"(",
"Node",
"node",
")",
"throws",
"PolicyIndexException",
"{",
"ByteArrayOutputStream",
"out",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"Writer",
"output",
"=",
"new",
"OutputStreamWriter",
"(",
"out",
",",
"Charset",
".",
"forName",
"(",
"\"UTF-8\"",
")",
")",
";",
"try",
"{",
"SunXmlSerializers",
".",
"writePrettyPrintWithDecl",
"(",
"node",
",",
"output",
")",
";",
"output",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"PolicyIndexException",
"(",
"\"Failed to serialise node \"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"return",
"out",
".",
"toByteArray",
"(",
")",
";",
"}"
] |
get XML document supplied as w3c dom Node as bytes
@param node
@return
@throws PolicyIndexException
|
[
"get",
"XML",
"document",
"supplied",
"as",
"w3c",
"dom",
"Node",
"as",
"bytes"
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-security/fcrepo-security-pdp/src/main/java/org/fcrepo/server/security/xacml/pdp/data/ExistPolicyIndex.java#L304-L316
|
8,929 |
fcrepo3/fcrepo
|
fcrepo-security/fcrepo-security-pdp/src/main/java/org/fcrepo/server/security/xacml/pdp/data/ExistPolicyIndex.java
|
ExistPolicyIndex.sortDescending
|
protected static String[] sortDescending(String[] s) {
Arrays.sort(s,
new Comparator<String>() {
@Override
public int compare(String o1, String o2) {
if (o1.length() < o2.length())
return 1;
if (o1.length() > o2.length())
return -1;
return 0;
}
}
);
return s;
}
|
java
|
protected static String[] sortDescending(String[] s) {
Arrays.sort(s,
new Comparator<String>() {
@Override
public int compare(String o1, String o2) {
if (o1.length() < o2.length())
return 1;
if (o1.length() > o2.length())
return -1;
return 0;
}
}
);
return s;
}
|
[
"protected",
"static",
"String",
"[",
"]",
"sortDescending",
"(",
"String",
"[",
"]",
"s",
")",
"{",
"Arrays",
".",
"sort",
"(",
"s",
",",
"new",
"Comparator",
"<",
"String",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"int",
"compare",
"(",
"String",
"o1",
",",
"String",
"o2",
")",
"{",
"if",
"(",
"o1",
".",
"length",
"(",
")",
"<",
"o2",
".",
"length",
"(",
")",
")",
"return",
"1",
";",
"if",
"(",
"o1",
".",
"length",
"(",
")",
">",
"o2",
".",
"length",
"(",
")",
")",
"return",
"-",
"1",
";",
"return",
"0",
";",
"}",
"}",
")",
";",
"return",
"s",
";",
"}"
] |
sorts a string array in descending order of length
@param s
@return
|
[
"sorts",
"a",
"string",
"array",
"in",
"descending",
"order",
"of",
"length"
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-security/fcrepo-security-pdp/src/main/java/org/fcrepo/server/security/xacml/pdp/data/ExistPolicyIndex.java#L342-L356
|
8,930 |
fcrepo3/fcrepo
|
fcrepo-security/fcrepo-security-pdp/src/main/java/org/fcrepo/server/security/xacml/pdp/data/ExistPolicyIndex.java
|
ExistPolicyIndex.createCollectionPath
|
protected Collection createCollectionPath(String collectionPath, Collection rootCollection) throws PolicyIndexException {
try {
if (rootCollection.getParentCollection() != null) {
throw new PolicyIndexException("Collection supplied is not a root collection");
}
String rootCollectionName = rootCollection.getName();
if (!collectionPath.startsWith(rootCollectionName)) {
throw new PolicyIndexException("Collection path " + collectionPath + " does not start from root collection - " + rootCollectionName );
}
// strip root collection from path, obtain each individual collection name in the path
String pathToCreate = collectionPath.substring(rootCollectionName.length());
String[] collections = pathToCreate.split("/");
// iterate each and create as necessary
Collection nextCollection = rootCollection;
for (String collectionName : collections ) {
Collection childCollection = nextCollection.getChildCollection(collectionName);
if (childCollection != null) {
// child exists
childCollection = nextCollection.getChildCollection(collectionName);
} else {
// does not exist, create it
CollectionManagementService mgtService = (CollectionManagementService) nextCollection.getService("CollectionManagementService", "1.0");
childCollection = mgtService.createCollection(collectionName);
log.debug("Created collection " + collectionName);
}
if (nextCollection.isOpen()) {
nextCollection.close();
}
nextCollection = childCollection;
}
return nextCollection;
} catch (XMLDBException e) {
log.error("Error creating collections from path " + e.getMessage(), e);
throw new PolicyIndexException("Error creating collections from path " + e.getMessage(), e);
}
}
|
java
|
protected Collection createCollectionPath(String collectionPath, Collection rootCollection) throws PolicyIndexException {
try {
if (rootCollection.getParentCollection() != null) {
throw new PolicyIndexException("Collection supplied is not a root collection");
}
String rootCollectionName = rootCollection.getName();
if (!collectionPath.startsWith(rootCollectionName)) {
throw new PolicyIndexException("Collection path " + collectionPath + " does not start from root collection - " + rootCollectionName );
}
// strip root collection from path, obtain each individual collection name in the path
String pathToCreate = collectionPath.substring(rootCollectionName.length());
String[] collections = pathToCreate.split("/");
// iterate each and create as necessary
Collection nextCollection = rootCollection;
for (String collectionName : collections ) {
Collection childCollection = nextCollection.getChildCollection(collectionName);
if (childCollection != null) {
// child exists
childCollection = nextCollection.getChildCollection(collectionName);
} else {
// does not exist, create it
CollectionManagementService mgtService = (CollectionManagementService) nextCollection.getService("CollectionManagementService", "1.0");
childCollection = mgtService.createCollection(collectionName);
log.debug("Created collection " + collectionName);
}
if (nextCollection.isOpen()) {
nextCollection.close();
}
nextCollection = childCollection;
}
return nextCollection;
} catch (XMLDBException e) {
log.error("Error creating collections from path " + e.getMessage(), e);
throw new PolicyIndexException("Error creating collections from path " + e.getMessage(), e);
}
}
|
[
"protected",
"Collection",
"createCollectionPath",
"(",
"String",
"collectionPath",
",",
"Collection",
"rootCollection",
")",
"throws",
"PolicyIndexException",
"{",
"try",
"{",
"if",
"(",
"rootCollection",
".",
"getParentCollection",
"(",
")",
"!=",
"null",
")",
"{",
"throw",
"new",
"PolicyIndexException",
"(",
"\"Collection supplied is not a root collection\"",
")",
";",
"}",
"String",
"rootCollectionName",
"=",
"rootCollection",
".",
"getName",
"(",
")",
";",
"if",
"(",
"!",
"collectionPath",
".",
"startsWith",
"(",
"rootCollectionName",
")",
")",
"{",
"throw",
"new",
"PolicyIndexException",
"(",
"\"Collection path \"",
"+",
"collectionPath",
"+",
"\" does not start from root collection - \"",
"+",
"rootCollectionName",
")",
";",
"}",
"// strip root collection from path, obtain each individual collection name in the path",
"String",
"pathToCreate",
"=",
"collectionPath",
".",
"substring",
"(",
"rootCollectionName",
".",
"length",
"(",
")",
")",
";",
"String",
"[",
"]",
"collections",
"=",
"pathToCreate",
".",
"split",
"(",
"\"/\"",
")",
";",
"// iterate each and create as necessary",
"Collection",
"nextCollection",
"=",
"rootCollection",
";",
"for",
"(",
"String",
"collectionName",
":",
"collections",
")",
"{",
"Collection",
"childCollection",
"=",
"nextCollection",
".",
"getChildCollection",
"(",
"collectionName",
")",
";",
"if",
"(",
"childCollection",
"!=",
"null",
")",
"{",
"// child exists",
"childCollection",
"=",
"nextCollection",
".",
"getChildCollection",
"(",
"collectionName",
")",
";",
"}",
"else",
"{",
"// does not exist, create it",
"CollectionManagementService",
"mgtService",
"=",
"(",
"CollectionManagementService",
")",
"nextCollection",
".",
"getService",
"(",
"\"CollectionManagementService\"",
",",
"\"1.0\"",
")",
";",
"childCollection",
"=",
"mgtService",
".",
"createCollection",
"(",
"collectionName",
")",
";",
"log",
".",
"debug",
"(",
"\"Created collection \"",
"+",
"collectionName",
")",
";",
"}",
"if",
"(",
"nextCollection",
".",
"isOpen",
"(",
")",
")",
"{",
"nextCollection",
".",
"close",
"(",
")",
";",
"}",
"nextCollection",
"=",
"childCollection",
";",
"}",
"return",
"nextCollection",
";",
"}",
"catch",
"(",
"XMLDBException",
"e",
")",
"{",
"log",
".",
"error",
"(",
"\"Error creating collections from path \"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"throw",
"new",
"PolicyIndexException",
"(",
"\"Error creating collections from path \"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}"
] |
Create a collection given a full path to the collection. The collection path must include
the root collection. Intermediate collections in the path are created if they do not
already exist.
@param collectionPath
@param rootCollection
@return
@throws PolicyIndexException
|
[
"Create",
"a",
"collection",
"given",
"a",
"full",
"path",
"to",
"the",
"collection",
".",
"The",
"collection",
"path",
"must",
"include",
"the",
"root",
"collection",
".",
"Intermediate",
"collections",
"in",
"the",
"path",
"are",
"created",
"if",
"they",
"do",
"not",
"already",
"exist",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-security/fcrepo-security-pdp/src/main/java/org/fcrepo/server/security/xacml/pdp/data/ExistPolicyIndex.java#L412-L449
|
8,931 |
fcrepo3/fcrepo
|
fcrepo-security/fcrepo-security-pdp/src/main/java/org/fcrepo/server/security/xacml/pdp/data/ExistPolicyIndex.java
|
ExistPolicyIndex.deleteCollection
|
protected void deleteCollection() throws PolicyIndexException {
// get root collection management service
Collection rootCol;
try {
rootCol = DatabaseManager.getCollection(m_databaseURI + ROOT_COLLECTION_PATH ,m_user, m_password);
CollectionManagementService mgtService = (CollectionManagementService) rootCol.getService("CollectionManagementService", "1.0");
// delete the collection
mgtService.removeCollection(m_collectionName);
log.debug("Policy collection deleted");
} catch (XMLDBException e) {
throw new PolicyIndexException("Error deleting collection " + e.getMessage(), e);
}
}
|
java
|
protected void deleteCollection() throws PolicyIndexException {
// get root collection management service
Collection rootCol;
try {
rootCol = DatabaseManager.getCollection(m_databaseURI + ROOT_COLLECTION_PATH ,m_user, m_password);
CollectionManagementService mgtService = (CollectionManagementService) rootCol.getService("CollectionManagementService", "1.0");
// delete the collection
mgtService.removeCollection(m_collectionName);
log.debug("Policy collection deleted");
} catch (XMLDBException e) {
throw new PolicyIndexException("Error deleting collection " + e.getMessage(), e);
}
}
|
[
"protected",
"void",
"deleteCollection",
"(",
")",
"throws",
"PolicyIndexException",
"{",
"// get root collection management service",
"Collection",
"rootCol",
";",
"try",
"{",
"rootCol",
"=",
"DatabaseManager",
".",
"getCollection",
"(",
"m_databaseURI",
"+",
"ROOT_COLLECTION_PATH",
",",
"m_user",
",",
"m_password",
")",
";",
"CollectionManagementService",
"mgtService",
"=",
"(",
"CollectionManagementService",
")",
"rootCol",
".",
"getService",
"(",
"\"CollectionManagementService\"",
",",
"\"1.0\"",
")",
";",
"// delete the collection",
"mgtService",
".",
"removeCollection",
"(",
"m_collectionName",
")",
";",
"log",
".",
"debug",
"(",
"\"Policy collection deleted\"",
")",
";",
"}",
"catch",
"(",
"XMLDBException",
"e",
")",
"{",
"throw",
"new",
"PolicyIndexException",
"(",
"\"Error deleting collection \"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}"
] |
delete the policy collection from the database
@throws PolicyIndexException
|
[
"delete",
"the",
"policy",
"collection",
"from",
"the",
"database"
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-security/fcrepo-security-pdp/src/main/java/org/fcrepo/server/security/xacml/pdp/data/ExistPolicyIndex.java#L562-L577
|
8,932 |
fcrepo3/fcrepo
|
fcrepo-security/fcrepo-security-pdp/src/main/java/org/fcrepo/server/security/xacml/pdp/data/ExistPolicyIndex.java
|
ExistPolicyIndex.createDocument
|
protected static Document createDocument(String document) throws PolicyIndexException {
// parse policy document and create dom
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
DocumentBuilder builder;
try {
builder = factory.newDocumentBuilder();
Document doc = builder.parse(new InputSource(new StringReader(document)));
return doc;
} catch (ParserConfigurationException e) {
throw new PolicyIndexException(e);
} catch (SAXException e) {
throw new PolicyIndexException(e);
} catch (IOException e) {
throw new PolicyIndexException(e);
}
}
|
java
|
protected static Document createDocument(String document) throws PolicyIndexException {
// parse policy document and create dom
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
DocumentBuilder builder;
try {
builder = factory.newDocumentBuilder();
Document doc = builder.parse(new InputSource(new StringReader(document)));
return doc;
} catch (ParserConfigurationException e) {
throw new PolicyIndexException(e);
} catch (SAXException e) {
throw new PolicyIndexException(e);
} catch (IOException e) {
throw new PolicyIndexException(e);
}
}
|
[
"protected",
"static",
"Document",
"createDocument",
"(",
"String",
"document",
")",
"throws",
"PolicyIndexException",
"{",
"// parse policy document and create dom",
"DocumentBuilderFactory",
"factory",
"=",
"DocumentBuilderFactory",
".",
"newInstance",
"(",
")",
";",
"factory",
".",
"setNamespaceAware",
"(",
"true",
")",
";",
"DocumentBuilder",
"builder",
";",
"try",
"{",
"builder",
"=",
"factory",
".",
"newDocumentBuilder",
"(",
")",
";",
"Document",
"doc",
"=",
"builder",
".",
"parse",
"(",
"new",
"InputSource",
"(",
"new",
"StringReader",
"(",
"document",
")",
")",
")",
";",
"return",
"doc",
";",
"}",
"catch",
"(",
"ParserConfigurationException",
"e",
")",
"{",
"throw",
"new",
"PolicyIndexException",
"(",
"e",
")",
";",
"}",
"catch",
"(",
"SAXException",
"e",
")",
"{",
"throw",
"new",
"PolicyIndexException",
"(",
"e",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"PolicyIndexException",
"(",
"e",
")",
";",
"}",
"}"
] |
create an XML Document from the policy document
|
[
"create",
"an",
"XML",
"Document",
"from",
"the",
"policy",
"document"
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-security/fcrepo-security-pdp/src/main/java/org/fcrepo/server/security/xacml/pdp/data/ExistPolicyIndex.java#L580-L597
|
8,933 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/journal/readerwriter/multicast/JournalEntrySizeEstimator.java
|
JournalEntrySizeEstimator.createXmlEventWriter
|
private XMLEventWriter createXmlEventWriter(StringWriter stringWriter)
throws FactoryConfigurationError, XMLStreamException {
return new IndentingXMLEventWriter(XMLOutputFactory.newInstance()
.createXMLEventWriter(stringWriter));
}
|
java
|
private XMLEventWriter createXmlEventWriter(StringWriter stringWriter)
throws FactoryConfigurationError, XMLStreamException {
return new IndentingXMLEventWriter(XMLOutputFactory.newInstance()
.createXMLEventWriter(stringWriter));
}
|
[
"private",
"XMLEventWriter",
"createXmlEventWriter",
"(",
"StringWriter",
"stringWriter",
")",
"throws",
"FactoryConfigurationError",
",",
"XMLStreamException",
"{",
"return",
"new",
"IndentingXMLEventWriter",
"(",
"XMLOutputFactory",
".",
"newInstance",
"(",
")",
".",
"createXMLEventWriter",
"(",
"stringWriter",
")",
")",
";",
"}"
] |
Wrap an XMLEventWriter around that StringWriter.
|
[
"Wrap",
"an",
"XMLEventWriter",
"around",
"that",
"StringWriter",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/readerwriter/multicast/JournalEntrySizeEstimator.java#L111-L115
|
8,934 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/journal/helpers/JournalHelper.java
|
JournalHelper.copyToTempFile
|
public static File copyToTempFile(InputStream serialization)
throws IOException, FileNotFoundException {
File tempFile = createTempFile();
StreamUtility.pipeStream(serialization,
new FileOutputStream(tempFile),
4096);
return tempFile;
}
|
java
|
public static File copyToTempFile(InputStream serialization)
throws IOException, FileNotFoundException {
File tempFile = createTempFile();
StreamUtility.pipeStream(serialization,
new FileOutputStream(tempFile),
4096);
return tempFile;
}
|
[
"public",
"static",
"File",
"copyToTempFile",
"(",
"InputStream",
"serialization",
")",
"throws",
"IOException",
",",
"FileNotFoundException",
"{",
"File",
"tempFile",
"=",
"createTempFile",
"(",
")",
";",
"StreamUtility",
".",
"pipeStream",
"(",
"serialization",
",",
"new",
"FileOutputStream",
"(",
"tempFile",
")",
",",
"4096",
")",
";",
"return",
"tempFile",
";",
"}"
] |
Copy an input stream to a temporary file, so we can hand an input stream
to the delegate and have another input stream for the journal.
|
[
"Copy",
"an",
"input",
"stream",
"to",
"a",
"temporary",
"file",
"so",
"we",
"can",
"hand",
"an",
"input",
"stream",
"to",
"the",
"delegate",
"and",
"have",
"another",
"input",
"stream",
"for",
"the",
"journal",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/helpers/JournalHelper.java#L45-L52
|
8,935 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/journal/helpers/JournalHelper.java
|
JournalHelper.captureStackTrace
|
public static String captureStackTrace(Throwable e) {
StringWriter buffer = new StringWriter();
e.printStackTrace(new PrintWriter(buffer));
return buffer.toString();
}
|
java
|
public static String captureStackTrace(Throwable e) {
StringWriter buffer = new StringWriter();
e.printStackTrace(new PrintWriter(buffer));
return buffer.toString();
}
|
[
"public",
"static",
"String",
"captureStackTrace",
"(",
"Throwable",
"e",
")",
"{",
"StringWriter",
"buffer",
"=",
"new",
"StringWriter",
"(",
")",
";",
"e",
".",
"printStackTrace",
"(",
"new",
"PrintWriter",
"(",
"buffer",
")",
")",
";",
"return",
"buffer",
".",
"toString",
"(",
")",
";",
"}"
] |
Capture the full stack trace of an Exception, and return it in a String.
|
[
"Capture",
"the",
"full",
"stack",
"trace",
"of",
"an",
"Exception",
"and",
"return",
"it",
"in",
"a",
"String",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/helpers/JournalHelper.java#L73-L77
|
8,936 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/journal/helpers/JournalHelper.java
|
JournalHelper.createInstanceAccordingToParameter
|
public static Object createInstanceAccordingToParameter(String parameterName,
Class<?>[] argClasses,
Object[] args,
Map<String, String> parameters)
throws JournalException {
String className = parameters.get(parameterName);
if (className == null) {
throw new JournalException("No parameter '" + parameterName + "'");
}
return createInstanceFromClassname(className, argClasses, args);
}
|
java
|
public static Object createInstanceAccordingToParameter(String parameterName,
Class<?>[] argClasses,
Object[] args,
Map<String, String> parameters)
throws JournalException {
String className = parameters.get(parameterName);
if (className == null) {
throw new JournalException("No parameter '" + parameterName + "'");
}
return createInstanceFromClassname(className, argClasses, args);
}
|
[
"public",
"static",
"Object",
"createInstanceAccordingToParameter",
"(",
"String",
"parameterName",
",",
"Class",
"<",
"?",
">",
"[",
"]",
"argClasses",
",",
"Object",
"[",
"]",
"args",
",",
"Map",
"<",
"String",
",",
"String",
">",
"parameters",
")",
"throws",
"JournalException",
"{",
"String",
"className",
"=",
"parameters",
".",
"get",
"(",
"parameterName",
")",
";",
"if",
"(",
"className",
"==",
"null",
")",
"{",
"throw",
"new",
"JournalException",
"(",
"\"No parameter '\"",
"+",
"parameterName",
"+",
"\"'\"",
")",
";",
"}",
"return",
"createInstanceFromClassname",
"(",
"className",
",",
"argClasses",
",",
"args",
")",
";",
"}"
] |
Look in the system parameters and create an instance of the named class.
@param parameterName
The name of the system parameter that contains the classname
@param argClasses
What types of arguments are required by the constructor?
@param args
Arguments to provide to the instance constructor.
@param parameters
The system parameters
@return the new instance created
|
[
"Look",
"in",
"the",
"system",
"parameters",
"and",
"create",
"an",
"instance",
"of",
"the",
"named",
"class",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/helpers/JournalHelper.java#L92-L102
|
8,937 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/journal/helpers/JournalHelper.java
|
JournalHelper.createInstanceFromClassname
|
public static Object createInstanceFromClassname(String className,
Class<?>[] argClasses,
Object[] args)
throws JournalException {
try {
Class<?> clazz = Class.forName(className);
Constructor<?> constructor = clazz.getConstructor(argClasses);
return constructor.newInstance(args);
} catch (Exception e) {
throw new JournalException(e);
}
}
|
java
|
public static Object createInstanceFromClassname(String className,
Class<?>[] argClasses,
Object[] args)
throws JournalException {
try {
Class<?> clazz = Class.forName(className);
Constructor<?> constructor = clazz.getConstructor(argClasses);
return constructor.newInstance(args);
} catch (Exception e) {
throw new JournalException(e);
}
}
|
[
"public",
"static",
"Object",
"createInstanceFromClassname",
"(",
"String",
"className",
",",
"Class",
"<",
"?",
">",
"[",
"]",
"argClasses",
",",
"Object",
"[",
"]",
"args",
")",
"throws",
"JournalException",
"{",
"try",
"{",
"Class",
"<",
"?",
">",
"clazz",
"=",
"Class",
".",
"forName",
"(",
"className",
")",
";",
"Constructor",
"<",
"?",
">",
"constructor",
"=",
"clazz",
".",
"getConstructor",
"(",
"argClasses",
")",
";",
"return",
"constructor",
".",
"newInstance",
"(",
"args",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"JournalException",
"(",
"e",
")",
";",
"}",
"}"
] |
Create an instance of the named class.
@param className
The classname of the desired instance
@param argClasses
What types of arguments are required by the constructor?
@param args
Arguments to provide to the instance constructor.
@return the new instance created
|
[
"Create",
"an",
"instance",
"of",
"the",
"named",
"class",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/helpers/JournalHelper.java#L115-L127
|
8,938 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/journal/helpers/JournalHelper.java
|
JournalHelper.formatDate
|
public static String formatDate(Date date) {
SimpleDateFormat formatter = new SimpleDateFormat(TIMESTAMP_FORMAT);
return formatter.format(date);
}
|
java
|
public static String formatDate(Date date) {
SimpleDateFormat formatter = new SimpleDateFormat(TIMESTAMP_FORMAT);
return formatter.format(date);
}
|
[
"public",
"static",
"String",
"formatDate",
"(",
"Date",
"date",
")",
"{",
"SimpleDateFormat",
"formatter",
"=",
"new",
"SimpleDateFormat",
"(",
"TIMESTAMP_FORMAT",
")",
";",
"return",
"formatter",
".",
"format",
"(",
"date",
")",
";",
"}"
] |
Format a date for the journal or the logger.
|
[
"Format",
"a",
"date",
"for",
"the",
"journal",
"or",
"the",
"logger",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/helpers/JournalHelper.java#L132-L135
|
8,939 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/journal/helpers/JournalHelper.java
|
JournalHelper.parseDate
|
public static Date parseDate(String date) throws JournalException {
try {
SimpleDateFormat parser = new SimpleDateFormat(TIMESTAMP_FORMAT);
return parser.parse(date);
} catch (ParseException e) {
throw new JournalException(e);
}
}
|
java
|
public static Date parseDate(String date) throws JournalException {
try {
SimpleDateFormat parser = new SimpleDateFormat(TIMESTAMP_FORMAT);
return parser.parse(date);
} catch (ParseException e) {
throw new JournalException(e);
}
}
|
[
"public",
"static",
"Date",
"parseDate",
"(",
"String",
"date",
")",
"throws",
"JournalException",
"{",
"try",
"{",
"SimpleDateFormat",
"parser",
"=",
"new",
"SimpleDateFormat",
"(",
"TIMESTAMP_FORMAT",
")",
";",
"return",
"parser",
".",
"parse",
"(",
"date",
")",
";",
"}",
"catch",
"(",
"ParseException",
"e",
")",
"{",
"throw",
"new",
"JournalException",
"(",
"e",
")",
";",
"}",
"}"
] |
Parse a date from the journal.
|
[
"Parse",
"a",
"date",
"from",
"the",
"journal",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/helpers/JournalHelper.java#L140-L147
|
8,940 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/journal/helpers/JournalHelper.java
|
JournalHelper.createTimestampedFilename
|
public static String createTimestampedFilename(String filenamePrefix,
Date date) {
SimpleDateFormat formatter =
new SimpleDateFormat(FORMAT_JOURNAL_FILENAME_TIMESTAMP);
formatter.setTimeZone(TimeZone.getTimeZone("GMT"));
return filenamePrefix + formatter.format(date) + "Z";
}
|
java
|
public static String createTimestampedFilename(String filenamePrefix,
Date date) {
SimpleDateFormat formatter =
new SimpleDateFormat(FORMAT_JOURNAL_FILENAME_TIMESTAMP);
formatter.setTimeZone(TimeZone.getTimeZone("GMT"));
return filenamePrefix + formatter.format(date) + "Z";
}
|
[
"public",
"static",
"String",
"createTimestampedFilename",
"(",
"String",
"filenamePrefix",
",",
"Date",
"date",
")",
"{",
"SimpleDateFormat",
"formatter",
"=",
"new",
"SimpleDateFormat",
"(",
"FORMAT_JOURNAL_FILENAME_TIMESTAMP",
")",
";",
"formatter",
".",
"setTimeZone",
"(",
"TimeZone",
".",
"getTimeZone",
"(",
"\"GMT\"",
")",
")",
";",
"return",
"filenamePrefix",
"+",
"formatter",
".",
"format",
"(",
"date",
")",
"+",
"\"Z\"",
";",
"}"
] |
Create the name for a Journal file or a log file, based on the prefix and
the current date.
|
[
"Create",
"the",
"name",
"for",
"a",
"Journal",
"file",
"or",
"a",
"log",
"file",
"based",
"on",
"the",
"prefix",
"and",
"the",
"current",
"date",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/helpers/JournalHelper.java#L153-L159
|
8,941 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/validation/ValidationUtility.java
|
ValidationUtility.validateURL
|
public static void validateURL(String url, String controlGroup)
throws ValidationException {
if (!(controlGroup.equalsIgnoreCase("M") || controlGroup.equalsIgnoreCase("E")) && url.startsWith("file:")) {
throw new ValidationException(
"Malformed URL (file: not allowed for control group "
+ controlGroup + ") " + url);
}
try {
new URL(url);
} catch (MalformedURLException e) {
if (url.startsWith(DatastreamManagedContent.UPLOADED_SCHEME)) {
return;
}
throw new ValidationException("Malformed URL: " + url, e);
}
}
|
java
|
public static void validateURL(String url, String controlGroup)
throws ValidationException {
if (!(controlGroup.equalsIgnoreCase("M") || controlGroup.equalsIgnoreCase("E")) && url.startsWith("file:")) {
throw new ValidationException(
"Malformed URL (file: not allowed for control group "
+ controlGroup + ") " + url);
}
try {
new URL(url);
} catch (MalformedURLException e) {
if (url.startsWith(DatastreamManagedContent.UPLOADED_SCHEME)) {
return;
}
throw new ValidationException("Malformed URL: " + url, e);
}
}
|
[
"public",
"static",
"void",
"validateURL",
"(",
"String",
"url",
",",
"String",
"controlGroup",
")",
"throws",
"ValidationException",
"{",
"if",
"(",
"!",
"(",
"controlGroup",
".",
"equalsIgnoreCase",
"(",
"\"M\"",
")",
"||",
"controlGroup",
".",
"equalsIgnoreCase",
"(",
"\"E\"",
")",
")",
"&&",
"url",
".",
"startsWith",
"(",
"\"file:\"",
")",
")",
"{",
"throw",
"new",
"ValidationException",
"(",
"\"Malformed URL (file: not allowed for control group \"",
"+",
"controlGroup",
"+",
"\") \"",
"+",
"url",
")",
";",
"}",
"try",
"{",
"new",
"URL",
"(",
"url",
")",
";",
"}",
"catch",
"(",
"MalformedURLException",
"e",
")",
"{",
"if",
"(",
"url",
".",
"startsWith",
"(",
"DatastreamManagedContent",
".",
"UPLOADED_SCHEME",
")",
")",
"{",
"return",
";",
"}",
"throw",
"new",
"ValidationException",
"(",
"\"Malformed URL: \"",
"+",
"url",
",",
"e",
")",
";",
"}",
"}"
] |
Validates the candidate URL. The result of the validation also depends on the
control group of the datastream in question. Managed datastreams may be ingested
using the file URI scheme, other datastreams may not.
@param url
The URL to validate.
@param controlGroup
The control group of the datastream the URL belongs to.
@throws ValidationException
if the URL is malformed.
|
[
"Validates",
"the",
"candidate",
"URL",
".",
"The",
"result",
"of",
"the",
"validation",
"also",
"depends",
"on",
"the",
"control",
"group",
"of",
"the",
"datastream",
"in",
"question",
".",
"Managed",
"datastreams",
"may",
"be",
"ingested",
"using",
"the",
"file",
"URI",
"scheme",
"other",
"datastreams",
"may",
"not",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/validation/ValidationUtility.java#L59-L74
|
8,942 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/validation/ValidationUtility.java
|
ValidationUtility.validateReservedDatastreams
|
public static void validateReservedDatastreams(DOReader reader)
throws ValidationException {
try {
for (Datastream ds: reader.GetDatastreams(null, null)) {
if ("X".equals(ds.DSControlGrp) || "M".equals(ds.DSControlGrp)) {
validateReservedDatastream(PID.getInstance(reader.GetObjectPID()),
ds.DatastreamID,
ds);
}
}
} catch (ValidationException e) {
throw e;
} catch (ServerException e) {
throw new FaultException(e);
}
}
|
java
|
public static void validateReservedDatastreams(DOReader reader)
throws ValidationException {
try {
for (Datastream ds: reader.GetDatastreams(null, null)) {
if ("X".equals(ds.DSControlGrp) || "M".equals(ds.DSControlGrp)) {
validateReservedDatastream(PID.getInstance(reader.GetObjectPID()),
ds.DatastreamID,
ds);
}
}
} catch (ValidationException e) {
throw e;
} catch (ServerException e) {
throw new FaultException(e);
}
}
|
[
"public",
"static",
"void",
"validateReservedDatastreams",
"(",
"DOReader",
"reader",
")",
"throws",
"ValidationException",
"{",
"try",
"{",
"for",
"(",
"Datastream",
"ds",
":",
"reader",
".",
"GetDatastreams",
"(",
"null",
",",
"null",
")",
")",
"{",
"if",
"(",
"\"X\"",
".",
"equals",
"(",
"ds",
".",
"DSControlGrp",
")",
"||",
"\"M\"",
".",
"equals",
"(",
"ds",
".",
"DSControlGrp",
")",
")",
"{",
"validateReservedDatastream",
"(",
"PID",
".",
"getInstance",
"(",
"reader",
".",
"GetObjectPID",
"(",
")",
")",
",",
"ds",
".",
"DatastreamID",
",",
"ds",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"ValidationException",
"e",
")",
"{",
"throw",
"e",
";",
"}",
"catch",
"(",
"ServerException",
"e",
")",
"{",
"throw",
"new",
"FaultException",
"(",
"e",
")",
";",
"}",
"}"
] |
Validates the latest version of all reserved datastreams in the given
object.
|
[
"Validates",
"the",
"latest",
"version",
"of",
"all",
"reserved",
"datastreams",
"in",
"the",
"given",
"object",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/validation/ValidationUtility.java#L99-L114
|
8,943 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/validation/ValidationUtility.java
|
ValidationUtility.validateReservedDatastream
|
public static void validateReservedDatastream(PID pid,
String dsId,
Datastream ds)
throws ValidationException {
// NB: only want to generate inputstream from .getContentStream() once
// we know that this is a datastream to validate
// to prevent reading of non-reserved datstream content when it is not needed
InputStream content = null;
try {
if ("POLICY".equals(dsId)) {
content = ds.getContentStream();
validatePOLICY(content);
} else if ("FESLPOLICY".equals(dsId)) {
content = ds.getContentStream();
validateFESLPOLICY(content);
} else if ("RELS-EXT".equals(dsId) || "RELS-INT".equals(dsId)) {
content = ds.getContentStream();
validateRELS(pid, dsId, content);
}
} catch (StreamIOException e) {
throw new ValidationException("Failed to get content stream for " + pid + "/" + dsId + ": " + e.getMessage(), e);
}
if (content != null) {
try {
content.close();
} catch (IOException e) {
throw new ValidationException("Error closing content stream for " + pid + "/" + dsId + ": " + e.getMessage(), e);
}
}
}
|
java
|
public static void validateReservedDatastream(PID pid,
String dsId,
Datastream ds)
throws ValidationException {
// NB: only want to generate inputstream from .getContentStream() once
// we know that this is a datastream to validate
// to prevent reading of non-reserved datstream content when it is not needed
InputStream content = null;
try {
if ("POLICY".equals(dsId)) {
content = ds.getContentStream();
validatePOLICY(content);
} else if ("FESLPOLICY".equals(dsId)) {
content = ds.getContentStream();
validateFESLPOLICY(content);
} else if ("RELS-EXT".equals(dsId) || "RELS-INT".equals(dsId)) {
content = ds.getContentStream();
validateRELS(pid, dsId, content);
}
} catch (StreamIOException e) {
throw new ValidationException("Failed to get content stream for " + pid + "/" + dsId + ": " + e.getMessage(), e);
}
if (content != null) {
try {
content.close();
} catch (IOException e) {
throw new ValidationException("Error closing content stream for " + pid + "/" + dsId + ": " + e.getMessage(), e);
}
}
}
|
[
"public",
"static",
"void",
"validateReservedDatastream",
"(",
"PID",
"pid",
",",
"String",
"dsId",
",",
"Datastream",
"ds",
")",
"throws",
"ValidationException",
"{",
"// NB: only want to generate inputstream from .getContentStream() once",
"// we know that this is a datastream to validate",
"// to prevent reading of non-reserved datstream content when it is not needed",
"InputStream",
"content",
"=",
"null",
";",
"try",
"{",
"if",
"(",
"\"POLICY\"",
".",
"equals",
"(",
"dsId",
")",
")",
"{",
"content",
"=",
"ds",
".",
"getContentStream",
"(",
")",
";",
"validatePOLICY",
"(",
"content",
")",
";",
"}",
"else",
"if",
"(",
"\"FESLPOLICY\"",
".",
"equals",
"(",
"dsId",
")",
")",
"{",
"content",
"=",
"ds",
".",
"getContentStream",
"(",
")",
";",
"validateFESLPOLICY",
"(",
"content",
")",
";",
"}",
"else",
"if",
"(",
"\"RELS-EXT\"",
".",
"equals",
"(",
"dsId",
")",
"||",
"\"RELS-INT\"",
".",
"equals",
"(",
"dsId",
")",
")",
"{",
"content",
"=",
"ds",
".",
"getContentStream",
"(",
")",
";",
"validateRELS",
"(",
"pid",
",",
"dsId",
",",
"content",
")",
";",
"}",
"}",
"catch",
"(",
"StreamIOException",
"e",
")",
"{",
"throw",
"new",
"ValidationException",
"(",
"\"Failed to get content stream for \"",
"+",
"pid",
"+",
"\"/\"",
"+",
"dsId",
"+",
"\": \"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"if",
"(",
"content",
"!=",
"null",
")",
"{",
"try",
"{",
"content",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"ValidationException",
"(",
"\"Error closing content stream for \"",
"+",
"pid",
"+",
"\"/\"",
"+",
"dsId",
"+",
"\": \"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}",
"}"
] |
Validates the given datastream if it's a reserved datastream.
The given stream is guaranteed to be closed when this method completes.
|
[
"Validates",
"the",
"given",
"datastream",
"if",
"it",
"s",
"a",
"reserved",
"datastream",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/validation/ValidationUtility.java#L121-L153
|
8,944 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/validation/ValidationUtility.java
|
ValidationUtility.validateRELS
|
private static void validateRELS(PID pid, String dsId, InputStream content)
throws ValidationException {
logger.debug("Validating " + dsId + " datastream");
new RelsValidator().validate(pid, dsId, content);
logger.debug(dsId + " datastream is valid");
}
|
java
|
private static void validateRELS(PID pid, String dsId, InputStream content)
throws ValidationException {
logger.debug("Validating " + dsId + " datastream");
new RelsValidator().validate(pid, dsId, content);
logger.debug(dsId + " datastream is valid");
}
|
[
"private",
"static",
"void",
"validateRELS",
"(",
"PID",
"pid",
",",
"String",
"dsId",
",",
"InputStream",
"content",
")",
"throws",
"ValidationException",
"{",
"logger",
".",
"debug",
"(",
"\"Validating \"",
"+",
"dsId",
"+",
"\" datastream\"",
")",
";",
"new",
"RelsValidator",
"(",
")",
".",
"validate",
"(",
"pid",
",",
"dsId",
",",
"content",
")",
";",
"logger",
".",
"debug",
"(",
"dsId",
"+",
"\" datastream is valid\"",
")",
";",
"}"
] |
validate relationships datastream
@param pid
@param dsId
@param content
@throws ValidationException
|
[
"validate",
"relationships",
"datastream"
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/validation/ValidationUtility.java#L181-L186
|
8,945 |
fcrepo3/fcrepo
|
fcrepo-webapp/fcrepo-webapp-fop/src/main/java/org/fcrepo/localservices/fop/FOPServlet.java
|
FOPServlet.convertString2Source
|
protected Source convertString2Source(String param) {
Source src;
try {
src = uriResolver.resolve(param, null);
} catch (TransformerException e) {
src = null;
}
if (src == null) {
src = new StreamSource(new File(param));
}
return src;
}
|
java
|
protected Source convertString2Source(String param) {
Source src;
try {
src = uriResolver.resolve(param, null);
} catch (TransformerException e) {
src = null;
}
if (src == null) {
src = new StreamSource(new File(param));
}
return src;
}
|
[
"protected",
"Source",
"convertString2Source",
"(",
"String",
"param",
")",
"{",
"Source",
"src",
";",
"try",
"{",
"src",
"=",
"uriResolver",
".",
"resolve",
"(",
"param",
",",
"null",
")",
";",
"}",
"catch",
"(",
"TransformerException",
"e",
")",
"{",
"src",
"=",
"null",
";",
"}",
"if",
"(",
"src",
"==",
"null",
")",
"{",
"src",
"=",
"new",
"StreamSource",
"(",
"new",
"File",
"(",
"param",
")",
")",
";",
"}",
"return",
"src",
";",
"}"
] |
Converts a String parameter to a JAXP Source object.
@param param a String parameter
@return Source the generated Source object
|
[
"Converts",
"a",
"String",
"parameter",
"to",
"a",
"JAXP",
"Source",
"object",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-webapp/fcrepo-webapp-fop/src/main/java/org/fcrepo/localservices/fop/FOPServlet.java#L115-L126
|
8,946 |
fcrepo3/fcrepo
|
fcrepo-webapp/fcrepo-webapp-fop/src/main/java/org/fcrepo/localservices/fop/FOPServlet.java
|
FOPServlet.renderFO
|
protected void renderFO(String fo, HttpServletResponse response)
throws FOPException, TransformerException, IOException {
//Setup source
Source foSrc = convertString2Source(fo);
//Setup the identity transformation
Transformer transformer = this.transFactory.newTransformer();
transformer.setURIResolver(this.uriResolver);
//Start transformation and rendering process
render(foSrc, transformer, response);
}
|
java
|
protected void renderFO(String fo, HttpServletResponse response)
throws FOPException, TransformerException, IOException {
//Setup source
Source foSrc = convertString2Source(fo);
//Setup the identity transformation
Transformer transformer = this.transFactory.newTransformer();
transformer.setURIResolver(this.uriResolver);
//Start transformation and rendering process
render(foSrc, transformer, response);
}
|
[
"protected",
"void",
"renderFO",
"(",
"String",
"fo",
",",
"HttpServletResponse",
"response",
")",
"throws",
"FOPException",
",",
"TransformerException",
",",
"IOException",
"{",
"//Setup source",
"Source",
"foSrc",
"=",
"convertString2Source",
"(",
"fo",
")",
";",
"//Setup the identity transformation",
"Transformer",
"transformer",
"=",
"this",
".",
"transFactory",
".",
"newTransformer",
"(",
")",
";",
"transformer",
".",
"setURIResolver",
"(",
"this",
".",
"uriResolver",
")",
";",
"//Start transformation and rendering process",
"render",
"(",
"foSrc",
",",
"transformer",
",",
"response",
")",
";",
"}"
] |
Renders an XSL-FO file into a PDF file. The PDF is written to a byte
array that is returned as the method's result.
@param fo the XSL-FO file
@param response HTTP response object
@throws FOPException If an error occurs during the rendering of the
XSL-FO
@throws TransformerException If an error occurs while parsing the input
file
@throws IOException In case of an I/O problem
|
[
"Renders",
"an",
"XSL",
"-",
"FO",
"file",
"into",
"a",
"PDF",
"file",
".",
"The",
"PDF",
"is",
"written",
"to",
"a",
"byte",
"array",
"that",
"is",
"returned",
"as",
"the",
"method",
"s",
"result",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-webapp/fcrepo-webapp-fop/src/main/java/org/fcrepo/localservices/fop/FOPServlet.java#L139-L151
|
8,947 |
fcrepo3/fcrepo
|
fcrepo-webapp/fcrepo-webapp-fop/src/main/java/org/fcrepo/localservices/fop/FOPServlet.java
|
FOPServlet.renderXML
|
protected void renderXML(String xml, String xslt, HttpServletResponse response)
throws FOPException, TransformerException, IOException {
//Setup sources
Source xmlSrc = convertString2Source(xml);
Source xsltSrc = convertString2Source(xslt);
//Setup the XSL transformation
Transformer transformer = this.transFactory.newTransformer(xsltSrc);
transformer.setURIResolver(this.uriResolver);
//Start transformation and rendering process
render(xmlSrc, transformer, response);
}
|
java
|
protected void renderXML(String xml, String xslt, HttpServletResponse response)
throws FOPException, TransformerException, IOException {
//Setup sources
Source xmlSrc = convertString2Source(xml);
Source xsltSrc = convertString2Source(xslt);
//Setup the XSL transformation
Transformer transformer = this.transFactory.newTransformer(xsltSrc);
transformer.setURIResolver(this.uriResolver);
//Start transformation and rendering process
render(xmlSrc, transformer, response);
}
|
[
"protected",
"void",
"renderXML",
"(",
"String",
"xml",
",",
"String",
"xslt",
",",
"HttpServletResponse",
"response",
")",
"throws",
"FOPException",
",",
"TransformerException",
",",
"IOException",
"{",
"//Setup sources",
"Source",
"xmlSrc",
"=",
"convertString2Source",
"(",
"xml",
")",
";",
"Source",
"xsltSrc",
"=",
"convertString2Source",
"(",
"xslt",
")",
";",
"//Setup the XSL transformation",
"Transformer",
"transformer",
"=",
"this",
".",
"transFactory",
".",
"newTransformer",
"(",
"xsltSrc",
")",
";",
"transformer",
".",
"setURIResolver",
"(",
"this",
".",
"uriResolver",
")",
";",
"//Start transformation and rendering process",
"render",
"(",
"xmlSrc",
",",
"transformer",
",",
"response",
")",
";",
"}"
] |
Renders an XML file into a PDF file by applying a stylesheet
that converts the XML to XSL-FO. The PDF is written to a byte array
that is returned as the method's result.
@param xml the XML file
@param xslt the XSLT file
@param response HTTP response object
@throws FOPException If an error occurs during the rendering of the
XSL-FO
@throws TransformerException If an error occurs during XSL
transformation
@throws IOException In case of an I/O problem
|
[
"Renders",
"an",
"XML",
"file",
"into",
"a",
"PDF",
"file",
"by",
"applying",
"a",
"stylesheet",
"that",
"converts",
"the",
"XML",
"to",
"XSL",
"-",
"FO",
".",
"The",
"PDF",
"is",
"written",
"to",
"a",
"byte",
"array",
"that",
"is",
"returned",
"as",
"the",
"method",
"s",
"result",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-webapp/fcrepo-webapp-fop/src/main/java/org/fcrepo/localservices/fop/FOPServlet.java#L166-L179
|
8,948 |
fcrepo3/fcrepo
|
fcrepo-security/fcrepo-security-pdp/src/main/java/org/fcrepo/server/security/xacml/pdp/data/FedoraPolicyStore.java
|
FedoraPolicyStore.setSchemaValidation
|
public void setSchemaValidation(boolean validate){
this.validateSchema = validate;
log.info("Initialising validation " + Boolean.toString(validate));
ValidationUtility.setValidateFeslPolicy(validate);
}
|
java
|
public void setSchemaValidation(boolean validate){
this.validateSchema = validate;
log.info("Initialising validation " + Boolean.toString(validate));
ValidationUtility.setValidateFeslPolicy(validate);
}
|
[
"public",
"void",
"setSchemaValidation",
"(",
"boolean",
"validate",
")",
"{",
"this",
".",
"validateSchema",
"=",
"validate",
";",
"log",
".",
"info",
"(",
"\"Initialising validation \"",
"+",
"Boolean",
".",
"toString",
"(",
"validate",
")",
")",
";",
"ValidationUtility",
".",
"setValidateFeslPolicy",
"(",
"validate",
")",
";",
"}"
] |
schema config properties
|
[
"schema",
"config",
"properties"
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-security/fcrepo-security-pdp/src/main/java/org/fcrepo/server/security/xacml/pdp/data/FedoraPolicyStore.java#L145-L149
|
8,949 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/journal/recoverylog/BufferedJournalRecoveryLog.java
|
BufferedJournalRecoveryLog.shutdown
|
@Override
public synchronized void shutdown() {
try {
if (open) {
open = false;
FileWriter logWriter = new FileWriter(logFile);
logWriter.write(buffer.toString());
logWriter.close();
}
} catch (IOException e) {
logger.error("Error shutting down", e);
}
}
|
java
|
@Override
public synchronized void shutdown() {
try {
if (open) {
open = false;
FileWriter logWriter = new FileWriter(logFile);
logWriter.write(buffer.toString());
logWriter.close();
}
} catch (IOException e) {
logger.error("Error shutting down", e);
}
}
|
[
"@",
"Override",
"public",
"synchronized",
"void",
"shutdown",
"(",
")",
"{",
"try",
"{",
"if",
"(",
"open",
")",
"{",
"open",
"=",
"false",
";",
"FileWriter",
"logWriter",
"=",
"new",
"FileWriter",
"(",
"logFile",
")",
";",
"logWriter",
".",
"write",
"(",
"buffer",
".",
"toString",
"(",
")",
")",
";",
"logWriter",
".",
"close",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Error shutting down\"",
",",
"e",
")",
";",
"}",
"}"
] |
On the first call to this method, write the buffer to the log file. Set
the flag so no more logging calls will be accepted.
|
[
"On",
"the",
"first",
"call",
"to",
"this",
"method",
"write",
"the",
"buffer",
"to",
"the",
"log",
"file",
".",
"Set",
"the",
"flag",
"so",
"no",
"more",
"logging",
"calls",
"will",
"be",
"accepted",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/recoverylog/BufferedJournalRecoveryLog.java#L79-L91
|
8,950 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/utilities/TableSpec.java
|
TableSpec.getTableSpecs
|
public static List<TableSpec> getTableSpecs(InputStream in)
throws InconsistentTableSpecException, IOException {
try {
TableSpecDeserializer tsd = new TableSpecDeserializer();
XmlTransformUtility.parseWithoutValidating(in, tsd);
tsd.assertTableSpecsConsistent();
return tsd.getTableSpecs();
} catch (InconsistentTableSpecException itse) {
throw itse;
} catch (Exception e) {
throw new IOException("Error parsing XML: " + e.getMessage());
}
}
|
java
|
public static List<TableSpec> getTableSpecs(InputStream in)
throws InconsistentTableSpecException, IOException {
try {
TableSpecDeserializer tsd = new TableSpecDeserializer();
XmlTransformUtility.parseWithoutValidating(in, tsd);
tsd.assertTableSpecsConsistent();
return tsd.getTableSpecs();
} catch (InconsistentTableSpecException itse) {
throw itse;
} catch (Exception e) {
throw new IOException("Error parsing XML: " + e.getMessage());
}
}
|
[
"public",
"static",
"List",
"<",
"TableSpec",
">",
"getTableSpecs",
"(",
"InputStream",
"in",
")",
"throws",
"InconsistentTableSpecException",
",",
"IOException",
"{",
"try",
"{",
"TableSpecDeserializer",
"tsd",
"=",
"new",
"TableSpecDeserializer",
"(",
")",
";",
"XmlTransformUtility",
".",
"parseWithoutValidating",
"(",
"in",
",",
"tsd",
")",
";",
"tsd",
".",
"assertTableSpecsConsistent",
"(",
")",
";",
"return",
"tsd",
".",
"getTableSpecs",
"(",
")",
";",
"}",
"catch",
"(",
"InconsistentTableSpecException",
"itse",
")",
"{",
"throw",
"itse",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Error parsing XML: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] |
Gets a TableSpec for each table element in the stream, where the stream
contains a valid XML document containing one or more table elements,
wrapped in the root element.
<p>
Input is of the form:
<pre>
<database>
<table name="<i>tableName</i>" primaryKey="<i>primaryColumnName</i>" type="<i>tableType</i>">
<column name="<i>columnName</i>"
type="<i>typeSpec</i>"
autoIncrement="<i>isAutoIncremented</i>"
index="<i>indexName</i>"
notNull="<i>isNotNull</i>"
unique="<i>isUnique</i>"
default="<i>defaultValue</i>"
foreignKey="<i>foreignTableName.columnName onDeleteAction</i>"/>
</table>
</database>
</pre>
About the attributes:
<ul>
<li> <b>tableName</b> - The desired name of the table.
<li> <b>primaryColumnName</b> - Identifies column that is the primary
key for the table. A column that is a primary key must be notNull, and
can't be a foreign key.
<li> <b>type</b> - The table type, which is RDBMS-specific. See
TableSpec(String, Set, String, String) for detail.
<li> <b>columnName</b> - The name of the column.
<li> <b>typeSpec</b> - The value type of the column. For instance,
varchar(255). This is not checked for validity. See <a
href="ColumnSpec.html">ColumnSpec javadoc</a> for detail.
<li> <b>isAutoIncremented</b> - (true|false) Whether values in the
column should be automatically generated by the database upon insert.
This requires that the type be some numeric variant, and is
RDBMS-specific. NUMERIC will generally work.
<li> <b>indexName</b> - Specifies that an index should be created on
this column and provides the column name.
<li> <b>isNotNull</b> - (true|false) Whether input should be limited to
actual values.
<li> <b>isUnique</b> - (true|false) Whether input should be limited such
that all values in the column are unique.
<li> <b>default</b> - The value to be used when inserts don't specify a
value for the column. This cannot be specified with autoIncrement true.
<li> <b>foreignTableName.column</b> - Specifies that this is a foreign
key column and identifies the (primary key) column in the database
containing the rows that values in this column refer to. This cannot be
specified with autoIncrement true.
<li> <b>onDeleteAction</b> - Optionally specifies a "CASCADE" or "SET
NULL" action to be taken on matching rows in this table when a row from
the parent (foreign) table is deleted. If "CASCADE", matching rows in
this table are automatically deleted. If "SET NULL", this column's value
will be set to NULL for all matching rows. This value is not checked for
validity.
</ul>
@param in
The xml-encoded table specs.
@return TableSpec objects.
@throws InconsistentTableSpecException
if inconsistencies are detected in table specifications.
@throws IOException
if an IO error occurs.
|
[
"Gets",
"a",
"TableSpec",
"for",
"each",
"table",
"element",
"in",
"the",
"stream",
"where",
"the",
"stream",
"contains",
"a",
"valid",
"XML",
"document",
"containing",
"one",
"or",
"more",
"table",
"elements",
"wrapped",
"in",
"the",
"root",
"element",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/utilities/TableSpec.java#L155-L167
|
8,951 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/journal/recoverylog/UnbufferedJournalRecoveryLog.java
|
UnbufferedJournalRecoveryLog.shutdown
|
@Override
public synchronized void shutdown() {
try {
if (open) {
open = false;
writer.close();
}
} catch (IOException e) {
logger.error("Error shutting down journal log", e);
}
}
|
java
|
@Override
public synchronized void shutdown() {
try {
if (open) {
open = false;
writer.close();
}
} catch (IOException e) {
logger.error("Error shutting down journal log", e);
}
}
|
[
"@",
"Override",
"public",
"synchronized",
"void",
"shutdown",
"(",
")",
"{",
"try",
"{",
"if",
"(",
"open",
")",
"{",
"open",
"=",
"false",
";",
"writer",
".",
"close",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Error shutting down journal log\"",
",",
"e",
")",
";",
"}",
"}"
] |
On the first call to this method, close the log file. Set the flag so no
more logging calls will be accepted.
|
[
"On",
"the",
"first",
"call",
"to",
"this",
"method",
"close",
"the",
"log",
"file",
".",
"Set",
"the",
"flag",
"so",
"no",
"more",
"logging",
"calls",
"will",
"be",
"accepted",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/recoverylog/UnbufferedJournalRecoveryLog.java#L88-L98
|
8,952 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/security/BESecurityConfig.java
|
BESecurityConfig.getEffectiveInternalSSL
|
public Boolean getEffectiveInternalSSL() {
if (m_internalSSL != null) {
return m_internalSSL;
} else if (m_defaultConfig != null) {
return m_defaultConfig.getEffectiveCallSSL();
} else {
return Boolean.FALSE;
}
}
|
java
|
public Boolean getEffectiveInternalSSL() {
if (m_internalSSL != null) {
return m_internalSSL;
} else if (m_defaultConfig != null) {
return m_defaultConfig.getEffectiveCallSSL();
} else {
return Boolean.FALSE;
}
}
|
[
"public",
"Boolean",
"getEffectiveInternalSSL",
"(",
")",
"{",
"if",
"(",
"m_internalSSL",
"!=",
"null",
")",
"{",
"return",
"m_internalSSL",
";",
"}",
"else",
"if",
"(",
"m_defaultConfig",
"!=",
"null",
")",
"{",
"return",
"m_defaultConfig",
".",
"getEffectiveCallSSL",
"(",
")",
";",
"}",
"else",
"{",
"return",
"Boolean",
".",
"FALSE",
";",
"}",
"}"
] |
Get whether SSL is effectively used for Fedora-to-self calls. This will
be the internalSSL value, if set, or the inherited call value from the
default role, if set, or Boolean.FALSE.
|
[
"Get",
"whether",
"SSL",
"is",
"effectively",
"used",
"for",
"Fedora",
"-",
"to",
"-",
"self",
"calls",
".",
"This",
"will",
"be",
"the",
"internalSSL",
"value",
"if",
"set",
"or",
"the",
"inherited",
"call",
"value",
"from",
"the",
"default",
"role",
"if",
"set",
"or",
"Boolean",
".",
"FALSE",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/security/BESecurityConfig.java#L137-L145
|
8,953 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/security/BESecurityConfig.java
|
BESecurityConfig.getEffectiveInternalBasicAuth
|
public Boolean getEffectiveInternalBasicAuth() {
if (m_internalBasicAuth != null) {
return m_internalBasicAuth;
} else if (m_defaultConfig != null) {
return m_defaultConfig.getEffectiveCallBasicAuth();
} else {
return Boolean.FALSE;
}
}
|
java
|
public Boolean getEffectiveInternalBasicAuth() {
if (m_internalBasicAuth != null) {
return m_internalBasicAuth;
} else if (m_defaultConfig != null) {
return m_defaultConfig.getEffectiveCallBasicAuth();
} else {
return Boolean.FALSE;
}
}
|
[
"public",
"Boolean",
"getEffectiveInternalBasicAuth",
"(",
")",
"{",
"if",
"(",
"m_internalBasicAuth",
"!=",
"null",
")",
"{",
"return",
"m_internalBasicAuth",
";",
"}",
"else",
"if",
"(",
"m_defaultConfig",
"!=",
"null",
")",
"{",
"return",
"m_defaultConfig",
".",
"getEffectiveCallBasicAuth",
"(",
")",
";",
"}",
"else",
"{",
"return",
"Boolean",
".",
"FALSE",
";",
"}",
"}"
] |
Get whether basic auth is effectively used for Fedora-to-self calls. This
will be the internalBasicAuth value, if set, or the inherited call value
from the default role, if set, or Boolean.FALSE.
|
[
"Get",
"whether",
"basic",
"auth",
"is",
"effectively",
"used",
"for",
"Fedora",
"-",
"to",
"-",
"self",
"calls",
".",
"This",
"will",
"be",
"the",
"internalBasicAuth",
"value",
"if",
"set",
"or",
"the",
"inherited",
"call",
"value",
"from",
"the",
"default",
"role",
"if",
"set",
"or",
"Boolean",
".",
"FALSE",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/security/BESecurityConfig.java#L169-L177
|
8,954 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/security/BESecurityConfig.java
|
BESecurityConfig.getEffectiveInternalUsername
|
public String getEffectiveInternalUsername() {
if (m_internalUsername != null) {
return m_internalUsername;
} else if (m_defaultConfig != null) {
return m_defaultConfig.getEffectiveCallUsername();
} else {
return null;
}
}
|
java
|
public String getEffectiveInternalUsername() {
if (m_internalUsername != null) {
return m_internalUsername;
} else if (m_defaultConfig != null) {
return m_defaultConfig.getEffectiveCallUsername();
} else {
return null;
}
}
|
[
"public",
"String",
"getEffectiveInternalUsername",
"(",
")",
"{",
"if",
"(",
"m_internalUsername",
"!=",
"null",
")",
"{",
"return",
"m_internalUsername",
";",
"}",
"else",
"if",
"(",
"m_defaultConfig",
"!=",
"null",
")",
"{",
"return",
"m_defaultConfig",
".",
"getEffectiveCallUsername",
"(",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] |
Get the effective internal username for basic auth Fedora-to-self calls.
This will be the internal username, if set, or the inherited call value
from the default role, if set, or null.
|
[
"Get",
"the",
"effective",
"internal",
"username",
"for",
"basic",
"auth",
"Fedora",
"-",
"to",
"-",
"self",
"calls",
".",
"This",
"will",
"be",
"the",
"internal",
"username",
"if",
"set",
"or",
"the",
"inherited",
"call",
"value",
"from",
"the",
"default",
"role",
"if",
"set",
"or",
"null",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/security/BESecurityConfig.java#L200-L208
|
8,955 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/security/BESecurityConfig.java
|
BESecurityConfig.getEffectiveInternalPassword
|
public String getEffectiveInternalPassword() {
if (m_internalPassword != null) {
return m_internalPassword;
} else if (m_defaultConfig != null) {
return m_defaultConfig.getEffectiveCallPassword();
} else {
return null;
}
}
|
java
|
public String getEffectiveInternalPassword() {
if (m_internalPassword != null) {
return m_internalPassword;
} else if (m_defaultConfig != null) {
return m_defaultConfig.getEffectiveCallPassword();
} else {
return null;
}
}
|
[
"public",
"String",
"getEffectiveInternalPassword",
"(",
")",
"{",
"if",
"(",
"m_internalPassword",
"!=",
"null",
")",
"{",
"return",
"m_internalPassword",
";",
"}",
"else",
"if",
"(",
"m_defaultConfig",
"!=",
"null",
")",
"{",
"return",
"m_defaultConfig",
".",
"getEffectiveCallPassword",
"(",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] |
Get the effective internal password for basic auth Fedora-to-self calls.
This will be the internal password, if set, or the inherited call value
from the default role, if set, or null.
|
[
"Get",
"the",
"effective",
"internal",
"password",
"for",
"basic",
"auth",
"Fedora",
"-",
"to",
"-",
"self",
"calls",
".",
"This",
"will",
"be",
"the",
"internal",
"password",
"if",
"set",
"or",
"the",
"inherited",
"call",
"value",
"from",
"the",
"default",
"role",
"if",
"set",
"or",
"null",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/security/BESecurityConfig.java#L231-L239
|
8,956 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/security/BESecurityConfig.java
|
BESecurityConfig.getEffectiveInternalIPList
|
public String[] getEffectiveInternalIPList() {
if (m_internalIPList != null) {
return m_internalIPList;
} else if (m_defaultConfig != null) {
return m_defaultConfig.getEffectiveIPList();
} else {
return null;
}
}
|
java
|
public String[] getEffectiveInternalIPList() {
if (m_internalIPList != null) {
return m_internalIPList;
} else if (m_defaultConfig != null) {
return m_defaultConfig.getEffectiveIPList();
} else {
return null;
}
}
|
[
"public",
"String",
"[",
"]",
"getEffectiveInternalIPList",
"(",
")",
"{",
"if",
"(",
"m_internalIPList",
"!=",
"null",
")",
"{",
"return",
"m_internalIPList",
";",
"}",
"else",
"if",
"(",
"m_defaultConfig",
"!=",
"null",
")",
"{",
"return",
"m_defaultConfig",
".",
"getEffectiveIPList",
"(",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] |
Get the effective list of internal IP addresses. This will be the
internalIPList value, if set, or the inherited value from the default
role, if set, or null.
|
[
"Get",
"the",
"effective",
"list",
"of",
"internal",
"IP",
"addresses",
".",
"This",
"will",
"be",
"the",
"internalIPList",
"value",
"if",
"set",
"or",
"the",
"inherited",
"value",
"from",
"the",
"default",
"role",
"if",
"set",
"or",
"null",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/security/BESecurityConfig.java#L262-L270
|
8,957 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/security/BESecurityConfig.java
|
BESecurityConfig.addEmptyConfigs
|
public void addEmptyConfigs(Map<String, List<String>> pidToMethodList) {
Iterator<String> pIter = pidToMethodList.keySet().iterator();
while (pIter.hasNext()) {
String sDepPID = pIter.next();
// add the sDep indicated by the key if it doesn't exist
ServiceDeploymentRoleConfig sDepRoleConfig = m_sDepConfigs.get(sDepPID);
if (sDepRoleConfig == null) {
sDepRoleConfig =
new ServiceDeploymentRoleConfig(m_defaultConfig, sDepPID);
m_sDepConfigs.put(sDepPID, sDepRoleConfig);
}
// add each method indicated by the List which doesn't already exist
Iterator<String> mIter = pidToMethodList.get(sDepPID).iterator();
while (mIter.hasNext()) {
String methodName = (String) mIter.next();
MethodRoleConfig methodRoleConfig =
sDepRoleConfig.getMethodConfigs().get(methodName);
if (methodRoleConfig == null) {
methodRoleConfig =
new MethodRoleConfig(sDepRoleConfig, methodName);
sDepRoleConfig.getMethodConfigs().put(methodName,
methodRoleConfig);
}
}
}
}
|
java
|
public void addEmptyConfigs(Map<String, List<String>> pidToMethodList) {
Iterator<String> pIter = pidToMethodList.keySet().iterator();
while (pIter.hasNext()) {
String sDepPID = pIter.next();
// add the sDep indicated by the key if it doesn't exist
ServiceDeploymentRoleConfig sDepRoleConfig = m_sDepConfigs.get(sDepPID);
if (sDepRoleConfig == null) {
sDepRoleConfig =
new ServiceDeploymentRoleConfig(m_defaultConfig, sDepPID);
m_sDepConfigs.put(sDepPID, sDepRoleConfig);
}
// add each method indicated by the List which doesn't already exist
Iterator<String> mIter = pidToMethodList.get(sDepPID).iterator();
while (mIter.hasNext()) {
String methodName = (String) mIter.next();
MethodRoleConfig methodRoleConfig =
sDepRoleConfig.getMethodConfigs().get(methodName);
if (methodRoleConfig == null) {
methodRoleConfig =
new MethodRoleConfig(sDepRoleConfig, methodName);
sDepRoleConfig.getMethodConfigs().put(methodName,
methodRoleConfig);
}
}
}
}
|
[
"public",
"void",
"addEmptyConfigs",
"(",
"Map",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"pidToMethodList",
")",
"{",
"Iterator",
"<",
"String",
">",
"pIter",
"=",
"pidToMethodList",
".",
"keySet",
"(",
")",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"pIter",
".",
"hasNext",
"(",
")",
")",
"{",
"String",
"sDepPID",
"=",
"pIter",
".",
"next",
"(",
")",
";",
"// add the sDep indicated by the key if it doesn't exist",
"ServiceDeploymentRoleConfig",
"sDepRoleConfig",
"=",
"m_sDepConfigs",
".",
"get",
"(",
"sDepPID",
")",
";",
"if",
"(",
"sDepRoleConfig",
"==",
"null",
")",
"{",
"sDepRoleConfig",
"=",
"new",
"ServiceDeploymentRoleConfig",
"(",
"m_defaultConfig",
",",
"sDepPID",
")",
";",
"m_sDepConfigs",
".",
"put",
"(",
"sDepPID",
",",
"sDepRoleConfig",
")",
";",
"}",
"// add each method indicated by the List which doesn't already exist",
"Iterator",
"<",
"String",
">",
"mIter",
"=",
"pidToMethodList",
".",
"get",
"(",
"sDepPID",
")",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"mIter",
".",
"hasNext",
"(",
")",
")",
"{",
"String",
"methodName",
"=",
"(",
"String",
")",
"mIter",
".",
"next",
"(",
")",
";",
"MethodRoleConfig",
"methodRoleConfig",
"=",
"sDepRoleConfig",
".",
"getMethodConfigs",
"(",
")",
".",
"get",
"(",
"methodName",
")",
";",
"if",
"(",
"methodRoleConfig",
"==",
"null",
")",
"{",
"methodRoleConfig",
"=",
"new",
"MethodRoleConfig",
"(",
"sDepRoleConfig",
",",
"methodName",
")",
";",
"sDepRoleConfig",
".",
"getMethodConfigs",
"(",
")",
".",
"put",
"(",
"methodName",
",",
"methodRoleConfig",
")",
";",
"}",
"}",
"}",
"}"
] |
Add empty sDep and method configurations given by the map if they are
not already already defined.
|
[
"Add",
"empty",
"sDep",
"and",
"method",
"configurations",
"given",
"by",
"the",
"map",
"if",
"they",
"are",
"not",
"already",
"already",
"defined",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/security/BESecurityConfig.java#L294-L319
|
8,958 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/security/BESecurityConfig.java
|
BESecurityConfig.toStream
|
public void toStream(boolean skipNonOverrides, OutputStream out)
throws Exception {
PrintWriter writer = null;
try {
writer = new PrintWriter(new OutputStreamWriter(out, "UTF-8"));
write(skipNonOverrides, true, writer);
} finally {
try {
writer.close();
} catch (Throwable th) {
}
try {
out.close();
} catch (Throwable th) {
}
}
}
|
java
|
public void toStream(boolean skipNonOverrides, OutputStream out)
throws Exception {
PrintWriter writer = null;
try {
writer = new PrintWriter(new OutputStreamWriter(out, "UTF-8"));
write(skipNonOverrides, true, writer);
} finally {
try {
writer.close();
} catch (Throwable th) {
}
try {
out.close();
} catch (Throwable th) {
}
}
}
|
[
"public",
"void",
"toStream",
"(",
"boolean",
"skipNonOverrides",
",",
"OutputStream",
"out",
")",
"throws",
"Exception",
"{",
"PrintWriter",
"writer",
"=",
"null",
";",
"try",
"{",
"writer",
"=",
"new",
"PrintWriter",
"(",
"new",
"OutputStreamWriter",
"(",
"out",
",",
"\"UTF-8\"",
")",
")",
";",
"write",
"(",
"skipNonOverrides",
",",
"true",
",",
"writer",
")",
";",
"}",
"finally",
"{",
"try",
"{",
"writer",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"Throwable",
"th",
")",
"{",
"}",
"try",
"{",
"out",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"Throwable",
"th",
")",
"{",
"}",
"}",
"}"
] |
Serialize to the given stream, closing it when finished. If
skipNonOverrides is true, any configuration whose values are all null
will not be written.
|
[
"Serialize",
"to",
"the",
"given",
"stream",
"closing",
"it",
"when",
"finished",
".",
"If",
"skipNonOverrides",
"is",
"true",
"any",
"configuration",
"whose",
"values",
"are",
"all",
"null",
"will",
"not",
"be",
"written",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/security/BESecurityConfig.java#L440-L456
|
8,959 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/security/BESecurityConfig.java
|
BESecurityConfig.write
|
public void write(boolean skipNonOverrides,
boolean withXMLDeclaration,
PrintWriter writer) {
final String indent = " ";
// header
if (withXMLDeclaration) {
writer.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
}
writer.println("<" + _CONFIG + " xmlns=\"" + BE_SECURITY.uri + "\"");
writer.println(indent + " xmlns:xsi=\"" + XSI.uri + "\"");
writer.println(indent + " xsi:schemaLocation=\"" + BE_SECURITY.uri
+ " " + BE_SECURITY1_0.xsdLocation + "\"");
// default values
writer.print(indent);
write(m_defaultConfig, false, skipNonOverrides, writer);
writer.println(">");
// fedoraInternalCall-1 and -2
writeInternalConfig(1,
m_internalSSL,
m_internalBasicAuth,
m_internalUsername,
m_internalPassword,
m_internalIPList,
writer);
writeInternalConfig(2,
Boolean.FALSE,
Boolean.FALSE,
null,
null,
m_internalIPList,
writer);
// sDep roles
Iterator<String> bIter = m_sDepConfigs.keySet().iterator();
while (bIter.hasNext()) {
String role = bIter.next();
ServiceDeploymentRoleConfig bConfig = m_sDepConfigs.get(role);
write(bConfig, true, skipNonOverrides, writer);
// per-method roles
Iterator<String> mIter = bConfig.getMethodConfigs().keySet().iterator();
while (mIter.hasNext()) {
String methodName = mIter.next();
MethodRoleConfig mConfig =
bConfig.getMethodConfigs().get(methodName);
write(mConfig, true, skipNonOverrides, writer);
}
}
// closing element for entire doc
writer.println("</" + _CONFIG + ">");
}
|
java
|
public void write(boolean skipNonOverrides,
boolean withXMLDeclaration,
PrintWriter writer) {
final String indent = " ";
// header
if (withXMLDeclaration) {
writer.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
}
writer.println("<" + _CONFIG + " xmlns=\"" + BE_SECURITY.uri + "\"");
writer.println(indent + " xmlns:xsi=\"" + XSI.uri + "\"");
writer.println(indent + " xsi:schemaLocation=\"" + BE_SECURITY.uri
+ " " + BE_SECURITY1_0.xsdLocation + "\"");
// default values
writer.print(indent);
write(m_defaultConfig, false, skipNonOverrides, writer);
writer.println(">");
// fedoraInternalCall-1 and -2
writeInternalConfig(1,
m_internalSSL,
m_internalBasicAuth,
m_internalUsername,
m_internalPassword,
m_internalIPList,
writer);
writeInternalConfig(2,
Boolean.FALSE,
Boolean.FALSE,
null,
null,
m_internalIPList,
writer);
// sDep roles
Iterator<String> bIter = m_sDepConfigs.keySet().iterator();
while (bIter.hasNext()) {
String role = bIter.next();
ServiceDeploymentRoleConfig bConfig = m_sDepConfigs.get(role);
write(bConfig, true, skipNonOverrides, writer);
// per-method roles
Iterator<String> mIter = bConfig.getMethodConfigs().keySet().iterator();
while (mIter.hasNext()) {
String methodName = mIter.next();
MethodRoleConfig mConfig =
bConfig.getMethodConfigs().get(methodName);
write(mConfig, true, skipNonOverrides, writer);
}
}
// closing element for entire doc
writer.println("</" + _CONFIG + ">");
}
|
[
"public",
"void",
"write",
"(",
"boolean",
"skipNonOverrides",
",",
"boolean",
"withXMLDeclaration",
",",
"PrintWriter",
"writer",
")",
"{",
"final",
"String",
"indent",
"=",
"\" \"",
";",
"// header",
"if",
"(",
"withXMLDeclaration",
")",
"{",
"writer",
".",
"println",
"(",
"\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\"",
")",
";",
"}",
"writer",
".",
"println",
"(",
"\"<\"",
"+",
"_CONFIG",
"+",
"\" xmlns=\\\"\"",
"+",
"BE_SECURITY",
".",
"uri",
"+",
"\"\\\"\"",
")",
";",
"writer",
".",
"println",
"(",
"indent",
"+",
"\" xmlns:xsi=\\\"\"",
"+",
"XSI",
".",
"uri",
"+",
"\"\\\"\"",
")",
";",
"writer",
".",
"println",
"(",
"indent",
"+",
"\" xsi:schemaLocation=\\\"\"",
"+",
"BE_SECURITY",
".",
"uri",
"+",
"\" \"",
"+",
"BE_SECURITY1_0",
".",
"xsdLocation",
"+",
"\"\\\"\"",
")",
";",
"// default values",
"writer",
".",
"print",
"(",
"indent",
")",
";",
"write",
"(",
"m_defaultConfig",
",",
"false",
",",
"skipNonOverrides",
",",
"writer",
")",
";",
"writer",
".",
"println",
"(",
"\">\"",
")",
";",
"// fedoraInternalCall-1 and -2",
"writeInternalConfig",
"(",
"1",
",",
"m_internalSSL",
",",
"m_internalBasicAuth",
",",
"m_internalUsername",
",",
"m_internalPassword",
",",
"m_internalIPList",
",",
"writer",
")",
";",
"writeInternalConfig",
"(",
"2",
",",
"Boolean",
".",
"FALSE",
",",
"Boolean",
".",
"FALSE",
",",
"null",
",",
"null",
",",
"m_internalIPList",
",",
"writer",
")",
";",
"// sDep roles",
"Iterator",
"<",
"String",
">",
"bIter",
"=",
"m_sDepConfigs",
".",
"keySet",
"(",
")",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"bIter",
".",
"hasNext",
"(",
")",
")",
"{",
"String",
"role",
"=",
"bIter",
".",
"next",
"(",
")",
";",
"ServiceDeploymentRoleConfig",
"bConfig",
"=",
"m_sDepConfigs",
".",
"get",
"(",
"role",
")",
";",
"write",
"(",
"bConfig",
",",
"true",
",",
"skipNonOverrides",
",",
"writer",
")",
";",
"// per-method roles",
"Iterator",
"<",
"String",
">",
"mIter",
"=",
"bConfig",
".",
"getMethodConfigs",
"(",
")",
".",
"keySet",
"(",
")",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"mIter",
".",
"hasNext",
"(",
")",
")",
"{",
"String",
"methodName",
"=",
"mIter",
".",
"next",
"(",
")",
";",
"MethodRoleConfig",
"mConfig",
"=",
"bConfig",
".",
"getMethodConfigs",
"(",
")",
".",
"get",
"(",
"methodName",
")",
";",
"write",
"(",
"mConfig",
",",
"true",
",",
"skipNonOverrides",
",",
"writer",
")",
";",
"}",
"}",
"// closing element for entire doc",
"writer",
".",
"println",
"(",
"\"</\"",
"+",
"_CONFIG",
"+",
"\">\"",
")",
";",
"}"
] |
Serialize to the given writer, keeping it open when finished. If
skipNonOverrides is true, any configuration whose values are all null
will not be written.
|
[
"Serialize",
"to",
"the",
"given",
"writer",
"keeping",
"it",
"open",
"when",
"finished",
".",
"If",
"skipNonOverrides",
"is",
"true",
"any",
"configuration",
"whose",
"values",
"are",
"all",
"null",
"will",
"not",
"be",
"written",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/security/BESecurityConfig.java#L463-L517
|
8,960 |
fcrepo3/fcrepo
|
fcrepo-security/fcrepo-security-pep/src/main/java/org/fcrepo/server/security/xacml/pep/ws/PEP.java
|
PEP.getHandler
|
private OperationHandler getHandler(String serviceName, String operationName) {
if (serviceName == null) {
if (logger.isDebugEnabled()) {
logger.debug("Service Name was null!");
}
return null;
}
if (operationName == null) {
if (logger.isDebugEnabled()) {
logger.debug("Operation Name was null!");
}
return null;
}
Map<String, OperationHandler> handlers =
m_serviceHandlers.get(serviceName);
if (handlers == null) {
if (logger.isDebugEnabled()) {
logger.debug("No Service Handlers found for: " + serviceName);
}
return null;
}
OperationHandler handler = handlers.get(operationName);
if (handler == null) {
if (logger.isDebugEnabled()) {
logger.debug("Handler not found for: " + serviceName + "/"
+ operationName);
}
}
return handler;
}
|
java
|
private OperationHandler getHandler(String serviceName, String operationName) {
if (serviceName == null) {
if (logger.isDebugEnabled()) {
logger.debug("Service Name was null!");
}
return null;
}
if (operationName == null) {
if (logger.isDebugEnabled()) {
logger.debug("Operation Name was null!");
}
return null;
}
Map<String, OperationHandler> handlers =
m_serviceHandlers.get(serviceName);
if (handlers == null) {
if (logger.isDebugEnabled()) {
logger.debug("No Service Handlers found for: " + serviceName);
}
return null;
}
OperationHandler handler = handlers.get(operationName);
if (handler == null) {
if (logger.isDebugEnabled()) {
logger.debug("Handler not found for: " + serviceName + "/"
+ operationName);
}
}
return handler;
}
|
[
"private",
"OperationHandler",
"getHandler",
"(",
"String",
"serviceName",
",",
"String",
"operationName",
")",
"{",
"if",
"(",
"serviceName",
"==",
"null",
")",
"{",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"logger",
".",
"debug",
"(",
"\"Service Name was null!\"",
")",
";",
"}",
"return",
"null",
";",
"}",
"if",
"(",
"operationName",
"==",
"null",
")",
"{",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"logger",
".",
"debug",
"(",
"\"Operation Name was null!\"",
")",
";",
"}",
"return",
"null",
";",
"}",
"Map",
"<",
"String",
",",
"OperationHandler",
">",
"handlers",
"=",
"m_serviceHandlers",
".",
"get",
"(",
"serviceName",
")",
";",
"if",
"(",
"handlers",
"==",
"null",
")",
"{",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"logger",
".",
"debug",
"(",
"\"No Service Handlers found for: \"",
"+",
"serviceName",
")",
";",
"}",
"return",
"null",
";",
"}",
"OperationHandler",
"handler",
"=",
"handlers",
".",
"get",
"(",
"operationName",
")",
";",
"if",
"(",
"handler",
"==",
"null",
")",
"{",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"logger",
".",
"debug",
"(",
"\"Handler not found for: \"",
"+",
"serviceName",
"+",
"\"/\"",
"+",
"operationName",
")",
";",
"}",
"}",
"return",
"handler",
";",
"}"
] |
Function to try and obtain a handler using the name of the current SOAP
service and operation.
@param opName
the name of the operation
@return OperationHandler to handle the operation
|
[
"Function",
"to",
"try",
"and",
"obtain",
"a",
"handler",
"using",
"the",
"name",
"of",
"the",
"current",
"SOAP",
"service",
"and",
"operation",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-security/fcrepo-security-pep/src/main/java/org/fcrepo/server/security/xacml/pep/ws/PEP.java#L196-L232
|
8,961 |
fcrepo3/fcrepo
|
fcrepo-security/fcrepo-security-pep/src/main/java/org/fcrepo/server/security/xacml/pep/ws/PEP.java
|
PEP.enforce
|
private void enforce(ResponseCtx res) {
@SuppressWarnings("unchecked")
Set<Result> results = res.getResults();
for (Result r : results) {
if (r.getDecision() != Result.DECISION_PERMIT) {
if (logger.isDebugEnabled()) {
logger.debug("Denying access: " + r.getDecision());
}
switch (r.getDecision()) {
case Result.DECISION_DENY:
throw CXFUtility
.getFault(new AuthzDeniedException("Deny"));
case Result.DECISION_INDETERMINATE:
throw CXFUtility
.getFault(new AuthzDeniedException("Indeterminate"));
case Result.DECISION_NOT_APPLICABLE:
throw CXFUtility
.getFault(new AuthzDeniedException("NotApplicable"));
default:
}
}
}
if (logger.isDebugEnabled()) {
logger.debug("Permitting access!");
}
}
|
java
|
private void enforce(ResponseCtx res) {
@SuppressWarnings("unchecked")
Set<Result> results = res.getResults();
for (Result r : results) {
if (r.getDecision() != Result.DECISION_PERMIT) {
if (logger.isDebugEnabled()) {
logger.debug("Denying access: " + r.getDecision());
}
switch (r.getDecision()) {
case Result.DECISION_DENY:
throw CXFUtility
.getFault(new AuthzDeniedException("Deny"));
case Result.DECISION_INDETERMINATE:
throw CXFUtility
.getFault(new AuthzDeniedException("Indeterminate"));
case Result.DECISION_NOT_APPLICABLE:
throw CXFUtility
.getFault(new AuthzDeniedException("NotApplicable"));
default:
}
}
}
if (logger.isDebugEnabled()) {
logger.debug("Permitting access!");
}
}
|
[
"private",
"void",
"enforce",
"(",
"ResponseCtx",
"res",
")",
"{",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"Set",
"<",
"Result",
">",
"results",
"=",
"res",
".",
"getResults",
"(",
")",
";",
"for",
"(",
"Result",
"r",
":",
"results",
")",
"{",
"if",
"(",
"r",
".",
"getDecision",
"(",
")",
"!=",
"Result",
".",
"DECISION_PERMIT",
")",
"{",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"logger",
".",
"debug",
"(",
"\"Denying access: \"",
"+",
"r",
".",
"getDecision",
"(",
")",
")",
";",
"}",
"switch",
"(",
"r",
".",
"getDecision",
"(",
")",
")",
"{",
"case",
"Result",
".",
"DECISION_DENY",
":",
"throw",
"CXFUtility",
".",
"getFault",
"(",
"new",
"AuthzDeniedException",
"(",
"\"Deny\"",
")",
")",
";",
"case",
"Result",
".",
"DECISION_INDETERMINATE",
":",
"throw",
"CXFUtility",
".",
"getFault",
"(",
"new",
"AuthzDeniedException",
"(",
"\"Indeterminate\"",
")",
")",
";",
"case",
"Result",
".",
"DECISION_NOT_APPLICABLE",
":",
"throw",
"CXFUtility",
".",
"getFault",
"(",
"new",
"AuthzDeniedException",
"(",
"\"NotApplicable\"",
")",
")",
";",
"default",
":",
"}",
"}",
"}",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"logger",
".",
"debug",
"(",
"\"Permitting access!\"",
")",
";",
"}",
"}"
] |
Method to check a response and enforce any denial. This is achieved by
throwing an SoapFault.
@param res
the ResponseCtx
|
[
"Method",
"to",
"check",
"a",
"response",
"and",
"enforce",
"any",
"denial",
".",
"This",
"is",
"achieved",
"by",
"throwing",
"an",
"SoapFault",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-security/fcrepo-security-pep/src/main/java/org/fcrepo/server/security/xacml/pep/ws/PEP.java#L241-L267
|
8,962 |
fcrepo3/fcrepo
|
fcrepo-security/fcrepo-security-pdp/src/main/java/org/fcrepo/server/security/xacml/util/ContextUtil.java
|
ContextUtil.setupResources
|
public List<Attribute> setupResources(Map<URI, AttributeValue> res, RelationshipResolver relationshipResolver)
throws MelcoeXacmlException {
if (res == null || res.size() == 0) {
return new ArrayList<Attribute>();
}
List<Attribute> attributes = new ArrayList<Attribute>(res.size());
try {
String pid = null;
AttributeValue pidAttr = res.get(Constants.XACML1_RESOURCE.ID.attributeId);
if (pidAttr != null) {
pid = pidAttr.encode();
pid = relationshipResolver.buildRESTParentHierarchy(pid);
String dsid = null;
AttributeValue dsidAttr =
res.get(Constants.DATASTREAM.ID.attributeId);
if (dsidAttr != null) {
dsid = dsidAttr.encode();
if (!dsid.isEmpty()) {
pid += "/" + dsid;
}
}
res.put(Constants.XACML1_RESOURCE.ID.attributeId, new AnyURIAttribute(new URI(pid)));
}
} catch (Exception e) {
logger.error("Error finding parents.", e);
throw new MelcoeXacmlException("Error finding parents.", e);
}
for (URI uri : res.keySet()) {
attributes.add(new SingletonAttribute(uri, null, null, res.get(uri)));
}
return attributes;
}
|
java
|
public List<Attribute> setupResources(Map<URI, AttributeValue> res, RelationshipResolver relationshipResolver)
throws MelcoeXacmlException {
if (res == null || res.size() == 0) {
return new ArrayList<Attribute>();
}
List<Attribute> attributes = new ArrayList<Attribute>(res.size());
try {
String pid = null;
AttributeValue pidAttr = res.get(Constants.XACML1_RESOURCE.ID.attributeId);
if (pidAttr != null) {
pid = pidAttr.encode();
pid = relationshipResolver.buildRESTParentHierarchy(pid);
String dsid = null;
AttributeValue dsidAttr =
res.get(Constants.DATASTREAM.ID.attributeId);
if (dsidAttr != null) {
dsid = dsidAttr.encode();
if (!dsid.isEmpty()) {
pid += "/" + dsid;
}
}
res.put(Constants.XACML1_RESOURCE.ID.attributeId, new AnyURIAttribute(new URI(pid)));
}
} catch (Exception e) {
logger.error("Error finding parents.", e);
throw new MelcoeXacmlException("Error finding parents.", e);
}
for (URI uri : res.keySet()) {
attributes.add(new SingletonAttribute(uri, null, null, res.get(uri)));
}
return attributes;
}
|
[
"public",
"List",
"<",
"Attribute",
">",
"setupResources",
"(",
"Map",
"<",
"URI",
",",
"AttributeValue",
">",
"res",
",",
"RelationshipResolver",
"relationshipResolver",
")",
"throws",
"MelcoeXacmlException",
"{",
"if",
"(",
"res",
"==",
"null",
"||",
"res",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"return",
"new",
"ArrayList",
"<",
"Attribute",
">",
"(",
")",
";",
"}",
"List",
"<",
"Attribute",
">",
"attributes",
"=",
"new",
"ArrayList",
"<",
"Attribute",
">",
"(",
"res",
".",
"size",
"(",
")",
")",
";",
"try",
"{",
"String",
"pid",
"=",
"null",
";",
"AttributeValue",
"pidAttr",
"=",
"res",
".",
"get",
"(",
"Constants",
".",
"XACML1_RESOURCE",
".",
"ID",
".",
"attributeId",
")",
";",
"if",
"(",
"pidAttr",
"!=",
"null",
")",
"{",
"pid",
"=",
"pidAttr",
".",
"encode",
"(",
")",
";",
"pid",
"=",
"relationshipResolver",
".",
"buildRESTParentHierarchy",
"(",
"pid",
")",
";",
"String",
"dsid",
"=",
"null",
";",
"AttributeValue",
"dsidAttr",
"=",
"res",
".",
"get",
"(",
"Constants",
".",
"DATASTREAM",
".",
"ID",
".",
"attributeId",
")",
";",
"if",
"(",
"dsidAttr",
"!=",
"null",
")",
"{",
"dsid",
"=",
"dsidAttr",
".",
"encode",
"(",
")",
";",
"if",
"(",
"!",
"dsid",
".",
"isEmpty",
"(",
")",
")",
"{",
"pid",
"+=",
"\"/\"",
"+",
"dsid",
";",
"}",
"}",
"res",
".",
"put",
"(",
"Constants",
".",
"XACML1_RESOURCE",
".",
"ID",
".",
"attributeId",
",",
"new",
"AnyURIAttribute",
"(",
"new",
"URI",
"(",
"pid",
")",
")",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Error finding parents.\"",
",",
"e",
")",
";",
"throw",
"new",
"MelcoeXacmlException",
"(",
"\"Error finding parents.\"",
",",
"e",
")",
";",
"}",
"for",
"(",
"URI",
"uri",
":",
"res",
".",
"keySet",
"(",
")",
")",
"{",
"attributes",
".",
"add",
"(",
"new",
"SingletonAttribute",
"(",
"uri",
",",
"null",
",",
"null",
",",
"res",
".",
"get",
"(",
"uri",
")",
")",
")",
";",
"}",
"return",
"attributes",
";",
"}"
] |
Creates a Resource specifying the resource-id, a required attribute.
@return a Set of Attributes for inclusion in a Request
|
[
"Creates",
"a",
"Resource",
"specifying",
"the",
"resource",
"-",
"id",
"a",
"required",
"attribute",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-security/fcrepo-security-pdp/src/main/java/org/fcrepo/server/security/xacml/util/ContextUtil.java#L137-L174
|
8,963 |
fcrepo3/fcrepo
|
fcrepo-security/fcrepo-security-pdp/src/main/java/org/fcrepo/server/security/xacml/util/ContextUtil.java
|
ContextUtil.setupAction
|
public List<Attribute> setupAction(Map<URI, AttributeValue> a) {
if (a == null || a.size() == 0) {
return Collections.emptyList();
}
List<Attribute> actions = new ArrayList<Attribute>(a.size());
Map<URI, AttributeValue> newActions =
new HashMap<URI, AttributeValue>();
for (URI uri : a.keySet()) {
URI newUri = null;
AttributeValue newValue = null;
if (actionMap != null && actionMap.size() > 0) {
newUri = actionMap.get(uri);
}
if (actionValueMap != null && actionValueMap.size() > 0) {
String tmpValue = actionValueMap.get(a.get(uri).encode());
if (tmpValue != null) {
newValue = new StringAttribute(tmpValue);
}
}
newUri = newUri == null ? uri : newUri;
newValue = newValue == null ? a.get(uri) : newValue;
newActions.put(newUri, newValue);
}
for (URI uri : newActions.keySet()) {
actions.add(new SingletonAttribute(uri, null, null, newActions.get(uri)));
}
return actions;
}
|
java
|
public List<Attribute> setupAction(Map<URI, AttributeValue> a) {
if (a == null || a.size() == 0) {
return Collections.emptyList();
}
List<Attribute> actions = new ArrayList<Attribute>(a.size());
Map<URI, AttributeValue> newActions =
new HashMap<URI, AttributeValue>();
for (URI uri : a.keySet()) {
URI newUri = null;
AttributeValue newValue = null;
if (actionMap != null && actionMap.size() > 0) {
newUri = actionMap.get(uri);
}
if (actionValueMap != null && actionValueMap.size() > 0) {
String tmpValue = actionValueMap.get(a.get(uri).encode());
if (tmpValue != null) {
newValue = new StringAttribute(tmpValue);
}
}
newUri = newUri == null ? uri : newUri;
newValue = newValue == null ? a.get(uri) : newValue;
newActions.put(newUri, newValue);
}
for (URI uri : newActions.keySet()) {
actions.add(new SingletonAttribute(uri, null, null, newActions.get(uri)));
}
return actions;
}
|
[
"public",
"List",
"<",
"Attribute",
">",
"setupAction",
"(",
"Map",
"<",
"URI",
",",
"AttributeValue",
">",
"a",
")",
"{",
"if",
"(",
"a",
"==",
"null",
"||",
"a",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"return",
"Collections",
".",
"emptyList",
"(",
")",
";",
"}",
"List",
"<",
"Attribute",
">",
"actions",
"=",
"new",
"ArrayList",
"<",
"Attribute",
">",
"(",
"a",
".",
"size",
"(",
")",
")",
";",
"Map",
"<",
"URI",
",",
"AttributeValue",
">",
"newActions",
"=",
"new",
"HashMap",
"<",
"URI",
",",
"AttributeValue",
">",
"(",
")",
";",
"for",
"(",
"URI",
"uri",
":",
"a",
".",
"keySet",
"(",
")",
")",
"{",
"URI",
"newUri",
"=",
"null",
";",
"AttributeValue",
"newValue",
"=",
"null",
";",
"if",
"(",
"actionMap",
"!=",
"null",
"&&",
"actionMap",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"newUri",
"=",
"actionMap",
".",
"get",
"(",
"uri",
")",
";",
"}",
"if",
"(",
"actionValueMap",
"!=",
"null",
"&&",
"actionValueMap",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"String",
"tmpValue",
"=",
"actionValueMap",
".",
"get",
"(",
"a",
".",
"get",
"(",
"uri",
")",
".",
"encode",
"(",
")",
")",
";",
"if",
"(",
"tmpValue",
"!=",
"null",
")",
"{",
"newValue",
"=",
"new",
"StringAttribute",
"(",
"tmpValue",
")",
";",
"}",
"}",
"newUri",
"=",
"newUri",
"==",
"null",
"?",
"uri",
":",
"newUri",
";",
"newValue",
"=",
"newValue",
"==",
"null",
"?",
"a",
".",
"get",
"(",
"uri",
")",
":",
"newValue",
";",
"newActions",
".",
"put",
"(",
"newUri",
",",
"newValue",
")",
";",
"}",
"for",
"(",
"URI",
"uri",
":",
"newActions",
".",
"keySet",
"(",
")",
")",
"{",
"actions",
".",
"add",
"(",
"new",
"SingletonAttribute",
"(",
"uri",
",",
"null",
",",
"null",
",",
"newActions",
".",
"get",
"(",
"uri",
")",
")",
")",
";",
"}",
"return",
"actions",
";",
"}"
] |
Creates an Action specifying the action-id, an optional attribute.
@return a Set of Attributes for inclusion in a Request
|
[
"Creates",
"an",
"Action",
"specifying",
"the",
"action",
"-",
"id",
"an",
"optional",
"attribute",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-security/fcrepo-security-pdp/src/main/java/org/fcrepo/server/security/xacml/util/ContextUtil.java#L181-L215
|
8,964 |
fcrepo3/fcrepo
|
fcrepo-security/fcrepo-security-pdp/src/main/java/org/fcrepo/server/security/xacml/util/ContextUtil.java
|
ContextUtil.setupEnvironment
|
public List<Attribute> setupEnvironment(Map<URI, AttributeValue> e) {
if (e == null || e.size() == 0) {
return Collections.emptyList();
}
List<Attribute> environment = new ArrayList<Attribute>(e.size());
for (URI uri : e.keySet()) {
environment.add(new SingletonAttribute(uri, null, null, e.get(uri)));
}
return environment;
}
|
java
|
public List<Attribute> setupEnvironment(Map<URI, AttributeValue> e) {
if (e == null || e.size() == 0) {
return Collections.emptyList();
}
List<Attribute> environment = new ArrayList<Attribute>(e.size());
for (URI uri : e.keySet()) {
environment.add(new SingletonAttribute(uri, null, null, e.get(uri)));
}
return environment;
}
|
[
"public",
"List",
"<",
"Attribute",
">",
"setupEnvironment",
"(",
"Map",
"<",
"URI",
",",
"AttributeValue",
">",
"e",
")",
"{",
"if",
"(",
"e",
"==",
"null",
"||",
"e",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"return",
"Collections",
".",
"emptyList",
"(",
")",
";",
"}",
"List",
"<",
"Attribute",
">",
"environment",
"=",
"new",
"ArrayList",
"<",
"Attribute",
">",
"(",
"e",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"URI",
"uri",
":",
"e",
".",
"keySet",
"(",
")",
")",
"{",
"environment",
".",
"add",
"(",
"new",
"SingletonAttribute",
"(",
"uri",
",",
"null",
",",
"null",
",",
"e",
".",
"get",
"(",
"uri",
")",
")",
")",
";",
"}",
"return",
"environment",
";",
"}"
] |
Creates the Environment attributes.
@return a Set of Attributes for inclusion in a Request
|
[
"Creates",
"the",
"Environment",
"attributes",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-security/fcrepo-security-pdp/src/main/java/org/fcrepo/server/security/xacml/util/ContextUtil.java#L222-L234
|
8,965 |
fcrepo3/fcrepo
|
fcrepo-security/fcrepo-security-pdp/src/main/java/org/fcrepo/server/security/xacml/util/ContextUtil.java
|
ContextUtil.buildRequest
|
public RequestCtx buildRequest(List<Map<URI, List<AttributeValue>>> subjects,
Map<URI, AttributeValue> actions,
Map<URI, AttributeValue> resources,
Map<URI, AttributeValue> environment,
RelationshipResolver relationshipResolver)
throws MelcoeXacmlException {
logger.debug("Building request!");
RequestCtx request = null;
// Create the new Request.
// Note that the Environment must be specified using a valid Set, even
// if that Set is empty
try {
request =
new BasicRequestCtx(setupSubjects(subjects),
setupResources(resources, relationshipResolver),
setupAction(actions),
setupEnvironment(environment));
} catch (Exception e) {
logger.error("Error creating request.", e);
throw new MelcoeXacmlException("Error creating request", e);
}
return request;
}
|
java
|
public RequestCtx buildRequest(List<Map<URI, List<AttributeValue>>> subjects,
Map<URI, AttributeValue> actions,
Map<URI, AttributeValue> resources,
Map<URI, AttributeValue> environment,
RelationshipResolver relationshipResolver)
throws MelcoeXacmlException {
logger.debug("Building request!");
RequestCtx request = null;
// Create the new Request.
// Note that the Environment must be specified using a valid Set, even
// if that Set is empty
try {
request =
new BasicRequestCtx(setupSubjects(subjects),
setupResources(resources, relationshipResolver),
setupAction(actions),
setupEnvironment(environment));
} catch (Exception e) {
logger.error("Error creating request.", e);
throw new MelcoeXacmlException("Error creating request", e);
}
return request;
}
|
[
"public",
"RequestCtx",
"buildRequest",
"(",
"List",
"<",
"Map",
"<",
"URI",
",",
"List",
"<",
"AttributeValue",
">",
">",
">",
"subjects",
",",
"Map",
"<",
"URI",
",",
"AttributeValue",
">",
"actions",
",",
"Map",
"<",
"URI",
",",
"AttributeValue",
">",
"resources",
",",
"Map",
"<",
"URI",
",",
"AttributeValue",
">",
"environment",
",",
"RelationshipResolver",
"relationshipResolver",
")",
"throws",
"MelcoeXacmlException",
"{",
"logger",
".",
"debug",
"(",
"\"Building request!\"",
")",
";",
"RequestCtx",
"request",
"=",
"null",
";",
"// Create the new Request.",
"// Note that the Environment must be specified using a valid Set, even",
"// if that Set is empty",
"try",
"{",
"request",
"=",
"new",
"BasicRequestCtx",
"(",
"setupSubjects",
"(",
"subjects",
")",
",",
"setupResources",
"(",
"resources",
",",
"relationshipResolver",
")",
",",
"setupAction",
"(",
"actions",
")",
",",
"setupEnvironment",
"(",
"environment",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Error creating request.\"",
",",
"e",
")",
";",
"throw",
"new",
"MelcoeXacmlException",
"(",
"\"Error creating request\"",
",",
"e",
")",
";",
"}",
"return",
"request",
";",
"}"
] |
Constructs a RequestCtx object.
@param subjects
list of Subjects
@param actions
list of Action attributes
@param resources
list of resource Attributes
@param environment
list of environment Attributes
@return the RequestCtx object
@throws MelcoeXacmlException
|
[
"Constructs",
"a",
"RequestCtx",
"object",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-security/fcrepo-security-pdp/src/main/java/org/fcrepo/server/security/xacml/util/ContextUtil.java#L250-L275
|
8,966 |
fcrepo3/fcrepo
|
fcrepo-security/fcrepo-security-pdp/src/main/java/org/fcrepo/server/security/xacml/util/ContextUtil.java
|
ContextUtil.makeResponseCtx
|
public ResponseCtx makeResponseCtx(String response)
throws MelcoeXacmlException {
ResponseCtx resCtx = null;
try {
ByteArrayInputStream is =
new ByteArrayInputStream(response.getBytes());
resCtx = ResponseCtx.getInstance(is);
} catch (ParsingException pe) {
throw new MelcoeXacmlException("Error parsing response.", pe);
}
return resCtx;
}
|
java
|
public ResponseCtx makeResponseCtx(String response)
throws MelcoeXacmlException {
ResponseCtx resCtx = null;
try {
ByteArrayInputStream is =
new ByteArrayInputStream(response.getBytes());
resCtx = ResponseCtx.getInstance(is);
} catch (ParsingException pe) {
throw new MelcoeXacmlException("Error parsing response.", pe);
}
return resCtx;
}
|
[
"public",
"ResponseCtx",
"makeResponseCtx",
"(",
"String",
"response",
")",
"throws",
"MelcoeXacmlException",
"{",
"ResponseCtx",
"resCtx",
"=",
"null",
";",
"try",
"{",
"ByteArrayInputStream",
"is",
"=",
"new",
"ByteArrayInputStream",
"(",
"response",
".",
"getBytes",
"(",
")",
")",
";",
"resCtx",
"=",
"ResponseCtx",
".",
"getInstance",
"(",
"is",
")",
";",
"}",
"catch",
"(",
"ParsingException",
"pe",
")",
"{",
"throw",
"new",
"MelcoeXacmlException",
"(",
"\"Error parsing response.\"",
",",
"pe",
")",
";",
"}",
"return",
"resCtx",
";",
"}"
] |
Converts a string based response to a ResponseCtx obejct.
@param response
the string response
@return the ResponseCtx object
@throws MelcoeXacmlException
|
[
"Converts",
"a",
"string",
"based",
"response",
"to",
"a",
"ResponseCtx",
"obejct",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-security/fcrepo-security-pdp/src/main/java/org/fcrepo/server/security/xacml/util/ContextUtil.java#L285-L296
|
8,967 |
fcrepo3/fcrepo
|
fcrepo-security/fcrepo-security-pdp/src/main/java/org/fcrepo/server/security/xacml/util/ContextUtil.java
|
ContextUtil.makeRequestCtx
|
public RequestCtx makeRequestCtx(String request)
throws MelcoeXacmlException {
RequestCtx reqCtx = null;
try {
ByteArrayInputStream is =
new ByteArrayInputStream(request.getBytes());
reqCtx = BasicRequestCtx.getInstance(is);
} catch (ParsingException pe) {
throw new MelcoeXacmlException("Error parsing response.", pe);
}
return reqCtx;
}
|
java
|
public RequestCtx makeRequestCtx(String request)
throws MelcoeXacmlException {
RequestCtx reqCtx = null;
try {
ByteArrayInputStream is =
new ByteArrayInputStream(request.getBytes());
reqCtx = BasicRequestCtx.getInstance(is);
} catch (ParsingException pe) {
throw new MelcoeXacmlException("Error parsing response.", pe);
}
return reqCtx;
}
|
[
"public",
"RequestCtx",
"makeRequestCtx",
"(",
"String",
"request",
")",
"throws",
"MelcoeXacmlException",
"{",
"RequestCtx",
"reqCtx",
"=",
"null",
";",
"try",
"{",
"ByteArrayInputStream",
"is",
"=",
"new",
"ByteArrayInputStream",
"(",
"request",
".",
"getBytes",
"(",
")",
")",
";",
"reqCtx",
"=",
"BasicRequestCtx",
".",
"getInstance",
"(",
"is",
")",
";",
"}",
"catch",
"(",
"ParsingException",
"pe",
")",
"{",
"throw",
"new",
"MelcoeXacmlException",
"(",
"\"Error parsing response.\"",
",",
"pe",
")",
";",
"}",
"return",
"reqCtx",
";",
"}"
] |
Converts a string based request to a RequestCtx obejct.
@param request
the string request
@return the RequestCtx object
@throws MelcoeXacmlException
|
[
"Converts",
"a",
"string",
"based",
"request",
"to",
"a",
"RequestCtx",
"obejct",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-security/fcrepo-security-pdp/src/main/java/org/fcrepo/server/security/xacml/util/ContextUtil.java#L306-L317
|
8,968 |
fcrepo3/fcrepo
|
fcrepo-security/fcrepo-security-pdp/src/main/java/org/fcrepo/server/security/xacml/util/ContextUtil.java
|
ContextUtil.makeRequestCtx
|
public String makeRequestCtx(RequestCtx reqCtx) {
ByteArrayOutputStream request = new ByteArrayOutputStream();
reqCtx.encode(request, new Indenter());
return new String(request.toByteArray());
}
|
java
|
public String makeRequestCtx(RequestCtx reqCtx) {
ByteArrayOutputStream request = new ByteArrayOutputStream();
reqCtx.encode(request, new Indenter());
return new String(request.toByteArray());
}
|
[
"public",
"String",
"makeRequestCtx",
"(",
"RequestCtx",
"reqCtx",
")",
"{",
"ByteArrayOutputStream",
"request",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"reqCtx",
".",
"encode",
"(",
"request",
",",
"new",
"Indenter",
"(",
")",
")",
";",
"return",
"new",
"String",
"(",
"request",
".",
"toByteArray",
"(",
")",
")",
";",
"}"
] |
Converts a RequestCtx object to its string representation.
@param reqCtx
the RequestCtx object
@return the String representation of the RequestCtx object
|
[
"Converts",
"a",
"RequestCtx",
"object",
"to",
"its",
"string",
"representation",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-security/fcrepo-security-pdp/src/main/java/org/fcrepo/server/security/xacml/util/ContextUtil.java#L326-L330
|
8,969 |
fcrepo3/fcrepo
|
fcrepo-security/fcrepo-security-pdp/src/main/java/org/fcrepo/server/security/xacml/util/ContextUtil.java
|
ContextUtil.makeResponseCtx
|
public String makeResponseCtx(ResponseCtx resCtx) {
ByteArrayOutputStream response = new ByteArrayOutputStream();
resCtx.encode(response, new Indenter());
return new String(response.toByteArray());
}
|
java
|
public String makeResponseCtx(ResponseCtx resCtx) {
ByteArrayOutputStream response = new ByteArrayOutputStream();
resCtx.encode(response, new Indenter());
return new String(response.toByteArray());
}
|
[
"public",
"String",
"makeResponseCtx",
"(",
"ResponseCtx",
"resCtx",
")",
"{",
"ByteArrayOutputStream",
"response",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"resCtx",
".",
"encode",
"(",
"response",
",",
"new",
"Indenter",
"(",
")",
")",
";",
"return",
"new",
"String",
"(",
"response",
".",
"toByteArray",
"(",
")",
")",
";",
"}"
] |
Converst a ResponseCtx object to its string representation.
@param resCtx
the ResponseCtx object
@return the String representation of the ResponseCtx object
|
[
"Converst",
"a",
"ResponseCtx",
"object",
"to",
"its",
"string",
"representation",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-security/fcrepo-security-pdp/src/main/java/org/fcrepo/server/security/xacml/util/ContextUtil.java#L339-L343
|
8,970 |
fcrepo3/fcrepo
|
fcrepo-security/fcrepo-security-pdp/src/main/java/org/fcrepo/server/security/xacml/util/ContextUtil.java
|
ContextUtil.makeResultMap
|
public Map<String, Result> makeResultMap(ResponseCtx resCtx) {
@SuppressWarnings("unchecked")
Iterator<Result> i = resCtx.getResults().iterator();
Map<String, Result> resultMap = new HashMap<String, Result>();
while (i.hasNext()) {
Result r = i.next();
resultMap.put(r.getResource(), r);
}
return resultMap;
}
|
java
|
public Map<String, Result> makeResultMap(ResponseCtx resCtx) {
@SuppressWarnings("unchecked")
Iterator<Result> i = resCtx.getResults().iterator();
Map<String, Result> resultMap = new HashMap<String, Result>();
while (i.hasNext()) {
Result r = i.next();
resultMap.put(r.getResource(), r);
}
return resultMap;
}
|
[
"public",
"Map",
"<",
"String",
",",
"Result",
">",
"makeResultMap",
"(",
"ResponseCtx",
"resCtx",
")",
"{",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"Iterator",
"<",
"Result",
">",
"i",
"=",
"resCtx",
".",
"getResults",
"(",
")",
".",
"iterator",
"(",
")",
";",
"Map",
"<",
"String",
",",
"Result",
">",
"resultMap",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Result",
">",
"(",
")",
";",
"while",
"(",
"i",
".",
"hasNext",
"(",
")",
")",
"{",
"Result",
"r",
"=",
"i",
".",
"next",
"(",
")",
";",
"resultMap",
".",
"put",
"(",
"r",
".",
"getResource",
"(",
")",
",",
"r",
")",
";",
"}",
"return",
"resultMap",
";",
"}"
] |
Returns a map of resource-id, result based on an XACML response.
@param resCtx
the XACML response
@return the Map of resource-id and result
|
[
"Returns",
"a",
"map",
"of",
"resource",
"-",
"id",
"result",
"based",
"on",
"an",
"XACML",
"response",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-security/fcrepo-security-pdp/src/main/java/org/fcrepo/server/security/xacml/util/ContextUtil.java#L352-L364
|
8,971 |
fcrepo3/fcrepo
|
fcrepo-installer/src/main/java/org/fcrepo/utilities/install/InstallOptions.java
|
InstallOptions.inputOption
|
private void inputOption(String optionId)
throws InstallationCancelledException {
OptionDefinition opt = OptionDefinition.get(optionId, this);
if (opt.getLabel() == null || opt.getLabel().length() == 0) {
throw new InstallationCancelledException(optionId
+ " is missing label (check OptionDefinition.properties?)");
}
System.out.println(opt.getLabel());
System.out.println(dashes(opt.getLabel().length()));
System.out.println(opt.getDescription());
System.out.println();
String[] valids = opt.getValidValues();
if (valids != null) {
System.out.print("Options : ");
for (int i = 0; i < valids.length; i++) {
if (i > 0) {
System.out.print(", ");
}
System.out.print(valids[i]);
}
System.out.println();
}
String defaultVal = opt.getDefaultValue();
if (valids != null || defaultVal != null) {
System.out.println();
}
boolean gotValidValue = false;
while (!gotValidValue) {
System.out.print("Enter a value ");
if (defaultVal != null) {
System.out.print("[default is " + defaultVal + "] ");
}
System.out.print("==> ");
String value = readLine().trim();
if (value.length() == 0 && defaultVal != null) {
value = defaultVal;
}
System.out.println();
if (value.equalsIgnoreCase("cancel")) {
throw new InstallationCancelledException("Cancelled by user.");
}
try {
opt.validateValue(value);
gotValidValue = true;
_map.put(optionId, value);
System.out.println();
} catch (OptionValidationException e) {
System.out.println("Error: " + e.getMessage());
}
}
}
|
java
|
private void inputOption(String optionId)
throws InstallationCancelledException {
OptionDefinition opt = OptionDefinition.get(optionId, this);
if (opt.getLabel() == null || opt.getLabel().length() == 0) {
throw new InstallationCancelledException(optionId
+ " is missing label (check OptionDefinition.properties?)");
}
System.out.println(opt.getLabel());
System.out.println(dashes(opt.getLabel().length()));
System.out.println(opt.getDescription());
System.out.println();
String[] valids = opt.getValidValues();
if (valids != null) {
System.out.print("Options : ");
for (int i = 0; i < valids.length; i++) {
if (i > 0) {
System.out.print(", ");
}
System.out.print(valids[i]);
}
System.out.println();
}
String defaultVal = opt.getDefaultValue();
if (valids != null || defaultVal != null) {
System.out.println();
}
boolean gotValidValue = false;
while (!gotValidValue) {
System.out.print("Enter a value ");
if (defaultVal != null) {
System.out.print("[default is " + defaultVal + "] ");
}
System.out.print("==> ");
String value = readLine().trim();
if (value.length() == 0 && defaultVal != null) {
value = defaultVal;
}
System.out.println();
if (value.equalsIgnoreCase("cancel")) {
throw new InstallationCancelledException("Cancelled by user.");
}
try {
opt.validateValue(value);
gotValidValue = true;
_map.put(optionId, value);
System.out.println();
} catch (OptionValidationException e) {
System.out.println("Error: " + e.getMessage());
}
}
}
|
[
"private",
"void",
"inputOption",
"(",
"String",
"optionId",
")",
"throws",
"InstallationCancelledException",
"{",
"OptionDefinition",
"opt",
"=",
"OptionDefinition",
".",
"get",
"(",
"optionId",
",",
"this",
")",
";",
"if",
"(",
"opt",
".",
"getLabel",
"(",
")",
"==",
"null",
"||",
"opt",
".",
"getLabel",
"(",
")",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"throw",
"new",
"InstallationCancelledException",
"(",
"optionId",
"+",
"\" is missing label (check OptionDefinition.properties?)\"",
")",
";",
"}",
"System",
".",
"out",
".",
"println",
"(",
"opt",
".",
"getLabel",
"(",
")",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"dashes",
"(",
"opt",
".",
"getLabel",
"(",
")",
".",
"length",
"(",
")",
")",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"opt",
".",
"getDescription",
"(",
")",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
")",
";",
"String",
"[",
"]",
"valids",
"=",
"opt",
".",
"getValidValues",
"(",
")",
";",
"if",
"(",
"valids",
"!=",
"null",
")",
"{",
"System",
".",
"out",
".",
"print",
"(",
"\"Options : \"",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"valids",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"i",
">",
"0",
")",
"{",
"System",
".",
"out",
".",
"print",
"(",
"\", \"",
")",
";",
"}",
"System",
".",
"out",
".",
"print",
"(",
"valids",
"[",
"i",
"]",
")",
";",
"}",
"System",
".",
"out",
".",
"println",
"(",
")",
";",
"}",
"String",
"defaultVal",
"=",
"opt",
".",
"getDefaultValue",
"(",
")",
";",
"if",
"(",
"valids",
"!=",
"null",
"||",
"defaultVal",
"!=",
"null",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
")",
";",
"}",
"boolean",
"gotValidValue",
"=",
"false",
";",
"while",
"(",
"!",
"gotValidValue",
")",
"{",
"System",
".",
"out",
".",
"print",
"(",
"\"Enter a value \"",
")",
";",
"if",
"(",
"defaultVal",
"!=",
"null",
")",
"{",
"System",
".",
"out",
".",
"print",
"(",
"\"[default is \"",
"+",
"defaultVal",
"+",
"\"] \"",
")",
";",
"}",
"System",
".",
"out",
".",
"print",
"(",
"\"==> \"",
")",
";",
"String",
"value",
"=",
"readLine",
"(",
")",
".",
"trim",
"(",
")",
";",
"if",
"(",
"value",
".",
"length",
"(",
")",
"==",
"0",
"&&",
"defaultVal",
"!=",
"null",
")",
"{",
"value",
"=",
"defaultVal",
";",
"}",
"System",
".",
"out",
".",
"println",
"(",
")",
";",
"if",
"(",
"value",
".",
"equalsIgnoreCase",
"(",
"\"cancel\"",
")",
")",
"{",
"throw",
"new",
"InstallationCancelledException",
"(",
"\"Cancelled by user.\"",
")",
";",
"}",
"try",
"{",
"opt",
".",
"validateValue",
"(",
"value",
")",
";",
"gotValidValue",
"=",
"true",
";",
"_map",
".",
"put",
"(",
"optionId",
",",
"value",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
")",
";",
"}",
"catch",
"(",
"OptionValidationException",
"e",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"Error: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"}"
] |
Get the indicated option from the console. Continue prompting until the
value is valid, or the user has indicated they want to cancel the
installation.
|
[
"Get",
"the",
"indicated",
"option",
"from",
"the",
"console",
".",
"Continue",
"prompting",
"until",
"the",
"value",
"is",
"valid",
"or",
"the",
"user",
"has",
"indicated",
"they",
"want",
"to",
"cancel",
"the",
"installation",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-installer/src/main/java/org/fcrepo/utilities/install/InstallOptions.java#L303-L363
|
8,972 |
fcrepo3/fcrepo
|
fcrepo-installer/src/main/java/org/fcrepo/utilities/install/InstallOptions.java
|
InstallOptions.getIntValue
|
public int getIntValue(String name, int defaultValue)
throws NumberFormatException {
String value = getValue(name);
if (value == null) {
return defaultValue;
} else {
return Integer.parseInt(value);
}
}
|
java
|
public int getIntValue(String name, int defaultValue)
throws NumberFormatException {
String value = getValue(name);
if (value == null) {
return defaultValue;
} else {
return Integer.parseInt(value);
}
}
|
[
"public",
"int",
"getIntValue",
"(",
"String",
"name",
",",
"int",
"defaultValue",
")",
"throws",
"NumberFormatException",
"{",
"String",
"value",
"=",
"getValue",
"(",
"name",
")",
";",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"return",
"defaultValue",
";",
"}",
"else",
"{",
"return",
"Integer",
".",
"parseInt",
"(",
"value",
")",
";",
"}",
"}"
] |
Get the value of the given option as an integer, or the given default
value if unspecified.
@throws NumberFormatException
if the value is specified, but cannot be parsed as an integer.
|
[
"Get",
"the",
"value",
"of",
"the",
"given",
"option",
"as",
"an",
"integer",
"or",
"the",
"given",
"default",
"value",
"if",
"unspecified",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-installer/src/main/java/org/fcrepo/utilities/install/InstallOptions.java#L419-L429
|
8,973 |
fcrepo3/fcrepo
|
fcrepo-installer/src/main/java/org/fcrepo/utilities/install/InstallOptions.java
|
InstallOptions.applyDefaults
|
private void applyDefaults() {
for (String name : getOptionNames()) {
String val = _map.get(name);
if (val == null || val.length() == 0) {
OptionDefinition opt = OptionDefinition.get(name, this);
_map.put(name, opt.getDefaultValue());
}
}
}
|
java
|
private void applyDefaults() {
for (String name : getOptionNames()) {
String val = _map.get(name);
if (val == null || val.length() == 0) {
OptionDefinition opt = OptionDefinition.get(name, this);
_map.put(name, opt.getDefaultValue());
}
}
}
|
[
"private",
"void",
"applyDefaults",
"(",
")",
"{",
"for",
"(",
"String",
"name",
":",
"getOptionNames",
"(",
")",
")",
"{",
"String",
"val",
"=",
"_map",
".",
"get",
"(",
"name",
")",
";",
"if",
"(",
"val",
"==",
"null",
"||",
"val",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"OptionDefinition",
"opt",
"=",
"OptionDefinition",
".",
"get",
"(",
"name",
",",
"this",
")",
";",
"_map",
".",
"put",
"(",
"name",
",",
"opt",
".",
"getDefaultValue",
"(",
")",
")",
";",
"}",
"}",
"}"
] |
Apply defaults to the options, where possible.
|
[
"Apply",
"defaults",
"to",
"the",
"options",
"where",
"possible",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-installer/src/main/java/org/fcrepo/utilities/install/InstallOptions.java#L458-L466
|
8,974 |
fcrepo3/fcrepo
|
fcrepo-installer/src/main/java/org/fcrepo/utilities/install/InstallOptions.java
|
InstallOptions.validateAll
|
private void validateAll() throws OptionValidationException {
boolean unattended = getBooleanValue(UNATTENDED, false);
for (String optionId : getOptionNames()) {
OptionDefinition opt = OptionDefinition.get(optionId, this);
if (opt == null) {
throw new OptionValidationException("Option is not defined", optionId);
}
opt.validateValue(getValue(optionId), unattended);
}
}
|
java
|
private void validateAll() throws OptionValidationException {
boolean unattended = getBooleanValue(UNATTENDED, false);
for (String optionId : getOptionNames()) {
OptionDefinition opt = OptionDefinition.get(optionId, this);
if (opt == null) {
throw new OptionValidationException("Option is not defined", optionId);
}
opt.validateValue(getValue(optionId), unattended);
}
}
|
[
"private",
"void",
"validateAll",
"(",
")",
"throws",
"OptionValidationException",
"{",
"boolean",
"unattended",
"=",
"getBooleanValue",
"(",
"UNATTENDED",
",",
"false",
")",
";",
"for",
"(",
"String",
"optionId",
":",
"getOptionNames",
"(",
")",
")",
"{",
"OptionDefinition",
"opt",
"=",
"OptionDefinition",
".",
"get",
"(",
"optionId",
",",
"this",
")",
";",
"if",
"(",
"opt",
"==",
"null",
")",
"{",
"throw",
"new",
"OptionValidationException",
"(",
"\"Option is not defined\"",
",",
"optionId",
")",
";",
"}",
"opt",
".",
"validateValue",
"(",
"getValue",
"(",
"optionId",
")",
",",
"unattended",
")",
";",
"}",
"}"
] |
Validate the options, assuming defaults have already been applied.
Validation for a given option might entail more than a syntax check. It
might check whether a given directory exists, for example.
|
[
"Validate",
"the",
"options",
"assuming",
"defaults",
"have",
"already",
"been",
"applied",
".",
"Validation",
"for",
"a",
"given",
"option",
"might",
"entail",
"more",
"than",
"a",
"syntax",
"check",
".",
"It",
"might",
"check",
"whether",
"a",
"given",
"directory",
"exists",
"for",
"example",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-installer/src/main/java/org/fcrepo/utilities/install/InstallOptions.java#L474-L483
|
8,975 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/utilities/rebuild/SQLRebuilder.java
|
SQLRebuilder.getFedoraTables
|
private List<String> getFedoraTables() {
try {
InputStream in =
getClass().getClassLoader()
.getResourceAsStream(DBSPEC_LOCATION);
List<TableSpec> specs = TableSpec.getTableSpecs(in);
ArrayList<String> names = new ArrayList<String>();
for (TableSpec spec: specs) {
names.add(spec.getName().toUpperCase());
}
return names;
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("Unexpected error reading dbspec file",
e);
}
}
|
java
|
private List<String> getFedoraTables() {
try {
InputStream in =
getClass().getClassLoader()
.getResourceAsStream(DBSPEC_LOCATION);
List<TableSpec> specs = TableSpec.getTableSpecs(in);
ArrayList<String> names = new ArrayList<String>();
for (TableSpec spec: specs) {
names.add(spec.getName().toUpperCase());
}
return names;
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("Unexpected error reading dbspec file",
e);
}
}
|
[
"private",
"List",
"<",
"String",
">",
"getFedoraTables",
"(",
")",
"{",
"try",
"{",
"InputStream",
"in",
"=",
"getClass",
"(",
")",
".",
"getClassLoader",
"(",
")",
".",
"getResourceAsStream",
"(",
"DBSPEC_LOCATION",
")",
";",
"List",
"<",
"TableSpec",
">",
"specs",
"=",
"TableSpec",
".",
"getTableSpecs",
"(",
"in",
")",
";",
"ArrayList",
"<",
"String",
">",
"names",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"TableSpec",
"spec",
":",
"specs",
")",
"{",
"names",
".",
"add",
"(",
"spec",
".",
"getName",
"(",
")",
".",
"toUpperCase",
"(",
")",
")",
";",
"}",
"return",
"names",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"throw",
"new",
"RuntimeException",
"(",
"\"Unexpected error reading dbspec file\"",
",",
"e",
")",
";",
"}",
"}"
] |
Get the names of all Fedora tables listed in the server's dbSpec file.
Names will be returned in ALL CAPS so that case-insensitive comparisons
can be done.
|
[
"Get",
"the",
"names",
"of",
"all",
"Fedora",
"tables",
"listed",
"in",
"the",
"server",
"s",
"dbSpec",
"file",
".",
"Names",
"will",
"be",
"returned",
"in",
"ALL",
"CAPS",
"so",
"that",
"case",
"-",
"insensitive",
"comparisons",
"can",
"be",
"done",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/utilities/rebuild/SQLRebuilder.java#L296-L312
|
8,976 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/utilities/rebuild/SQLRebuilder.java
|
SQLRebuilder.registerObject
|
private void registerObject(DigitalObject obj)
throws StorageDeviceException {
String pid = obj.getPid();
String userId = "the userID field is no longer used";
String label = "the label field is no longer used";
Connection conn = null;
PreparedStatement s1 = null;
try {
String query =
"INSERT INTO doRegistry (doPID, ownerId, label) VALUES (?, ?, ?)";
conn = m_connectionPool.getReadWriteConnection();
s1 = conn.prepareStatement(query);
s1.setString(1,pid);
s1.setString(2,userId);
s1.setString(3, label);
s1.executeUpdate();
if (obj.hasContentModel(Models.SERVICE_DEPLOYMENT_3_0)){
updateDeploymentMap(obj, conn);
}
} catch (SQLException sqle) {
throw new StorageDeviceException("Unexpected error from SQL database while registering object: "
+ sqle.getMessage(), sqle);
} finally {
try {
if (s1 != null) {
s1.close();
}
} catch (Exception sqle) {
throw new StorageDeviceException("Unexpected error from SQL database while registering object: "
+ sqle.getMessage(), sqle);
} finally {
s1 = null;
}
}
PreparedStatement s2 = null;
ResultSet results = null;
try {
// REGISTRY:
// update systemVersion in doRegistry (add one)
logger.debug("COMMIT: Updating registry...");
String query =
"SELECT systemVersion FROM doRegistry WHERE doPID=?";
s2 = conn.prepareStatement(query);
s2.setString(1, pid);
results = s2.executeQuery();
if (!results.next()) {
throw new ObjectNotFoundException("Error creating replication job: The requested object doesn't exist in the registry.");
}
int systemVersion = results.getInt("systemVersion");
systemVersion++;
query = "UPDATE doRegistry SET systemVersion=? WHERE doPID=?";
s2.close();
s2 = conn.prepareStatement(query);
s2.setInt(1, systemVersion);
s2.setString(2,pid);
s2.executeUpdate();
} catch (SQLException sqle) {
throw new StorageDeviceException("Error creating replication job: "
+ sqle.getMessage());
} catch (ObjectNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
try {
if (results != null) {
results.close();
}
if (s2 != null) {
s2.close();
}
if (conn != null) {
m_connectionPool.free(conn);
}
} catch (SQLException sqle) {
throw new StorageDeviceException("Unexpected error from SQL database: "
+ sqle.getMessage());
} finally {
results = null;
s2 = null;
}
}
}
|
java
|
private void registerObject(DigitalObject obj)
throws StorageDeviceException {
String pid = obj.getPid();
String userId = "the userID field is no longer used";
String label = "the label field is no longer used";
Connection conn = null;
PreparedStatement s1 = null;
try {
String query =
"INSERT INTO doRegistry (doPID, ownerId, label) VALUES (?, ?, ?)";
conn = m_connectionPool.getReadWriteConnection();
s1 = conn.prepareStatement(query);
s1.setString(1,pid);
s1.setString(2,userId);
s1.setString(3, label);
s1.executeUpdate();
if (obj.hasContentModel(Models.SERVICE_DEPLOYMENT_3_0)){
updateDeploymentMap(obj, conn);
}
} catch (SQLException sqle) {
throw new StorageDeviceException("Unexpected error from SQL database while registering object: "
+ sqle.getMessage(), sqle);
} finally {
try {
if (s1 != null) {
s1.close();
}
} catch (Exception sqle) {
throw new StorageDeviceException("Unexpected error from SQL database while registering object: "
+ sqle.getMessage(), sqle);
} finally {
s1 = null;
}
}
PreparedStatement s2 = null;
ResultSet results = null;
try {
// REGISTRY:
// update systemVersion in doRegistry (add one)
logger.debug("COMMIT: Updating registry...");
String query =
"SELECT systemVersion FROM doRegistry WHERE doPID=?";
s2 = conn.prepareStatement(query);
s2.setString(1, pid);
results = s2.executeQuery();
if (!results.next()) {
throw new ObjectNotFoundException("Error creating replication job: The requested object doesn't exist in the registry.");
}
int systemVersion = results.getInt("systemVersion");
systemVersion++;
query = "UPDATE doRegistry SET systemVersion=? WHERE doPID=?";
s2.close();
s2 = conn.prepareStatement(query);
s2.setInt(1, systemVersion);
s2.setString(2,pid);
s2.executeUpdate();
} catch (SQLException sqle) {
throw new StorageDeviceException("Error creating replication job: "
+ sqle.getMessage());
} catch (ObjectNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
try {
if (results != null) {
results.close();
}
if (s2 != null) {
s2.close();
}
if (conn != null) {
m_connectionPool.free(conn);
}
} catch (SQLException sqle) {
throw new StorageDeviceException("Unexpected error from SQL database: "
+ sqle.getMessage());
} finally {
results = null;
s2 = null;
}
}
}
|
[
"private",
"void",
"registerObject",
"(",
"DigitalObject",
"obj",
")",
"throws",
"StorageDeviceException",
"{",
"String",
"pid",
"=",
"obj",
".",
"getPid",
"(",
")",
";",
"String",
"userId",
"=",
"\"the userID field is no longer used\"",
";",
"String",
"label",
"=",
"\"the label field is no longer used\"",
";",
"Connection",
"conn",
"=",
"null",
";",
"PreparedStatement",
"s1",
"=",
"null",
";",
"try",
"{",
"String",
"query",
"=",
"\"INSERT INTO doRegistry (doPID, ownerId, label) VALUES (?, ?, ?)\"",
";",
"conn",
"=",
"m_connectionPool",
".",
"getReadWriteConnection",
"(",
")",
";",
"s1",
"=",
"conn",
".",
"prepareStatement",
"(",
"query",
")",
";",
"s1",
".",
"setString",
"(",
"1",
",",
"pid",
")",
";",
"s1",
".",
"setString",
"(",
"2",
",",
"userId",
")",
";",
"s1",
".",
"setString",
"(",
"3",
",",
"label",
")",
";",
"s1",
".",
"executeUpdate",
"(",
")",
";",
"if",
"(",
"obj",
".",
"hasContentModel",
"(",
"Models",
".",
"SERVICE_DEPLOYMENT_3_0",
")",
")",
"{",
"updateDeploymentMap",
"(",
"obj",
",",
"conn",
")",
";",
"}",
"}",
"catch",
"(",
"SQLException",
"sqle",
")",
"{",
"throw",
"new",
"StorageDeviceException",
"(",
"\"Unexpected error from SQL database while registering object: \"",
"+",
"sqle",
".",
"getMessage",
"(",
")",
",",
"sqle",
")",
";",
"}",
"finally",
"{",
"try",
"{",
"if",
"(",
"s1",
"!=",
"null",
")",
"{",
"s1",
".",
"close",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"sqle",
")",
"{",
"throw",
"new",
"StorageDeviceException",
"(",
"\"Unexpected error from SQL database while registering object: \"",
"+",
"sqle",
".",
"getMessage",
"(",
")",
",",
"sqle",
")",
";",
"}",
"finally",
"{",
"s1",
"=",
"null",
";",
"}",
"}",
"PreparedStatement",
"s2",
"=",
"null",
";",
"ResultSet",
"results",
"=",
"null",
";",
"try",
"{",
"// REGISTRY:",
"// update systemVersion in doRegistry (add one)",
"logger",
".",
"debug",
"(",
"\"COMMIT: Updating registry...\"",
")",
";",
"String",
"query",
"=",
"\"SELECT systemVersion FROM doRegistry WHERE doPID=?\"",
";",
"s2",
"=",
"conn",
".",
"prepareStatement",
"(",
"query",
")",
";",
"s2",
".",
"setString",
"(",
"1",
",",
"pid",
")",
";",
"results",
"=",
"s2",
".",
"executeQuery",
"(",
")",
";",
"if",
"(",
"!",
"results",
".",
"next",
"(",
")",
")",
"{",
"throw",
"new",
"ObjectNotFoundException",
"(",
"\"Error creating replication job: The requested object doesn't exist in the registry.\"",
")",
";",
"}",
"int",
"systemVersion",
"=",
"results",
".",
"getInt",
"(",
"\"systemVersion\"",
")",
";",
"systemVersion",
"++",
";",
"query",
"=",
"\"UPDATE doRegistry SET systemVersion=? WHERE doPID=?\"",
";",
"s2",
".",
"close",
"(",
")",
";",
"s2",
"=",
"conn",
".",
"prepareStatement",
"(",
"query",
")",
";",
"s2",
".",
"setInt",
"(",
"1",
",",
"systemVersion",
")",
";",
"s2",
".",
"setString",
"(",
"2",
",",
"pid",
")",
";",
"s2",
".",
"executeUpdate",
"(",
")",
";",
"}",
"catch",
"(",
"SQLException",
"sqle",
")",
"{",
"throw",
"new",
"StorageDeviceException",
"(",
"\"Error creating replication job: \"",
"+",
"sqle",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"catch",
"(",
"ObjectNotFoundException",
"e",
")",
"{",
"// TODO Auto-generated catch block",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"finally",
"{",
"try",
"{",
"if",
"(",
"results",
"!=",
"null",
")",
"{",
"results",
".",
"close",
"(",
")",
";",
"}",
"if",
"(",
"s2",
"!=",
"null",
")",
"{",
"s2",
".",
"close",
"(",
")",
";",
"}",
"if",
"(",
"conn",
"!=",
"null",
")",
"{",
"m_connectionPool",
".",
"free",
"(",
"conn",
")",
";",
"}",
"}",
"catch",
"(",
"SQLException",
"sqle",
")",
"{",
"throw",
"new",
"StorageDeviceException",
"(",
"\"Unexpected error from SQL database: \"",
"+",
"sqle",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"finally",
"{",
"results",
"=",
"null",
";",
"s2",
"=",
"null",
";",
"}",
"}",
"}"
] |
Adds a new object.
|
[
"Adds",
"a",
"new",
"object",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/utilities/rebuild/SQLRebuilder.java#L421-L505
|
8,977 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/journal/readerwriter/multifile/MultiFileJournalWriter.java
|
MultiFileJournalWriter.checkForPotentialFilenameConflict
|
private void checkForPotentialFilenameConflict() throws JournalException {
File[] journalFiles =
MultiFileJournalHelper
.getSortedArrayOfJournalFiles(journalDirectory,
filenamePrefix);
if (journalFiles.length == 0) {
return;
}
String newestFilename = journalFiles[journalFiles.length - 1].getName();
String potentialFilename =
JournalHelper.createTimestampedFilename(filenamePrefix,
new Date());
if (newestFilename.compareTo(potentialFilename) > 0) {
throw new JournalException("The name of one or more existing files in the journal "
+ "directory (e.g. '"
+ newestFilename
+ "') may conflict with new Journal "
+ "files. Has the system clock changed?");
}
}
|
java
|
private void checkForPotentialFilenameConflict() throws JournalException {
File[] journalFiles =
MultiFileJournalHelper
.getSortedArrayOfJournalFiles(journalDirectory,
filenamePrefix);
if (journalFiles.length == 0) {
return;
}
String newestFilename = journalFiles[journalFiles.length - 1].getName();
String potentialFilename =
JournalHelper.createTimestampedFilename(filenamePrefix,
new Date());
if (newestFilename.compareTo(potentialFilename) > 0) {
throw new JournalException("The name of one or more existing files in the journal "
+ "directory (e.g. '"
+ newestFilename
+ "') may conflict with new Journal "
+ "files. Has the system clock changed?");
}
}
|
[
"private",
"void",
"checkForPotentialFilenameConflict",
"(",
")",
"throws",
"JournalException",
"{",
"File",
"[",
"]",
"journalFiles",
"=",
"MultiFileJournalHelper",
".",
"getSortedArrayOfJournalFiles",
"(",
"journalDirectory",
",",
"filenamePrefix",
")",
";",
"if",
"(",
"journalFiles",
".",
"length",
"==",
"0",
")",
"{",
"return",
";",
"}",
"String",
"newestFilename",
"=",
"journalFiles",
"[",
"journalFiles",
".",
"length",
"-",
"1",
"]",
".",
"getName",
"(",
")",
";",
"String",
"potentialFilename",
"=",
"JournalHelper",
".",
"createTimestampedFilename",
"(",
"filenamePrefix",
",",
"new",
"Date",
"(",
")",
")",
";",
"if",
"(",
"newestFilename",
".",
"compareTo",
"(",
"potentialFilename",
")",
">",
"0",
")",
"{",
"throw",
"new",
"JournalException",
"(",
"\"The name of one or more existing files in the journal \"",
"+",
"\"directory (e.g. '\"",
"+",
"newestFilename",
"+",
"\"') may conflict with new Journal \"",
"+",
"\"files. Has the system clock changed?\"",
")",
";",
"}",
"}"
] |
Look at the list of files in the current directory, and make sure that
any new files we create won't conflict with them.
|
[
"Look",
"at",
"the",
"list",
"of",
"files",
"in",
"the",
"current",
"directory",
"and",
"make",
"sure",
"that",
"any",
"new",
"files",
"we",
"create",
"won",
"t",
"conflict",
"with",
"them",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/readerwriter/multifile/MultiFileJournalWriter.java#L75-L95
|
8,978 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/journal/readerwriter/multifile/MultiFileJournalWriter.java
|
MultiFileJournalWriter.writeJournalEntry
|
@Override
public void writeJournalEntry(CreatorJournalEntry journalEntry)
throws JournalException {
if (open) {
try {
synchronized (JournalWriter.SYNCHRONIZER) {
XMLEventWriter xmlWriter = currentJournal.getXmlWriter();
super.writeJournalEntry(journalEntry, xmlWriter);
xmlWriter.flush();
currentJournal.closeIfAppropriate();
}
} catch (XMLStreamException e) {
throw new JournalException(e);
}
}
}
|
java
|
@Override
public void writeJournalEntry(CreatorJournalEntry journalEntry)
throws JournalException {
if (open) {
try {
synchronized (JournalWriter.SYNCHRONIZER) {
XMLEventWriter xmlWriter = currentJournal.getXmlWriter();
super.writeJournalEntry(journalEntry, xmlWriter);
xmlWriter.flush();
currentJournal.closeIfAppropriate();
}
} catch (XMLStreamException e) {
throw new JournalException(e);
}
}
}
|
[
"@",
"Override",
"public",
"void",
"writeJournalEntry",
"(",
"CreatorJournalEntry",
"journalEntry",
")",
"throws",
"JournalException",
"{",
"if",
"(",
"open",
")",
"{",
"try",
"{",
"synchronized",
"(",
"JournalWriter",
".",
"SYNCHRONIZER",
")",
"{",
"XMLEventWriter",
"xmlWriter",
"=",
"currentJournal",
".",
"getXmlWriter",
"(",
")",
";",
"super",
".",
"writeJournalEntry",
"(",
"journalEntry",
",",
"xmlWriter",
")",
";",
"xmlWriter",
".",
"flush",
"(",
")",
";",
"currentJournal",
".",
"closeIfAppropriate",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"XMLStreamException",
"e",
")",
"{",
"throw",
"new",
"JournalException",
"(",
"e",
")",
";",
"}",
"}",
"}"
] |
We've prepared for the entry, so just write it, but remember to
synchronize on the file, so we don't get an asynchronous close while
we're writing. After writing the entry, flush the file.
|
[
"We",
"ve",
"prepared",
"for",
"the",
"entry",
"so",
"just",
"write",
"it",
"but",
"remember",
"to",
"synchronize",
"on",
"the",
"file",
"so",
"we",
"don",
"t",
"get",
"an",
"asynchronous",
"close",
"while",
"we",
"re",
"writing",
".",
"After",
"writing",
"the",
"entry",
"flush",
"the",
"file",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/readerwriter/multifile/MultiFileJournalWriter.java#L122-L137
|
8,979 |
fcrepo3/fcrepo
|
fcrepo-security/fcrepo-security-pep/src/main/java/org/fcrepo/server/security/xacml/pep/ws/operations/AbstractOperationHandler.java
|
AbstractOperationHandler.getSOAPRequestObjects
|
protected Object getSOAPRequestObjects(SOAPMessageContext context) {
// Obtain the operation details and message type
// Extract the SOAP Message
SOAPElement requestNode = getSOAPRequestNode(context);
return unmarshall(requestNode);
}
|
java
|
protected Object getSOAPRequestObjects(SOAPMessageContext context) {
// Obtain the operation details and message type
// Extract the SOAP Message
SOAPElement requestNode = getSOAPRequestNode(context);
return unmarshall(requestNode);
}
|
[
"protected",
"Object",
"getSOAPRequestObjects",
"(",
"SOAPMessageContext",
"context",
")",
"{",
"// Obtain the operation details and message type",
"// Extract the SOAP Message",
"SOAPElement",
"requestNode",
"=",
"getSOAPRequestNode",
"(",
"context",
")",
";",
"return",
"unmarshall",
"(",
"requestNode",
")",
";",
"}"
] |
Extracts the request as object from the context.
@param context
the message context.
@return Object
@throws SoapFault
|
[
"Extracts",
"the",
"request",
"as",
"object",
"from",
"the",
"context",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-security/fcrepo-security-pep/src/main/java/org/fcrepo/server/security/xacml/pep/ws/operations/AbstractOperationHandler.java#L89-L94
|
8,980 |
fcrepo3/fcrepo
|
fcrepo-security/fcrepo-security-pep/src/main/java/org/fcrepo/server/security/xacml/pep/ws/operations/AbstractOperationHandler.java
|
AbstractOperationHandler.setSOAPRequestObjects
|
protected void setSOAPRequestObjects(SOAPMessageContext context,
List<SOAPElement> params) {
// Extract the SOAP Message
SOAPMessage message = context.getMessage();
// Get the envelope body
SOAPBody body;
try {
body = message.getSOAPBody();
} catch (SOAPException e) {
throw CXFUtility.getFault(e);
}
try {
body.removeContents();
for (SOAPElement p : params) {
body.addChildElement(p);
}
} catch (Exception e) {
logger.error("Problem changing SOAP message contents", e);
throw CXFUtility.getFault(e);
}
}
|
java
|
protected void setSOAPRequestObjects(SOAPMessageContext context,
List<SOAPElement> params) {
// Extract the SOAP Message
SOAPMessage message = context.getMessage();
// Get the envelope body
SOAPBody body;
try {
body = message.getSOAPBody();
} catch (SOAPException e) {
throw CXFUtility.getFault(e);
}
try {
body.removeContents();
for (SOAPElement p : params) {
body.addChildElement(p);
}
} catch (Exception e) {
logger.error("Problem changing SOAP message contents", e);
throw CXFUtility.getFault(e);
}
}
|
[
"protected",
"void",
"setSOAPRequestObjects",
"(",
"SOAPMessageContext",
"context",
",",
"List",
"<",
"SOAPElement",
">",
"params",
")",
"{",
"// Extract the SOAP Message",
"SOAPMessage",
"message",
"=",
"context",
".",
"getMessage",
"(",
")",
";",
"// Get the envelope body",
"SOAPBody",
"body",
";",
"try",
"{",
"body",
"=",
"message",
".",
"getSOAPBody",
"(",
")",
";",
"}",
"catch",
"(",
"SOAPException",
"e",
")",
"{",
"throw",
"CXFUtility",
".",
"getFault",
"(",
"e",
")",
";",
"}",
"try",
"{",
"body",
".",
"removeContents",
"(",
")",
";",
"for",
"(",
"SOAPElement",
"p",
":",
"params",
")",
"{",
"body",
".",
"addChildElement",
"(",
"p",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Problem changing SOAP message contents\"",
",",
"e",
")",
";",
"throw",
"CXFUtility",
".",
"getFault",
"(",
"e",
")",
";",
"}",
"}"
] |
Sets the request parameters for a request.
@param context
the message context
@param params
list of parameters to set in order
@throws SoapFault
|
[
"Sets",
"the",
"request",
"parameters",
"for",
"a",
"request",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-security/fcrepo-security-pep/src/main/java/org/fcrepo/server/security/xacml/pep/ws/operations/AbstractOperationHandler.java#L188-L210
|
8,981 |
fcrepo3/fcrepo
|
fcrepo-security/fcrepo-security-pep/src/main/java/org/fcrepo/server/security/xacml/pep/ws/operations/AbstractOperationHandler.java
|
AbstractOperationHandler.setSOAPResponseObject
|
protected void setSOAPResponseObject(SOAPMessageContext context,
Object newResponse) {
if (newResponse == null) {
return;
}
// Extract the SOAP Message
SOAPMessage message = context.getMessage();
// Get the envelope body
SOAPElement body;
try {
body = message.getSOAPBody();
SOAPElement response = getSOAPResponseNode(context);
body.removeChild(response);
marshall(newResponse, body);
} catch (SOAPException e) {
logger.error("Problem changing SOAP message contents", e);
throw CXFUtility.getFault(e);
}
}
|
java
|
protected void setSOAPResponseObject(SOAPMessageContext context,
Object newResponse) {
if (newResponse == null) {
return;
}
// Extract the SOAP Message
SOAPMessage message = context.getMessage();
// Get the envelope body
SOAPElement body;
try {
body = message.getSOAPBody();
SOAPElement response = getSOAPResponseNode(context);
body.removeChild(response);
marshall(newResponse, body);
} catch (SOAPException e) {
logger.error("Problem changing SOAP message contents", e);
throw CXFUtility.getFault(e);
}
}
|
[
"protected",
"void",
"setSOAPResponseObject",
"(",
"SOAPMessageContext",
"context",
",",
"Object",
"newResponse",
")",
"{",
"if",
"(",
"newResponse",
"==",
"null",
")",
"{",
"return",
";",
"}",
"// Extract the SOAP Message",
"SOAPMessage",
"message",
"=",
"context",
".",
"getMessage",
"(",
")",
";",
"// Get the envelope body",
"SOAPElement",
"body",
";",
"try",
"{",
"body",
"=",
"message",
".",
"getSOAPBody",
"(",
")",
";",
"SOAPElement",
"response",
"=",
"getSOAPResponseNode",
"(",
"context",
")",
";",
"body",
".",
"removeChild",
"(",
"response",
")",
";",
"marshall",
"(",
"newResponse",
",",
"body",
")",
";",
"}",
"catch",
"(",
"SOAPException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Problem changing SOAP message contents\"",
",",
"e",
")",
";",
"throw",
"CXFUtility",
".",
"getFault",
"(",
"e",
")",
";",
"}",
"}"
] |
Sets the return object for a response as the param.
@param context
the message context
@param newResponse
the object to set as the return object
@throws SoapFault
|
[
"Sets",
"the",
"return",
"object",
"for",
"a",
"response",
"as",
"the",
"param",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-security/fcrepo-security-pep/src/main/java/org/fcrepo/server/security/xacml/pep/ws/operations/AbstractOperationHandler.java#L221-L240
|
8,982 |
fcrepo3/fcrepo
|
fcrepo-security/fcrepo-security-pep/src/main/java/org/fcrepo/server/security/xacml/pep/ws/operations/AbstractOperationHandler.java
|
AbstractOperationHandler.getSubjects
|
protected List<Map<URI, List<AttributeValue>>> getSubjects(SOAPMessageContext context) {
// setup the id and value for the requesting subject
List<Map<URI, List<AttributeValue>>> subjects =
new ArrayList<Map<URI, List<AttributeValue>>>();
if (getUser(context) == null
|| getUser(context).trim().isEmpty()) {
return subjects;
}
String[] fedoraRole = getUserRoles(context);
Map<URI, List<AttributeValue>> subAttr = null;
List<AttributeValue> attrList = null;
subAttr = new HashMap<URI, List<AttributeValue>>();
attrList = new ArrayList<AttributeValue>();
attrList.add(new StringAttribute(getUser(context)));
subAttr.put(Constants.SUBJECT.LOGIN_ID.getURI(), attrList);
if (fedoraRole != null && fedoraRole.length > 0) {
attrList = new ArrayList<AttributeValue>();
for (String r : fedoraRole) {
attrList.add(new StringAttribute(r));
}
subAttr.put(Constants.SUBJECT.ROLE.getURI(), attrList);
}
subjects.add(subAttr);
subAttr = new HashMap<URI, List<AttributeValue>>();
attrList = new ArrayList<AttributeValue>();
attrList.add(new StringAttribute(getUser(context)));
subAttr.put(Constants.SUBJECT.USER_REPRESENTED.getURI(), attrList);
if (fedoraRole != null && fedoraRole.length > 0) {
attrList = new ArrayList<AttributeValue>();
for (String r : fedoraRole) {
attrList.add(new StringAttribute(r));
}
subAttr.put(Constants.SUBJECT.ROLE.getURI(), attrList);
}
subjects.add(subAttr);
subAttr = new HashMap<URI, List<AttributeValue>>();
attrList = new ArrayList<AttributeValue>();
attrList.add(new StringAttribute(getUser(context)));
subAttr.put(Constants.XACML1_SUBJECT.ID.getURI(), attrList);
if (fedoraRole != null && fedoraRole.length > 0) {
attrList = new ArrayList<AttributeValue>();
for (String r : fedoraRole) {
attrList.add(new StringAttribute(r));
}
subAttr.put(Constants.SUBJECT.ROLE.getURI(), attrList);
}
subjects.add(subAttr);
return subjects;
}
|
java
|
protected List<Map<URI, List<AttributeValue>>> getSubjects(SOAPMessageContext context) {
// setup the id and value for the requesting subject
List<Map<URI, List<AttributeValue>>> subjects =
new ArrayList<Map<URI, List<AttributeValue>>>();
if (getUser(context) == null
|| getUser(context).trim().isEmpty()) {
return subjects;
}
String[] fedoraRole = getUserRoles(context);
Map<URI, List<AttributeValue>> subAttr = null;
List<AttributeValue> attrList = null;
subAttr = new HashMap<URI, List<AttributeValue>>();
attrList = new ArrayList<AttributeValue>();
attrList.add(new StringAttribute(getUser(context)));
subAttr.put(Constants.SUBJECT.LOGIN_ID.getURI(), attrList);
if (fedoraRole != null && fedoraRole.length > 0) {
attrList = new ArrayList<AttributeValue>();
for (String r : fedoraRole) {
attrList.add(new StringAttribute(r));
}
subAttr.put(Constants.SUBJECT.ROLE.getURI(), attrList);
}
subjects.add(subAttr);
subAttr = new HashMap<URI, List<AttributeValue>>();
attrList = new ArrayList<AttributeValue>();
attrList.add(new StringAttribute(getUser(context)));
subAttr.put(Constants.SUBJECT.USER_REPRESENTED.getURI(), attrList);
if (fedoraRole != null && fedoraRole.length > 0) {
attrList = new ArrayList<AttributeValue>();
for (String r : fedoraRole) {
attrList.add(new StringAttribute(r));
}
subAttr.put(Constants.SUBJECT.ROLE.getURI(), attrList);
}
subjects.add(subAttr);
subAttr = new HashMap<URI, List<AttributeValue>>();
attrList = new ArrayList<AttributeValue>();
attrList.add(new StringAttribute(getUser(context)));
subAttr.put(Constants.XACML1_SUBJECT.ID.getURI(), attrList);
if (fedoraRole != null && fedoraRole.length > 0) {
attrList = new ArrayList<AttributeValue>();
for (String r : fedoraRole) {
attrList.add(new StringAttribute(r));
}
subAttr.put(Constants.SUBJECT.ROLE.getURI(), attrList);
}
subjects.add(subAttr);
return subjects;
}
|
[
"protected",
"List",
"<",
"Map",
"<",
"URI",
",",
"List",
"<",
"AttributeValue",
">",
">",
">",
"getSubjects",
"(",
"SOAPMessageContext",
"context",
")",
"{",
"// setup the id and value for the requesting subject",
"List",
"<",
"Map",
"<",
"URI",
",",
"List",
"<",
"AttributeValue",
">",
">",
">",
"subjects",
"=",
"new",
"ArrayList",
"<",
"Map",
"<",
"URI",
",",
"List",
"<",
"AttributeValue",
">",
">",
">",
"(",
")",
";",
"if",
"(",
"getUser",
"(",
"context",
")",
"==",
"null",
"||",
"getUser",
"(",
"context",
")",
".",
"trim",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"subjects",
";",
"}",
"String",
"[",
"]",
"fedoraRole",
"=",
"getUserRoles",
"(",
"context",
")",
";",
"Map",
"<",
"URI",
",",
"List",
"<",
"AttributeValue",
">",
">",
"subAttr",
"=",
"null",
";",
"List",
"<",
"AttributeValue",
">",
"attrList",
"=",
"null",
";",
"subAttr",
"=",
"new",
"HashMap",
"<",
"URI",
",",
"List",
"<",
"AttributeValue",
">",
">",
"(",
")",
";",
"attrList",
"=",
"new",
"ArrayList",
"<",
"AttributeValue",
">",
"(",
")",
";",
"attrList",
".",
"add",
"(",
"new",
"StringAttribute",
"(",
"getUser",
"(",
"context",
")",
")",
")",
";",
"subAttr",
".",
"put",
"(",
"Constants",
".",
"SUBJECT",
".",
"LOGIN_ID",
".",
"getURI",
"(",
")",
",",
"attrList",
")",
";",
"if",
"(",
"fedoraRole",
"!=",
"null",
"&&",
"fedoraRole",
".",
"length",
">",
"0",
")",
"{",
"attrList",
"=",
"new",
"ArrayList",
"<",
"AttributeValue",
">",
"(",
")",
";",
"for",
"(",
"String",
"r",
":",
"fedoraRole",
")",
"{",
"attrList",
".",
"add",
"(",
"new",
"StringAttribute",
"(",
"r",
")",
")",
";",
"}",
"subAttr",
".",
"put",
"(",
"Constants",
".",
"SUBJECT",
".",
"ROLE",
".",
"getURI",
"(",
")",
",",
"attrList",
")",
";",
"}",
"subjects",
".",
"add",
"(",
"subAttr",
")",
";",
"subAttr",
"=",
"new",
"HashMap",
"<",
"URI",
",",
"List",
"<",
"AttributeValue",
">",
">",
"(",
")",
";",
"attrList",
"=",
"new",
"ArrayList",
"<",
"AttributeValue",
">",
"(",
")",
";",
"attrList",
".",
"add",
"(",
"new",
"StringAttribute",
"(",
"getUser",
"(",
"context",
")",
")",
")",
";",
"subAttr",
".",
"put",
"(",
"Constants",
".",
"SUBJECT",
".",
"USER_REPRESENTED",
".",
"getURI",
"(",
")",
",",
"attrList",
")",
";",
"if",
"(",
"fedoraRole",
"!=",
"null",
"&&",
"fedoraRole",
".",
"length",
">",
"0",
")",
"{",
"attrList",
"=",
"new",
"ArrayList",
"<",
"AttributeValue",
">",
"(",
")",
";",
"for",
"(",
"String",
"r",
":",
"fedoraRole",
")",
"{",
"attrList",
".",
"add",
"(",
"new",
"StringAttribute",
"(",
"r",
")",
")",
";",
"}",
"subAttr",
".",
"put",
"(",
"Constants",
".",
"SUBJECT",
".",
"ROLE",
".",
"getURI",
"(",
")",
",",
"attrList",
")",
";",
"}",
"subjects",
".",
"add",
"(",
"subAttr",
")",
";",
"subAttr",
"=",
"new",
"HashMap",
"<",
"URI",
",",
"List",
"<",
"AttributeValue",
">",
">",
"(",
")",
";",
"attrList",
"=",
"new",
"ArrayList",
"<",
"AttributeValue",
">",
"(",
")",
";",
"attrList",
".",
"add",
"(",
"new",
"StringAttribute",
"(",
"getUser",
"(",
"context",
")",
")",
")",
";",
"subAttr",
".",
"put",
"(",
"Constants",
".",
"XACML1_SUBJECT",
".",
"ID",
".",
"getURI",
"(",
")",
",",
"attrList",
")",
";",
"if",
"(",
"fedoraRole",
"!=",
"null",
"&&",
"fedoraRole",
".",
"length",
">",
"0",
")",
"{",
"attrList",
"=",
"new",
"ArrayList",
"<",
"AttributeValue",
">",
"(",
")",
";",
"for",
"(",
"String",
"r",
":",
"fedoraRole",
")",
"{",
"attrList",
".",
"add",
"(",
"new",
"StringAttribute",
"(",
"r",
")",
")",
";",
"}",
"subAttr",
".",
"put",
"(",
"Constants",
".",
"SUBJECT",
".",
"ROLE",
".",
"getURI",
"(",
")",
",",
"attrList",
")",
";",
"}",
"subjects",
".",
"add",
"(",
"subAttr",
")",
";",
"return",
"subjects",
";",
"}"
] |
Extracts the list of Subjects from the given context.
@param context
the message context
@return a list of Subjects
@throws SoapFault
|
[
"Extracts",
"the",
"list",
"of",
"Subjects",
"from",
"the",
"given",
"context",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-security/fcrepo-security-pep/src/main/java/org/fcrepo/server/security/xacml/pep/ws/operations/AbstractOperationHandler.java#L250-L305
|
8,983 |
fcrepo3/fcrepo
|
fcrepo-security/fcrepo-security-pep/src/main/java/org/fcrepo/server/security/xacml/pep/ws/operations/AbstractOperationHandler.java
|
AbstractOperationHandler.getResources
|
protected Map<URI, AttributeValue> getResources(SOAPMessageContext context) throws OperationHandlerException, URISyntaxException {
Object oMap = null;
String pid = null;
try {
oMap = getSOAPRequestObjects(context);
logger.debug("Retrieved SOAP Request Objects");
} catch (SoapFault af) {
logger.error("Error obtaining SOAP Request Objects", af);
throw new OperationHandlerException("Error obtaining SOAP Request Objects",
af);
}
try {
pid = (String) callGetter("getPid",oMap);
} catch (Exception e) {
logger.error("Error obtaining parameters", e);
throw new OperationHandlerException("Error obtaining parameters.",
e);
}
Map<URI, AttributeValue> resAttr = ResourceAttributes.getResources(pid);
logger.debug("Extracted SOAP Request Objects");
return resAttr;
}
|
java
|
protected Map<URI, AttributeValue> getResources(SOAPMessageContext context) throws OperationHandlerException, URISyntaxException {
Object oMap = null;
String pid = null;
try {
oMap = getSOAPRequestObjects(context);
logger.debug("Retrieved SOAP Request Objects");
} catch (SoapFault af) {
logger.error("Error obtaining SOAP Request Objects", af);
throw new OperationHandlerException("Error obtaining SOAP Request Objects",
af);
}
try {
pid = (String) callGetter("getPid",oMap);
} catch (Exception e) {
logger.error("Error obtaining parameters", e);
throw new OperationHandlerException("Error obtaining parameters.",
e);
}
Map<URI, AttributeValue> resAttr = ResourceAttributes.getResources(pid);
logger.debug("Extracted SOAP Request Objects");
return resAttr;
}
|
[
"protected",
"Map",
"<",
"URI",
",",
"AttributeValue",
">",
"getResources",
"(",
"SOAPMessageContext",
"context",
")",
"throws",
"OperationHandlerException",
",",
"URISyntaxException",
"{",
"Object",
"oMap",
"=",
"null",
";",
"String",
"pid",
"=",
"null",
";",
"try",
"{",
"oMap",
"=",
"getSOAPRequestObjects",
"(",
"context",
")",
";",
"logger",
".",
"debug",
"(",
"\"Retrieved SOAP Request Objects\"",
")",
";",
"}",
"catch",
"(",
"SoapFault",
"af",
")",
"{",
"logger",
".",
"error",
"(",
"\"Error obtaining SOAP Request Objects\"",
",",
"af",
")",
";",
"throw",
"new",
"OperationHandlerException",
"(",
"\"Error obtaining SOAP Request Objects\"",
",",
"af",
")",
";",
"}",
"try",
"{",
"pid",
"=",
"(",
"String",
")",
"callGetter",
"(",
"\"getPid\"",
",",
"oMap",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Error obtaining parameters\"",
",",
"e",
")",
";",
"throw",
"new",
"OperationHandlerException",
"(",
"\"Error obtaining parameters.\"",
",",
"e",
")",
";",
"}",
"Map",
"<",
"URI",
",",
"AttributeValue",
">",
"resAttr",
"=",
"ResourceAttributes",
".",
"getResources",
"(",
"pid",
")",
";",
"logger",
".",
"debug",
"(",
"\"Extracted SOAP Request Objects\"",
")",
";",
"return",
"resAttr",
";",
"}"
] |
Obtains a map of resource Attributes.
@param context
the message context
@return map of resource Attributes
@throws OperationHandlerException
@throws URISyntaxException
|
[
"Obtains",
"a",
"map",
"of",
"resource",
"Attributes",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-security/fcrepo-security-pep/src/main/java/org/fcrepo/server/security/xacml/pep/ws/operations/AbstractOperationHandler.java#L339-L362
|
8,984 |
fcrepo3/fcrepo
|
fcrepo-security/fcrepo-security-pep/src/main/java/org/fcrepo/server/security/xacml/pep/ws/operations/AbstractOperationHandler.java
|
AbstractOperationHandler.getUserRoles
|
@SuppressWarnings("unchecked")
protected String[] getUserRoles(SOAPMessageContext context) {
HttpServletRequest request =
(HttpServletRequest) context
.get(SOAPMessageContext.SERVLET_REQUEST);
Map<String, Set<String>> reqAttr = null;
reqAttr =
(Map<String, Set<String>>) request
.getAttribute("FEDORA_AUX_SUBJECT_ATTRIBUTES");
if (reqAttr == null) {
return null;
}
Set<String> fedoraRoles = reqAttr.get("fedoraRole");
if (fedoraRoles == null || fedoraRoles.size() == 0) {
return null;
}
String[] fedoraRole =
fedoraRoles.toArray(new String[fedoraRoles.size()]);
return fedoraRole;
}
|
java
|
@SuppressWarnings("unchecked")
protected String[] getUserRoles(SOAPMessageContext context) {
HttpServletRequest request =
(HttpServletRequest) context
.get(SOAPMessageContext.SERVLET_REQUEST);
Map<String, Set<String>> reqAttr = null;
reqAttr =
(Map<String, Set<String>>) request
.getAttribute("FEDORA_AUX_SUBJECT_ATTRIBUTES");
if (reqAttr == null) {
return null;
}
Set<String> fedoraRoles = reqAttr.get("fedoraRole");
if (fedoraRoles == null || fedoraRoles.size() == 0) {
return null;
}
String[] fedoraRole =
fedoraRoles.toArray(new String[fedoraRoles.size()]);
return fedoraRole;
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"protected",
"String",
"[",
"]",
"getUserRoles",
"(",
"SOAPMessageContext",
"context",
")",
"{",
"HttpServletRequest",
"request",
"=",
"(",
"HttpServletRequest",
")",
"context",
".",
"get",
"(",
"SOAPMessageContext",
".",
"SERVLET_REQUEST",
")",
";",
"Map",
"<",
"String",
",",
"Set",
"<",
"String",
">",
">",
"reqAttr",
"=",
"null",
";",
"reqAttr",
"=",
"(",
"Map",
"<",
"String",
",",
"Set",
"<",
"String",
">",
">",
")",
"request",
".",
"getAttribute",
"(",
"\"FEDORA_AUX_SUBJECT_ATTRIBUTES\"",
")",
";",
"if",
"(",
"reqAttr",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"Set",
"<",
"String",
">",
"fedoraRoles",
"=",
"reqAttr",
".",
"get",
"(",
"\"fedoraRole\"",
")",
";",
"if",
"(",
"fedoraRoles",
"==",
"null",
"||",
"fedoraRoles",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"return",
"null",
";",
"}",
"String",
"[",
"]",
"fedoraRole",
"=",
"fedoraRoles",
".",
"toArray",
"(",
"new",
"String",
"[",
"fedoraRoles",
".",
"size",
"(",
")",
"]",
")",
";",
"return",
"fedoraRole",
";",
"}"
] |
Returns the roles that the user has.
@param context
the message context
@return a String array of roles
|
[
"Returns",
"the",
"roles",
"that",
"the",
"user",
"has",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-security/fcrepo-security-pep/src/main/java/org/fcrepo/server/security/xacml/pep/ws/operations/AbstractOperationHandler.java#L377-L401
|
8,985 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/storage/types/DatastreamReferencedContent.java
|
DatastreamReferencedContent.getExternalContentManager
|
private ExternalContentManager getExternalContentManager()
throws Exception {
if (s_ecm == null) {
Server server;
try {
server = Server.getInstance(new File(Constants.FEDORA_HOME),
false);
s_ecm = (ExternalContentManager) server
.getModule("org.fcrepo.server.storage.ExternalContentManager");
} catch (InitializationException e) {
throw new Exception(
"Unable to get ExternalContentManager Module: "
+ e.getMessage(), e);
}
}
return s_ecm;
}
|
java
|
private ExternalContentManager getExternalContentManager()
throws Exception {
if (s_ecm == null) {
Server server;
try {
server = Server.getInstance(new File(Constants.FEDORA_HOME),
false);
s_ecm = (ExternalContentManager) server
.getModule("org.fcrepo.server.storage.ExternalContentManager");
} catch (InitializationException e) {
throw new Exception(
"Unable to get ExternalContentManager Module: "
+ e.getMessage(), e);
}
}
return s_ecm;
}
|
[
"private",
"ExternalContentManager",
"getExternalContentManager",
"(",
")",
"throws",
"Exception",
"{",
"if",
"(",
"s_ecm",
"==",
"null",
")",
"{",
"Server",
"server",
";",
"try",
"{",
"server",
"=",
"Server",
".",
"getInstance",
"(",
"new",
"File",
"(",
"Constants",
".",
"FEDORA_HOME",
")",
",",
"false",
")",
";",
"s_ecm",
"=",
"(",
"ExternalContentManager",
")",
"server",
".",
"getModule",
"(",
"\"org.fcrepo.server.storage.ExternalContentManager\"",
")",
";",
"}",
"catch",
"(",
"InitializationException",
"e",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Unable to get ExternalContentManager Module: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}",
"return",
"s_ecm",
";",
"}"
] |
Gets the external content manager which is used for the retrieval of
content.
@return an instance of <code>ExternalContentManager</code>
@throws Exception is thrown in case the server is not able to find the module.
|
[
"Gets",
"the",
"external",
"content",
"manager",
"which",
"is",
"used",
"for",
"the",
"retrieval",
"of",
"content",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/storage/types/DatastreamReferencedContent.java#L49-L65
|
8,986 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/storage/types/DatastreamReferencedContent.java
|
DatastreamReferencedContent.getContentStream
|
@Override
public InputStream getContentStream(Context context) throws StreamIOException {
try {
ContentManagerParams params = new ContentManagerParams(DSLocation);
if (context != null ) {
params.setContext(context);
}
MIMETypedStream stream = getExternalContentManager()
.getExternalContent(params);
DSSize = getContentLength(stream);
return stream.getStream();
} catch (Exception ex) {
throw new StreamIOException("Error getting content stream", ex);
}
}
|
java
|
@Override
public InputStream getContentStream(Context context) throws StreamIOException {
try {
ContentManagerParams params = new ContentManagerParams(DSLocation);
if (context != null ) {
params.setContext(context);
}
MIMETypedStream stream = getExternalContentManager()
.getExternalContent(params);
DSSize = getContentLength(stream);
return stream.getStream();
} catch (Exception ex) {
throw new StreamIOException("Error getting content stream", ex);
}
}
|
[
"@",
"Override",
"public",
"InputStream",
"getContentStream",
"(",
"Context",
"context",
")",
"throws",
"StreamIOException",
"{",
"try",
"{",
"ContentManagerParams",
"params",
"=",
"new",
"ContentManagerParams",
"(",
"DSLocation",
")",
";",
"if",
"(",
"context",
"!=",
"null",
")",
"{",
"params",
".",
"setContext",
"(",
"context",
")",
";",
"}",
"MIMETypedStream",
"stream",
"=",
"getExternalContentManager",
"(",
")",
".",
"getExternalContent",
"(",
"params",
")",
";",
"DSSize",
"=",
"getContentLength",
"(",
"stream",
")",
";",
"return",
"stream",
".",
"getStream",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"throw",
"new",
"StreamIOException",
"(",
"\"Error getting content stream\"",
",",
"ex",
")",
";",
"}",
"}"
] |
Gets an InputStream to the content of this externally-referenced
datastream.
<p>The DSLocation of this datastream must be non-null before invoking
this method.
<p>If successful, the DSMIME type is automatically set based on the web
server's response header. If the web server doesn't send a valid
Content-type: header, as a last resort, the content-type is guessed by
using a map of common extensions to mime-types.
<p>If the content-length header is present in the response, DSSize will
be set accordingly.
@see org.fcrepo.server.storage.types.Datastream#getContentStream()
|
[
"Gets",
"an",
"InputStream",
"to",
"the",
"content",
"of",
"this",
"externally",
"-",
"referenced",
"datastream",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/storage/types/DatastreamReferencedContent.java#L84-L98
|
8,987 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/storage/types/DatastreamReferencedContent.java
|
DatastreamReferencedContent.getContentLength
|
public long getContentLength(MIMETypedStream stream) {
long length = 0;
if (stream.header != null) {
for (int i = 0; i < stream.header.length; i++) {
if (stream.header[i].name != null
&& !stream.header[i].name.equalsIgnoreCase("")
&& stream.header[i].name.equalsIgnoreCase("content-length")) {
length = Long.parseLong(stream.header[i].value);
break;
}
}
}
return length;
}
|
java
|
public long getContentLength(MIMETypedStream stream) {
long length = 0;
if (stream.header != null) {
for (int i = 0; i < stream.header.length; i++) {
if (stream.header[i].name != null
&& !stream.header[i].name.equalsIgnoreCase("")
&& stream.header[i].name.equalsIgnoreCase("content-length")) {
length = Long.parseLong(stream.header[i].value);
break;
}
}
}
return length;
}
|
[
"public",
"long",
"getContentLength",
"(",
"MIMETypedStream",
"stream",
")",
"{",
"long",
"length",
"=",
"0",
";",
"if",
"(",
"stream",
".",
"header",
"!=",
"null",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"stream",
".",
"header",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"stream",
".",
"header",
"[",
"i",
"]",
".",
"name",
"!=",
"null",
"&&",
"!",
"stream",
".",
"header",
"[",
"i",
"]",
".",
"name",
".",
"equalsIgnoreCase",
"(",
"\"\"",
")",
"&&",
"stream",
".",
"header",
"[",
"i",
"]",
".",
"name",
".",
"equalsIgnoreCase",
"(",
"\"content-length\"",
")",
")",
"{",
"length",
"=",
"Long",
".",
"parseLong",
"(",
"stream",
".",
"header",
"[",
"i",
"]",
".",
"value",
")",
";",
"break",
";",
"}",
"}",
"}",
"return",
"length",
";",
"}"
] |
Returns the length of the content of this stream.
@param stream the MIMETypedStream
@return length the length of the content
|
[
"Returns",
"the",
"length",
"of",
"the",
"content",
"of",
"this",
"stream",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/storage/types/DatastreamReferencedContent.java#L105-L118
|
8,988 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/utilities/CleanupContextListener.java
|
CleanupContextListener.contextDestroyed
|
@Override
public void contextDestroyed(ServletContextEvent event) {
// deregister database drivers
try {
for (Enumeration<Driver> e = DriverManager.getDrivers(); e
.hasMoreElements();) {
Driver driver = e.nextElement();
if (driver.getClass().getClassLoader() == getClass()
.getClassLoader()) {
DriverManager.deregisterDriver(driver);
}
}
} catch (Throwable e) {
// Any errors thrown in clearing the caches aren't significant to
// the normal execution of the application, so we ignore them
}
// Clean the axis method cache, see FCREPO-496
// org.apache.axis.utils.cache.MethodCache.getInstance().clearCache();
}
|
java
|
@Override
public void contextDestroyed(ServletContextEvent event) {
// deregister database drivers
try {
for (Enumeration<Driver> e = DriverManager.getDrivers(); e
.hasMoreElements();) {
Driver driver = e.nextElement();
if (driver.getClass().getClassLoader() == getClass()
.getClassLoader()) {
DriverManager.deregisterDriver(driver);
}
}
} catch (Throwable e) {
// Any errors thrown in clearing the caches aren't significant to
// the normal execution of the application, so we ignore them
}
// Clean the axis method cache, see FCREPO-496
// org.apache.axis.utils.cache.MethodCache.getInstance().clearCache();
}
|
[
"@",
"Override",
"public",
"void",
"contextDestroyed",
"(",
"ServletContextEvent",
"event",
")",
"{",
"// deregister database drivers",
"try",
"{",
"for",
"(",
"Enumeration",
"<",
"Driver",
">",
"e",
"=",
"DriverManager",
".",
"getDrivers",
"(",
")",
";",
"e",
".",
"hasMoreElements",
"(",
")",
";",
")",
"{",
"Driver",
"driver",
"=",
"e",
".",
"nextElement",
"(",
")",
";",
"if",
"(",
"driver",
".",
"getClass",
"(",
")",
".",
"getClassLoader",
"(",
")",
"==",
"getClass",
"(",
")",
".",
"getClassLoader",
"(",
")",
")",
"{",
"DriverManager",
".",
"deregisterDriver",
"(",
"driver",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"Throwable",
"e",
")",
"{",
"// Any errors thrown in clearing the caches aren't significant to",
"// the normal execution of the application, so we ignore them",
"}",
"// Clean the axis method cache, see FCREPO-496",
"// org.apache.axis.utils.cache.MethodCache.getInstance().clearCache();",
"}"
] |
Clean up resources used by the application when stopped
@see javax.servlet.ServletContextListener#contextDestroyed(javax.servlet
.ServletContextEvent)
|
[
"Clean",
"up",
"resources",
"used",
"by",
"the",
"application",
"when",
"stopped"
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/utilities/CleanupContextListener.java#L58-L76
|
8,989 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/storage/service/WSDLParser.java
|
WSDLParser.checkForUnsupportedPattern
|
private void checkForUnsupportedPattern(String namespaceURI,
String localName,
String qName,
Attributes attrs)
throws SAXException {
// Elements in XML schema definitions (within WSDL types)
if (namespaceURI.equalsIgnoreCase(XML_XSD.uri)
&& localName.equalsIgnoreCase("complexType")) {
throw new SAXException("WSDLParser: Detected a WSDL pattern that Fedora does not yet support: "
+ qName);
} else if (namespaceURI.equalsIgnoreCase(XML_XSD.uri)
&& localName.equalsIgnoreCase("element")) {
throw new SAXException("WSDLParser: Detected a WSDL pattern that Fedora does not yet support: "
+ qName);
} else if (namespaceURI.equalsIgnoreCase(XML_XSD.uri)
&& localName.equalsIgnoreCase("list")) {
throw new SAXException("WSDLParser: Detected a WSDL pattern that Fedora does not yet support: "
+ qName);
} else if (namespaceURI.equalsIgnoreCase(XML_XSD.uri)
&& localName.equalsIgnoreCase("union")) {
throw new SAXException("WSDLParser: Detected a WSDL pattern that Fedora does not yet support: "
+ qName);
}
// WSDL Elements
else if (namespaceURI.equalsIgnoreCase(WSDL.uri)
&& localName.equalsIgnoreCase("import")) {
throw new SAXException("WSDLParser: Detected a WSDL pattern that Fedora does not yet support: "
+ qName);
} else if (namespaceURI.equalsIgnoreCase(WSDL.uri)
&& localName.equalsIgnoreCase("fault")) {
throw new SAXException("WSDLParser: Detected a WSDL pattern that Fedora does not yet support: "
+ qName);
} else if (namespaceURI.equalsIgnoreCase(WSDL.uri)
&& localName.equalsIgnoreCase("part")
&& attrs.getValue("element") != null) {
throw new SAXException("WSDLParser: Detected a WSDL pattern that Fedora does not yet support: "
+ qName + " element attr");
}
// Extension Elements
else if (namespaceURI.equalsIgnoreCase(SOAP.uri)
&& localName.equalsIgnoreCase("binding")) {
throw new SAXException("WSDLParser: Detected a WSDL pattern that Fedora does not yet support: "
+ qName);
} else if (namespaceURI.equalsIgnoreCase(WSDL_MIME.uri)
&& localName.equalsIgnoreCase("multipartRelated")) {
throw new SAXException("WSDLParser: Detected a WSDL pattern that Fedora does not yet support: "
+ qName);
} else if (namespaceURI.equalsIgnoreCase(WSDL_HTTP.uri)
&& localName.equalsIgnoreCase("urlEncoded")) {
throw new SAXException("WSDLParser: Detected a WSDL pattern that Fedora does not yet support: "
+ qName);
}
}
|
java
|
private void checkForUnsupportedPattern(String namespaceURI,
String localName,
String qName,
Attributes attrs)
throws SAXException {
// Elements in XML schema definitions (within WSDL types)
if (namespaceURI.equalsIgnoreCase(XML_XSD.uri)
&& localName.equalsIgnoreCase("complexType")) {
throw new SAXException("WSDLParser: Detected a WSDL pattern that Fedora does not yet support: "
+ qName);
} else if (namespaceURI.equalsIgnoreCase(XML_XSD.uri)
&& localName.equalsIgnoreCase("element")) {
throw new SAXException("WSDLParser: Detected a WSDL pattern that Fedora does not yet support: "
+ qName);
} else if (namespaceURI.equalsIgnoreCase(XML_XSD.uri)
&& localName.equalsIgnoreCase("list")) {
throw new SAXException("WSDLParser: Detected a WSDL pattern that Fedora does not yet support: "
+ qName);
} else if (namespaceURI.equalsIgnoreCase(XML_XSD.uri)
&& localName.equalsIgnoreCase("union")) {
throw new SAXException("WSDLParser: Detected a WSDL pattern that Fedora does not yet support: "
+ qName);
}
// WSDL Elements
else if (namespaceURI.equalsIgnoreCase(WSDL.uri)
&& localName.equalsIgnoreCase("import")) {
throw new SAXException("WSDLParser: Detected a WSDL pattern that Fedora does not yet support: "
+ qName);
} else if (namespaceURI.equalsIgnoreCase(WSDL.uri)
&& localName.equalsIgnoreCase("fault")) {
throw new SAXException("WSDLParser: Detected a WSDL pattern that Fedora does not yet support: "
+ qName);
} else if (namespaceURI.equalsIgnoreCase(WSDL.uri)
&& localName.equalsIgnoreCase("part")
&& attrs.getValue("element") != null) {
throw new SAXException("WSDLParser: Detected a WSDL pattern that Fedora does not yet support: "
+ qName + " element attr");
}
// Extension Elements
else if (namespaceURI.equalsIgnoreCase(SOAP.uri)
&& localName.equalsIgnoreCase("binding")) {
throw new SAXException("WSDLParser: Detected a WSDL pattern that Fedora does not yet support: "
+ qName);
} else if (namespaceURI.equalsIgnoreCase(WSDL_MIME.uri)
&& localName.equalsIgnoreCase("multipartRelated")) {
throw new SAXException("WSDLParser: Detected a WSDL pattern that Fedora does not yet support: "
+ qName);
} else if (namespaceURI.equalsIgnoreCase(WSDL_HTTP.uri)
&& localName.equalsIgnoreCase("urlEncoded")) {
throw new SAXException("WSDLParser: Detected a WSDL pattern that Fedora does not yet support: "
+ qName);
}
}
|
[
"private",
"void",
"checkForUnsupportedPattern",
"(",
"String",
"namespaceURI",
",",
"String",
"localName",
",",
"String",
"qName",
",",
"Attributes",
"attrs",
")",
"throws",
"SAXException",
"{",
"// Elements in XML schema definitions (within WSDL types)",
"if",
"(",
"namespaceURI",
".",
"equalsIgnoreCase",
"(",
"XML_XSD",
".",
"uri",
")",
"&&",
"localName",
".",
"equalsIgnoreCase",
"(",
"\"complexType\"",
")",
")",
"{",
"throw",
"new",
"SAXException",
"(",
"\"WSDLParser: Detected a WSDL pattern that Fedora does not yet support: \"",
"+",
"qName",
")",
";",
"}",
"else",
"if",
"(",
"namespaceURI",
".",
"equalsIgnoreCase",
"(",
"XML_XSD",
".",
"uri",
")",
"&&",
"localName",
".",
"equalsIgnoreCase",
"(",
"\"element\"",
")",
")",
"{",
"throw",
"new",
"SAXException",
"(",
"\"WSDLParser: Detected a WSDL pattern that Fedora does not yet support: \"",
"+",
"qName",
")",
";",
"}",
"else",
"if",
"(",
"namespaceURI",
".",
"equalsIgnoreCase",
"(",
"XML_XSD",
".",
"uri",
")",
"&&",
"localName",
".",
"equalsIgnoreCase",
"(",
"\"list\"",
")",
")",
"{",
"throw",
"new",
"SAXException",
"(",
"\"WSDLParser: Detected a WSDL pattern that Fedora does not yet support: \"",
"+",
"qName",
")",
";",
"}",
"else",
"if",
"(",
"namespaceURI",
".",
"equalsIgnoreCase",
"(",
"XML_XSD",
".",
"uri",
")",
"&&",
"localName",
".",
"equalsIgnoreCase",
"(",
"\"union\"",
")",
")",
"{",
"throw",
"new",
"SAXException",
"(",
"\"WSDLParser: Detected a WSDL pattern that Fedora does not yet support: \"",
"+",
"qName",
")",
";",
"}",
"// WSDL Elements",
"else",
"if",
"(",
"namespaceURI",
".",
"equalsIgnoreCase",
"(",
"WSDL",
".",
"uri",
")",
"&&",
"localName",
".",
"equalsIgnoreCase",
"(",
"\"import\"",
")",
")",
"{",
"throw",
"new",
"SAXException",
"(",
"\"WSDLParser: Detected a WSDL pattern that Fedora does not yet support: \"",
"+",
"qName",
")",
";",
"}",
"else",
"if",
"(",
"namespaceURI",
".",
"equalsIgnoreCase",
"(",
"WSDL",
".",
"uri",
")",
"&&",
"localName",
".",
"equalsIgnoreCase",
"(",
"\"fault\"",
")",
")",
"{",
"throw",
"new",
"SAXException",
"(",
"\"WSDLParser: Detected a WSDL pattern that Fedora does not yet support: \"",
"+",
"qName",
")",
";",
"}",
"else",
"if",
"(",
"namespaceURI",
".",
"equalsIgnoreCase",
"(",
"WSDL",
".",
"uri",
")",
"&&",
"localName",
".",
"equalsIgnoreCase",
"(",
"\"part\"",
")",
"&&",
"attrs",
".",
"getValue",
"(",
"\"element\"",
")",
"!=",
"null",
")",
"{",
"throw",
"new",
"SAXException",
"(",
"\"WSDLParser: Detected a WSDL pattern that Fedora does not yet support: \"",
"+",
"qName",
"+",
"\" element attr\"",
")",
";",
"}",
"// Extension Elements",
"else",
"if",
"(",
"namespaceURI",
".",
"equalsIgnoreCase",
"(",
"SOAP",
".",
"uri",
")",
"&&",
"localName",
".",
"equalsIgnoreCase",
"(",
"\"binding\"",
")",
")",
"{",
"throw",
"new",
"SAXException",
"(",
"\"WSDLParser: Detected a WSDL pattern that Fedora does not yet support: \"",
"+",
"qName",
")",
";",
"}",
"else",
"if",
"(",
"namespaceURI",
".",
"equalsIgnoreCase",
"(",
"WSDL_MIME",
".",
"uri",
")",
"&&",
"localName",
".",
"equalsIgnoreCase",
"(",
"\"multipartRelated\"",
")",
")",
"{",
"throw",
"new",
"SAXException",
"(",
"\"WSDLParser: Detected a WSDL pattern that Fedora does not yet support: \"",
"+",
"qName",
")",
";",
"}",
"else",
"if",
"(",
"namespaceURI",
".",
"equalsIgnoreCase",
"(",
"WSDL_HTTP",
".",
"uri",
")",
"&&",
"localName",
".",
"equalsIgnoreCase",
"(",
"\"urlEncoded\"",
")",
")",
"{",
"throw",
"new",
"SAXException",
"(",
"\"WSDLParser: Detected a WSDL pattern that Fedora does not yet support: \"",
"+",
"qName",
")",
";",
"}",
"}"
] |
we might encounter!
|
[
"we",
"might",
"encounter!"
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/storage/service/WSDLParser.java#L745-L797
|
8,990 |
fcrepo3/fcrepo
|
fcrepo-webapp/fcrepo-webapp-imagemanip/src/main/java/org/fcrepo/localservices/imagemanip/ImageManipulation.java
|
ImageManipulation.resize
|
private ImageProcessor resize(ImageProcessor ip, String newWidth) {
if (newWidth != null) {
try {
int width = Integer.parseInt(newWidth);
if (width < 0) {
return ip;
}
int imgWidth = ip.getWidth();
int imgHeight = ip.getHeight();
ip = ip.resize(width, width * imgHeight / imgWidth);
}
// no need to do anything with number format exception since the servlet
// returns only images; just return the original image
catch (NumberFormatException e) {
}
}
return ip;
}
|
java
|
private ImageProcessor resize(ImageProcessor ip, String newWidth) {
if (newWidth != null) {
try {
int width = Integer.parseInt(newWidth);
if (width < 0) {
return ip;
}
int imgWidth = ip.getWidth();
int imgHeight = ip.getHeight();
ip = ip.resize(width, width * imgHeight / imgWidth);
}
// no need to do anything with number format exception since the servlet
// returns only images; just return the original image
catch (NumberFormatException e) {
}
}
return ip;
}
|
[
"private",
"ImageProcessor",
"resize",
"(",
"ImageProcessor",
"ip",
",",
"String",
"newWidth",
")",
"{",
"if",
"(",
"newWidth",
"!=",
"null",
")",
"{",
"try",
"{",
"int",
"width",
"=",
"Integer",
".",
"parseInt",
"(",
"newWidth",
")",
";",
"if",
"(",
"width",
"<",
"0",
")",
"{",
"return",
"ip",
";",
"}",
"int",
"imgWidth",
"=",
"ip",
".",
"getWidth",
"(",
")",
";",
"int",
"imgHeight",
"=",
"ip",
".",
"getHeight",
"(",
")",
";",
"ip",
"=",
"ip",
".",
"resize",
"(",
"width",
",",
"width",
"*",
"imgHeight",
"/",
"imgWidth",
")",
";",
"}",
"// no need to do anything with number format exception since the servlet",
"// returns only images; just return the original image",
"catch",
"(",
"NumberFormatException",
"e",
")",
"{",
"}",
"}",
"return",
"ip",
";",
"}"
] |
Resizes an image to the supplied new width in pixels. The height is
reduced proportionally to the new width.
@param ip
The image to resize newWidth The width in pixels to resize the
image to
@return The image resized
|
[
"Resizes",
"an",
"image",
"to",
"the",
"supplied",
"new",
"width",
"in",
"pixels",
".",
"The",
"height",
"is",
"reduced",
"proportionally",
"to",
"the",
"new",
"width",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-webapp/fcrepo-webapp-imagemanip/src/main/java/org/fcrepo/localservices/imagemanip/ImageManipulation.java#L374-L395
|
8,991 |
fcrepo3/fcrepo
|
fcrepo-webapp/fcrepo-webapp-imagemanip/src/main/java/org/fcrepo/localservices/imagemanip/ImageManipulation.java
|
ImageManipulation.zoom
|
private ImageProcessor zoom(ImageProcessor ip, String zoomAmt) {
if (zoomAmt != null) {
try {
float zoom = Float.parseFloat(zoomAmt);
if (zoom < 0) {
return ip;
}
ip.scale(zoom, zoom);
// if the image is being zoomed out, trim the extra whitespace around the image
if (zoom < 1) {
int imgWidth = ip.getWidth();
int imgHeight = ip.getHeight();
// set a ROI around the image, minus the extra whitespace
ip.setRoi(Math.round(imgWidth / 2 - imgWidth * zoom / 2),
Math.round(imgHeight / 2 - imgHeight * zoom / 2),
Math.round(imgWidth * zoom),
Math.round(imgHeight * zoom));
ip = ip.crop();
}
}
// no need to do anything with number format exception since the servlet
// returns only images; just return the original image
catch (NumberFormatException e) {
}
}
return ip;
}
|
java
|
private ImageProcessor zoom(ImageProcessor ip, String zoomAmt) {
if (zoomAmt != null) {
try {
float zoom = Float.parseFloat(zoomAmt);
if (zoom < 0) {
return ip;
}
ip.scale(zoom, zoom);
// if the image is being zoomed out, trim the extra whitespace around the image
if (zoom < 1) {
int imgWidth = ip.getWidth();
int imgHeight = ip.getHeight();
// set a ROI around the image, minus the extra whitespace
ip.setRoi(Math.round(imgWidth / 2 - imgWidth * zoom / 2),
Math.round(imgHeight / 2 - imgHeight * zoom / 2),
Math.round(imgWidth * zoom),
Math.round(imgHeight * zoom));
ip = ip.crop();
}
}
// no need to do anything with number format exception since the servlet
// returns only images; just return the original image
catch (NumberFormatException e) {
}
}
return ip;
}
|
[
"private",
"ImageProcessor",
"zoom",
"(",
"ImageProcessor",
"ip",
",",
"String",
"zoomAmt",
")",
"{",
"if",
"(",
"zoomAmt",
"!=",
"null",
")",
"{",
"try",
"{",
"float",
"zoom",
"=",
"Float",
".",
"parseFloat",
"(",
"zoomAmt",
")",
";",
"if",
"(",
"zoom",
"<",
"0",
")",
"{",
"return",
"ip",
";",
"}",
"ip",
".",
"scale",
"(",
"zoom",
",",
"zoom",
")",
";",
"// if the image is being zoomed out, trim the extra whitespace around the image",
"if",
"(",
"zoom",
"<",
"1",
")",
"{",
"int",
"imgWidth",
"=",
"ip",
".",
"getWidth",
"(",
")",
";",
"int",
"imgHeight",
"=",
"ip",
".",
"getHeight",
"(",
")",
";",
"// set a ROI around the image, minus the extra whitespace",
"ip",
".",
"setRoi",
"(",
"Math",
".",
"round",
"(",
"imgWidth",
"/",
"2",
"-",
"imgWidth",
"*",
"zoom",
"/",
"2",
")",
",",
"Math",
".",
"round",
"(",
"imgHeight",
"/",
"2",
"-",
"imgHeight",
"*",
"zoom",
"/",
"2",
")",
",",
"Math",
".",
"round",
"(",
"imgWidth",
"*",
"zoom",
")",
",",
"Math",
".",
"round",
"(",
"imgHeight",
"*",
"zoom",
")",
")",
";",
"ip",
"=",
"ip",
".",
"crop",
"(",
")",
";",
"}",
"}",
"// no need to do anything with number format exception since the servlet",
"// returns only images; just return the original image",
"catch",
"(",
"NumberFormatException",
"e",
")",
"{",
"}",
"}",
"return",
"ip",
";",
"}"
] |
Zooms either in or out of an image by a supplied amount. The zooming
occurs from the center of the image.
@param ip
The image to zoom zoomAmt The amount to zoom the image. 0 <
zoomAmt < 1 : zoom out 1 = zoomAmt : original image 1 < zoomAmt :
zoom in
@return The image zoomed
|
[
"Zooms",
"either",
"in",
"or",
"out",
"of",
"an",
"image",
"by",
"a",
"supplied",
"amount",
".",
"The",
"zooming",
"occurs",
"from",
"the",
"center",
"of",
"the",
"image",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-webapp/fcrepo-webapp-imagemanip/src/main/java/org/fcrepo/localservices/imagemanip/ImageManipulation.java#L407-L440
|
8,992 |
fcrepo3/fcrepo
|
fcrepo-webapp/fcrepo-webapp-imagemanip/src/main/java/org/fcrepo/localservices/imagemanip/ImageManipulation.java
|
ImageManipulation.brightness
|
private ImageProcessor brightness(ImageProcessor ip, String brightAmt) {
if (brightAmt != null) {
try {
float bright = Float.parseFloat(brightAmt);
if (bright < 0) {
return ip;
}
ip.multiply(bright);
}
// no need to do anything with number format exception since the servlet
// returns only images; just return the original image
catch (NumberFormatException e) {
}
}
return ip;
}
|
java
|
private ImageProcessor brightness(ImageProcessor ip, String brightAmt) {
if (brightAmt != null) {
try {
float bright = Float.parseFloat(brightAmt);
if (bright < 0) {
return ip;
}
ip.multiply(bright);
}
// no need to do anything with number format exception since the servlet
// returns only images; just return the original image
catch (NumberFormatException e) {
}
}
return ip;
}
|
[
"private",
"ImageProcessor",
"brightness",
"(",
"ImageProcessor",
"ip",
",",
"String",
"brightAmt",
")",
"{",
"if",
"(",
"brightAmt",
"!=",
"null",
")",
"{",
"try",
"{",
"float",
"bright",
"=",
"Float",
".",
"parseFloat",
"(",
"brightAmt",
")",
";",
"if",
"(",
"bright",
"<",
"0",
")",
"{",
"return",
"ip",
";",
"}",
"ip",
".",
"multiply",
"(",
"bright",
")",
";",
"}",
"// no need to do anything with number format exception since the servlet",
"// returns only images; just return the original image",
"catch",
"(",
"NumberFormatException",
"e",
")",
"{",
"}",
"}",
"return",
"ip",
";",
"}"
] |
Adjusts the brightness of an image by a supplied amount.
@param ip
The image to adjust the brightness of brightAmt The amount to
adjust the brightness of the image by 0 <= brightAmt < 1 : darkens
image 1 = brightAmt : original image 1 < brightAmt : brightens
image
@return The image with brightness levels adjusted
|
[
"Adjusts",
"the",
"brightness",
"of",
"an",
"image",
"by",
"a",
"supplied",
"amount",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-webapp/fcrepo-webapp-imagemanip/src/main/java/org/fcrepo/localservices/imagemanip/ImageManipulation.java#L452-L472
|
8,993 |
fcrepo3/fcrepo
|
fcrepo-webapp/fcrepo-webapp-imagemanip/src/main/java/org/fcrepo/localservices/imagemanip/ImageManipulation.java
|
ImageManipulation.crop
|
public ImageProcessor crop(ImageProcessor ip,
String cropX,
String cropY,
String cropWidth,
String cropHeight) {
if (cropX != null && cropY != null) {
try {
int x = Integer.parseInt(cropX);
int y = Integer.parseInt(cropY);
int width;
int height;
// if value for cropWidth is not given, just use the width of the image
if (cropWidth != null) {
width = Integer.parseInt(cropWidth);
} else {
width = ip.getWidth();
}
// if value for cropHeight is not given, just use the height of the image
if (cropHeight != null) {
height = Integer.parseInt(cropHeight);
} else {
height = ip.getHeight();
}
// if any value is negative, this causes ImageJ to explode, so just return
if (x < 0 || y < 0 || width < 0 || height < 0) {
return ip;
}
ip.setRoi(x, y, width, height);
ip = ip.crop();
}
// no need to do anything with number format exception since the servlet
// returns only images; just return the original image
catch (NumberFormatException e) {
}
}
return ip;
}
|
java
|
public ImageProcessor crop(ImageProcessor ip,
String cropX,
String cropY,
String cropWidth,
String cropHeight) {
if (cropX != null && cropY != null) {
try {
int x = Integer.parseInt(cropX);
int y = Integer.parseInt(cropY);
int width;
int height;
// if value for cropWidth is not given, just use the width of the image
if (cropWidth != null) {
width = Integer.parseInt(cropWidth);
} else {
width = ip.getWidth();
}
// if value for cropHeight is not given, just use the height of the image
if (cropHeight != null) {
height = Integer.parseInt(cropHeight);
} else {
height = ip.getHeight();
}
// if any value is negative, this causes ImageJ to explode, so just return
if (x < 0 || y < 0 || width < 0 || height < 0) {
return ip;
}
ip.setRoi(x, y, width, height);
ip = ip.crop();
}
// no need to do anything with number format exception since the servlet
// returns only images; just return the original image
catch (NumberFormatException e) {
}
}
return ip;
}
|
[
"public",
"ImageProcessor",
"crop",
"(",
"ImageProcessor",
"ip",
",",
"String",
"cropX",
",",
"String",
"cropY",
",",
"String",
"cropWidth",
",",
"String",
"cropHeight",
")",
"{",
"if",
"(",
"cropX",
"!=",
"null",
"&&",
"cropY",
"!=",
"null",
")",
"{",
"try",
"{",
"int",
"x",
"=",
"Integer",
".",
"parseInt",
"(",
"cropX",
")",
";",
"int",
"y",
"=",
"Integer",
".",
"parseInt",
"(",
"cropY",
")",
";",
"int",
"width",
";",
"int",
"height",
";",
"// if value for cropWidth is not given, just use the width of the image",
"if",
"(",
"cropWidth",
"!=",
"null",
")",
"{",
"width",
"=",
"Integer",
".",
"parseInt",
"(",
"cropWidth",
")",
";",
"}",
"else",
"{",
"width",
"=",
"ip",
".",
"getWidth",
"(",
")",
";",
"}",
"// if value for cropHeight is not given, just use the height of the image",
"if",
"(",
"cropHeight",
"!=",
"null",
")",
"{",
"height",
"=",
"Integer",
".",
"parseInt",
"(",
"cropHeight",
")",
";",
"}",
"else",
"{",
"height",
"=",
"ip",
".",
"getHeight",
"(",
")",
";",
"}",
"// if any value is negative, this causes ImageJ to explode, so just return",
"if",
"(",
"x",
"<",
"0",
"||",
"y",
"<",
"0",
"||",
"width",
"<",
"0",
"||",
"height",
"<",
"0",
")",
"{",
"return",
"ip",
";",
"}",
"ip",
".",
"setRoi",
"(",
"x",
",",
"y",
",",
"width",
",",
"height",
")",
";",
"ip",
"=",
"ip",
".",
"crop",
"(",
")",
";",
"}",
"// no need to do anything with number format exception since the servlet",
"// returns only images; just return the original image",
"catch",
"(",
"NumberFormatException",
"e",
")",
"{",
"}",
"}",
"return",
"ip",
";",
"}"
] |
Crops an image with supplied starting point and ending point.
@param ip
The image to crop cropX The starting x position; x=0 corresponds
to left side of image cropY The starting y position; y=0
corresponds to top of image cropWidth The width of the crop,
starting from the above x cropHeight The height of the crop,
starting from the above y
@return The image cropped
|
[
"Crops",
"an",
"image",
"with",
"supplied",
"starting",
"point",
"and",
"ending",
"point",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-webapp/fcrepo-webapp-imagemanip/src/main/java/org/fcrepo/localservices/imagemanip/ImageManipulation.java#L498-L540
|
8,994 |
fcrepo3/fcrepo
|
fcrepo-client/fcrepo-client-messaging/src/main/java/org/fcrepo/client/messaging/JmsMessagingClient.java
|
JmsMessagingClient.start
|
public void start(boolean wait) throws MessagingException {
Thread connector = new JMSBrokerConnector();
connector.start();
if(wait) {
int maxWait = RETRY_INTERVAL * MAX_RETRIES;
int waitTime = 0;
while(!isConnected()) {
if(waitTime < maxWait) {
try {
Thread.sleep(100);
waitTime += 100;
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
}
} else {
throw new MessagingException("Timeout reached waiting " +
"for messaging client to start.");
}
}
}
}
|
java
|
public void start(boolean wait) throws MessagingException {
Thread connector = new JMSBrokerConnector();
connector.start();
if(wait) {
int maxWait = RETRY_INTERVAL * MAX_RETRIES;
int waitTime = 0;
while(!isConnected()) {
if(waitTime < maxWait) {
try {
Thread.sleep(100);
waitTime += 100;
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
}
} else {
throw new MessagingException("Timeout reached waiting " +
"for messaging client to start.");
}
}
}
}
|
[
"public",
"void",
"start",
"(",
"boolean",
"wait",
")",
"throws",
"MessagingException",
"{",
"Thread",
"connector",
"=",
"new",
"JMSBrokerConnector",
"(",
")",
";",
"connector",
".",
"start",
"(",
")",
";",
"if",
"(",
"wait",
")",
"{",
"int",
"maxWait",
"=",
"RETRY_INTERVAL",
"*",
"MAX_RETRIES",
";",
"int",
"waitTime",
"=",
"0",
";",
"while",
"(",
"!",
"isConnected",
"(",
")",
")",
"{",
"if",
"(",
"waitTime",
"<",
"maxWait",
")",
"{",
"try",
"{",
"Thread",
".",
"sleep",
"(",
"100",
")",
";",
"waitTime",
"+=",
"100",
";",
"}",
"catch",
"(",
"InterruptedException",
"ie",
")",
"{",
"Thread",
".",
"currentThread",
"(",
")",
".",
"interrupt",
"(",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"MessagingException",
"(",
"\"Timeout reached waiting \"",
"+",
"\"for messaging client to start.\"",
")",
";",
"}",
"}",
"}",
"}"
] |
Starts the MessagingClient. This method must be called
in order to receive messages.
@param wait Set to true to wait until the startup process
is complete before returning. Set to false to
allow for asynchronous startup.
|
[
"Starts",
"the",
"MessagingClient",
".",
"This",
"method",
"must",
"be",
"called",
"in",
"order",
"to",
"receive",
"messages",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-client/fcrepo-client-messaging/src/main/java/org/fcrepo/client/messaging/JmsMessagingClient.java#L228-L249
|
8,995 |
fcrepo3/fcrepo
|
fcrepo-client/fcrepo-client-messaging/src/main/java/org/fcrepo/client/messaging/JmsMessagingClient.java
|
JmsMessagingClient.createDestinations
|
private void createDestinations() throws MessagingException {
try {
// Create Destinations based on properties
Enumeration<?> propertyNames = m_connectionProperties.keys();
while (propertyNames.hasMoreElements()) {
String propertyName = (String) propertyNames.nextElement();
if (propertyName.startsWith("topic.")) {
String destinationName =
m_connectionProperties.getProperty(propertyName);
m_jmsManager.createDestination(destinationName,
DestinationType.Topic);
} else if (propertyName.startsWith("queue.")) {
String destinationName =
m_connectionProperties.getProperty(propertyName);
m_jmsManager.createDestination(destinationName,
DestinationType.Queue);
}
}
// Get destination list
List<Destination> destinations = m_jmsManager.getDestinations();
// If there are no Destinations, throw an exception
if (destinations.size() == 0) {
throw new MessagingException("No destinations available for "
+ "subscription, make sure that there is at least one topic "
+ "or queue specified in the connection properties.");
}
// Subscribe
for (Destination destination : destinations) {
if (m_durable && (destination instanceof Topic)) {
m_jmsManager.listenDurable((Topic) destination,
m_messageSelector,
this,
null);
} else {
m_jmsManager.listen(destination, m_messageSelector, this);
}
}
} catch (MessagingException me) {
logger.error("MessagingException encountered attempting to start "
+ "Messaging Client: " + m_clientId
+ ". Exception message: " + me.getMessage(), me);
throw me;
}
}
|
java
|
private void createDestinations() throws MessagingException {
try {
// Create Destinations based on properties
Enumeration<?> propertyNames = m_connectionProperties.keys();
while (propertyNames.hasMoreElements()) {
String propertyName = (String) propertyNames.nextElement();
if (propertyName.startsWith("topic.")) {
String destinationName =
m_connectionProperties.getProperty(propertyName);
m_jmsManager.createDestination(destinationName,
DestinationType.Topic);
} else if (propertyName.startsWith("queue.")) {
String destinationName =
m_connectionProperties.getProperty(propertyName);
m_jmsManager.createDestination(destinationName,
DestinationType.Queue);
}
}
// Get destination list
List<Destination> destinations = m_jmsManager.getDestinations();
// If there are no Destinations, throw an exception
if (destinations.size() == 0) {
throw new MessagingException("No destinations available for "
+ "subscription, make sure that there is at least one topic "
+ "or queue specified in the connection properties.");
}
// Subscribe
for (Destination destination : destinations) {
if (m_durable && (destination instanceof Topic)) {
m_jmsManager.listenDurable((Topic) destination,
m_messageSelector,
this,
null);
} else {
m_jmsManager.listen(destination, m_messageSelector, this);
}
}
} catch (MessagingException me) {
logger.error("MessagingException encountered attempting to start "
+ "Messaging Client: " + m_clientId
+ ". Exception message: " + me.getMessage(), me);
throw me;
}
}
|
[
"private",
"void",
"createDestinations",
"(",
")",
"throws",
"MessagingException",
"{",
"try",
"{",
"// Create Destinations based on properties",
"Enumeration",
"<",
"?",
">",
"propertyNames",
"=",
"m_connectionProperties",
".",
"keys",
"(",
")",
";",
"while",
"(",
"propertyNames",
".",
"hasMoreElements",
"(",
")",
")",
"{",
"String",
"propertyName",
"=",
"(",
"String",
")",
"propertyNames",
".",
"nextElement",
"(",
")",
";",
"if",
"(",
"propertyName",
".",
"startsWith",
"(",
"\"topic.\"",
")",
")",
"{",
"String",
"destinationName",
"=",
"m_connectionProperties",
".",
"getProperty",
"(",
"propertyName",
")",
";",
"m_jmsManager",
".",
"createDestination",
"(",
"destinationName",
",",
"DestinationType",
".",
"Topic",
")",
";",
"}",
"else",
"if",
"(",
"propertyName",
".",
"startsWith",
"(",
"\"queue.\"",
")",
")",
"{",
"String",
"destinationName",
"=",
"m_connectionProperties",
".",
"getProperty",
"(",
"propertyName",
")",
";",
"m_jmsManager",
".",
"createDestination",
"(",
"destinationName",
",",
"DestinationType",
".",
"Queue",
")",
";",
"}",
"}",
"// Get destination list",
"List",
"<",
"Destination",
">",
"destinations",
"=",
"m_jmsManager",
".",
"getDestinations",
"(",
")",
";",
"// If there are no Destinations, throw an exception",
"if",
"(",
"destinations",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"throw",
"new",
"MessagingException",
"(",
"\"No destinations available for \"",
"+",
"\"subscription, make sure that there is at least one topic \"",
"+",
"\"or queue specified in the connection properties.\"",
")",
";",
"}",
"// Subscribe",
"for",
"(",
"Destination",
"destination",
":",
"destinations",
")",
"{",
"if",
"(",
"m_durable",
"&&",
"(",
"destination",
"instanceof",
"Topic",
")",
")",
"{",
"m_jmsManager",
".",
"listenDurable",
"(",
"(",
"Topic",
")",
"destination",
",",
"m_messageSelector",
",",
"this",
",",
"null",
")",
";",
"}",
"else",
"{",
"m_jmsManager",
".",
"listen",
"(",
"destination",
",",
"m_messageSelector",
",",
"this",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"MessagingException",
"me",
")",
"{",
"logger",
".",
"error",
"(",
"\"MessagingException encountered attempting to start \"",
"+",
"\"Messaging Client: \"",
"+",
"m_clientId",
"+",
"\". Exception message: \"",
"+",
"me",
".",
"getMessage",
"(",
")",
",",
"me",
")",
";",
"throw",
"me",
";",
"}",
"}"
] |
Creates topics and queues and starts listeners
|
[
"Creates",
"topics",
"and",
"queues",
"and",
"starts",
"listeners"
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-client/fcrepo-client-messaging/src/main/java/org/fcrepo/client/messaging/JmsMessagingClient.java#L258-L304
|
8,996 |
fcrepo3/fcrepo
|
fcrepo-client/fcrepo-client-messaging/src/main/java/org/fcrepo/client/messaging/JmsMessagingClient.java
|
JmsMessagingClient.stop
|
public void stop(boolean unsubscribe) throws MessagingException {
try {
if (unsubscribe) {
m_jmsManager.unsubscribeAllDurable();
}
m_jmsManager.close();
m_jmsManager = null;
m_connected = false;
} catch (MessagingException me) {
logger.error("Messaging Exception encountered attempting to stop "
+ "Messaging Client: " + m_clientId
+ ". Exception message: " + me.getMessage(), me);
throw me;
}
}
|
java
|
public void stop(boolean unsubscribe) throws MessagingException {
try {
if (unsubscribe) {
m_jmsManager.unsubscribeAllDurable();
}
m_jmsManager.close();
m_jmsManager = null;
m_connected = false;
} catch (MessagingException me) {
logger.error("Messaging Exception encountered attempting to stop "
+ "Messaging Client: " + m_clientId
+ ". Exception message: " + me.getMessage(), me);
throw me;
}
}
|
[
"public",
"void",
"stop",
"(",
"boolean",
"unsubscribe",
")",
"throws",
"MessagingException",
"{",
"try",
"{",
"if",
"(",
"unsubscribe",
")",
"{",
"m_jmsManager",
".",
"unsubscribeAllDurable",
"(",
")",
";",
"}",
"m_jmsManager",
".",
"close",
"(",
")",
";",
"m_jmsManager",
"=",
"null",
";",
"m_connected",
"=",
"false",
";",
"}",
"catch",
"(",
"MessagingException",
"me",
")",
"{",
"logger",
".",
"error",
"(",
"\"Messaging Exception encountered attempting to stop \"",
"+",
"\"Messaging Client: \"",
"+",
"m_clientId",
"+",
"\". Exception message: \"",
"+",
"me",
".",
"getMessage",
"(",
")",
",",
"me",
")",
";",
"throw",
"me",
";",
"}",
"}"
] |
Stops the MessagingClient, shuts down connections. If the unsubscribe
parameter is set to true, all durable subscriptions will be removed.
@param unsubscribe
|
[
"Stops",
"the",
"MessagingClient",
"shuts",
"down",
"connections",
".",
"If",
"the",
"unsubscribe",
"parameter",
"is",
"set",
"to",
"true",
"all",
"durable",
"subscriptions",
"will",
"be",
"removed",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-client/fcrepo-client-messaging/src/main/java/org/fcrepo/client/messaging/JmsMessagingClient.java#L312-L326
|
8,997 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/management/DBPIDGenerator.java
|
DBPIDGenerator.upgradeIfNeeded
|
private void upgradeIfNeeded(File oldPidGenDir) throws IOException {
if (oldPidGenDir != null && oldPidGenDir.isDirectory()) {
String[] names = oldPidGenDir.list();
Arrays.sort(names);
if (names.length > 0) {
BufferedReader in =
new BufferedReader(new InputStreamReader(new FileInputStream(new File(oldPidGenDir,
names[names.length - 1]))));
String lastLine = null;
String line;
while ((line = in.readLine()) != null) {
lastLine = line;
}
in.close();
if (lastLine != null) {
String[] parts = lastLine.split("|");
if (parts.length == 2) {
neverGeneratePID(parts[0]);
}
}
}
}
}
|
java
|
private void upgradeIfNeeded(File oldPidGenDir) throws IOException {
if (oldPidGenDir != null && oldPidGenDir.isDirectory()) {
String[] names = oldPidGenDir.list();
Arrays.sort(names);
if (names.length > 0) {
BufferedReader in =
new BufferedReader(new InputStreamReader(new FileInputStream(new File(oldPidGenDir,
names[names.length - 1]))));
String lastLine = null;
String line;
while ((line = in.readLine()) != null) {
lastLine = line;
}
in.close();
if (lastLine != null) {
String[] parts = lastLine.split("|");
if (parts.length == 2) {
neverGeneratePID(parts[0]);
}
}
}
}
}
|
[
"private",
"void",
"upgradeIfNeeded",
"(",
"File",
"oldPidGenDir",
")",
"throws",
"IOException",
"{",
"if",
"(",
"oldPidGenDir",
"!=",
"null",
"&&",
"oldPidGenDir",
".",
"isDirectory",
"(",
")",
")",
"{",
"String",
"[",
"]",
"names",
"=",
"oldPidGenDir",
".",
"list",
"(",
")",
";",
"Arrays",
".",
"sort",
"(",
"names",
")",
";",
"if",
"(",
"names",
".",
"length",
">",
"0",
")",
"{",
"BufferedReader",
"in",
"=",
"new",
"BufferedReader",
"(",
"new",
"InputStreamReader",
"(",
"new",
"FileInputStream",
"(",
"new",
"File",
"(",
"oldPidGenDir",
",",
"names",
"[",
"names",
".",
"length",
"-",
"1",
"]",
")",
")",
")",
")",
";",
"String",
"lastLine",
"=",
"null",
";",
"String",
"line",
";",
"while",
"(",
"(",
"line",
"=",
"in",
".",
"readLine",
"(",
")",
")",
"!=",
"null",
")",
"{",
"lastLine",
"=",
"line",
";",
"}",
"in",
".",
"close",
"(",
")",
";",
"if",
"(",
"lastLine",
"!=",
"null",
")",
"{",
"String",
"[",
"]",
"parts",
"=",
"lastLine",
".",
"split",
"(",
"\"|\"",
")",
";",
"if",
"(",
"parts",
".",
"length",
"==",
"2",
")",
"{",
"neverGeneratePID",
"(",
"parts",
"[",
"0",
"]",
")",
";",
"}",
"}",
"}",
"}",
"}"
] |
Read the highest value from the old pidGen directory if it exists, and
ensure it is never used.
|
[
"Read",
"the",
"highest",
"value",
"from",
"the",
"old",
"pidGen",
"directory",
"if",
"it",
"exists",
"and",
"ensure",
"it",
"is",
"never",
"used",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/management/DBPIDGenerator.java#L124-L146
|
8,998 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/management/DBPIDGenerator.java
|
DBPIDGenerator.generatePID
|
public synchronized PID generatePID(String namespace) throws IOException {
int i = getHighestID(namespace);
i++;
try {
m_lastPID = new PID(namespace + ":" + i);
} catch (MalformedPIDException e) {
throw new IOException(e.getMessage());
}
setHighestID(namespace, i);
return m_lastPID;
}
|
java
|
public synchronized PID generatePID(String namespace) throws IOException {
int i = getHighestID(namespace);
i++;
try {
m_lastPID = new PID(namespace + ":" + i);
} catch (MalformedPIDException e) {
throw new IOException(e.getMessage());
}
setHighestID(namespace, i);
return m_lastPID;
}
|
[
"public",
"synchronized",
"PID",
"generatePID",
"(",
"String",
"namespace",
")",
"throws",
"IOException",
"{",
"int",
"i",
"=",
"getHighestID",
"(",
"namespace",
")",
";",
"i",
"++",
";",
"try",
"{",
"m_lastPID",
"=",
"new",
"PID",
"(",
"namespace",
"+",
"\":\"",
"+",
"i",
")",
";",
"}",
"catch",
"(",
"MalformedPIDException",
"e",
")",
"{",
"throw",
"new",
"IOException",
"(",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"setHighestID",
"(",
"namespace",
",",
"i",
")",
";",
"return",
"m_lastPID",
";",
"}"
] |
Generate a new pid that is guaranteed to be unique, within the given
namespace.
|
[
"Generate",
"a",
"new",
"pid",
"that",
"is",
"guaranteed",
"to",
"be",
"unique",
"within",
"the",
"given",
"namespace",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/management/DBPIDGenerator.java#L152-L165
|
8,999 |
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/management/DBPIDGenerator.java
|
DBPIDGenerator.neverGeneratePID
|
public synchronized void neverGeneratePID(String pid) throws IOException {
logger.debug("Never generating PID: {}", pid);
try {
PID p = new PID(pid);
String ns = p.getNamespaceId();
int id = Integer.parseInt(p.getObjectId());
if (id > getHighestID(ns)) {
setHighestID(ns, id);
}
} catch (MalformedPIDException mpe) {
throw new IOException(mpe.getMessage());
} catch (NumberFormatException nfe) {
// if the id part is not numeric, we already know we'll
// never generate that id because all generated ids are numeric.
}
}
|
java
|
public synchronized void neverGeneratePID(String pid) throws IOException {
logger.debug("Never generating PID: {}", pid);
try {
PID p = new PID(pid);
String ns = p.getNamespaceId();
int id = Integer.parseInt(p.getObjectId());
if (id > getHighestID(ns)) {
setHighestID(ns, id);
}
} catch (MalformedPIDException mpe) {
throw new IOException(mpe.getMessage());
} catch (NumberFormatException nfe) {
// if the id part is not numeric, we already know we'll
// never generate that id because all generated ids are numeric.
}
}
|
[
"public",
"synchronized",
"void",
"neverGeneratePID",
"(",
"String",
"pid",
")",
"throws",
"IOException",
"{",
"logger",
".",
"debug",
"(",
"\"Never generating PID: {}\"",
",",
"pid",
")",
";",
"try",
"{",
"PID",
"p",
"=",
"new",
"PID",
"(",
"pid",
")",
";",
"String",
"ns",
"=",
"p",
".",
"getNamespaceId",
"(",
")",
";",
"int",
"id",
"=",
"Integer",
".",
"parseInt",
"(",
"p",
".",
"getObjectId",
"(",
")",
")",
";",
"if",
"(",
"id",
">",
"getHighestID",
"(",
"ns",
")",
")",
"{",
"setHighestID",
"(",
"ns",
",",
"id",
")",
";",
"}",
"}",
"catch",
"(",
"MalformedPIDException",
"mpe",
")",
"{",
"throw",
"new",
"IOException",
"(",
"mpe",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"nfe",
")",
"{",
"// if the id part is not numeric, we already know we'll",
"// never generate that id because all generated ids are numeric.",
"}",
"}"
] |
Cause the given PID to never be generated by the PID generator.
|
[
"Cause",
"the",
"given",
"PID",
"to",
"never",
"be",
"generated",
"by",
"the",
"PID",
"generator",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/management/DBPIDGenerator.java#L177-L192
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.