Package org.fcrepo.server.storage

Examples of org.fcrepo.server.storage.DOReader


    public Validation validate(Context context, String pid, Date asOfDateTime)
            throws ServerException {
        if (asOfDateTime == null) asOfDateTime = new Date();

        DOReader currentObjectReader = doMgr.getReader(false, context, pid);

        List<String> contentmodels = currentObjectReader.getContentModels();

        return doValidate(context, currentObjectReader, asOfDateTime, contentmodels);

    }
View Full Code Here


    }
  @Override
  public void validate(Context context, DOReader reader)
      throws ServerException {

    DOReader currentObjectReader = reader;

    List<String> contentmodels = currentObjectReader.getContentModels();

    // don't validate self-referential content model objects - this would
    // effectively be validating a new (uncommitted) version of the object
    // against the previous (committed) version, which doesn't make sense
    // (and prevents the server ingesting the initial system content model object)
    String pid = currentObjectReader.GetObjectPID();
    String objectUri = "info:fedora/" + pid;
    if (!contentmodels.contains(objectUri)) {

    Validation validation = doValidate(context, currentObjectReader, new Date(), contentmodels);
View Full Code Here

        //For each content model, parse the DS-COMPOSITE-MODEL
        for (String contentmodel : contentmodels) {
            contentmodel = contentmodel.substring("info:fedora/".length());

            DOReader contentmodelReader = doMgr.getReader(false, context, contentmodel);
            Datastream dscompmodelDS = contentmodelReader.GetDatastream("DS-COMPOSITE-MODEL", asOfDateTime);

            if (dscompmodelDS == null) {//NO ds composite model, thats okay, continue to next content model
                continue;
            }
            DsCompositeModel dscompobject = JAXB.unmarshal(dscompmodelDS.getContentStream(), DsCompositeModel.class);
View Full Code Here

            logger.error(e.getMessage());
        }

        try {
            logger.info("COMMIT: Attempting replication: " + obj.getPid());
            DOReader reader =
                    manager.getReader(Server.USE_DEFINITIVE_STORE,
                                      m_context,
                                      obj.getPid());
            logger.info("COMMIT: Updating FieldSearch indexes...");
            fieldSearch.update(reader);
View Full Code Here

        List<String> contentmodels = currentObjectReader.getContentModels();

        for (String contentmodel : contentmodels) {
            contentmodel = contentmodel.substring("info:fedora/".length());
            DOReader contentmodelReader;
            try {
                contentmodelReader = doMgr.getReader(false, context, contentmodel);
            } catch (LowlevelStorageException e) {//content model could not be found
                continue;
            }

            if (asOfDateTime != null) { //disregard content models created after the asOfDateTime
                if (!contentmodelReader.getCreateDate().before(asOfDateTime)) {
                    continue;
                }
            }

            Datastream ontologyDS = contentmodelReader.GetDatastream("ONTOLOGY", asOfDateTime);

            if (ontologyDS == null) {//No ontology in the content model, continue
                continue;
            }
            InputStream ontologyStream = ontologyDS.getContentStream();
View Full Code Here

        } else { //target is an object
            targetPid = target;
        }
        List<String> targetContentModels;

        DOReader targetReader = doMgr.getReader(false, context, targetPid);
        targetContentModels = targetReader.getContentModels();

        for (String targetContentModel : targetContentModels) {
            targetContentModel = targetContentModel+"#" +dsname+"class";
            classes.add(targetContentModel);
        }
View Full Code Here

        ArrayList<String> names = new ArrayList<String>();
        if (contentmodel.startsWith("info:fedora/")) {
            contentmodel = contentmodel.substring("info:fedora/".length());
        }
        DOReader reader = doMgr.getReader(false, context, contentmodel);
        Datastream dscompmodelDS = reader.GetDatastream("DS-COMPOSITE-MODEL", asOfDateTime);
        if (dscompmodelDS == null) {//NO ds composite model, thats okay, continue to next content model
            return names;
        }
        DsCompositeModel dscompobject = JAXB.unmarshal(dscompmodelDS.getContentStream(context), DsCompositeModel.class);
View Full Code Here

    @Override
    public String[] getObjectHistory(Context context, String PID)
            throws ServerException {
        PID = Server.getPID(PID).toString();
        m_authorizationModule.enforceGetObjectHistory(context, PID);
        DOReader reader =
                m_manager.getReader(Server.USE_DEFINITIVE_STORE, context, PID);

        return reader.getObjectHistory(PID);
    }
View Full Code Here

                                                                PID,
                                                                dsID,
                                                                asOfDateTime);
        MIMETypedStream mimeTypedStream = null;
        long startTime = new Date().getTime();
        DOReader reader =
                m_manager.getReader(Server.USE_DEFINITIVE_STORE, context, PID);

        Datastream ds = reader.GetDatastream(dsID, asOfDateTime);
        if (ds == null) {
            String message =
                    "[DefaulAccess] No datastream could be returned. "
                    + "Either there is no datastream for the digital "
                    + "object \""
                    + PID
                    + "\" with datastream ID of \""
                    + dsID
                    + " \"  OR  there are no datastreams that match the specified "
                    + "date/time value of \""
                    + DateUtility.convertDateToString(asOfDateTime)
                    + " \"  .";
            throw new DatastreamNotFoundException(message);
        }

        if (ds.DSControlGrp.equalsIgnoreCase("E")) {
            DatastreamReferencedContent drc =
                    (DatastreamReferencedContent) reader
                            .GetDatastream(dsID, asOfDateTime);
            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);
        } else if (ds.DSControlGrp.equalsIgnoreCase("R")) {
            DatastreamReferencedContent drc =
                    (DatastreamReferencedContent) reader
                            .GetDatastream(dsID, asOfDateTime);
            // The dsControlGroupType of Redirect("R") is a special control type
            // used primarily for streaming media. Datastreams of this type are
            // not mediated (proxied by Fedora) and their physical dsLocation is
            // simply redirected back to the client. Therefore, the contents
View Full Code Here

            if ("".equals(pid)) {
                logger.debug("no pid");
                return null;
            }
            logger.debug("getResourceAttribute {}, pid={}", attributeId, pid);
            DOReader reader = null;
            try {
                logger.debug("pid={}", pid);
                reader =
                        doManager.getReader(Server.USE_DEFINITIVE_STORE,
                                            ReadOnlyContext.EMPTY,
                                            pid);
            } catch (ServerException e) {
                logger.debug("couldn't get object reader");
                return null;
            }
            String[] values = null;
            if (Constants.OBJECT.STATE.uri.equals(attributeId)) {
                try {
                    values = new String[1];
                    values[0] = reader.GetObjectState();
                    logger.debug("got " + Constants.OBJECT.STATE.uri + "="
                            + values[0]);
                } catch (ServerException e) {
                    logger.debug("failed getting " + Constants.OBJECT.STATE.uri,e);
                    return null;
                }
            }
            else if (Constants.OBJECT.OWNER.uri.equals(attributeId)) {
                try {
                    logger.debug("ResourceAttributeFinder.getAttributeLocally using ownerIdSeparator==["
                                    + ownerIdSeparator + "]");
                    String ownerId = reader.getOwnerId();
                    if (ownerId == null) {
                        values = new String[0];
                    } else {
                        values = reader.getOwnerId().split(ownerIdSeparator);
                    }
                    String temp = "got " + Constants.OBJECT.OWNER.uri + "=";
                    for (int i = 0; i < values.length; i++) {
                        temp += (" [" + values[i] + "]");
                    }
                    logger.debug(temp);
                } catch (ServerException e) {
                    logger.debug("failed getting " + Constants.OBJECT.OWNER.uri,e);
                    return null;
                }
            } else if (Constants.MODEL.HAS_MODEL.uri.equals(attributeId)) {
                Set<String> models = new HashSet<String>();
                try {
                    models.addAll(reader.getContentModels());
                } catch (ServerException e) {
                    logger.debug("failed getting " + Constants.MODEL.HAS_MODEL.uri,e);
                    return null;
                }
                values = models.toArray(new String[0]);
            } else if (Constants.OBJECT.CREATED_DATETIME.uri.equals(attributeId)) {
                try {
                    values = new String[1];
                    values[0] =
                            DateUtility.convertDateToString(reader
                                    .getCreateDate());
                    logger.debug("got " + Constants.OBJECT.CREATED_DATETIME.uri
                            + "=" + values[0]);
                } catch (ServerException e) {
                    logger.debug("failed getting "
                            + Constants.OBJECT.CREATED_DATETIME.uri);
                    return null;
                }
            } else if (Constants.OBJECT.LAST_MODIFIED_DATETIME.uri
                    .equals(attributeId)) {
                try {
                    values = new String[1];
                    values[0] =
                            DateUtility.convertDateToString(reader
                                    .getLastModDate());
                    logger.debug("got "
                            + Constants.OBJECT.LAST_MODIFIED_DATETIME.uri + "="
                            + values[0]);
                } catch (ServerException e) {
                    logger.debug("failed getting "
                            + Constants.OBJECT.LAST_MODIFIED_DATETIME.uri);
                    return null;
                }
            } else if (Constants.DATASTREAM.STATE.uri.equals(attributeId)
                    || Constants.DATASTREAM.CONTROL_GROUP.uri
                            .equals(attributeId)
                    || Constants.DATASTREAM.FORMAT_URI.uri.equals(attributeId)
                    || Constants.DATASTREAM.CREATED_DATETIME.uri
                            .equals(attributeId)
                    || Constants.DATASTREAM.INFO_TYPE.uri.equals(attributeId)
                    || Constants.DATASTREAM.LOCATION.uri.equals(attributeId)
                    || Constants.DATASTREAM.LOCATION_TYPE.uri
                            .equals(attributeId)
                    || Constants.DATASTREAM.MIME_TYPE.uri.equals(attributeId)
                    || Constants.DATASTREAM.CONTENT_LENGTH.uri
                            .equals(attributeId)) {
                String datastreamId = getDatastreamId(context);
                if ("".equals(datastreamId)) {
                    logger.debug("no datastreamId");
                    return null;
                }
                logger.debug("datastreamId=" + datastreamId);
                Datastream datastream;
                try {
                    datastream = reader.GetDatastream(datastreamId, new Date()); //right import (above)?
                } catch (ServerException e) {
                    logger.debug("couldn't get datastream");
                    return null;
                }
                if (datastream == null) {
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.