Search in sources :

Example 1 with VcsArchiver

use of com.centurylink.mdw.dataaccess.file.VcsArchiver in project mdw-designer by CenturyLinkCloud.

the class ImportPackageWizard method unzipToLocal.

void unzipToLocal(WorkflowProject wfp, java.io.File zipFile, java.io.File tempDir, java.io.File assetDir, List<WorkflowPackage> importedPackages, ProgressMonitor progressMonitor) throws IOException, DataAccessException, CoreException, JSONException {
    VersionControl vcs = new VersionControlGit();
    vcs.connect(null, null, null, wfp.getAssetDir());
    progressMonitor.subTask("Archive existing assets...");
    VcsArchiver archiver = new VcsArchiver(assetDir, tempDir, vcs, progressMonitor);
    archiver.backup();
    PluginMessages.log("Unzipping " + zipFile + " into: " + assetDir);
    ZipHelper.unzip(zipFile, assetDir, null, null, true);
    archiver.archive();
    ZipHelper.unzip(zipFile, tempDir, null, null, true);
    wfp.getSourceProject().refreshLocal(2, null);
    java.io.File explodedDir = new java.io.File(tempDir + "/com");
    if (explodedDir.isDirectory()) {
        List<java.io.File> fileList = FileHelper.getFilesRecursive(explodedDir, "package.json", new ArrayList<java.io.File>());
        for (java.io.File file : fileList) {
            WorkflowPackage workflowPackage = new WorkflowPackage();
            workflowPackage.setProject(wfp);
            workflowPackage.setPackageVO(new PackageVO(new JSONObject(FileHelper.getFileContents(file.getPath()))));
            importedPackages.add(workflowPackage);
        }
        FileHelper.deleteRecursive(explodedDir);
    }
}
Also used : VcsArchiver(com.centurylink.mdw.dataaccess.file.VcsArchiver) VersionControlGit(com.centurylink.mdw.dataaccess.file.VersionControlGit) WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) PackageVO(com.centurylink.mdw.model.value.process.PackageVO) JSONObject(org.json.JSONObject) VersionControl(com.centurylink.mdw.dataaccess.VersionControl) File(com.centurylink.mdw.plugin.designer.model.File)

Aggregations

VersionControl (com.centurylink.mdw.dataaccess.VersionControl)1 VcsArchiver (com.centurylink.mdw.dataaccess.file.VcsArchiver)1 VersionControlGit (com.centurylink.mdw.dataaccess.file.VersionControlGit)1 PackageVO (com.centurylink.mdw.model.value.process.PackageVO)1 File (com.centurylink.mdw.plugin.designer.model.File)1 WorkflowPackage (com.centurylink.mdw.plugin.designer.model.WorkflowPackage)1 JSONObject (org.json.JSONObject)1