Package org.fcrepo.server.storage.types

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


        if (ds == null) {
            throw new DatastreamNotFoundException("The object, "
                    + GetObjectPID() + " does not have a WSDL datastream"
                    + " existing at " + getWhenString(versDateTime));
        }
        DatastreamXMLMetadata wsdlDS = null;
        try {
            wsdlDS = (DatastreamXMLMetadata) ds;
        } catch (Throwable th) {
            throw new ObjectIntegrityException("The object, " + GetObjectPID()
                    + " has a WSDL datastream existing at "
View Full Code Here


        if (ds == null) {
            throw new DatastreamNotFoundException("The object, "
                    + GetObjectPID() + " does not have a METHODMAP datastream"
                    + " existing at " + getWhenString(versDateTime));
        }
        DatastreamXMLMetadata mmapDS = null;
        try {
            mmapDS = (DatastreamXMLMetadata) ds;
        } catch (Throwable th) {
            throw new ObjectIntegrityException("The object, " + GetObjectPID()
                    + " has a METHODMAP datastream existing at "
View Full Code Here

            throw new DatastreamNotFoundException("The object, "
                    + GetObjectPID()
                    + " does not have a DSINPUTSPEC datastream"
                    + " existing at " + getWhenString(versDateTime));
        }
        DatastreamXMLMetadata dsInSpecDS = null;
        try {
            dsInSpecDS = (DatastreamXMLMetadata) ds;
        } catch (Throwable th) {
            throw new ObjectIntegrityException("The object, " + GetObjectPID()
                    + " has a DSINPUTSPEC datastream existing at "
View Full Code Here

            checkDatastreamLabel(dsLabel);

            w = m_manager.getWriter(Server.USE_DEFINITIVE_STORE, context, pid);
            Datastream ds;
            if (controlGroup.equals("X")) {
                ds = new DatastreamXMLMetadata();
                ds.DSInfoType = ""; // field is now deprecated
                try {
                    InputStream in;
                    MIMETypedStream mimeTypedStream = null;
                    if (dsLocation.startsWith(DatastreamManagedContent.UPLOADED_SCHEME)) {
                        in = getTempStream(dsLocation);
                    } else {
                        ContentManagerParams params = new ContentManagerParams(dsLocation);
                        params.setContext(context);
                        mimeTypedStream = m_contentManager.getExternalContent(params);
                        in = mimeTypedStream.getStream();
                    }
                    // set and validate the content
                    DatastreamXMLMetadata dsm = (DatastreamXMLMetadata) ds;
                    dsm.xmlContent = getEmbeddableXML(in);
                    dsm.DSSize = dsm.xmlContent.length;
                    ValidationUtility.validateReservedDatastream(PID.getInstance(pid),
                                                                 dsID,
                                                                 dsm);
View Full Code Here

                // (order might not strictly be necessary)
                Arrays.sort(versions);
                for (int i = versions.length - 1; i >= 0; i--) {

                    // get a managed content copy of this datastream version
                    DatastreamXMLMetadata existing = (DatastreamXMLMetadata)copyDS.get(versions[i]);
                    DatastreamManagedContent newDS = new DatastreamManagedContent();
                    existing.copy(newDS);

                    // X control group will have been copied over by above, reset it
                    newDS.DSControlGrp = controlGroup;

                    // probably not necessary, but just in case...
                    newDS.DSLocation = null;
                    newDS.DSLocationType = null;

                    // add character encoding to mime type (will always be UTF-8 as it has come from X datastream in FOXML)
                    if (setMIMETypeCharset) {
                        if (newDS.DSMIME != null && !newDS.DSMIME.equals("") & !newDS.DSMIME.contains("charset=")) {
                            newDS.DSMIME = newDS.DSMIME + "; charset=UTF-8";
                        } else {
                            newDS.DSMIME = "text/xml; charset=UTF-8";
                        }
                    }

                    byte[] byteContent;

                    // Note: use getContentStream() rather than getting bytes directly, as this is how
                    // X datastreams are disseminated (we want the M content to be identical on
                    // dissemination)
                    if (reformat) {
                        byteContent = this.getXML(existing.getContentStream(), addXMLHeader);
                    } else {
                        // add just the XML header declaring encoding, if requested
                        if (addXMLHeader) {
                            byte[] header;
                            try {
                                header = xmlHeader.getBytes("UTF-8");
                            } catch (UnsupportedEncodingException e) {
                                // should never happen
                                throw new RuntimeException(e);
                            }
                            byte[] existingContent;
                            try {
                                existingContent = IOUtils.toByteArray(existing.getContentStream());
                            } catch (IOException e) {
                                throw new GeneralException("Error reading existing content from X datastream", e);
                            }
                            byteContent = Arrays.copyOf(header, header.length + existingContent.length);
                            System.arraycopy(existing.xmlContent, 0, byteContent, header.length, existingContent.length);
                        } else {
                            try {
                                byteContent = IOUtils.toByteArray(existing.getContentStream());
                            } catch (IOException e) {
                                throw new GeneralException("Error reading existing content from X datastream", e);
                            }
                        }
                    }
View Full Code Here

    @Test
    public void testTwoInlineDatastreams() throws TransformerException, XpathException, XPathExpressionException {
        DigitalObject obj = createTestObject(FEDORA_OBJECT_3_0);

        final String dsID1 = "DS1";
        DatastreamXMLMetadata ds1 = createXDatastream(dsID1);

        final String dsID2 = "DS2";
        DatastreamXMLMetadata ds2 = createXDatastream(dsID2);

        obj.addDatastreamVersion(ds1, true);
        obj.addDatastreamVersion(ds2, true);
        Document xml = doSerializeOrFail(obj);
       
View Full Code Here

    private static void validatePolicy(PolicyParser parser, String policy)
            throws IOException, SAXException, ValidationException {
        ValidationUtility.setPolicyParser(parser);
        // need a datastream to validate
        DatastreamXMLMetadata dsxml = new DatastreamXMLMetadata();
        dsxml.xmlContent = policy.getBytes();

        ValidationUtility.validateReservedDatastream(PID.getInstance(TEST_PID),
                                                     "POLICY",
                                                     dsxml);
View Full Code Here

    }

    private static void validateRels(String dsId, String rels)
            throws ValidationException {
        // need a datastream to validate
        DatastreamXMLMetadata dsxml = new DatastreamXMLMetadata();
        dsxml.xmlContent = rels.getBytes();

        ValidationUtility.validateReservedDatastream(PID.getInstance(TEST_PID),
                                                     dsId,
                                                     dsxml);
View Full Code Here

    @Test
    public void testSerialize() throws Exception {
        DigitalObject obj = createTestObject(Models.FEDORA_OBJECT_3_0);
        obj.setLastModDate(new Date());
        DatastreamXMLMetadata ds1 = createXDatastream("DS1");
        ds1.DSCreateDT = new Date();
        obj.addDatastreamVersion(ds1, true);

        OutputStream out = new ByteArrayOutputStream();
View Full Code Here

    @Test
    public void testAtomZip() throws Exception {
        DigitalObject obj = createTestObject(FEDORA_OBJECT_3_0);
        obj.setLastModDate(new Date());
        DatastreamXMLMetadata ds1 = createXDatastream("DS1");
        ds1.DSCreateDT = new Date();
        obj.addDatastreamVersion(ds1, true);

        File f = File.createTempFile("atom", ".zip");
        OutputStream out = new FileOutputStream(f);
View Full Code Here

TOP

Related Classes of org.fcrepo.server.storage.types.DatastreamXMLMetadata

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.