Package eu.scape_project.planning.model

Examples of eu.scape_project.planning.model.ByteStream


     *             if an error occurred
     * @throws TavernaParserException
     *             if the executable plan could not be parsed
     */
    public void readT2flowExecutablePlan(InputStream stream) throws PlanningException, TavernaParserException {
        ByteStream bsData = this.convertToByteStream(stream);
        if (bsData == null) {
            throw new PlanningException("An error occurred while storing the executable plan");
        }

        T2FlowParser parser = T2FlowParser.createParser(new ByteArrayInputStream(bsData.getData()));

        String name = parser.getName();
        storeExecutablePlan(FileUtils.makeFilename(name) + ".t2flow", bsData);
    }
View Full Code Here


            XMLWriter writer = new XMLWriter(out, outputFormat);

            writer.write(papDoc);
            writer.close();

            ByteStream bs = new ByteStream();
            bs.setData(out.toByteArray());
            bs.setSize(out.size());

            DigitalObject digitalObject = new DigitalObject();
            digitalObject.setFullname(PreservationActionPlanGenerator.FULL_NAME);
            digitalObject.setContentType("application/xml");
            digitalObject.setData(bs);
View Full Code Here

     * @param stream
     *            the stream to wrap.
     * @return the new {@link ByteStream} or null if an error occurred.
     */
    private ByteStream convertToByteStream(InputStream stream) {
        ByteStream bsData = null;
        byte[] bytes = null;
        try {
            bytes = FileUtils.inputStreamToBytes(stream);
            bsData = new ByteStream();
            bsData.setData(bytes);
            bsData.setSize(bytes.length);
        } catch (IOException e) {
            log.error("An error occurred while converting the stream: {}", e.getMessage());
        }

        return bsData;
View Full Code Here

                }
            }
        }

        byte[] data = out.toByteArray();
        ByteStream bsData = new ByteStream();
        bsData.setData(data);

        workflow.setContentType("application/vnd.taverna.t2flow+xml");
        workflow.setData(bsData);
        workflow.setFullname(FileUtils.makeFilename(name + ".t2flow"));
View Full Code Here

                }
            }
        }

        byte[] data = out.toByteArray();
        ByteStream bsData = new ByteStream();
        bsData.setData(data);

        workflow.setContentType("application/vnd.taverna.t2flow+xml");
        workflow.setData(bsData);
        workflow.setFullname(FileUtils.makeFilename(name + ".t2flow"));
View Full Code Here

    public SampleObject addSample(String filename, String contentType, byte[] data) throws PlanningException {
        SampleObject sample = new SampleObject(filename);
        sample.setFullname(filename);
        sample.setContentType(contentType);

        ByteStream bsData = new ByteStream();
        bsData.setData(data);
        sample.setData(bsData);

        digitalObjectManager.moveDataToStorage(sample);
        addedBytestreams.add(sample.getPid());
        plan.getSampleRecordsDefinition().addRecord(sample);
View Full Code Here

     *             if the profile cannot be read for some reason.
     */
    public void readProfile(InputStream stream, final String repositoryUser, final String repositoryPassword) throws ParserException, PlanningException {
        log.info("Pre-processing profile information");

        ByteStream bsData = this.convertToByteStream(stream);
        if (bsData == null) {
            throw new PlanningException("An error occurred while storing the profile");
        }

        log.info("Parsing profile information");
        stream = new ByteArrayInputStream(bsData.getData());
        C3POProfileParser parser = new C3POProfileParser();
        parser.read(stream, false);

        // if we are here the profile was read successfully
        String id = parser.getCollectionId();
View Full Code Here

     * @param stream
     *            the stream to wrap.
     * @return the new {@link ByteStream} or null if an error occurred.
     */
    private ByteStream convertToByteStream(InputStream stream) {
        ByteStream bsData = null;
        byte[] bytes = null;
        try {
            bytes = FileUtils.inputStreamToBytes(stream);
            bsData = new ByteStream();
            bsData.setData(bytes);
            bsData.setSize(bytes.length);
        } catch (IOException e) {
            log.error("An error occurred while converting the stream: {}", e.getMessage());
        }

        return bsData;
View Full Code Here

            boolean loadedData = false;
            if (Helper.isLocalIdentifier(uid)) {
                log.info("Sample object is from local filesystem {}", uid);
                try {
                    InputStream sampleStream = new FileInputStream((new URL(uid)).getFile());
                    ByteStream bsSample = this.convertToByteStream(sampleStream);
                    sample.setData(bsSample);

                    digitalObjectManager.moveDataToStorage(sample);
                    addedBytestreams.add(sample.getPid());
                    loadedData = true;
                } catch (FileNotFoundException e) {
                    log.error("An error occurred while downloading sample {}", sample.getFullname(), e);
                } catch (MalformedURLException e) {
                    log.error("An error occurred while downloading sample {}", sample.getFullname(), e);
                }
            } else {               
                log.info("Sample object is from repository {}. Downloading {}", repo.getRepositoryIdentifier(), uid);
                try {
                    InputStream sampleStream = repo.downloadFile(uid);
                    log.info("To bytestream: sample {}", sample.getFullname());
                    ByteStream bsSample = this.convertToByteStream(sampleStream);
                    sample.setData(bsSample);

                    log.info("Moving to storage: sample {}", sample.getFullname());
                    digitalObjectManager.moveDataToStorage(sample);
                    addedBytestreams.add(sample.getPid());
View Full Code Here

    @Test
    public void moveDataToFileSystem_worksAsExpected() throws StorageException {
        // input object
        DigitalObject object = new DigitalObject();
        String content = "This is a test content";
        ByteStream contentByteStream = new ByteStream();
        contentByteStream.setData(content.getBytes());
        object.setData(contentByteStream);

        // mock ByteStreamManager
        ByteStreamManager byteStreamManager = mock(ByteStreamManager.class);
        when(byteStreamManager.store(null, content.getBytes())).thenReturn("myPid");
View Full Code Here

TOP

Related Classes of eu.scape_project.planning.model.ByteStream

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.