Package org.openoffice.idesupport.xml

Examples of org.openoffice.idesupport.xml.Manifest


        throws IOException {

        ZipInputStream documentStream = null;
        ZipInputStream parcelStream = null;
        ZipOutputStream outStream = null;
        Manifest manifest;
       
        String language = getParcelLanguage(parcel);

        if (isDocumentOverwriteNeeded(parcel, targetDocument)) {
            String parcelName = language + "/" +
View Full Code Here


    public String removeParcel(File document, String parcelName)
        throws IOException {

        ZipInputStream documentStream = null;
        ZipOutputStream outStream = null;
        Manifest manifest = null;
       
        if (!parcelName.startsWith(PARCEL_PREFIX_DIR))
            parcelName = PARCEL_PREFIX_DIR + parcelName;
        manifest = removeParcelFromManifest(document, parcelName);

        // first write contents of document to tmpfile
        File tmpfile = new File(document.getAbsolutePath() + ".tmp");

        try {
            ZipEntry outEntry;
            ZipEntry inEntry;
            byte[] bytes = new byte[1024];
            int len;
   
            documentStream = new ZipInputStream(new FileInputStream(document));
            outStream = new ZipOutputStream(new FileOutputStream(tmpfile));
       
            while ((inEntry = documentStream.getNextEntry()) != null) {
               
                if(inEntry.getName().startsWith(parcelName))
                    continue;
               
                outEntry = new ZipEntry(inEntry);
                outStream.putNextEntry(outEntry);
       
                if(inEntry.getName().equals("META-INF/manifest.xml") &&
                   manifest != null) {
                    InputStream manifestStream = null;
                    try {
                        manifestStream = manifest.getInputStream();
                        while ((len = manifestStream.read(bytes)) != -1)
                            outStream.write(bytes, 0, len);
                    }
                    finally {
                        if (manifestStream != null)
View Full Code Here

        return document.getAbsolutePath();
    }

    private Manifest getManifestFromDocument(File document) {
        ZipFile documentZip = null;
        Manifest result = null;

        try {
            documentZip = new ZipFile(document);
            ZipEntry original = documentZip.getEntry("META-INF/manifest.xml");
            if (original != null) {
                result = new Manifest(documentZip.getInputStream(original));
            }
        }
        catch (IOException ioe) {
            result = null;
        }
View Full Code Here

    private Manifest addParcelToManifest(File document, File parcel)
        throws IOException {

        ZipFile parcelZip = null;
        Manifest result = null;

        result = getManifestFromDocument(document);
        if (result == null)
            return null;

        String language = getParcelLanguage(parcel);

        try {
            parcelZip = new ZipFile(parcel);

            String prefix = PARCEL_PREFIX_DIR + language + "/" +
                getParcelDirFromParcelZip(parcel.getName()) + "/";

            Enumeration entries = parcelZip.entries();
            while (entries.hasMoreElements()) {
                ZipEntry entry = (ZipEntry)entries.nextElement();
                result.add(prefix + entry.getName());
            }
        }
        catch (IOException ioe) {
            return null;
        }
View Full Code Here

        return result;
    }

    private Manifest removeParcelFromManifest(File document, String name) {
        Manifest result = null;

        result = getManifestFromDocument(document);
        if (result == null)
            return null;

        result.remove(name);
        return result;
    }
View Full Code Here

        throws IOException {

        ZipInputStream documentStream = null;
        ZipInputStream parcelStream = null;
        ZipOutputStream outStream = null;
        Manifest manifest;
       
        String language = getParcelLanguage(parcel);

        if (isDocumentOverwriteNeeded(parcel, targetDocument)) {
            String parcelName = language + "/" +
View Full Code Here

    public String removeParcel(File document, String parcelName)
        throws IOException {

        ZipInputStream documentStream = null;
        ZipOutputStream outStream = null;
        Manifest manifest = null;
       
        if (!parcelName.startsWith(PARCEL_PREFIX_DIR))
            parcelName = PARCEL_PREFIX_DIR + parcelName;
        manifest = removeParcelFromManifest(document, parcelName);

        // first write contents of document to tmpfile
        File tmpfile = new File(document.getAbsolutePath() + ".tmp");

        try {
            ZipEntry outEntry;
            ZipEntry inEntry;
            byte[] bytes = new byte[1024];
            int len;
   
            documentStream = new ZipInputStream(new FileInputStream(document));
            outStream = new ZipOutputStream(new FileOutputStream(tmpfile));
       
            while ((inEntry = documentStream.getNextEntry()) != null) {
               
                if(inEntry.getName().startsWith(parcelName))
                    continue;
               
                outEntry = new ZipEntry(inEntry);
                outStream.putNextEntry(outEntry);
       
                if(inEntry.getName().equals("META-INF/manifest.xml") &&
                   manifest != null) {
                    InputStream manifestStream = null;
                    try {
                        manifestStream = manifest.getInputStream();
                        while ((len = manifestStream.read(bytes)) != -1)
                            outStream.write(bytes, 0, len);
                    }
                    finally {
                        if (manifestStream != null)
View Full Code Here

        return document.getAbsolutePath();
    }

    private Manifest getManifestFromDocument(File document) {
        ZipFile documentZip = null;
        Manifest result = null;

        try {
            documentZip = new ZipFile(document);
            ZipEntry original = documentZip.getEntry("META-INF/manifest.xml");
            if (original != null) {
                result = new Manifest(documentZip.getInputStream(original));
            }
        }
        catch (IOException ioe) {
            result = null;
        }
View Full Code Here

    private Manifest addParcelToManifest(File document, File parcel)
        throws IOException {

        ZipFile parcelZip = null;
        Manifest result = null;

        result = getManifestFromDocument(document);
        if (result == null)
            return null;

        String language = getParcelLanguage(parcel);

        try {
            parcelZip = new ZipFile(parcel);

            String prefix = PARCEL_PREFIX_DIR + language + "/" +
                getParcelDirFromParcelZip(parcel.getName()) + "/";

            Enumeration entries = parcelZip.entries();
            while (entries.hasMoreElements()) {
                ZipEntry entry = (ZipEntry)entries.nextElement();
                result.add(prefix + entry.getName());
            }
        }
        catch (IOException ioe) {
            return null;
        }
View Full Code Here

        return result;
    }

    private Manifest removeParcelFromManifest(File document, String name) {
        Manifest result = null;

        result = getManifestFromDocument(document);
        if (result == null)
            return null;

        result.remove(name);
        return result;
    }
View Full Code Here

TOP

Related Classes of org.openoffice.idesupport.xml.Manifest

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.