Package org.fcrepo.server.storage

Examples of org.fcrepo.server.storage.DOReader


     */
    private ObjectFields getObjectFields(String pid)
            throws UnrecognizedFieldException, ObjectIntegrityException,
            RepositoryConfigurationException, StreamIOException,
            ServerException {
        DOReader r =
                m_repoReader.getReader(Server.USE_DEFINITIVE_STORE,
                                       ReadOnlyContext.EMPTY,
                                       pid);
        ObjectFields f;
        // If there's a DC record available, use SAX to parse the most
        // recent version of it into f.
        Datastream dcmd = null;
        try {
            dcmd = r.GetDatastream("DC", null);
        } catch (ClassCastException cce) {
            throw new ObjectIntegrityException("Object " + r.GetObjectPID()
                    + " has a DC datastream, but it's not inline XML.");
        }
        if (dcmd != null) {
            f = new ObjectFields(m_resultFields, dcmd.getContentStream());
            // add dcmDate if wanted
            for (String element : m_resultFields) {
                if (element.equals("dcmDate")) {
                    f.setDCMDate(dcmd.DSCreateDT);
                }
            }
        } else {
            f = new ObjectFields();
        }
        // add non-dc values from doReader for the others in m_resultFields[]
        //        Disseminator[] disses=null;
        for (String n : m_resultFields) {
            if (n.equals("pid")) {
                f.setPid(pid);
            }
            if (n.equals("label")) {
                f.setLabel(r.GetObjectLabel());
            }
            if (n.equals("state")) {
                f.setState(r.GetObjectState());
            }
            if (n.equals("ownerId")) {
                f.setOwnerId(r.getOwnerId());
            }
            if (n.equals("cDate")) {
                f.setCDate(r.getCreateDate());
            }
            if (n.equals("mDate")) {
                f.setMDate(r.getLastModDate());
            }
        }
        return f;
    }
View Full Code Here


    // if the object exists and has a POLICY datastream, parse and return it
    // the passed parser must be safe to use in this thread
    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;
View Full Code Here

                dsID = s[1];
                dsVersionID = s[2];
                logger.debug("PID=" + PID + ", dsID=" + dsID + ", dsVersionID="
                        + dsVersionID);

                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();
View Full Code Here

        try {
            logger.debug("Entered getObjectXML");

            m_authz.enforceGetObjectXML(context, pid, encoding);

            DOReader reader =
                    m_manager.getReader(Server.USE_DEFINITIVE_STORE,
                                        context,
                                        pid);
            InputStream instream = reader.GetObjectXML();
            return instream;
        } finally {
            // Logger completion
            if (logger.isInfoEnabled()) {
                StringBuilder logMsg =
View Full Code Here

                                  pid,
                                  format,
                                  exportContext,
                                  encoding);

            DOReader reader =
                    m_manager.getReader(Server.USE_DEFINITIVE_STORE,
                                        context,
                                        pid);
            InputStream instream = reader.Export(format, exportContext);

            return instream;
        } finally {
            // Logger completion
            if (logger.isInfoEnabled()) {
View Full Code Here

            m_authz.enforceGetDatastream(context,
                                         pid,
                                         datastreamID,
                                         asOfDateTime);

            DOReader r =
                    m_manager.getReader(Server.GLOBAL_CHOICE, context, pid);

            return r.GetDatastream(datastreamID, asOfDateTime);
        } finally {
            // Logger completion
            if (logger.isInfoEnabled()) {
                StringBuilder logMsg =
                        new StringBuilder("Completed getDatastream(");
View Full Code Here

            m_authz.enforceGetDatastreams(context,
                                          pid,
                                          asOfDateTime,
                                          state);

            DOReader r =
                    m_manager.getReader(Server.GLOBAL_CHOICE, context, pid);

            return r.GetDatastreams(asOfDateTime, state);
        } finally {
            // Logger completion
            if (logger.isInfoEnabled()) {
                StringBuilder logMsg =
                        new StringBuilder("Completed getDatastreams(");
View Full Code Here

            m_authz.enforceGetDatastreamHistory(context,
                                                pid,
                                                datastreamID);

            DOReader r =
                    m_manager.getReader(Server.GLOBAL_CHOICE, context, pid);
            Date[] versionDates = r.getDatastreamVersions(datastreamID);
            Datastream[] versions = new Datastream[versionDates.length];
            for (int i = 0; i < versionDates.length; i++) {
                versions[i] = r.GetDatastream(datastreamID, versionDates[i]);
            }
            // sort, ascending
            Arrays.sort(versions, new DatastreamDateComparator());
            // reverse it (make it descend, so most recent date is element 0)
            Datastream[] out = new Datastream[versions.length];
View Full Code Here

    public String compareDatastreamChecksum(Context context,
                                            String pid,
                                            String datastreamID,
                                            Date versionDate)
            throws ServerException {
        DOReader r = null;
        try {
            logger.debug("Entered compareDatastreamChecksum");

            m_authz.enforceCompareDatastreamChecksum(context,
                                                     pid,
                                                     datastreamID,
                                                     versionDate);

            logger.debug("Getting Reader");
            r = m_manager.getReader(Server.USE_DEFINITIVE_STORE, context, pid);
            logger.debug("Getting datastream:" + datastreamID + "date: "
                         + versionDate);
            Datastream ds = r.GetDatastream(datastreamID, versionDate);
            logger.debug("Got Datastream, comparing checksum");
            boolean check = ds.compareChecksum();
            logger.debug("compared checksum = " + check);

            return check ? ds.getChecksum() : "Checksum validation error";
View Full Code Here

    @Override
    public RelationshipTuple[] getRelationships(Context context,
                                                String subject,
                                                String relationship)
            throws ServerException {
        DOReader r = null;
        String pid = null;
        try {
            logger.debug("Entered getRelationships");

            pid = SubjectProcessor.getSubjectPID(subject);

            m_authz.enforceGetRelationships(context,
                                            pid,
                                            relationship);

            r = m_manager.getReader(Server.USE_DEFINITIVE_STORE, context, pid);
            logger.debug("Getting Relationships:  pid = " + pid + " predicate = "
                         + relationship);
            try {
                URIReference pred = null;
                if (relationship != null) {
                    pred = new SimpleURIReference(new URI(relationship));
                }
                URIReference subj = null;
                if (subject != null) {
                    subj = new SimpleURIReference(new URI(SubjectProcessor.getSubjectAsUri(subject)));
                }
                Set<RelationshipTuple> tuples =
                        r.getRelationships(subj, pred, null);
                return tuples.toArray(new RelationshipTuple[tuples.size()]);
            } catch (URISyntaxException e) {
                throw new GeneralException("Relationship must be a URI", e);
            }
        } finally {
View Full Code Here

TOP

Related Classes of org.fcrepo.server.storage.DOReader

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.