.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 {
// For all non-redirected disseminations, Fedora captures
// and returns
// the MIMETypedStream resulting from the dissemination
// request.
logger.debug("Finished assembling dissemination, URL={}",
dissURL);
// See if backend service reference is to fedora server
// itself or an external location.
// We must examine URL to see if this is referencing a
// remote backend service or is
// simply a callback to the fedora server. If the reference
// is remote, then use
// the role of backend service deployment PID. If the
// referenc is to the fedora server,
// use the special role of "fedoraInternalCall-1" to denote
// that the callback will come from the
// fedora server itself.
String beServiceRole = null;
if (ServerUtility.isURLFedoraServer(dissURL)) {
beServiceRole = BackendPolicies.FEDORA_INTERNAL_CALL;
} else {
beServiceRole = deploymentPID;
}
// Get basicAuth and SSL info about the backend service and
// use this info to configure the
// "call" to the backend service.
Hashtable<String, String> beHash = m_beSS.getSecuritySpec(
beServiceRole, methodName);
boolean beServiceCallSSL = new Boolean(
beHash.get("callSSL")).booleanValue();
String beServiceCallUsername = "";
String beServiceCallPassword = "";
boolean beServiceCallBasicAuth = new Boolean(
beHash.get("callBasicAuth")).booleanValue();
if (beServiceCallBasicAuth) {
beServiceCallUsername = beHash.get("callUsername");
beServiceCallPassword = beHash.get("callPassword");
}
if (logger.isDebugEnabled()) {
logger.debug(
"******************getDisseminationContent beServiceRole: {}",
beServiceRole);
logger.debug(
"******************getDisseminationContent beServiceCallBasicAuth: {}",
beServiceCallBasicAuth);
logger.debug(
"******************getDisseminationContent beServiceCallSSL: {}",
beServiceCallSSL);
logger.debug(
"******************getDisseminationContent beServiceCallUsername: {}",
beServiceCallUsername);
logger.debug(
"******************getDisseminationContent beServiceCallPassword: {}",
beServiceCallPassword);
logger.debug(
"******************getDisseminationContent dissURL: {}",
dissURL);
}
// Dispatch backend service URL request authenticating as
// necessary based on beSecurity configuration
ContentManagerParams params = new ContentManagerParams(
dissURL, null, beServiceCallUsername,
beServiceCallPassword);
params.setBypassBackend(true);
params.setContext(context);
dissemination = m_ecm.getExternalContent(params);
}
} else if (protocolType.equalsIgnoreCase("soap")) {
// FIXME!! future handling of soap bindings.
String message = "[DisseminationService] Protocol type: "
+ protocolType + "NOT yet implemented";
logger.error(message);
throw new DisseminationException(message);
} else if (protocolType.equalsIgnoreCase("file")) {
ContentManagerParams params = new ContentManagerParams(dissURL);
params.setContext(context);
dissemination = m_ecm.getExternalContent(params);
} else {
String message = "[DisseminationService] Protocol type: "
+ protocolType + "NOT supported.";
logger.error(message);
throw new DisseminationException(message);
}
} else {
// DisseminationBindingInfo was empty so there was no information
// provided to construct a dissemination.