Search in sources :

Example 1 with JdbcDataSource

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

the class ProjectUpdater method getPropertiesMap.

private Map<String, String> getPropertiesMap() {
    Map<String, String> propsMap = new HashMap<String, String>();
    ServerSettings serverSettings = workflowProject.getServerSettings();
    JdbcDataSource mdwDataSource = workflowProject.getMdwDataSource();
    propsMap.put("USER_NAME", System.getProperty("user.name"));
    propsMap.put("CONTAINER", serverSettings.getContainerName());
    propsMap.put("CONTAINER_VERSION", serverSettings.getContainerVersion());
    propsMap.put("CONTAINER_HOME", serverSettings.getHomeWithFwdSlashes());
    propsMap.put("NAMING_PROVIDER", serverSettings.getNamingProvider());
    propsMap.put("DATASOURCE_PROVIDER", serverSettings.getDataSourceProvider());
    propsMap.put("JMS_PROVIDER", serverSettings.getJmsProvider());
    propsMap.put("THREADPOOL_PROVIDER", serverSettings.getThreadPoolProvider());
    propsMap.put("MESSENGER", serverSettings.getMessenger());
    propsMap.put("SERVER_ROOT", serverSettings.getServerLocWithFwdSlashes());
    propsMap.put("SERVER_HOST", serverSettings.getHost());
    propsMap.put("SERVER_PORT", String.valueOf(serverSettings.getPort()));
    propsMap.put("SERVER_USER", serverSettings.getUser());
    propsMap.put("SERVER_PASSWORD", serverSettings.getPassword());
    propsMap.put("JAVA_HOME", serverSettings.getJdkHomeWithFwdSlashes());
    propsMap.put("APP_DIR", mdwSettings.getWorkspaceDirectory());
    propsMap.put("APP_NAME", workflowProject.getSourceProjectName());
    propsMap.put("SERVER_APP_SUBDIR", "mdw");
    propsMap.put("MDW_JDBC_URL", mdwDataSource.getJdbcUrl());
    propsMap.put("MDW_DB_USER", mdwDataSource.getDbUser());
    propsMap.put("MDW_DB_PASSWORD", mdwDataSource.getDbPassword());
    propsMap.put("MDW_DB_POOLSIZE", "5");
    propsMap.put("MDW_DB_POOLMAXIDLE", "3");
    propsMap.put("GENERIC_MDW_BUS_TOPIC", "Q.*.ORDEH.MDW.@USER_NAME@");
    propsMap.put("DQNAME_GENERIC_MDW_BUS_TOPIC", "LOCAL_ORDEH_MDW_@USER_NAME@");
    propsMap.put("GENERIC_MDW_LISTENER_COUNT", "1");
    propsMap.put("GENERIC_MDW_BUS_URI", "rvd://239.75.2.3:7523/denvzd.qwest.net:7523");
    propsMap.put("DEFAULT_BUS_URI", "rvd://239.75.2.3:7523/denvzd.qwest.net:7523");
    propsMap.put("LDAP_HOST", "ldapt.dev.qintra.com");
    propsMap.put("MDW_HUB_URL", serverSettings.getUrlBase() + "/MDWHub");
    propsMap.put("SERVICES_URL", serverSettings.getUrlBase() + "/" + workflowProject.getMdwWebProjectName());
    propsMap.put("REPORTS_URL", serverSettings.getUrlBase() + "/MDWReports");
    propsMap.put("HELPERS_URL", serverSettings.getUrlBase() + "/" + workflowProject.getMdwWebProjectName());
    propsMap.put("TASK_MANAGER_URL", serverSettings.getUrlBase() + "/" + workflowProject.getTaskManagerWebProjectName());
    propsMap.put("WORKFLOW_SNAPSHOT_IMAGE_URL", serverSettings.getUrlBase() + "/" + workflowProject.getDesignerWebProjectName() + "/servlet/imageServlet");
    propsMap.put("ATTACHMENTS_STORAGE_LOCATION", "C:/temp/");
    propsMap.put("MANAGED_SERVER_LIST", "localhost:8181");
    return propsMap;
}
Also used : HashMap(java.util.HashMap) ServerSettings(com.centurylink.mdw.plugin.project.model.ServerSettings) JdbcDataSource(com.centurylink.mdw.plugin.project.model.JdbcDataSource)

Example 2 with JdbcDataSource

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

the class DataSourcePage method getStatuses.

/**
 * @see WizardPage#getStatuses()
 */
@Override
public IStatus[] getStatuses() {
    if (isPageComplete())
        return null;
    JdbcDataSource dataSource = getDataSource();
    String msg = null;
    if (dataSource != null) {
        if (containsWhitespace(dataSource.getName()))
            msg = "Invalid value for DataSource Name";
        else if (containsWhitespace(dataSource.getDriver()))
            msg = "Invalid value for JDBC Driver";
        else if (containsWhitespace(dataSource.getJdbcUrl()))
            msg = "Invalid value for JDBC URL";
        else if (containsWhitespace(dataSource.getDbUser()))
            msg = "Invalid value for DB User";
        else if (containsWhitespace(dataSource.getDbPassword()))
            msg = "Invalid value for DB Password";
    }
    if (msg == null)
        return null;
    return new IStatus[] { new Status(IStatus.ERROR, getPluginId(), 0, msg, null) };
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) IStatus(org.eclipse.core.runtime.IStatus) JdbcDataSource(com.centurylink.mdw.plugin.project.model.JdbcDataSource)

Example 3 with JdbcDataSource

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

the class ProjectSection method elementChanged.

@Override
public void elementChanged(ElementChangeEvent ece) {
    if (ece.getChangeType().equals(ChangeType.SETTINGS_CHANGE)) {
        if (ece.getNewValue() instanceof JdbcDataSource && jdbcUrlEditor != null) {
            JdbcDataSource dataSource = (JdbcDataSource) ece.getNewValue();
            if (!"projectSection".equals(dataSource.getEntrySource())) {
                // avoid overwriting
                String newJdbcUrl = dataSource.getJdbcUrlWithMaskedCredentials();
                jdbcUrlEditor.setValue(newJdbcUrl);
            }
        } else if (ece.getNewValue() instanceof ServerSettings) {
            ServerSettings serverSettings = (ServerSettings) ece.getNewValue();
            if (!hostEditor.getValue().equals(serverSettings.getHost()))
                hostEditor.setValue(serverSettings.getHost());
            if (!portEditor.getValue().equals(String.valueOf(serverSettings.getPort())))
                portEditor.setValue(serverSettings.getPort());
        } else if (ece.getNewValue() instanceof String) {
            if (!webContextRootEditor.getValue().equals(ece.getNewValue()))
                webContextRootEditor.setValue(ece.getNewValue().toString());
        } else if (ece.getNewValue() instanceof Boolean && !updateServerCacheEditor.getValue().equalsIgnoreCase(ece.getNewValue().toString()))
            updateServerCacheEditor.setValue(ece.getNewValue().toString());
    } else if (ece.getChangeType().equals(ChangeType.VERSION_CHANGE) && project.equals(ece.getElement()) && !mdwVersionEditor.getValue().equals(ece.getNewValue()))
        mdwVersionEditor.setValue(ece.getNewValue().toString());
}
Also used : ServerSettings(com.centurylink.mdw.plugin.project.model.ServerSettings) JdbcDataSource(com.centurylink.mdw.plugin.project.model.JdbcDataSource)

Example 4 with JdbcDataSource

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

the class ProcessExplorerContentProvider method handleElementChange.

private void handleElementChange(ElementChangeEvent ece) {
    if (ece.getChangeType().equals(ChangeType.ELEMENT_CREATE)) {
        Object parent = getParent(ece.getElement());
        if (parent == null) {
            treeViewer.refresh(true);
            ece.getElement().addElementChangeListener(this);
        } else {
            if (parent instanceof WorkflowPackage) {
                try {
                    ((WorkflowPackage) parent).getFolder().refreshLocal(IResource.DEPTH_ONE, null);
                } catch (Exception ex) {
                    PluginMessages.log(ex);
                }
            }
            treeViewer.refresh(parent, true);
        }
        treeViewer.expandToLevel(ece.getElement(), 0);
        treeViewer.setSelection(ece.getElement());
    } else if (ece.getChangeType().equals(ChangeType.ELEMENT_DELETE)) {
        Object parent = getParent(ece.getElement());
        if (parent != null) {
            if (ece.getElement() instanceof ActivityImpl)
                // impl can be associated with
                treeViewer.refresh();
            else
                // multiple packages
                treeViewer.refresh(parent, true);
        } else {
            // must be a workflowProject
            ece.getElement().removeElementChangeListener(this);
            treeViewer.refresh();
        }
    } else if (ece.getChangeType().equals(ChangeType.RENAME)) {
        treeViewer.refresh(ece.getElement(), true);
        treeViewer.getControl().forceFocus();
    } else if (ece.getChangeType().equals(ChangeType.VERSION_CHANGE)) {
        treeViewer.refresh(ece.getElement(), true);
        if (ece.getElement() instanceof WorkflowPackage)
            treeViewer.refresh(ece.getElement().getProject().getArchivedUserVisiblePackagesFolder(), true);
    } else if (ece.getChangeType().equals(ChangeType.LABEL_CHANGE)) {
        treeViewer.update(ece.getElement(), null);
    } else if (ece.getChangeType().equals(ChangeType.SETTINGS_CHANGE)) {
        // only applies for workflow projects
        if (ece.getElement() instanceof WorkflowProject) {
            WorkflowProject workflowProject = (WorkflowProject) ece.getElement();
            if (ece.getNewValue() instanceof JdbcDataSource) {
                treeViewer.collapseToLevel(workflowProject, TreeViewer.ALL_LEVELS);
                treeViewer.refresh(workflowProject, true);
            } else if (ece.getNewValue() == null) {
                // general refresh
                treeViewer.refresh(workflowProject, true);
            }
        } else {
            treeViewer.refresh(ece.getElement(), true);
        }
    } else if (ece.getChangeType().equals(ChangeType.STATUS_CHANGE)) {
        treeViewer.update(ece.getElement(), null);
        if (ece.getElement() instanceof AutomatedTestCase) {
            AutomatedTestCase testCase = (AutomatedTestCase) ece.getElement();
            Object testResults;
            if (testCase.isLegacy())
                testResults = testCase.getLegacyExpectedResults();
            else
                testResults = testCase.getExpectedResults();
            if (testResults != null)
                treeViewer.refresh(testResults, true);
        }
    }
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) ActivityImpl(com.centurylink.mdw.plugin.designer.model.ActivityImpl) JdbcDataSource(com.centurylink.mdw.plugin.project.model.JdbcDataSource) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) AutomatedTestCase(com.centurylink.mdw.plugin.designer.model.AutomatedTestCase) DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) InvocationTargetException(java.lang.reflect.InvocationTargetException) DataUnavailableException(com.centurylink.mdw.designer.DataUnavailableException)

Example 5 with JdbcDataSource

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

the class ProjectUpdater method postFilterProperties.

private void postFilterProperties(IFile mdwPropsFile, IProgressMonitor monitor) {
    if (mdwPropsFile.exists()) {
        String mdwProps = new String(PluginUtil.readFile(mdwPropsFile));
        mdwProps = mdwProps.replaceFirst("MDWFramework\\.ApplicationDetails-@GROUP_SEP@MdwVersion.*", "");
        mdwProps = mdwProps.replaceFirst("MDWFramework\\.ApplicationDetails@GROUP_SEP@EnvironmentName.*", "");
        mdwProps = mdwProps.replaceAll("@GROUP_SEP@", workflowProject.isOsgi() ? "-" : "/");
        mdwProps = mdwProps.replaceFirst("MDWFramework.TaskManagerWeb/dev.tm.gui.user=.*", "MDWFramework.TaskManagerWeb/dev.tm.gui.user=" + System.getProperty("user.name"));
        mdwProps = mdwProps.replaceFirst("mdw.hub.user=.*", "mdw.hub.user=" + System.getProperty("user.name"));
        // db settings
        JdbcDataSource dataSource = workflowProject.getMdwDataSource();
        if (dataSource.getJdbcUrl() != null) {
            mdwProps = mdwProps.replaceFirst("mdw.database.driver=.*", "mdw.database.driver=" + dataSource.getDriver());
            mdwProps = mdwProps.replaceFirst("mdw.database.url=.*", "mdw.database.url=" + dataSource.getJdbcUrl());
            mdwProps = mdwProps.replaceFirst("mdw.database.username=.*", "mdw.database.username=" + dataSource.getDbUser());
            mdwProps = mdwProps.replaceFirst("mdw.database.password=.*", "mdw.database.password=" + dataSource.getDbPassword());
        }
        if (workflowProject.isFilePersist()) {
            // also handle case where properties are commented out
            mdwProps = mdwProps.replaceFirst("#?mdw.asset.location=.*", "mdw.asset.location=" + workflowProject.getAssetDir().toString().replace('\\', '/'));
            if (workflowProject.getMdwVcsRepository().hasRemoteRepository()) {
                mdwProps = mdwProps.replaceFirst("#?mdw.git.local.path=.*", "mdw.git.local.path=" + workflowProject.getProjectDir().toString().replace('\\', '/'));
                if (workflowProject.getMdwVcsRepository().getRepositoryUrl() != null)
                    mdwProps = mdwProps.replaceFirst("#?mdw.git.remote.url=.*", "mdw.git.remote.url=" + workflowProject.getMdwVcsRepository().getRepositoryUrl());
            } else {
                mdwProps = mdwProps.replaceFirst("mdw.git.local.path=", "# mdw.git.local.path=");
                mdwProps = mdwProps.replaceFirst("mdw.git.remote.url=", "# mdw.git.remote.url=");
                mdwProps = mdwProps.replaceFirst("mdw.git.branch=", "# mdw.git.branch=");
            }
        } else {
            mdwProps = mdwProps.replaceFirst("mdw.asset.location=", "# mdw.asset.location=");
            mdwProps = mdwProps.replaceFirst("mdw.git.local.path=", "# mdw.git.local.path=");
            mdwProps = mdwProps.replaceFirst("mdw.git.remote.url=", "# mdw.git.remote.url=");
        }
        if (workflowProject.isOsgi()) {
            mdwProps = mdwProps.replaceAll("@@", "~at~@");
            StringBuffer substituted = new StringBuffer(mdwProps.length());
            Pattern tokenPattern = Pattern.compile("(@.*?@)");
            Matcher matcher = tokenPattern.matcher(mdwProps);
            int index = 0;
            while (matcher.find()) {
                String match = matcher.group();
                substituted.append(mdwProps.substring(index, matcher.start()));
                String value = match.substring(1, match.length() - 1);
                substituted.append("${").append(value).append("}");
                index = matcher.end();
            }
            substituted.append(mdwProps.substring(index));
            mdwProps = substituted.toString();
            mdwProps = mdwProps.replaceAll("~at~", "@");
            if (workflowProject.checkRequiredVersion(5, 5)) {
                Map<String, String> values = getPropertiesMap();
                try {
                    mdwProps = ExpressionUtil.substitute(mdwProps, values, true);
                } catch (MDWException ex) {
                    PluginMessages.log(ex);
                }
            }
        }
        PluginUtil.writeFile(mdwPropsFile, mdwProps, monitor);
    }
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) JdbcDataSource(com.centurylink.mdw.plugin.project.model.JdbcDataSource) MDWException(com.centurylink.mdw.common.exception.MDWException)

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