Search in sources :

Example 6 with VcsRepository

use of com.centurylink.mdw.plugin.project.model.VcsRepository in project mdw-designer by CenturyLinkCloud.

the class ProjectPersist method saveProjectPrefs.

/**
 * Preferences may be local to a particular user, so save with workspace
 * prefs
 */
public void saveProjectPrefs(IProject project) {
    ServerSettings serverSettings = workflowProject.getServerSettings();
    try {
        setPersistentProperty(project, MDW_SERVER_HOME, serverSettings.getHome());
        setPersistentProperty(project, MDW_SERVER_JDK_HOME, serverSettings.getJdkHome());
        setPersistentProperty(project, MDW_SERVER_LOCATION, serverSettings.getServerLoc());
        int cmdPort = serverSettings.getCommandPort();
        if (cmdPort != 0)
            setPersistentProperty(project, MDW_SERVER_CMD_PORT, String.valueOf(cmdPort));
        String user = serverSettings.getUser();
        setPersistentProperty(project, MDW_SERVER_USER, user);
        if (user != null) {
            String password = serverSettings.getPassword();
            if (password != null) {
                try {
                    setPersistentProperty(project, MDW_SERVER_PASSWORD, CryptUtil.encrypt(password));
                } catch (GeneralSecurityException ex) {
                    PluginMessages.log(ex);
                }
            }
        }
        if (!workflowProject.isRemote()) {
            // default prefs for server type
            setPersistentProperty(MDW_SERVER_TYPE, serverSettings.getContainerType().toString());
            setPersistentProperty(serverSettings.getContainerType() + "-" + MDW_SERVER_HOME, serverSettings.getHome());
            setPersistentProperty(serverSettings.getContainerType() + "-" + MDW_SERVER_JDK_HOME, serverSettings.getJdkHome());
            setPersistentProperty(serverSettings.getContainerType() + "-" + MDW_SERVER_HOST, serverSettings.getHost());
            setPersistentProperty(serverSettings.getContainerType() + "-" + MDW_SERVER_PORT, String.valueOf(serverSettings.getPort() == 0 ? "" : serverSettings.getPort()));
            setPersistentProperty(serverSettings.getContainerType() + "-" + MDW_SERVER_CMD_PORT, String.valueOf(serverSettings.getCommandPort() == 0 ? "" : serverSettings.getCommandPort()));
            setPersistentProperty(serverSettings.getContainerType() + "-" + MDW_SERVER_USER, serverSettings.getUser());
            setPersistentProperty(serverSettings.getContainerType() + "-" + MDW_SERVER_VERSION, serverSettings.getContainerVersion());
            if (workflowProject.getPersistType() == PersistType.Git) {
                VcsRepository vcsRepo = workflowProject.getMdwVcsRepository();
                setPersistentProperty("MDW" + workflowProject.getMdwVersion() + "-" + MDW_VCS_GIT, vcsRepo.getProvider());
                setPersistentProperty("MDW" + workflowProject.getMdwVersion() + "-" + MDW_VCS_REPO_URL, vcsRepo.getRepositoryUrl());
                setPersistentProperty("MDW" + workflowProject.getMdwVersion() + "-" + MDW_VCS_USER, vcsRepo.getUser());
            }
            JdbcDataSource dataSource = workflowProject.getMdwDataSource();
            setPersistentProperty("MDW" + workflowProject.getMdwVersion() + "-" + MDW_DB_DRIVER, dataSource.getDriver());
            setPersistentProperty("MDW" + workflowProject.getMdwVersion() + "-" + MDW_DB_URL, dataSource.getJdbcUrl());
            setPersistentProperty("MDW" + workflowProject.getMdwVersion() + "-" + MDW_DB_USER, dataSource.getDbUser());
            setPersistentProperty(serverSettings.getContainerType() + "-" + MDW_SERVER_JAVA_OPTS, serverSettings.getJavaOptions());
        }
        if (serverSettings.isDebug()) {
            setPersistentProperty(project, MDW_SERVER_DEBUG, "true");
            setPersistentProperty(project, MDW_SERVER_DEBUG_PORT, String.valueOf(serverSettings.getDebugPort()));
            setPersistentProperty(project, MDW_SERVER_SUSPEND, String.valueOf(serverSettings.isSuspend()));
        } else {
            setPersistentProperty(project, MDW_SERVER_DEBUG, null);
        }
        setPersistentProperty(project, LOG_WATCHER_PORT, String.valueOf(serverSettings.getLogWatcherPort()));
        setPersistentProperty(project, LOG_WATCHER_TIMEOUT, String.valueOf(serverSettings.getLogWatcherTimeout()));
        setPersistentProperty(project, STUB_SERVER_PORT, String.valueOf(serverSettings.getStubServerPort()));
        setPersistentProperty(project, STUB_SERVER_TIMEOUT, String.valueOf(serverSettings.getStubServerTimeout()));
        if (workflowProject.getPersistType() == PersistType.Git) {
            setPersistentProperty(project, MDW_VCS_SYNC_ARCHIVE, String.valueOf(workflowProject.getMdwVcsRepository().isSyncAssetArchive()));
        }
        setPersistentProperty(project, MDW_UPDATE_SERVER_CACHE, String.valueOf(workflowProject.isUpdateServerCache()));
    } catch (CoreException ex) {
        PluginMessages.log(ex);
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) ServerSettings(com.centurylink.mdw.plugin.project.model.ServerSettings) GeneralSecurityException(java.security.GeneralSecurityException) JdbcDataSource(com.centurylink.mdw.plugin.project.model.JdbcDataSource) VcsRepository(com.centurylink.mdw.plugin.project.model.VcsRepository)

Example 7 with VcsRepository

use of com.centurylink.mdw.plugin.project.model.VcsRepository in project mdw-designer by CenturyLinkCloud.

the class ProjectInflator method createGitRepository.

public void createGitRepository(IProgressMonitor monitor) {
    try {
        File localDir = new File(ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile() + "/" + workflowProject.getName());
        Repository newRepo = null;
        if (workflowProject.getMdwVcsRepository().hasRemoteRepository()) {
            monitor.subTask("Cloning Git repository");
            VcsRepository gitRepo = workflowProject.getMdwVcsRepository();
            Git.cloneRepository().setURI(gitRepo.getRepositoryUrlWithCredentials()).setDirectory(localDir).call();
        } else {
            newRepo = new FileRepository(new File(localDir + "/.git"));
            newRepo.create();
        }
        // .gitignore
        Generator generator = new Generator(shell);
        JetAccess jet = getJet("source/.ignorejet", getProject().getSourceProject(), ".gitignore", null);
        generator.createFile(jet, monitor);
    } catch (Exception ex) {
        PluginMessages.uiError(ex, "Create Cloud Project", workflowProject);
    }
}
Also used : FileRepository(org.eclipse.jgit.internal.storage.file.FileRepository) FileRepository(org.eclipse.jgit.internal.storage.file.FileRepository) Repository(org.eclipse.jgit.lib.Repository) VcsRepository(com.centurylink.mdw.plugin.project.model.VcsRepository) JetAccess(com.centurylink.mdw.plugin.codegen.JetAccess) VcsRepository(com.centurylink.mdw.plugin.project.model.VcsRepository) IFile(org.eclipse.core.resources.IFile) File(java.io.File) URISyntaxException(java.net.URISyntaxException) CoreException(org.eclipse.core.runtime.CoreException) IOException(java.io.IOException) ExecutionException(org.eclipse.core.commands.ExecutionException) InvocationTargetException(java.lang.reflect.InvocationTargetException) Generator(com.centurylink.mdw.plugin.codegen.Generator)

Aggregations

VcsRepository (com.centurylink.mdw.plugin.project.model.VcsRepository)7 File (java.io.File)3 IOException (java.io.IOException)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 CoreException (org.eclipse.core.runtime.CoreException)3 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3 VersionControlGit (com.centurylink.mdw.dataaccess.file.VersionControlGit)2 ServerSettings (com.centurylink.mdw.plugin.project.model.ServerSettings)2 IFile (org.eclipse.core.resources.IFile)2 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)2 AuthenticationException (com.centurylink.mdw.auth.AuthenticationException)1 DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)1 TranslationException (com.centurylink.mdw.common.exception.TranslationException)1 DataAccessOfflineException (com.centurylink.mdw.dataaccess.DataAccessOfflineException)1 VersionControl (com.centurylink.mdw.dataaccess.VersionControl)1 VersionControlDummy (com.centurylink.mdw.dataaccess.VersionControlDummy)1 MainFrame (com.centurylink.mdw.designer.MainFrame)1 MdwAuthenticator (com.centurylink.mdw.designer.auth.MdwAuthenticator)1 AppSummary (com.centurylink.mdw.designer.model.AppSummary)1 RestfulServer (com.centurylink.mdw.designer.utils.RestfulServer)1