Package eu.planets_project.ifr.core.techreg.formats

Examples of eu.planets_project.ifr.core.techreg.formats.FormatRegistry


                        log.info("Extracted metadata: " + metadata);
                    }
                   
                    // Migrate
                    try {
                        FormatRegistry fr = FormatRegistryFactory.getFormatRegistry();
                        String ext = fr.getFirstExtension(new URI(types[0]));
                        log.info("Getting extension: " + ext);
                        if (ext != null) {
                            dgo = runMigrateService(dgo, fr.createExtensionUri(ext), wfResult);
                            dgo = new DigitalObject.Builder(dgo.getContent())
                                .title(title)
                                .build();
                            objects.add(dgo);
                            log.info(new Message("Migration", new Parameter("Input", ext), new Parameter("Result", dgo
View Full Code Here


                  wfResultItem.addLogInfo("Extracted metadata: " + metadata);
                }
               
                // Migrate
                try {
                    FormatRegistry fr = FormatRegistryFactory.getFormatRegistry();
                    String ext = fr.getFirstExtension(new URI(types[0]));
                    wfResultItem.addLogInfo("Getting extension: " + ext);
                    if (ext != null) {
                        URI uridgo = runMigration(migrate, dgo.getPermanentUri());
                        dgo = new DigitalObject.Builder(dgo.getContent())
                            .title(title)
View Full Code Here

                    // Migrate
                    try {
                        String ext = dgo.getTitle().substring(dgo.getTitle().lastIndexOf('.')+1, dgo.getTitle().length());
                        log.info("detected extension: "+ext);
                       
                        FormatRegistry fr = FormatRegistryFactory.getFormatRegistry();
                        //String ext = fr.getFirstExtension(new URI(types[0]));
                        log.info("Getting extension: " + ext);
                        if (ext != null) {
                            DigitalObject dgoOut = runMigrateService(dgo, fr.createExtensionUri(ext), wfResult);
                           
                            objects.add(dgoOut);
                            log.info(new Message("Migration", new Parameter("Input", ext), new Parameter("Result", dgo
                                    .getTitle())));
                        }
View Full Code Here

        Migrate m = (Migrate) service.getPort(Migrate.class);
       
        // create digital object that contains our sample object
        DigitalObject dob = new DigitalObject.Builder( Content.byValue(sampleObject.getData().getData()) ).title("data").build();

        FormatRegistry formatRegistry = FormatRegistryFactory.getFormatRegistry();

        // create Planets URI from extension
        URI sourceFormat = formatRegistry.createExtensionUri(sampleObject.getFormatInfo().getDefaultExtension());
       
        URI targetFormat;
        try {
            targetFormat = new URI(action.getTargetFormat());
        } catch (URISyntaxException e) {
            throw new PlatoServiceException("Error in target format.", e);
        }
       
        List<Parameter> serviceParams = getParameters(action.getParamByName("settings"));
       
        if (serviceParams.size() <= 0) {
            serviceParams = null;
        }
       
        // perform migration
        MigrateResult result = m.migrate(dob, sourceFormat, targetFormat, serviceParams);

        MigrationResult migrationResult = new MigrationResult();
        migrationResult.setSuccessful((result != null) && (result.getDigitalObject() != null));

        if (migrationResult.isSuccessful()) {
            migrationResult.setReport(String.format("Service %s successfully migrated object.", wsdlLocation));
        } else {
            migrationResult.setReport(String.format("Service %s failed migrating object. " + ((result==null)? "" : result.getReport()), wsdlLocation));
            lastResult = migrationResult;
            return true;
        }

        InputStream in = result.getDigitalObject().getContent().getInputStream();
        ByteArrayOutputStream out = new ByteArrayOutputStream();

        byte[] b = new byte[1024];

        try {
            while ((in.read(b)) != -1) {
                out.write(b);
            }
        } catch (IOException e) {
            throw new PlatoServiceException("Unable to read result data from service response.", e);
        }

        migrationResult.getMigratedObject().getData().setData(out.toByteArray());

        String fullName = sampleObject.getFullname();

        String ext;
        try {
            ext = formatRegistry.getFirstExtension(new URI(action.getTargetFormat()));
        } catch (URISyntaxException e) {
            ext = "";
        }
       
        // if we find an extension, cut if off ...
View Full Code Here

                                    "PA/sanselan/test/resources/PlanetsLogo-lowq-png.test")
                                    .toURI().toURL())).permanentUri(
                    URI.create("http://some")).build();
            System.out.println("Input: " + input);

            FormatRegistry format = FormatRegistryFactory.getFormatRegistry();
            MigrateResult mr = dom.migrate(input, format.createExtensionUri("png"),
                    format.createExtensionUri("gif"), null);

            ServiceReport sr = mr.getReport();
            System.out.println("Got Report: " + sr);

            DigitalObject doOut = mr.getDigitalObject();
View Full Code Here

     * @see eu.planets_project.services.characterise.Characterise#listProperties(java.net.URI)
     */
    public List<Property> listProperties(final URI formatURI) {
        ArrayList<Property> result = new ArrayList<Property>();
        /* Get the extensions for the supplied Pronom ID: */
        FormatRegistry registry = FormatRegistryFactory.getFormatRegistry();
        Set<String> extensions = registry.getExtensions(formatURI);
        /* Find the corresponding metadata file type: */
        MetadataType[] types = MetadataType.values();
        for (MetadataType metadataType : types) {
            String[] split = metadataType.sample.split("\\.");
            String suffix = split[split.length - 1];
View Full Code Here

     */
    public ServiceDescription describe() {
        /*
         * Gather all supported input formats using the tech reg and the types enum:
         */
        FormatRegistry formatRegistry = FormatRegistryFactory.getFormatRegistry();
        List<URI> inputFormats = new ArrayList<URI>();
        MetadataType[] metadataTypes = MetadataType.values();
        for (MetadataType metadataType : metadataTypes) {
            /*
             * We use the sample file extension instead of the mime type, as the latter is
             * file/unknown for many types (it's what the tool returns as a result, used for
             * testing)
             */
            String[] split = metadataType.sample.split("\\.");
            String extension = split[split.length - 1];
            inputFormats.addAll(formatRegistry.getUrisForExtension(extension));
        }
        Builder builder = new ServiceDescription.Builder("New Zealand Metadata Extractor Service",
                Characterise.class.getName());
        builder.author("Fabian Steeg");
        builder.classname(this.getClass().getName());
View Full Code Here

        Set<URI> outputformats = new HashSet<URI>();
        outputformats.add(outputformatUnicode);
        outputformats.add(outputformatHtml);

        FormatRegistry fm = FormatRegistryFactory.getFormatRegistry();
        List<MigrationPath> paths =
                MigrationPath.constructPaths(fm.getUrisForExtension("pdf"),
                        outputformats);

        builder.paths(paths.toArray(new MigrationPath[]{}));
        builder.version("0.1");
View Full Code Here

     * @param format The format to check for support
     * @return True, if the given format is supported
     */
    public static boolean supported(final URI format) {
        for (URI uri : JhoveIdentification.inputFormats()) {
            FormatRegistry registry = FormatRegistryFactory.getFormatRegistry();
            if (registry.getFormatUriAliases(uri).contains(format)) {
                return true;
            }
        }
        return false;
    }
View Full Code Here

     * @return An array of Pronom IDs supported as input formats by Jhove
     */
    public static URI[] inputFormats() {
        List<URI> result = new ArrayList<URI>();
        for (SupportedFileType type : SupportedFileType.values()) {
            FormatRegistry formatRegistry = FormatRegistryFactory
                    .getFormatRegistry();
            Set<URI> urisForMimeType = formatRegistry
                    .getUrisForMimeType(type.mime);
            if (urisForMimeType != null && urisForMimeType.size() > 0) {
                result.addAll(urisForMimeType);
            }
        }
View Full Code Here

TOP

Related Classes of eu.planets_project.ifr.core.techreg.formats.FormatRegistry

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.