Package org.fcrepo.server.errors

Examples of org.fcrepo.server.errors.DisseminationException


          .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.
View Full Code Here


        dsRegistry.put(tempID, dm);
        logger.debug("DatastreammediationKey added to Hash: " + tempID);
      }

    } catch (Throwable th) {
      throw new DisseminationException("[DisseminationService] register"
          + "DatastreamLocation: "
          + "returned an error. The underlying error was a "
          + th.getClass().getName() + " The message " + "was \""
          + th.getMessage() + "\" .");
    }
View Full Code Here

  private String resolveInternalDSLocation(Context context,
      String internalDSLocation, Date dsCreateDT, String callbackHost)
      throws ServerException {

    if (callbackHost == null || callbackHost.equals("")) {
      throw new DisseminationException(
          "[DisseminationService] was unable to "
              + "resolve the base URL of the Fedora Server. The URL specified was: \""
              + callbackHost
              + "\". This information is required by the Dissemination Service.");
    }
View Full Code Here

            transformer.transform(new StreamSource(in), new StreamResult(out));
            byte [] bytes = out.toByteArray();
            in = new ByteArrayInputStream(bytes);
            return new MIMETypedStream("text/html", in, null, bytes.length);
        } catch (TransformerException e) {
            throw new DisseminationException("[DefaultDisseminatorImpl] had an error "
                    + "in transforming xml for viewObjectProfile. "
                    + "Underlying exception was: " + e.getMessage());
        }
    }
View Full Code Here

            transformer.transform(new StreamSource(in), new StreamResult(out));
            byte [] bytes = out.toByteArray();
            in = new ByteArrayInputStream(bytes);
            return new MIMETypedStream("text/html", in, null, bytes.length);
        } catch (TransformerException e) {
            throw new DisseminationException("[DefaultDisseminatorImpl] had an error "
                    + "in transforming xml for viewItemIndex. "
                    + "Underlying exception was: " + e.getMessage());
        }
    }
View Full Code Here

            byte [] bytes = out.toByteArray();
            in = new ByteArrayInputStream(bytes);
            return new MIMETypedStream("text/html", in, null, bytes.length);
        } catch (TransformerException e) {
            throw new DisseminationException("[DefaultDisseminatorImpl] had an error "
                    + "in transforming xml for viewItemIndex. "
                    + "Underlying exception was: " + e.getMessage());
        }
    }
View Full Code Here

            transformer.transform(new StreamSource(in), new StreamResult(out));
            byte[] bytes = out.toByteArray();
            in = new ByteArrayInputStream(bytes);
            return new MIMETypedStream("text/html", in, null,bytes.length);
        } catch (TransformerException e) {
            throw new DisseminationException("[DefaultDisseminatorImpl] had an error "
                    + "in transforming xml for viewDublinCore. "
                    + "Underlying exception was: " + e.getMessage());
        }
    }
View Full Code Here

                    m_manager.lookupDeploymentForCModel(cModelPID, sDefPID);

            if (foundDeploymentPID != null) {
                if (serviceDeploymentPID != null
                    && !foundDeploymentPID.equals(serviceDeploymentPID)) {
                    throw new DisseminationException("More than one deployment ("
                                                     + foundDeploymentPID
                                                     + ", "
                                                     + serviceDeploymentPID
                                                     + ") found for service "
                                                     + sDefPID
View Full Code Here

            } else {
                try {
                    cmReader =
                            m_repoReader.getReader(false, m_context, cModelPid);
                } catch (StorageException e) {
                    throw new DisseminationException(null,
                                                     "Content Model Object "
                                                     + cModelPid
                                                     + " does not exist.",
                                                     null,
                                                     null,
                                                     e);
                }
            }
            Set<RelationshipTuple> hasServiceRels =
                    cmReader
                            .getRelationships(MODEL.HAS_SERVICE, null);
            for (RelationshipTuple element2 : hasServiceRels) {
                String sDefPid = element2.getObjectPID();

                try {
                    sDefReader =
                            m_repoReader.getServiceDefinitionReader(false,
                                                                    m_context,
                                                                    sDefPid);
                } catch (StorageException se) {
                    throw new DisseminationException("Service definition "
                                                     + sDefPid + " required by Content Model "
                                                     + cModelPid + " not found.");
                }
                MethodDef[] methods =
                        listMethods(sDefPid, sDefReader, versDateTime);
View Full Code Here

TOP

Related Classes of org.fcrepo.server.errors.DisseminationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.