Search in sources :

Example 11 with JdbcDataSource

use of com.centurylink.mdw.plugin.project.model.JdbcDataSource 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)

Aggregations

JdbcDataSource (com.centurylink.mdw.plugin.project.model.JdbcDataSource)11 GridData (org.eclipse.swt.layout.GridData)4 Label (org.eclipse.swt.widgets.Label)4 ServerSettings (com.centurylink.mdw.plugin.project.model.ServerSettings)3 ModifyEvent (org.eclipse.swt.events.ModifyEvent)3 ModifyListener (org.eclipse.swt.events.ModifyListener)3 Text (org.eclipse.swt.widgets.Text)3 MDWException (com.centurylink.mdw.common.exception.MDWException)1 DataAccessOfflineException (com.centurylink.mdw.dataaccess.DataAccessOfflineException)1 DataUnavailableException (com.centurylink.mdw.designer.DataUnavailableException)1 ActivityImpl (com.centurylink.mdw.plugin.designer.model.ActivityImpl)1 AutomatedTestCase (com.centurylink.mdw.plugin.designer.model.AutomatedTestCase)1 WorkflowPackage (com.centurylink.mdw.plugin.designer.model.WorkflowPackage)1 VcsRepository (com.centurylink.mdw.plugin.project.model.VcsRepository)1 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 GeneralSecurityException (java.security.GeneralSecurityException)1 HashMap (java.util.HashMap)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1