+ uee.getClass().getName()
+ "\" . The Reason was \""
+ uee.getMessage()
+ "\" . String value: " + replaceString + " . ";
logger.error(message);
throw new GeneralException(message);
}
logger.debug("Replaced dissURL: " + dissURL.toString()
+ " DissBindingInfo index: " + i);
}
DeploymentDSBindSpec dsBindSpec = bmReader
.getServiceDSInputSpec(null);
DeploymentDSBindRule rules[] = dsBindSpec.dsBindRules;
for (DeploymentDSBindRule element : rules) {
String rulePattern = "(" + element.bindingKeyName + ")";
if (dissURL.indexOf(rulePattern) != -1) {
throw new DisseminationException(null, "Data Object " + PID
+ " missing required datastream: "
+ element.bindingKeyName, null, null, null);
}
}
// Substitute method parameter values in dissemination URL
Enumeration<String> e = h_userParms.keys();
while (e.hasMoreElements()) {
String name = null;
String value = null;
try {
name = URLEncoder.encode(e.nextElement(), "UTF-8");
value = URLEncoder.encode(h_userParms.get(name), "UTF-8");
} catch (UnsupportedEncodingException uee) {
String message = "[DisseminationService] An error occured. The error "
+ "was \""
+ uee.getClass().getName()
+ "\" . The Reason was \""
+ uee.getMessage()
+ "\" . Parameter name: "
+ name
+ " . "
+ "Parameter value: " + value + " .";
logger.error(message);
throw new GeneralException(message);
}
String pattern = "\\(" + name + "\\)";
dissURL = substituteString(dissURL, pattern, value);
logger.debug("User parm substituted in URL: " + dissURL);
}
// FIXME Need a more elegant means of handling optional
// userInputParm
// method parameters that are not supplied by the invoking client;
// for now, any optional parms that were not supplied are removed
// from
// the outgoing URL. This works because parms are validated in
// DefaultAccess to insure all required parms are present and all
// parm
// names match parm names defined for the specific method. The only
// unsubstituted parms left in the operationLocation string at this
// point
// are those for optional parameters that the client omitted in the
// initial request so they can safely be removed from the outgoing
// dissemination URL. This step is only needed when optional
// parameters
// are not supplied by the client.
if (dissURL.indexOf("(") != -1) {
dissURL = stripParms(dissURL);
logger.debug("Non-supplied optional userInputParm values removed "
+ "from URL: " + dissURL);
}
if (dissURL.indexOf("(") != -1) {
String datastreamName = dissURL.substring(
dissURL.indexOf("(") + 1, dissURL.indexOf(")"));
throw new DisseminationException(null, "Data Object " + PID
+ " missing required datastream: " + datastreamName,
null, null, null);
}
// Resolve content referenced by dissemination result.
logger.debug("ProtocolType: " + protocolType);
if (protocolType.equalsIgnoreCase("http")) {
if (isRedirect) {
// The dsControlGroupType of Redirect("R") is a special
// control type
// used primarily for streaming media. Datastreams of this
// type are
// not mediated (proxied by Fedora) and their physical
// dsLocation is
// simply redirected back to the client. Therefore, the
// contents
// of the MIMETypedStream returned for dissemination
// requests will
// contain the raw URL of the dsLocation and will be
// assigned a
// special fedora-specific MIME type to identify the stream
// as
// a MIMETypedStream whose contents contain a URL to which
// the client
// should be redirected.
InputStream is = null;
try {
is = new ByteArrayInputStream(dissURL.getBytes("UTF-8"));
} catch (UnsupportedEncodingException uee) {
String message = "[DisseminationService] An error has occurred. "
+ "The error was a \""
+ uee.getClass().getName()
+ "\" . The "
+ "Reason was \""
+ uee.getMessage()
+ "\" . String value: " + dissURL + " . ";
logger.error(message);
throw new GeneralException(message);
}
logger.debug("Finished assembling dissemination");
dissemination = new MIMETypedStream(
"application/fedora-redirect", is, null);
} else {