Package org.fcrepo.server.storage.types

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


        InputStream in = new FileInputStream(source);
        File f = File.createTempFile("test", null);
        OutputStream out = new FileOutputStream(f);

        DODeserializer deser = new FOXML1_1DODeserializer();
        DigitalObject obj = new BasicDigitalObject();
        deser.deserialize(in, obj, "UTF-8", DESERIALIZE_INSTANCE);

        // some sanity checks
        setObjectDefaults(obj);
View Full Code Here


    //---
    // Static helpers
    //---

    protected static DigitalObject createTestObject(URIReference... contentModelURIs) {
        DigitalObject obj = new BasicDigitalObject();
        obj.setPid(TEST_PID);
        DatastreamXMLMetadata ds = createXDatastream("RELS-EXT");

        StringBuilder rdf = new StringBuilder();
        rdf
                .append("<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" "
                        + "xmlns:fedora-model=\"info:fedora/fedora-system:def/model#\">\n"
                        + "<rdf:Description rdf:about=\"");
        rdf.append(PID.getInstance(TEST_PID).toURI() + "\">\n");

        for (URIReference model : contentModelURIs) {
            rdf.append("<fedora-model:hasModel rdf:resource=\""
                    + model.getURI().toString()
                    + "\"></fedora-model:hasModel>\n");
        }
        rdf.append("</rdf:Description></rdf:RDF>");
        ds.xmlContent = rdf.toString().getBytes();

        obj.addDatastreamVersion(ds, false);
        obj.setCreateDate(new Date());
        obj.setLastModDate(new Date());
        obj.setCreateDate(new Date());
        obj.setLastModDate(new Date());
        return obj;
    }
View Full Code Here

                       out,
                       "utf-8",
                       DOTranslationUtility.SERIALIZE_EXPORT_ARCHIVE);

        // deserialize the object
        DigitalObject candidate = new BasicDigitalObject();
        DODeserializer deserA = new AtomDODeserializer();
        InputStream in = new FileInputStream(f);
        deserA.deserialize(in,
                           candidate,
                           "utf-8",
                           DOTranslationUtility.DESERIALIZE_INSTANCE);

        // check the deserialization
        assertEquals(original.getLastModDate(), candidate.getLastModDate());
        DatastreamXMLMetadata candidateDS =
                (DatastreamXMLMetadata) candidate.datastreams("DS1").iterator()
                        .next();
        assertEquals(ds1.DatastreamID, candidateDS.DatastreamID);
        assertEquals(ds1.DSCreateDT, candidateDS.DSCreateDT);

        // FIXME dsSize tests omitted for now b/c of handling of closing tags
View Full Code Here

                {"atom/local-server-demos/simple-image-demo/sdep_demo_2.xml",
                 "atom/local-server-demos/formatting-objects-demo/obj_demo_26.xml"};
        for (String source : demoSources) {
            File sourceFile = new File(DEMO_DIR_PREFIX + source);
            InputStream in = new FileInputStream(sourceFile);
            DigitalObject candidate = new BasicDigitalObject();
            DODeserializer deserA = new AtomDODeserializer();
            deserA.deserialize(in,
                               candidate,
                               "utf-8",
                               DOTranslationUtility.DESERIALIZE_INSTANCE);
View Full Code Here

        Datastream.defaultChecksumType = "MD5";
        Datastream.autoChecksum = true;
        byte[] demo1001ATOMZip = get_demo1001_zip();

        InputStream in = new ByteArrayInputStream(demo1001ATOMZip);
        DigitalObject obj = new BasicDigitalObject();
        DODeserializer dser = new AtomDODeserializer(Constants.ATOM_ZIP1_1);
        dser.deserialize(in, obj, "UTF-8", DOTranslationUtility.DESERIALIZE_INSTANCE);
        assertEquals("demo:1001", obj.getPid());
        assertEquals(true, Datastream.autoChecksum);

        // RELS-EXT is not marked, so should default
        String id = "RELS-EXT";
        for (Datastream version : obj.datastreams(id)) {
            System.out.println("Test object was: " + obj.getPid());
            assertEquals(obj.getPid() + "/" + id + " did not have expected CS type",
                    Datastream.getDefaultChecksumType(),
                    version.DSChecksumType);
            assertEquals(32, version.getChecksum().length());
        }
    }
View Full Code Here

        Datastream.defaultChecksumType = "DISABLED";
        Datastream.autoChecksum = false;
        byte[] demo1001ATOMZip = get_demo1001_zip();

        InputStream in = new ByteArrayInputStream(demo1001ATOMZip);
        DigitalObject obj = new BasicDigitalObject();
        DODeserializer dser = new AtomDODeserializer(Constants.ATOM_ZIP1_1);
        dser.deserialize(in, obj, "UTF-8", DOTranslationUtility.DESERIALIZE_INSTANCE);
        assertEquals("demo:1001", obj.getPid());
        assertEquals(false, Datastream.autoChecksum);

        String id = "RELS-EXT";
        for (Datastream version : obj.datastreams(id)) {
            System.out.println("Test object was: " + obj.getPid());
            assertEquals(obj.getPid() + "/" + id + " did not have expected CS type",
                    Datastream.CHECKSUMTYPE_DISABLED,
                    version.DSChecksumType);
            assertEquals(Datastream.CHECKSUM_NONE, version.getChecksum());
        }
    }
View Full Code Here

            dcmd.DSCreateDT = objectData.getDcModifiedDate();
            dcmd.xmlContent = objectData.getDcPayload().getBytes();
        }

        // Create the object and populate it.
        BasicDigitalObject theObject = new BasicDigitalObject();
        theObject.setPid(objectData.getPid());
        theObject.setLabel(objectData.getLabel());

        theObject.setState(objectData.getState());
        theObject.setOwnerId(objectData.getOwnerId());
        theObject.setCreateDate(objectData.getCreateDate());
        theObject.setLastModDate(objectData.getLastModDate());
        if (dcmd != null) {
            theObject.addDatastreamVersion(dcmd, false);
        }

        // Create the test instance.
        FieldSearchSQLImpl fssi = new FieldSearchSQLImpl(this.connectionPool,
                this.mockRepositoryReader, 50, 50, longFields);
View Full Code Here

        OutputStream out = new FileOutputStream(temp);
        m_serializer.serialize(original, out, "utf-8", DOTranslationUtility.SERIALIZE_EXPORT_PUBLIC);
        out.close();

        // deserialize
        DigitalObject candidate = new BasicDigitalObject();
        InputStream in = new FileInputStream(temp);
        m_deserializer.deserialize(in, candidate, "utf-8", DOTranslationUtility.DESERIALIZE_INSTANCE);
        List<AuditRecord> a1 = original.getAuditRecords();
        List<AuditRecord> a2 = candidate.getAuditRecords();
        assertEquals(a1.size(), a2.size());
        for (int i = 0; i < a1.size(); i++) {
            assertEquals(a1.get(i).action, a2.get(i).action);
            assertEquals(a1.get(i).componentID, a2.get(i).componentID);
            assertEquals(a1.get(i).date, a2.get(i).date);
View Full Code Here

     * @throws StreamIOException
     */
    private DigitalObject translatedCopy(DigitalObject original)
            throws UnsupportedEncodingException, ObjectIntegrityException,
            StreamIOException {
        DigitalObject copy = new BasicDigitalObject();
        ByteArrayOutputStream out = new ByteArrayOutputStream();

        m_serializer.serialize(original,
                               out,
                               "UTF-8",
View Full Code Here

        return doDeserialize(getStream(obj));
    }

    protected DigitalObject doDeserialize(InputStream in)
            throws ObjectIntegrityException, StreamIOException {
        BasicDigitalObject obj = new BasicDigitalObject();

        try {
            m_deserializer.deserialize(in, obj, "UTF-8", DESERIALIZE_INSTANCE);
        } catch (UnsupportedEncodingException wontHappen) {
            fail("Deserializer doesn't support UTF-8?!");
View Full Code Here

TOP

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

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.