Examples of ArchiveManipulator


Examples of org.wso2.carbon.utils.ArchiveManipulator

        String fileSeparator = (File.separator.equals("\\")) ? "\\" : "/";
        String extractedCarbonDir =
                carbonServerZipFile.substring(carbonServerZipFile.lastIndexOf(fileSeparator) + 1,
                        indexOfZip);
        FileManipulator.deleteDir(extractedCarbonDir);
        new ArchiveManipulator().extract(carbonServerZipFile, "carbontmp");
        return new File(".").getAbsolutePath() + File.separator + "carbontmp" +
                File.separator + extractedCarbonDir;
    }
View Full Code Here

Examples of org.wso2.carbon.utils.ArchiveManipulator

                FileUtils.forceMkdir(emmaOutput);
            }
            String emmaJarName = null;
            for (File file : new File(emmaHome).listFiles()) {
                if (file.getName().startsWith("org.wso2.carbon.integration.core")) {
                    ArchiveManipulator archiveManipulator = new ArchiveManipulator();
                    archiveManipulator.extract(file.getAbsolutePath(), emmaHome);
                } else if (file.getName().startsWith("emma")) {
                    emmaJarName = file.getName();
                }
            }
View Full Code Here

Examples of org.wso2.carbon.utils.ArchiveManipulator

        } catch (Exception e) {
            throw new RuleServiceManagementException("Cannot write to the rule service file : " +
                    ruleFile, e, log);
        }

        ArchiveManipulator archiveManipulator = new ArchiveManipulator();
        try {
            String servicePath = paths.getServicePath();
            if (!servicePath.endsWith(RuleConstants.RULE_SERVICE_ARCHIVE_EXTENSION)) {
                File serviceFile = new File(servicePath);
                File absoluteServiceFile = serviceFile.getAbsoluteFile();
                if (absoluteServiceFile.exists()) {
                    absoluteServiceFile.delete();
                }
                servicePath = servicePath.substring(0, servicePath.lastIndexOf(".") + 1) +
                        RuleConstants.RULE_SERVICE_ARCHIVE_EXTENSION;
            }
            archiveManipulator.archiveDir(servicePath, paths.getWorkingDirPath());
        } catch (IOException e) {
            throw new RuleServiceManagementException("Error creating a archive a rule service ", e,
                    log);
        }
//        saveToRegistry(paths, ruleServiceDescription.getName());
View Full Code Here

Examples of org.wso2.carbon.utils.ArchiveManipulator

            fos.flush();
            fos.close();
        } catch (IOException e) {
            throw new RuleServiceManagementException("Cannot write facts", e, log);
        }
        ArchiveManipulator archiveManipulator = new ArchiveManipulator();
        try {
            String[] strings = archiveManipulator.check(factFile.getAbsolutePath());
            List<String> list = filterClasses(strings);
            return list.toArray(new String[list.size()]);
        } catch (IOException e) {
            throw new RuleServiceManagementException("Cannot extractPayload classes from the fact" +
                    " file", e, log);
View Full Code Here

Examples of org.wso2.carbon.utils.ArchiveManipulator

            File[] jars = FileManipulator.getMatchingFiles(
                    lib.getAbsolutePath(), null, ".jar");
            for (File file : jars) {
                try {
                    String[] strings =
                            new ArchiveManipulator().check(file.getAbsolutePath());
                    facts.addAll(filterClasses(strings));
                } catch (IOException e) {
                    throw new RuleServiceManagementException("Cannot extractPayload classes from " +
                            "the fact file", e, log);
                }
View Full Code Here

Examples of org.wso2.carbon.utils.ArchiveManipulator

        String targetDirectory = getTempDir() + File.separator + serviceName + "." +
                RuleConstants.RULE_SERVICE_ARCHIVE_EXTENSION;

        if (sourceFile.exists() &&
                servicePath.endsWith(RuleConstants.RULE_SERVICE_ARCHIVE_EXTENSION)) {
            ArchiveManipulator manipulator = new ArchiveManipulator();
            try {
                manipulator.extractFromStream(new FileInputStream(sourceFile), targetDirectory);
            } catch (IOException e) {
                throw new RuleServiceManagementException(
                        "Error extracting files from a source:  " + sourceFile +
                                " into destination : " + targetDirectory, log);
            }
View Full Code Here

Examples of org.wso2.carbon.utils.ArchiveManipulator

                throw new IllegalStateException("Unable to create temporary directory");
            }
            if (!tempFile.delete() || !tempFile.mkdir()) {
                throw new IllegalStateException("Unable to create temporary directory");
            }
            ArchiveManipulator am = new ArchiveManipulator();
            am.extract(source, dir);
            Properties properties;
            try {
                if (propertyFile == null) {
                    propertyFile = source.substring(0, source.lastIndexOf(".")) +
                            PROPERTIES_FILE_EXTENSION;
                }
                properties = loadProperties(propertyFile);
                if (properties.size() > 0) {
                    for (String str : am.check(source)) {
                        try {
                            String filePath = dir + File.separator + str;
                            File file = new File(filePath);
                            if (file.isFile()) {
                                List<String> archiveTypes = Arrays.asList("jar", "aar", "war",
                                        "dar", "mar", "gar", "zip");
                                List<String> textTypes = Arrays.asList("xml", "dbs", "xslt",
                                        "properties", "service", "js", "jsp", "css", "txt", "wsdl",
                                        "bpel");
                                if (FilenameUtils.isExtension(filePath, archiveTypes)) {
                                    File modified = new File(generateAppArchiveForTenant(filePath,
                                            session, propertyFile));
                                    FileUtils.copyFile(modified, file);
                                    FileUtils.deleteDirectory(modified.getParentFile());
                                } else if (FilenameUtils.isExtension(filePath, textTypes)) {
                                    String line;
                                    StringBuffer oldText = new StringBuffer();
                                    BufferedReader reader = new BufferedReader(
                                            new FileReader(file));
                                    FileWriter writer = null;
                                    try {
                                        while ((line = reader.readLine()) != null) {
                                            oldText.append(line).append("\n");
                                        }
                                        String newText = oldText.toString();
                                        for (String key : properties.stringPropertyNames()) {
                                            String value = properties.getProperty(key)
                                                    .replace(TENANT_ID_KEY,
                                                            Integer.toString(tenantId))
                                                    .replace(TENANT_DOMAIN_KEY, tenantDomain)
                                                    .replace(USER_NAME, username);
                                            newText = newText.replace(key, value);
                                        }
                                        writer = new FileWriter(file);
                                        writer.write(newText);
                                    } finally {
                                        try {
                                            reader.close();
                                        } finally {
                                            if (writer != null) {
                                                writer.close();
                                            }
                                        }
                                    }
                                }
                            }
                        } catch (IOException e) {
                            log.warn("An error occurred while making replacements in a file in: " +
                                    source, e);
                        }
                    }
                }
            } catch (IOException e) {
                log.warn("An error occurred while reading properties file for: " + source, e);
            }
            am.archiveDir(destination, dir);
        } finally {
            if (tempDir != null) {
                FileUtils.deleteDirectory(tempDir);
            }
        }
View Full Code Here

Examples of org.wso2.carbon.utils.ArchiveManipulator

    public void deployArtifacts(CarbonApplication carbonApp, AxisConfiguration axisConfig) {

        List<Artifact.Dependency> artifacts =
                carbonApp.getAppConfig().getApplicationArtifact().getDependencies();

        ArchiveManipulator archiveManipulator = new ArchiveManipulator();

        String repo = axisConfig.getRepository().getPath();

        String artifactPath, destPath;
        for (Artifact.Dependency dep : artifacts) {
            Artifact artifact = dep.getArtifact();
            if (artifact == null) {
                continue;
            }

            String artifactName = artifact.getName();
            if (!isAccepted(artifact.getType())) {
                log.warn("Can't deploy artifact : " + artifactName + " of type : " +
                        artifact.getType() + ". Required features are not installed in the system");
                continue;
            }

            if (MASHUP_TYPE.equals(artifact.getType())) {
                destPath = repo + File.separator + MASHUP_DIR + File.separator + MASHUP_CONTEXT;
            } else {
                continue;
            }

            List<CappFile> files = artifact.getFiles();
            if (files.size() != 1) {
                log.error(
                        "Mashups must have a single file to " + "be deployed. But " + files.size() +
                                " files found.");
                continue;
            }
            String fileName = artifact.getFiles().get(0).getName();
            artifactPath = artifact.getExtractedPath() + File.separator + fileName;
            try {
                archiveManipulator.extract(artifactPath, destPath);
            } catch (IOException e) {
                log.error("Unable to copy the Mashup : " + artifactName, e);
            }

        }
View Full Code Here

Examples of org.wso2.carbon.utils.ArchiveManipulator

     */
    public void undeployArtifacts(CarbonApplication carbonApp, AxisConfiguration axisConfig) {

        List<Artifact.Dependency> artifacts =
                carbonApp.getAppConfig().getApplicationArtifact().getDependencies();
        ArchiveManipulator archiveManipulator = new ArchiveManipulator();

        String repo = axisConfig.getRepository().getPath();
        String artifactPath, destPath;
        for (Artifact.Dependency dep : artifacts) {
            Artifact artifact = dep.getArtifact();
            if (artifact == null) {
                continue;
            }
            if (MashupAppDeployer.MASHUP_TYPE.equals(artifact.getType())) {
                destPath = repo + File.separator + MashupAppDeployer.MASHUP_DIR + File.separator +
                        MashupAppDeployer.MASHUP_CONTEXT;
            } else {
                continue;
            }

            List<CappFile> files = artifact.getFiles();
            if (files.size() != 1) {
                log.error(
                        "A Mashup must have a single file. But " + files.size() + " files found.");
                continue;
            }
            String fileName = artifact.getFiles().get(0).getName();
            artifactPath = artifact.getExtractedPath() + File.separator + fileName;
            File artifactInRepo;
            if (new File(artifactPath).exists()) {
                try {
                    String[] filesInZip = archiveManipulator.check(artifactPath);
                    File jsFile = null;
                    for (String file : filesInZip) {
                        String artifactRepoPath = destPath + File.separator + file;
                        if (file.indexOf("/") == -1) {
                            String extension = file.substring(file.indexOf(".") + 1);
View Full Code Here

Examples of org.wso2.carbon.utils.ArchiveManipulator

        */
       public void undeployArtifacts(CarbonApplication carbonApp, AxisConfiguration axisConfig) {

           List<Artifact.Dependency> artifacts =
                   carbonApp.getAppConfig().getApplicationArtifact().getDependencies();
           ArchiveManipulator archiveManipulator = new ArchiveManipulator();

           String repo = axisConfig.getRepository().getPath();
           String artifactPath, destPath;
           for (Artifact.Dependency dep : artifacts) {
               Artifact artifact = dep.getArtifact();
               if (artifact == null) {
                   continue;
               }
               if (BRSAppDeployer.BRS_TYPE.equals(artifact.getType())) {
                   destPath = repo + File.separator + BRSAppDeployer.BRS_DIR;
               } else {
                   continue;
               }

               List<CappFile> files = artifact.getFiles();
               if (files.size() != 1) {
                   log.error(
                           "A BRS must have a single file. But " + files.size() + " files found.");
                   continue;
               }
               String fileName = artifact.getFiles().get(0).getName();
               artifactPath = artifact.getExtractedPath() + File.separator + fileName;
               File artifactInRepo;
               try {
                   String[] filesInZip = archiveManipulator.check(artifactPath);
                   File jsFile = null;
                   for (String file : filesInZip) {
                       String artifactRepoPath = destPath + File.separator + file;
                       if (file.indexOf("/") == -1) {
                           String extension = file.substring(file.indexOf(".") + 1);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.