Package org.fcrepo.server.storage.types

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


            ContentManagerParams params = new ContentManagerParams(drc.DSLocation,
                                                                   drc.DSMIME, null, null);
            params.setContext(context);
            mimeTypedStream = m_externalContentManager.getExternalContent(params);
        } else if (ds.DSControlGrp.equalsIgnoreCase("M")) {
            DatastreamManagedContent dmc =
                    (DatastreamManagedContent) reader
                            .GetDatastream(dsID, asOfDateTime);

            mimeTypedStream = new MIMETypedStream(ds.DSMIME, dmc.getContentStream(context), null,ds.DSSize);
        } else if (ds.DSControlGrp.equalsIgnoreCase("X")) {
            DatastreamXMLMetadata dxm =
                    (DatastreamXMLMetadata) reader.GetDatastream(dsID,
                                                                 asOfDateTime);
            mimeTypedStream = new MIMETypedStream(ds.DSMIME, dxm.getContentStream(context), null, ds.DSSize);
View Full Code Here


        return ds;
    }

    private Datastream addManagedDatastreamVersion(Entry entry)
            throws StreamIOException, ObjectIntegrityException {
        Datastream ds = new DatastreamManagedContent();
        setDSCommonProperties(ds, entry);
        ds.DSLocationType = Datastream.DS_LOCATION_TYPE_INTERNAL;

        ds.DSMIME = getDSMimeType(entry);
View Full Code Here

                    } else {
                        m_dsLocationType = Datastream.DS_LOCATION_TYPE_INTERNAL;
                    }
                    m_dsInfoType = "DATA";
                    m_dsLocation = dsLocation;
                    instantiateDatastream(new DatastreamManagedContent());
                }
            } else if (localName.equals("FContent")) {
                // In METS_EXT, the FContent element contains base64-encoded
                // data.
                m_readingContent = true;
View Full Code Here

                            m_dsLocationType = Datastream.DS_LOCATION_TYPE_INTERNAL;
                            m_dsLocation =
                                DatastreamManagedContent.TEMP_SCHEME
                                            + m_binaryContentTempFile
                                                    .getAbsolutePath();
                            instantiateDatastream(new DatastreamManagedContent());
                        } catch (FileNotFoundException fnfe) {
                            throw new SAXException(new StreamIOException("Unable to open temporary file created for binary content"));
                        } catch (IOException fnfe) {
                            throw new SAXException(new StreamIOException("Error writing to temporary file created for binary content"));
                        }
View Full Code Here

                    }
                    else {
                        m_dsLocationType = Datastream.DS_LOCATION_TYPE_INTERNAL;
                    }
                    m_dsLocation = dsLocation;
                    instantiateDatastream(new DatastreamManagedContent());
                }
            } else if (localName.equals("binaryContent")) {
                if (m_dsControlGrp.equalsIgnoreCase("M")) {
                    m_readingBinaryContent = true;
                    m_binaryContentTempFile = null;
View Full Code Here

                    os.close();
                    m_dsLocationType = Datastream.DS_LOCATION_TYPE_INTERNAL;
                    m_dsLocation =
                        DatastreamManagedContent.TEMP_SCHEME
                                    + m_binaryContentTempFile.getAbsolutePath();
                    instantiateDatastream(new DatastreamManagedContent());
                } catch (FileNotFoundException fnfe) {
                    throw new SAXException(new StreamIOException("Unable to open temporary file created for binary content"));
                } catch (IOException fnfe) {
                    throw new SAXException(new StreamIOException("Error writing to temporary file created for binary content"));
                }
View Full Code Here

                    }
                    throw new GeneralException("Error with " + dsLocation
                                               + extraInfo);
                }
            } else if (controlGroup.equals("M")) {
                ds = new DatastreamManagedContent();
                ds.DSInfoType = "DATA";
                ds.DSLocationType = Datastream.DS_LOCATION_TYPE_URL;
            } else if (controlGroup.equals("R") || controlGroup.equals("E")) {
                ds = new DatastreamReferencedContent();
                ds.DSInfoType = "DATA";
View Full Code Here

            // instantiate the right class of datastream
            // (inline xml "X" datastreams have already been rejected)
            Datastream newds;
            if (orig.DSControlGrp.equals("M")) {
                newds = new DatastreamManagedContent();
            } else {
                newds = new DatastreamReferencedContent();
            }
            // update ds attributes that are common to all versions...
            // first, those that cannot be changed by client...
View Full Code Here

                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);
                            }
                        }
                    }

                    // add the content stream
                    MIMETypedStream content = new MIMETypedStream(null, new ByteArrayInputStream(byteContent), null, byteContent.length);
                    newDS.putContentStream(content);

                    // checksum only needs recalc if we added a header
                    // note getChecksum() caters for checksum type set to disabled
                    if (addXMLHeader) {
                        logger.debug("Recalculating checksum.  Type=" + newDS.DSChecksumType + " Existing checksum: " + newDS.DSChecksum != null ? newDS.DSChecksum : "none");

                        // forces computation rather than return existing
                        newDS.DSChecksum = Datastream.CHECKSUM_NONE;
                        newDS.DSChecksum = newDS.getChecksum();

                        logger.debug("New checksum: " + newDS.DSChecksum);
                        logger.debug("Testing new checksum, response is {}", newDS.compareChecksum());
                    }

                    w.addDatastream(newDS, true);
                }
View Full Code Here

        DigitalObject obj = createTestObject(FEDORA_OBJECT_3_0);

        final String dsID1 = "DS1";
        final String dsID2 = "DS2";
        // hugely randomly generated test data
        DatastreamManagedContent ds1 = createMDatastream(dsID1, "aölksdiudshfljdsfnalj mdscmjlfjaö nsaölkjfsölkjfsöldkjfaöslfjasödflaöl".getBytes());
        DatastreamManagedContent ds2 = createMDatastream(dsID2, "älkfddöslfjsölkfjäaoiam,yjöoicncäaskcäaäöl kf,jvdhfkjh".getBytes());


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

TOP

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

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.