Package org.milyn.archive

Examples of org.milyn.archive.Archive$DeleteOnExitHook


    locator.setBaseURI(baseURI);

    InputStream rawZipStream = locator.getResource(mappingModelFile);
    if(rawZipStream != null) {
            Archive archive = loadArchive(rawZipStream);

      if(archive != null) {
        List<String> rootMappingModels = getMappingModelList(archive);

        if(rootMappingModels.isEmpty()) {
View Full Code Here


        } else if(ediMappingModel.endsWith(".jar") || ediMappingModel.endsWith(".zip")) {
            URIResourceLocator locator = new URIResourceLocator();

            InputStream rawZipStream = locator.getResource(ediMappingModel);
            if(rawZipStream != null) {
                Archive archive = loadArchive(rawZipStream);
                if(archive != null) {
                    byte[] bytes = archive.getEntryBytes(EDI_MAPPING_MODEL_INTERCHANGE_PROPERTIES_FILE);
                    if(bytes != null) {
                        interchangePropertiesStream = new ByteArrayInputStream(bytes);
                    }
                }
            }
View Full Code Here

        return rootMappingModels;
    }

    private static Archive loadArchive(InputStream rawStream) {
        try {
            return new Archive(new ZipInputStream(rawStream));
    } catch(Exception e) {
      // Assume it's not a Zip file.  Just return null...
      return null;
    }
  }
View Full Code Here

    public static void fromSpec(EdiSpecificationReader ediSpecificationReader, ZipOutputStream modelSetOutStream, String urn) throws IOException {
        AssertArgument.isNotNull(ediSpecificationReader, "ediSpecificationReader");
        AssertArgument.isNotNull(modelSetOutStream, "modelSetOutStream");

        try {
            Archive archive = createArchive(ediSpecificationReader, urn);

            // Now output the generated archive...
            archive.toOutputStream(modelSetOutStream);
        } catch (Throwable t) {
            logger.fatal("Error while generating EDI Mapping Model archive for '" + urn + "'.", t);
        } finally {
            modelSetOutStream.close();
        }
View Full Code Here

     */
    public static void fromSpec(EdiSpecificationReader ediSpecificationReader, File modelSetOutFolder, String urn) throws IOException {
        AssertArgument.isNotNull(ediSpecificationReader, "ediSpecificationReader");
        AssertArgument.isNotNull(modelSetOutFolder, "modelSetOutFolder");

        Archive archive = createArchive(ediSpecificationReader, urn);

        // Now output the generated archive...
        archive.toFileSystem(modelSetOutFolder);
    }
View Full Code Here

        // Now output the generated archive...
        archive.toFileSystem(modelSetOutFolder);
    }

    private static Archive createArchive(EdiSpecificationReader ediSpecificationReader, String urn, String... messages) throws IOException {
        Archive archive = new Archive();
        StringBuilder modelListBuilder = new StringBuilder();
        StringWriter messageEntryWriter = new StringWriter();
        String pathPrefix = urn.replace(".", "_").replace(":", "/");
        EdiDirectory ediDirectory = ediSpecificationReader.getEdiDirectory(messages);

        // Add the common model...
        addModel(ediDirectory.getCommonModel(), pathPrefix, modelListBuilder, messageEntryWriter, archive);

        // Add each of the messages...
        for(Edimap messageModel : ediDirectory.getMessageModels()) {
            addModel(messageModel, pathPrefix, modelListBuilder, messageEntryWriter, archive);
        }

        // Now create XML Schemas
        Set<EPackage> packages = new ECoreGenerator().generatePackages(ediDirectory);
        String pluginID = "org.milyn.edi.unedifact.unknown";
        if (urn.lastIndexOf(':') > 0) {
          pluginID = urn.substring(0, urn.lastIndexOf(':')).replace(':', '.').toLowerCase();
        }
        Archive schemas = SchemaConverter.INSTANCE.createArchive(packages, pluginID, pathPrefix);
        archive.merge(schemas);

        // Add the generated mapping model to the archive...
        archive.addEntry(EDIUtils.EDI_MAPPING_MODEL_ZIP_LIST_FILE, modelListBuilder.toString());
View Full Code Here

        AssertArgument.isNotNull(archives, "archives");
       
        final List<Archive> jars = new ArrayList<Archive>();
        for (File jar : archives)
        {
            jars.add(new Archive(new JarInputStream(new FileInputStream(jar))));
        }
        return mergeJars(jarname, jars);
    }
View Full Code Here

    public Archive mergeJars(final String jarname, final List<Archive> archives) throws IOException
    {
        AssertArgument.isNotNull(jarname, "jarname");
        AssertArgument.isNotNull(archives, "archives");
       
        final Archive all = getOrCreateArchive(jarname);
        final Map<String, List<byte[]>> pathToBytesMap = new HashMap<String, List<byte[]>>();

        for (Archive jar : archives)
        {
            for (String resourcePath : resourcePaths)
            {
                byte[] content = jar.getEntryBytes(resourcePath);
                if (content != null)
                {
                    List<byte[]> list = getContentListForResource(pathToBytesMap, resourcePath);
                    list.add(content);
                    pathToBytesMap.put(resourcePath, list);
                }
            }
            all.merge(jar);
        }
        return mergeResources(pathToBytesMap, all);
    }
View Full Code Here

    private Archive getOrCreateArchive(final String jarname) throws FileNotFoundException, IOException
    {
        final File jarfile = new File(jarname);
        if (jarfile.exists())
        {
            return new Archive(new ZipInputStream(new FileInputStream(jarfile)));
        }
        else
        {
            return new Archive(jarname);
        }
    }
View Full Code Here

    private void mergeJars() throws IOException
    {
        log("Building " + jarName);
        final List<File> jars = getJarsFromFileSet();
        final ResourceMerger resourceMerger = new ResourceMerger(resourcesPaths);
        final Archive mergedJar = resourceMerger.mergeJars(jarName, jars.toArray(new File[]{}));
        setManifest(mergedJar);
        final File newJar = exportJarFile(mergedJar, jarName);
        log("Produced [" + newJar.getAbsolutePath());
    }
View Full Code Here

TOP

Related Classes of org.milyn.archive.Archive$DeleteOnExitHook

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.