Example usage for org.apache.commons.io FileUtils copyDirectory

List of usage examples for org.apache.commons.io FileUtils copyDirectory

Introduction

In this page you can find the example usage for org.apache.commons.io FileUtils copyDirectory.

Prototype

public static void copyDirectory(File srcDir, File destDir) throws IOException 

Source Link

Document

Copies a whole directory to a new location preserving the file dates.

Usage

From source file:com.liferay.sync.engine.service.SyncAccountService.java

public static void updateSyncAccountSyncFile(Path targetFilePath, long syncAccountId, boolean moveFile)
        throws Exception {

    SyncAccount syncAccount = fetchSyncAccount(syncAccountId);

    if (!moveFile) {
        SyncFile syncFile = SyncFileService.fetchSyncFile(syncAccount.getFilePathName());

        if (!FileKeyUtil.hasFileKey(targetFilePath, syncFile.getSyncFileId())) {

            throw new Exception("Target folder is not the moved sync data folder");
        }/*from  ww w . j  a  v  a  2s.  c o m*/
    }

    syncAccount.setActive(false);

    update(syncAccount);

    boolean resetFileKeys = false;

    if (moveFile) {
        Path sourceFilePath = Paths.get(syncAccount.getFilePathName());

        try {
            FileUtil.moveFile(sourceFilePath, targetFilePath, false);
        } catch (Exception e1) {
            try {
                FileUtils.copyDirectory(sourceFilePath.toFile(), targetFilePath.toFile());

                FileUtil.deleteFile(sourceFilePath);

                resetFileKeys = true;
            } catch (Exception e2) {
                syncAccount.setActive(true);

                update(syncAccount);

                throw e2;
            }
        }
    }

    syncAccount = setFilePathName(syncAccountId, targetFilePath.toString());

    if (resetFileKeys) {
        FileKeyUtil.writeFileKeys(targetFilePath);
    }

    syncAccount.setActive(true);
    syncAccount.setUiEvent(SyncAccount.UI_EVENT_NONE);

    update(syncAccount);
}

From source file:com.taobao.android.builder.tasks.library.ResMerger.java

public void mergeRes() {
    List<MergeResources> mergeResources = TaskQueryHelper.findTask(project, MergeResources.class);
    for (MergeResources task : mergeResources) {
        if (task.getName().equals("packageDebugResources")
                || task.getName().equals("packageReleaseResources")) {
            task.doLast(new Action<Task>() {
                @Override/*from   ww w.  j av a  2  s.c  o m*/
                public void execute(Task task) {
                    try {
                        MergeResources task2 = (MergeResources) task;
                        FileUtils.deleteDirectory(task2.getOutputDir());
                        File srcFile = task2.getInputResourceSets().get(0).getSourceFiles().get(0);
                        FileUtils.copyDirectory(srcFile, task2.getOutputDir());
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            });
        }
    }
}

From source file:com.taobao.android.builder.tools.cache.SimpleLocalCache.java

@Override
public void cacheFile(String type, String key, File file) throws FileCacheException {
    if (StringUtils.isEmpty(key)) {
        throw new FileCacheException("cache key is empty ");
    }/*from w ww .  j  a  v  a 2 s  .  com*/
    File cacheFile = getLocalCacheFile(type, key);
    if (cacheFile.exists()) {
        throw new FileCacheException("file cache alerady exist:" + cacheFile.getAbsolutePath());
    }

    try {

        cacheFile.getParentFile().mkdirs();

        if (file.isFile()) {
            FileUtils.copyFile(file, cacheFile);
        } else {

            cacheFile.mkdirs();

            FileLockUtils.lock(cacheFile, new Runnable() {
                @Override
                public void run() {
                    try {
                        FileUtils.copyDirectory(file, cacheFile);
                    } catch (Throwable e) {
                        try {
                            FileUtils.forceDelete(cacheFile);
                        } catch (IOException e1) {
                            e1.printStackTrace();
                        }
                        throw new RuntimeException(e.getMessage(), e);
                    }
                }
            });
        }
    } catch (Throwable e) {
        throw new FileCacheException(e.getMessage(), e);
    }

}

From source file:com.cisco.ca.cstg.pdi.services.ConfigurationServiceImpl.java

@Override
public void cloneProject(Integer sourceProjectId, Integer newProjectId)
        throws IOException, IllegalStateException, JAXBException, DocumentException {
    LOGGER.info("Cloning project id {} to new project id {}", sourceProjectId, newProjectId);
    XmlGenProjectDetails pd = (XmlGenProjectDetails) findById(XmlGenProjectDetails.class, sourceProjectId);

    if (pd != null) {
        Map<String, Object> status = processUcsPdiConfiguration(pd);
        String sourceDataPath = Util
                .getPdiConfDataFolderPath(projectDetailsService.fetchProjectDetails(sourceProjectId));
        String destDataPath = Util
                .getPdiConfDataFolderPath(projectDetailsService.fetchProjectDetails(newProjectId));

        if (status.get(CONF_CREATION).equals(true)) {
            try {
                FileUtils.copyDirectory(new File(sourceDataPath), new File(destDataPath));
                LOGGER.debug("Copied directory from {} to {}", sourceDataPath, destDataPath);

                synchronized (this) {
                    unmarshalUcsXml.unmarshalMetatData(
                            destDataPath + File.separator + Constants.PDI_META_DATA_FILE_NAME, newProjectId);
                    deleteRecords(Toproot.class);
                    unmarshalUcsXml.unmarshalTopRootElement(
                            destDataPath + File.separator + Constants.PDI_CONFIG_FILE_NAME);
                    LOGGER.info("Unmarshalled data to UCS tables successfully.");
                    String errorMessage = executeStoredProcedure(PROC_NAME_FOR_UCS_ADA, newProjectId);
                    if (errorMessage != null && !errorMessage.isEmpty()) {
                        throw new HibernateException(errorMessage);
                    }//from  w w w .  j av a2s. co m
                    LOGGER.info("Stored Procedure for translating data to ADA tables executed successfully.");
                    unmarshalUcsXml.unmarshalMetatDataMO(
                            destDataPath + File.separator + Constants.PDI_META_DATA_FILE_NAME, newProjectId);

                    // step: call the store procedure to save Chassis count
                    errorMessage = executeStoredProcedure(PROC_NAME_FOR_CHASSIS_COUNT, newProjectId);
                    if (errorMessage != null && !errorMessage.isEmpty()) {
                        throw new HibernateException(errorMessage);
                    }
                }
            } catch (IOException | HibernateException | JAXBException e) {
                LOGGER.error("Error occured while trying to clone the project.", e);
                throw e;
            }
        } else {
            LOGGER.error("Error while generating XML for the source project");
            throw new IllegalStateException("Error while generating XML from source project");
        }
    }
}

From source file:com.constellio.app.services.appManagement.AppManagementService.java

private void copyCurrentPlugins(File oldPluginsFolder, File newWebAppFolder) throws CannotSaveOldPlugins {
    if (oldPluginsFolder.exists()) {
        try {/*from  w w  w.  jav  a 2 s.c o m*/
            LOGGER.info("plugins : copy to " + newWebAppFolder);
            LOGGER.info("plugins : copy from ", oldPluginsFolder.getPath() + "to "
                    + foldersLocator.getPluginsJarsFolder(newWebAppFolder).getPath());
            FileUtils.copyDirectory(oldPluginsFolder, foldersLocator.getPluginsJarsFolder(newWebAppFolder));
        } catch (IOException e) {
            throw new CannotSaveOldPlugins(e);
        }
    }
}

From source file:com.litt.core.security.license.gui.CustomerPanel.java

public CustomerPanel() {
    GridBagLayout gridBagLayout = new GridBagLayout();
    gridBagLayout.columnWidths = new int[] { 0, 0, 0, 0 };
    gridBagLayout.rowHeights = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
    gridBagLayout.columnWeights = new double[] { 0.0, 1.0, 0.0, Double.MIN_VALUE };
    gridBagLayout.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0 };
    setLayout(gridBagLayout);//from  w w w .  ja v a2 s  .com

    JLabel lblProduct = new JLabel("\u4EA7\u54C1\uFF1A");
    GridBagConstraints gbc_lblProduct = new GridBagConstraints();
    gbc_lblProduct.insets = new Insets(0, 0, 5, 5);
    gbc_lblProduct.anchor = GridBagConstraints.EAST;
    gbc_lblProduct.gridx = 0;
    gbc_lblProduct.gridy = 0;
    add(lblProduct, gbc_lblProduct);

    comboBoxProduct = new JComboBox();
    GridBagConstraints gbc_comboBoxProduct = new GridBagConstraints();
    gbc_comboBoxProduct.insets = new Insets(0, 0, 5, 5);
    gbc_comboBoxProduct.fill = GridBagConstraints.HORIZONTAL;
    gbc_comboBoxProduct.gridx = 1;
    gbc_comboBoxProduct.gridy = 0;
    add(comboBoxProduct, gbc_comboBoxProduct);

    JButton btnRefresh = new JButton("");
    btnRefresh.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            initProduct();
        }
    });
    btnRefresh.setIcon(new ImageIcon(CustomerPanel.class.getResource("/images/icon_refresh.png")));
    GridBagConstraints gbc_btnRefresh = new GridBagConstraints();
    gbc_btnRefresh.insets = new Insets(0, 0, 5, 0);
    gbc_btnRefresh.gridx = 2;
    gbc_btnRefresh.gridy = 0;
    add(btnRefresh, gbc_btnRefresh);

    JLabel lblProductVersion = new JLabel("\u4EA7\u54C1\u7248\u672C\uFF1A");
    GridBagConstraints gbc_lblProductVersion = new GridBagConstraints();
    gbc_lblProductVersion.anchor = GridBagConstraints.EAST;
    gbc_lblProductVersion.insets = new Insets(0, 0, 5, 5);
    gbc_lblProductVersion.gridx = 0;
    gbc_lblProductVersion.gridy = 1;
    add(lblProductVersion, gbc_lblProductVersion);

    textFieldProductVersion = new VersionTextField();
    textFieldProductVersion.setColumns(10);
    GridBagConstraints gbc_textFieldProductVersion = new GridBagConstraints();
    gbc_textFieldProductVersion.anchor = GridBagConstraints.WEST;
    gbc_textFieldProductVersion.insets = new Insets(0, 0, 5, 5);
    gbc_textFieldProductVersion.gridx = 1;
    gbc_textFieldProductVersion.gridy = 1;
    add(textFieldProductVersion, gbc_textFieldProductVersion);

    JLabel lblCompanyName = new JLabel("\u516C\u53F8\u540D\u79F0\uFF1A");
    GridBagConstraints gbc_lblCompanyName = new GridBagConstraints();
    gbc_lblCompanyName.anchor = GridBagConstraints.EAST;
    gbc_lblCompanyName.insets = new Insets(0, 0, 5, 5);
    gbc_lblCompanyName.gridx = 0;
    gbc_lblCompanyName.gridy = 2;
    add(lblCompanyName, gbc_lblCompanyName);

    textFieldCompanyName = new JTextField();
    GridBagConstraints gbc_textFieldCompanyName = new GridBagConstraints();
    gbc_textFieldCompanyName.insets = new Insets(0, 0, 5, 5);
    gbc_textFieldCompanyName.fill = GridBagConstraints.HORIZONTAL;
    gbc_textFieldCompanyName.gridx = 1;
    gbc_textFieldCompanyName.gridy = 2;
    add(textFieldCompanyName, gbc_textFieldCompanyName);
    textFieldCompanyName.setColumns(10);

    JLabel lblCustomerCode = new JLabel("\u5BA2\u6237\u7F16\u53F7\uFF1A");
    GridBagConstraints gbc_lblCustomerCode = new GridBagConstraints();
    gbc_lblCustomerCode.anchor = GridBagConstraints.EAST;
    gbc_lblCustomerCode.insets = new Insets(0, 0, 5, 5);
    gbc_lblCustomerCode.gridx = 0;
    gbc_lblCustomerCode.gridy = 3;
    add(lblCustomerCode, gbc_lblCustomerCode);

    textFieldCustomerCode = new JTextField();
    GridBagConstraints gbc_textFieldCustomerCode = new GridBagConstraints();
    gbc_textFieldCustomerCode.insets = new Insets(0, 0, 5, 5);
    gbc_textFieldCustomerCode.fill = GridBagConstraints.HORIZONTAL;
    gbc_textFieldCustomerCode.gridx = 1;
    gbc_textFieldCustomerCode.gridy = 3;
    add(textFieldCustomerCode, gbc_textFieldCustomerCode);
    textFieldCustomerCode.setColumns(10);

    JLabel lblCustomerName = new JLabel("\u5BA2\u6237\u540D\u79F0\uFF1A");
    GridBagConstraints gbc_lblCustomerName = new GridBagConstraints();
    gbc_lblCustomerName.anchor = GridBagConstraints.EAST;
    gbc_lblCustomerName.insets = new Insets(0, 0, 5, 5);
    gbc_lblCustomerName.gridx = 0;
    gbc_lblCustomerName.gridy = 4;
    add(lblCustomerName, gbc_lblCustomerName);

    textFieldCustomerName = new JTextField();
    GridBagConstraints gbc_textFieldCustomerName = new GridBagConstraints();
    gbc_textFieldCustomerName.insets = new Insets(0, 0, 5, 5);
    gbc_textFieldCustomerName.fill = GridBagConstraints.HORIZONTAL;
    gbc_textFieldCustomerName.gridx = 1;
    gbc_textFieldCustomerName.gridy = 4;
    add(textFieldCustomerName, gbc_textFieldCustomerName);
    textFieldCustomerName.setColumns(10);

    JLabel lblLicenseType = new JLabel("\u8BC1\u4E66\u7C7B\u578B\uFF1A");
    GridBagConstraints gbc_lblLicenseType = new GridBagConstraints();
    gbc_lblLicenseType.anchor = GridBagConstraints.EAST;
    gbc_lblLicenseType.insets = new Insets(0, 0, 5, 5);
    gbc_lblLicenseType.gridx = 0;
    gbc_lblLicenseType.gridy = 5;
    add(lblLicenseType, gbc_lblLicenseType);

    comboBoxLicenseType = new JComboBox();
    GridBagConstraints gbc_comboBoxLicenseType = new GridBagConstraints();
    gbc_comboBoxLicenseType.insets = new Insets(0, 0, 5, 5);
    gbc_comboBoxLicenseType.fill = GridBagConstraints.HORIZONTAL;
    gbc_comboBoxLicenseType.gridx = 1;
    gbc_comboBoxLicenseType.gridy = 5;
    add(comboBoxLicenseType, gbc_comboBoxLicenseType);

    JLabel lblExpiredDate = new JLabel("\u8FC7\u671F\u65F6\u95F4\uFF1A");
    GridBagConstraints gbc_lblExpiredDate = new GridBagConstraints();
    gbc_lblExpiredDate.insets = new Insets(0, 0, 5, 5);
    gbc_lblExpiredDate.gridx = 0;
    gbc_lblExpiredDate.gridy = 6;
    add(lblExpiredDate, gbc_lblExpiredDate);

    datePickerExpiredDate = new DatePicker(new Date(), "yyyy-MM-dd", null, null);
    GridBagConstraints gbc_datePicker = new GridBagConstraints();
    gbc_datePicker.anchor = GridBagConstraints.WEST;
    gbc_datePicker.insets = new Insets(0, 0, 5, 5);
    gbc_datePicker.gridx = 1;
    gbc_datePicker.gridy = 6;
    add(datePickerExpiredDate, gbc_datePicker);

    JButton btnSave = new JButton("\u4FDD\u5B58");
    btnSave.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                //????????
                if (comboBoxProduct.getSelectedIndex() <= 0) {
                    JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), "??");
                    return;
                }
                String[] array = StringUtils.split(comboBoxProduct.getSelectedItem().toString(), '-');
                String productCode = array[0];
                String productName = array[1];
                String customerCode = textFieldCustomerCode.getText();

                //??
                File configFile = ResourceUtils.getFile(Gui.HOME_PATH + File.separator + "config.xml");
                Document document = XmlUtils.readXml(configFile);
                Element customerNode = (Element) document.selectSingleNode(
                        "//product[@code='" + productCode + "']/customer[@code='" + customerCode + "']");
                if (customerNode != null) {
                    JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),
                            "???");
                    return;
                }

                String licenseId = new RandomGUID().toString();
                String licenseType = Utility.splitStringAll(comboBoxLicenseType.getSelectedItem().toString(),
                        " - ")[0];
                String companyName = textFieldCompanyName.getText();
                String customerName = textFieldCustomerName.getText();
                String version = textFieldProductVersion.getText();
                Date expiredDate = Utility.parseDate(datePickerExpiredDate.getText());

                License license = new License();
                license.setLicenseId(licenseId);
                license.setLicenseType(licenseType);
                license.setProductName(productName);
                license.setCompanyName(companyName);
                license.setCustomerName(customerName);
                license.setVersion(Version.parseVersion(version));
                license.setCreateDate(new Date());
                license.setExpiredDate(expiredDate);

                LicenseService service = new LicenseService();
                String productPath = Gui.HOME_PATH + File.separator + productCode;
                File licenseDir = new File(productPath, customerCode);
                if (!licenseDir.exists()) {
                    licenseDir.mkdir();
                    //?
                    FileUtils.copyFileToDirectory(new File(productPath, "license.key"), licenseDir);
                }
                File priKeyFile = new File(Gui.HOME_PATH + File.separator + productCode, "private.key");
                File licenseFile = new File(licenseDir, "license.xml");

                service.save(Gui.HOME_PATH, productCode, customerCode, license, priKeyFile, licenseFile);

                //??zip?
                File customerPath = licenseFile.getParentFile();
                //???license?????
                File licensePath = new File(customerPath.getParent(), "license");
                if (!licensePath.exists() && !licensePath.isDirectory()) {
                    licensePath.mkdir();
                } else {
                    FileUtils.cleanDirectory(licensePath);
                }

                //?
                FileUtils.copyDirectory(customerPath, licensePath);

                String currentTime = FormatDateTime.formatDateTimeNum(new Date());
                ZipUtils.zip(licensePath,
                        new File(licensePath.getParentFile(), customerCode + "-" + currentTime + ".zip"));
                //license
                FileUtils.deleteDirectory(licensePath);

                JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), "??");
            } catch (Exception e1) {
                e1.printStackTrace();
                JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), e1.getMessage());
            }

        }
    });
    GridBagConstraints gbc_btnSave = new GridBagConstraints();
    gbc_btnSave.insets = new Insets(0, 0, 5, 5);
    gbc_btnSave.gridx = 1;
    gbc_btnSave.gridy = 7;
    add(btnSave, gbc_btnSave);

    //??
    initData();
}

From source file:com.att.aro.ui.view.MainFrame.java

@SuppressWarnings("deprecation")
private void createVideoOptimizerFolder() {
    File aroFolder = new File(Util.getAroLibrary());
    String videoOptimizerFolder = Util.getVideoOptimizerLibrary() + System.getProperty("file.separator");
    File videoOptimizerConfigFile = new File(videoOptimizerFolder + "config.properties");
    if (aroFolder.exists() && videoOptimizerConfigFile.length() == 0) {
        try {//from   ww w . ja  va2  s  .c o  m
            FileUtils.copyDirectory(new File(Util.getAroLibrary()), new File(Util.getVideoOptimizerLibrary()));
        } catch (IOException e) {
            log.error("Failed to copy file to VOLibrary", e);
        }
    }
}

From source file:com.github.hexocraft.worldrestorer.WorldRestorerApi.java

private static boolean copyWorldFolder(File sourceFolder, File destinationFolder) {
    try {// w w w.j av  a 2s  .  c o  m
        FileUtils.copyDirectory(sourceFolder, destinationFolder);
    } catch (IOException e) {
        WarningPrefixedMessage.toConsole(WorldRestorer.instance, prefix,
                "Failed to copy folder " + sourceFolder.getName() + " to " + destinationFolder.getName());
        return false;
    }

    // Remove the uid.dat file if exist
    File uidFile = new File(destinationFolder, "uid.dat");
    if (uidFile.exists() && !FileUtils.deleteQuietly(uidFile)) {
        WarningPrefixedMessage.toConsole(WorldRestorer.instance, prefix,
                "Failed to delete uid.dat file from world " + destinationFolder.getName());
        return false;
    }
    // Remove the session.lock file if exist
    File sessionFile = new File(destinationFolder, "session.lock");
    if (sessionFile.exists() && !FileUtils.deleteQuietly(sessionFile)) {
        WarningPrefixedMessage.toConsole(WorldRestorer.instance, prefix,
                "Failed to delete session.lock file from world " + destinationFolder.getName());
        return false;
    }
    // Remove the worldSettings file if exist
    File worldSettingsFile = new File(destinationFolder, worldSettings);
    if (worldSettingsFile.exists() && !FileUtils.deleteQuietly(worldSettingsFile)) {
        WarningPrefixedMessage.toConsole(WorldRestorer.instance, prefix,
                "Failed to delete " + worldSettings + " file from world " + destinationFolder.getName() + ".");
        return false;
    }

    return true;
}

From source file:com.taobao.android.builder.tasks.app.merge.MergeResV4Dir.java

private void moveFiles(File root) throws IOException {
    if (null == root || !root.exists()) {
        return;/* w  w  w .j  a  v  a 2s  . c o  m*/
    }

    File[] files = root.listFiles();
    for (File tmp : files) {

        if (tmp.isDirectory() && tmp.getName().startsWith("drawable-") && tmp.getName().endsWith("dpi")) {
            File toDir = new File(root, tmp.getName() + "-v4");
            toDir.mkdirs();

            FileUtils.copyDirectory(tmp, toDir);
            FileUtils.deleteDirectory(tmp);
        }
    }
}

From source file:com.liferay.ide.project.core.PluginsSDKProjectProvider.java

@Override
public IStatus createNewProject(NewLiferayPluginProjectOp op, IProgressMonitor monitor) throws CoreException {
    ElementList<ProjectName> projectNames = op.getProjectNames();

    final PluginType pluginType = op.getPluginType().content(true);
    final String originalProjectName = op.getProjectName().content();
    final String pluginTypeSuffix = NewLiferayPluginProjectOpMethods.getPluginTypeSuffix(pluginType);

    String fixedProjectName = originalProjectName;

    if (originalProjectName.endsWith(pluginTypeSuffix)) {
        fixedProjectName = originalProjectName.substring(0,
                originalProjectName.length() - pluginTypeSuffix.length());
    }/* w  ww .  ja  v  a 2s.  c o  m*/

    final String projectName = fixedProjectName;

    final String displayName = op.getDisplayName().content(true);
    final boolean separateJRE = true;

    SDK sdk = getSDK(op);

    // workingDir should always be the directory of the type of plugin /sdk/portlets/ for a portlet, etc
    String workingDir = null;

    ArrayList<String> arguments = new ArrayList<String>();
    arguments.add(projectName);
    arguments.add(displayName);

    final boolean hasGradleTools = SDKUtil.hasGradleTools(sdk.getLocation());

    IPath newSDKProjectPath = null;

    switch (pluginType) {
    case servicebuilder:
        op.setPortletFramework("mvc");
    case portlet:
        final String frameworkName = NewLiferayPluginProjectOpMethods.getFrameworkName(op);

        workingDir = sdk.getLocation().append(ISDKConstants.PORTLET_PLUGIN_PROJECT_FOLDER).toOSString();

        if (hasGradleTools) {
            arguments.add(frameworkName);

            sdk.createNewProject(projectName, arguments, "portlet", workingDir, monitor);
        } else {
            newSDKProjectPath = sdk.createNewPortletProject(projectName, displayName, frameworkName,
                    separateJRE, workingDir, null, monitor);
        }

        break;

    case hook:
        workingDir = sdk.getLocation().append(ISDKConstants.HOOK_PLUGIN_PROJECT_FOLDER).toOSString();

        if (hasGradleTools) {
            sdk.createNewProject(projectName, arguments, "hook", workingDir, monitor);
        } else {
            newSDKProjectPath = sdk.createNewHookProject(projectName, displayName, separateJRE, workingDir,
                    null, monitor);
        }

        break;

    case ext:
        workingDir = sdk.getLocation().append(ISDKConstants.EXT_PLUGIN_PROJECT_FOLDER).toOSString();

        if (hasGradleTools) {
            sdk.createNewProject(projectName, arguments, "ext", workingDir, monitor);
        } else {
            newSDKProjectPath = sdk.createNewExtProject(projectName, displayName, separateJRE, workingDir, null,
                    monitor);
        }

        break;

    case layouttpl:
        workingDir = sdk.getLocation().append(ISDKConstants.LAYOUTTPL_PLUGIN_PROJECT_FOLDER).toOSString();

        if (hasGradleTools) {
            sdk.createNewProject(projectName, arguments, "layouttpl", workingDir, monitor);
        } else {
            newSDKProjectPath = sdk.createNewLayoutTplProject(projectName, displayName, separateJRE, workingDir,
                    null, monitor);
        }

        break;

    case theme:
        workingDir = sdk.getLocation().append(ISDKConstants.THEME_PLUGIN_PROJECT_FOLDER).toOSString();

        if (hasGradleTools) {
            sdk.createNewProject(projectName, arguments, "theme", workingDir, monitor);
        } else {
            newSDKProjectPath = sdk.createNewThemeProject(projectName, displayName, separateJRE, workingDir,
                    null, monitor);
        }

        break;

    case web:
        workingDir = sdk.getLocation().append(ISDKConstants.WEB_PLUGIN_PROJECT_FOLDER).toOSString();

        if (hasGradleTools) {
            sdk.createNewProject(projectName, arguments, "web", workingDir, monitor);
        } else {
            newSDKProjectPath = sdk.createNewWebProject(projectName, displayName, separateJRE, workingDir, null,
                    monitor);
        }

        break;
    }

    NewLiferayPluginProjectOpMethods.updateLocation(op);

    final Path projectLocation = op.getLocation().content();

    if (!hasGradleTools) {
        final File projectDir = projectLocation.toFile();

        final File projectParent = projectDir.getParentFile();

        projectParent.mkdirs();

        final File newSDKProjectDir = newSDKProjectPath.toFile();

        try {
            FileUtils.copyDirectory(newSDKProjectDir, projectParent);

            FileUtils.deleteDirectory(newSDKProjectDir);
        } catch (IOException e) {
            throw new CoreException(ProjectCore.createErrorStatus(e));
        }
    }

    final ProjectRecord projectRecord = ProjectUtil.getProjectRecordForDir(projectLocation.toOSString());

    final IProject newProject = ProjectImportUtil.importProject(projectRecord.getProjectLocation(), monitor,
            op);

    newProject.open(monitor);

    // need to update project name incase the suffix was not correct
    op.setFinalProjectName(newProject.getName());

    projectNames.insert().setName(op.getFinalProjectName().content());

    projectCreated(newProject);

    switch (op.getPluginType().content()) {
    case portlet:

        portletProjectCreated(op, newProject, monitor);

        break;

    case servicebuilder:

        PortalBundle bundle = ServerUtil.getPortalBundle(newProject);
        serviceBuilderProjectCreated(op, bundle.getVersion(), newProject, monitor);

        break;
    case theme:

        themeProjectCreated(newProject);

        break;
    default:
        break;
    }

    return Status.OK_STATUS;

}