Package eu.planets_project.ifr.core.storage.impl.fedora.connector

Examples of eu.planets_project.ifr.core.storage.impl.fedora.connector.StoreException


        String pid;

        pid = fedora.uri2Pid(piduri);
        boolean exists = fedora.exists(pid);
        if (!exists){
            throw new StoreException("Object does not already exist");
        }


        if (!isWritable(piduri)){
            throw new StoreException("This object is not writable");
        }

        String planetsModel;

        try {
            if (!fedora.isPlanetsObject(pid)){
                throw new StoreException("pdURI "+pid.toString()+" is not a planets compatible object");
            }
            planetsModel = fedora.getPlanetsContentModel(pid);
        } catch (DigitalObjectNotFoundException e) {
            //we have just checked that it exists...
            throw new StoreException("Object was there, but then it was gone",e);
        }

        PlanetsDatastreamType planetsDatastreamObject;
        try {
            planetsDatastreamObject = readPlanetsDatastream(planetsModel);
        } catch (ParseException e) {
            throw new StoreException(e);
        } catch (DigitalObjectNotFoundException e) {
            throw new StoreException("Object '"+pid+"' was a planets object but cannot read the content model",e);
        }
        //If so far, we have now read the datastream in as a java class



        //decode the streams for the planets object

        MetadatastreamsType metadatastreams = planetsDatastreamObject.getMetadatastreams();
        Map<String, MetadatastreamType> metamap = new HashMap<String, MetadatastreamType>();
        for (MetadatastreamType datastream: metadatastreams.getMetadatastream()){
            metamap.put(datastream.getPlanetsName(),datastream);
        }



        for (Metadata metadata : digitalObject.getMetadata()) {
            MetadatastreamType ds = metamap.get(metadata.getName());
            URI formatURI = metadata.getType();
            if (ds!=null){

                try {
                    fedora.modifyDatastream(pid,ds.getName(),metadata.getContent(),formatURI);
                } catch (ParseException e) {
                    throw new StoreException(e);
                }
            }
        }

        try {
            fedora.setObjectLabel(pid,digitalObject.getTitle());
        } catch (DigitalObjectNotFoundException e) {
            //we have just checked that it exists...
            throw new StoreException("Object was there, but then it was gone",e);
        }

        ContentdatastreamType filedatastream = planetsDatastreamObject.getContentdatastream();
        URI formatURI = digitalObject.getFormat();

        try {
            fedora.modifyDatastream(pid,filedatastream.getName(),digitalObject.getContent().getInputStream(),formatURI);
            return  fedora.pid2Uri(pid);
        } catch (ParseException e) {
            throw new StoreException(e);//cannot happen
        }

    }
View Full Code Here

TOP

Related Classes of eu.planets_project.ifr.core.storage.impl.fedora.connector.StoreException

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.