Package com.eviware.soapui.actions

Source Code of com.eviware.soapui.actions.ImportPackedProject

/*
* Copyright 2004-2014 SmartBear Software
*
* Licensed under the EUPL, Version 1.1 or - as soon as they will be approved by the European Commission - subsequent
* versions of the EUPL (the "Licence");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://ec.europa.eu/idabc/eupl
*
* Unless required by applicable law or agreed to in writing, software distributed under the Licence is
* distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the Licence for the specific language governing permissions and limitations
* under the Licence.
*/
package com.eviware.soapui.actions;

import java.io.File;
import java.util.List;

import com.eviware.soapui.impl.WorkspaceImpl;
import com.eviware.soapui.impl.actions.ImportWsdlProjectAction;
import com.eviware.soapui.integration.exporter.ProjectExporter;
import com.eviware.soapui.support.UISupport;
import com.eviware.soapui.support.action.support.AbstractSoapUIAction;

public class ImportPackedProject extends AbstractSoapUIAction<WorkspaceImpl> {
    public ImportPackedProject() {
        super("Import Packed Project", "Import Packed Project");
    }

    @Override
    public void perform(WorkspaceImpl workspace, Object param) {

        try {

            File target = UISupport.getFileDialogs().open(this, "Select file to unpack project", "zip", "zip",
                    System.getProperty("user.home"));
            if (target == null) {
                return;
            }

            String fileName = target.getAbsolutePath();
            if (fileName == null) {
                return;
            }

            File dest = UISupport.getFileDialogs().saveAsDirectory(this, "Select where to unpack it",
                    new File(System.getProperty("user.home")));

            if (dest.getAbsoluteFile() == null) {
                return;
            }
            ProjectExporter.unpackageAll(fileName, dest.getAbsolutePath());
            List<String> contents = ProjectExporter.getZipContents(fileName);

            for (String fName : dest.list()) {
                if (contents.contains(fName) && fName.endsWith("-soapui-project.xml")) {
                    new ImportWsdlProjectAction().perform(workspace, new File(dest, fName).getAbsoluteFile());
                    break;
                }
            }

        } catch (Exception e1) {
            UISupport.showErrorMessage("Failed to export project; " + e1);
        }

    }

}
TOP

Related Classes of com.eviware.soapui.actions.ImportPackedProject

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.