Examples of Datastream


Examples of org.fcrepo.server.storage.types.Datastream

        super(context, repoReader, translator, exportFormat, encoding, obj);
    }

    protected DatastreamXMLMetadata getWSDLDatastream(Date versDateTime)
            throws DatastreamNotFoundException, ObjectIntegrityException {
        Datastream ds = GetDatastream("WSDL", versDateTime);
        if (ds == null) {
            throw new DatastreamNotFoundException("The object, "
                    + GetObjectPID() + " does not have a WSDL datastream"
                    + " existing at " + getWhenString(versDateTime));
        }
View Full Code Here

Examples of org.fcrepo.server.storage.types.Datastream

        return wsdlDS;
    }

    protected DatastreamXMLMetadata getMethodMapDatastream(Date versDateTime)
            throws DatastreamNotFoundException, ObjectIntegrityException {
        Datastream ds = GetDatastream("METHODMAP", versDateTime);
        if (ds == null) {
            throw new DatastreamNotFoundException("The object, "
                    + GetObjectPID() + " does not have a METHODMAP datastream"
                    + " existing at " + getWhenString(versDateTime));
        }
View Full Code Here

Examples of org.fcrepo.server.storage.types.Datastream

        return mmapDS;
    }

    protected DatastreamXMLMetadata getDSInputSpecDatastream(Date versDateTime)
            throws DatastreamNotFoundException, ObjectIntegrityException {
        Datastream ds = GetDatastream("DSINPUTSPEC", versDateTime);
        if (ds == null) {
            throw new DatastreamNotFoundException("The object, "
                    + GetObjectPID()
                    + " does not have a DSINPUTSPEC datastream"
                    + " existing at " + getWhenString(versDateTime));
View Full Code Here

Examples of org.fcrepo.server.storage.types.Datastream

            }
            // Given a datastream ID, get all the datastream versions.
            // Use the first version to pick up the attributes common to all versions.

            for (Datastream v : obj.datastreams(dsid)) {
                Datastream vds = DOTranslationUtility.setDatastreamDefaults(v);

                // insert the ds attributes common to all versions, when necessary
                if (!haveWrittenCommonAttributes) {
                    writer.print("<");
                    writer.print(FOXML.prefix);
                    writer.print(":datastream ID=\"");
                    writer.print(vds.DatastreamID);
                    writer.print("\"");
                    if (m_transContext == DOTranslationUtility.SERIALIZE_EXPORT_PUBLIC) {
                        writer.print(" FEDORA_URI=\"");
                        writer.print("info:fedora/");
                        writer.print(obj.getPid());
                        writer.print("/");
                        writer.print(vds.DatastreamID);
                        writer.print("\"");
                    }
                    writer.print(" STATE=\"");
                    writer.print(vds.DSState);
                    writer.print("\"");
                    writer.print(" CONTROL_GROUP=\"");
                    writer.print(vds.DSControlGrp);
                    writer.print("\"");
                    writer.print(" VERSIONABLE=\"");
                    writer.print(vds.DSVersionable);
                    writer.print("\">\n");
                    haveWrittenCommonAttributes = true;
                }

                // insert the ds version elements
                writer.print("<");
                writer.print(FOXML.prefix);
                writer.print(":datastreamVersion ID=\"");
                writer.print(vds.DSVersionID);
                writer.print("\"");
                writer.print(" LABEL=\"");
                writer.print(StreamUtility.enc(vds.DSLabel));
                writer.print("\"");
                if (vds.DSCreateDT != null) {
                    writer.print(" CREATED=\"");
                    writer.print(DateUtility.convertDateToString(vds.DSCreateDT));
                    writer.print("\"");
                }
                String altIds =
                        DOTranslationUtility.oneString(vds.DatastreamAltIDs);
                if (altIds != null && !altIds.equals("")) {
                    writer.print(" ALT_IDS=\"");
                    writer.print(StreamUtility.enc(altIds));
                    writer.print("\"");
                }
                writer.print(" MIMETYPE=\"");
                writer.print(StreamUtility.enc(vds.DSMIME));
                writer.print("\"");
                if (vds.DSFormatURI != null && !vds.DSFormatURI.equals("")) {
                    writer.print(" FORMAT_URI=\"");
                    writer.print(StreamUtility.enc(vds.DSFormatURI));
                    writer.print("\"");
                }
                // include size if it's non-zero
                if (vds.DSSize != 0) {
                    writer.print(" SIZE=\"");
                    writer.print(vds.DSSize);
                    writer.print("\"");
                }
                writer.print(">\n");

                // include checksum if it has a value
                String csType = vds.getChecksumType();
                if (csType != null && csType.length() > 0
                        && !csType.equals(Datastream.CHECKSUMTYPE_DISABLED)) {
                    writer.print("<");
                    writer.print(FOXML.prefix);
                    writer.print(":contentDigest TYPE=\"");
                    writer.print(csType);
                    writer.print("\"");
                    writer.print(" DIGEST=\"");
                    writer.print(vds.getChecksum());
                    writer.print("\"/>\n");
                }

                // if E or R insert ds content location as URL
                if (vds.DSControlGrp.equalsIgnoreCase("E")
                        || vds.DSControlGrp.equalsIgnoreCase("R")) {
                    writer.print("<");
                    writer.print(FOXML.prefix);
                    writer.print(":contentLocation TYPE=\"");
                    writer.print(Datastream.DS_LOCATION_TYPE_URL);
                    writer.print("\" REF=\"");
                    String urls = DOTranslationUtility.normalizeDSLocationURLs(
                            obj.getPid(),
                            vds,
                            m_transContext).DSLocation;
                    writer.print(StreamUtility.enc(urls));
                    writer.print("\"/>\n");
                    // if M insert ds content location as an internal identifier
                } else if (vds.DSControlGrp.equalsIgnoreCase("M")) {
                    if (m_transContext == DOTranslationUtility.SERIALIZE_EXPORT_ARCHIVE) {
                        writer.print("<");
                        writer.print(FOXML.prefix);
                        writer.print(":binaryContent> \n");
                        String encoded = Base64.encodeToString(vds.getContentStream());
                        writer.print(StringUtility.splitAndIndent(encoded,
                                                                  14,
                                                                  80));
                        writer.print("</");
                        writer.print(FOXML.prefix);
View Full Code Here

Examples of org.fcrepo.server.storage.types.Datastream

    protected AbstractPolicy loadObjectPolicy(PolicyParser policyParser, String pid, boolean validate) throws ServerException {
        try {
            DOReader reader = m_repoReader.getReader(Server.USE_DEFINITIVE_STORE,
                                                     ReadOnlyContext.EMPTY,
                                                     pid);
            Datastream ds = reader.GetDatastream("POLICY", null);
            if (ds != null) {
                logger.debug("Using POLICY for " + pid);
                return policyParser.parse(ds.getContentStream(), validate);
            } else {
                return null;
            }
        } catch (ObjectNotInLowlevelStorageException e) {
            return null;
View Full Code Here

Examples of org.fcrepo.server.storage.types.Datastream

                                         @QueryParam(RestParam.VALIDATE_CHECKSUM) @DefaultValue("false") boolean validateChecksum,
                                         @QueryParam(RestParam.FLASH) @DefaultValue("false") boolean flash) {
        try {
            Date asOfDateTime = DateUtility.parseDateOrNull(dateTime);
            Context context = getContext();
            Datastream dsProfile =
                    m_management.getDatastream(context, pid, dsID, asOfDateTime);

            if (dsProfile == null) {
                return Response
                        .status(Status.NOT_FOUND)
View Full Code Here

Examples of org.fcrepo.server.storage.types.Datastream

                altIDs = altIDList.toArray(new String[altIDList.size()]);
            }

            Context context = getContext();

            Datastream existingDS =
                    m_management.getDatastream(context, pid, dsID, null);
            if (!posted && versionable == null && existingDS != null){
                versionable = existingDS.DSVersionable;
            }
            Date requestModDate = null;
            if (lastModifiedDate != null) {
                requestModDate = lastModifiedDate.getValue();
            }

            // If a datastream is set to Deleted state, it must be set to
            // another state before any other changes can be made
            if (existingDS != null && existingDS.DSState.equals("D")
                    && dsState != null) {
                if (dsState.equals("A") || dsState.equals("I")) {
                    m_management.setDatastreamState(context,
                                                   pid,
                                                   dsID,
                                                   dsState,
                                                   logMessage);
                    existingDS.DSState = dsState;
                }
            }

            InputStream is = null;

            // Determine if datastream content is included in the request
            if (!ignoreContent) {
                RequestContent content =
                        RestUtil.getRequestContent(m_servletRequest, m_headers);

                if (content != null && content.getContentStream() != null) {
                    is = content.getContentStream();
                    // Give preference to the passed in mimeType
                    if (mimeType == null && content.getMimeType() != null) {
                        mimeType = content.getMimeType();
                    }
                }
            } else {
              LOGGER.warn("ignoring content on {}/{}", pid, dsID);
            }

            // Make sure that there is a mime type value
            if (mimeType == null && mediaType != null) {
                mimeType = mediaType.toString();
            } else if (mimeType == null && mediaType == null
                    && existingDS != null) {
                mimeType = existingDS.DSMIME;
            }

            // set default control group based on mimeType
            if (dsLocation == null
                    && TEXT_XML.isCompatible(MediaType.valueOf(mimeType))
                    && controlGroup == null) {
                controlGroup = "X";
            }

            if (existingDS == null) {
                if (posted) {
                  LOGGER.debug("new ds posted at {}/{}", pid, dsID);
                    if ((dsLocation == null || dsLocation.equals(""))
                            && ("X".equals(controlGroup) || "M"
                                    .equals(controlGroup))) {
                      if (is == null) {
                        LOGGER.warn("No content stream to copy for {}/{}",
                            pid, dsID);
                        return Response.status(Response.Status.BAD_REQUEST)
                            .build();
                      }
                        dsLocation = m_management.putTempStream(context, is);
                    }
                    dsID =
                            m_management.addDatastream(context,
                                                      pid,
                                                      dsID,
                                                      altIDs,
                                                      dsLabel,
                                                      versionable,
                                                      mimeType,
                                                      formatURI,
                                                      dsLocation,
                                                      controlGroup,
                                                      dsState,
                                                      checksumType,
                                                      checksum,
                                                      logMessage);
                } else {
                  LOGGER.warn("new ds but no posted content at {}/{}", pid, dsID);
                    return Response.status(Response.Status.NOT_FOUND).build();
                }
            } else {
                if ("X".equals(existingDS.DSControlGrp)) {
                    // Inline XML can only be modified by value. If there is no stream,
                    // but there is a dsLocation attempt to retrieve the content.
                    if (is == null && dsLocation != null
                            && !dsLocation.equals("")) {
                        try {
                            WebClientConfiguration webconfig = m_server.getWebClientConfig();
                            WebClient webClient = new WebClient(webconfig);
                            is = webClient.get(dsLocation, true);
                        } catch (IOException ioe) {
                            throw new Exception("Could not retrive content from "
                                    + dsLocation
                                    + " due to error: "
                                    + ioe.getMessage());
                        }
                    }
                    m_management.modifyDatastreamByValue(context,
                                                        pid,
                                                        dsID,
                                                        altIDs,
                                                        dsLabel,
                                                        mimeType,
                                                        formatURI,
                                                        is,
                                                        checksumType,
                                                        checksum,
                                                        logMessage,
                                                        requestModDate);
                } else {
                    // Managed content can only be modified by reference.
                    // If there is no dsLocation, but there is a content stream,
                    // store the stream in a temporary location.
                    if (dsLocation == null
                            && ("M".equals(existingDS.DSControlGrp))) {
                        if (is != null) {
                            dsLocation = m_management.putTempStream(context, is);
                        } else {
                            dsLocation = null;
                        }
                    }

                    m_management.modifyDatastreamByReference(context,
                                                            pid,
                                                            dsID,
                                                            altIDs,
                                                            dsLabel,
                                                            mimeType,
                                                            formatURI,
                                                            dsLocation,
                                                            checksumType,
                                                            checksum,
                                                            logMessage,
                                                            requestModDate);
                }

                if (dsState != null) {
                    if (dsState.equals("A") || dsState.equals("D")
                            || dsState.equals("I")) {
                        if (!dsState.equals(existingDS.DSState)) {
                            m_management.setDatastreamState(context,
                                                           pid,
                                                           dsID,
                                                           dsState,
                                                           logMessage);
                        }
                    }
                }

                if (versionable != existingDS.DSVersionable) {
                    m_management.setDatastreamVersionable(context,
                                                         pid,
                                                         dsID,
                                                         versionable,
                                                         logMessage);
                }
            }

            ResponseBuilder builder;
            if (posted) {
                builder =
                        Response.created(m_uriInfo.getRequestUri()
                                .resolve(URLEncoder.encode(dsID, DEFAULT_ENC)));
            } else { // put
                builder = Response.ok();
            }
            builder.header("Content-Type", MediaType.TEXT_XML);
            Datastream dsProfile =
                    m_management.getDatastream(context, pid, dsID, null);
            String xml =
                    getSerializer(context).datastreamProfileToXML(pid,
                                                                  dsID,
                                                                  dsProfile,
View Full Code Here

Examples of org.fcrepo.server.storage.types.Datastream

                DOReader doReader =
                        m_manager.getReader(Server.USE_DEFINITIVE_STORE,
                                            context,
                                            PID);
                Datastream d =
                        doReader.getDatastream(dsID, dsVersionID);
                logger.debug("Got datastream: " + d.DatastreamID);
                InputStream is = d.getContentStream(context);
                int bytestream = 0;
                response.setContentType(d.DSMIME);
                outStream = response.getOutputStream();
                byte[] buffer = new byte[255];
                while ((bytestream = is.read(buffer)) != -1) {
View Full Code Here

Examples of org.fcrepo.server.storage.types.Datastream

    }

    private MethodDef[] getAbstractMethods(DOReader reader)
            throws ServerException {
        ServiceMapper mapper = new ServiceMapper(reader.GetObjectPID());
        Datastream methodmap = reader.GetDatastream(METHODMAP_DS, null);
        if (methodmap != null) {
            InputStream contentStream = methodmap.getContentStream();
            try {
                return mapper.getMethodDefs(new InputSource(contentStream));
            } finally {
                try {
                    contentStream.close();
View Full Code Here

Examples of org.fcrepo.server.storage.types.Datastream

     * @return html packaged as a MIMETypedStream
     * @throws ServerException
     */
    public MIMETypedStream viewDublinCore() throws ServerException {
        // get dublin core record as xml
        Datastream dcmd = null;
        InputStream in = null;
        try {
            dcmd =
                    reader.GetDatastream("DC",
                                                                 asOfDateTime);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.