Search in sources :

Example 1 with AppSummary

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

the class WorkflowProjectManager method makeLocal.

public void makeLocal(WorkflowProject remoteProject) {
    if (remoteProject.getMdwVersion() == null) {
        AppSummary appSummary = remoteProject.getRemoteAppSummary(true);
        if (appSummary != null)
            remoteProject.setMdwVersion(appSummary.getMdwVersion());
    }
    if (remoteProject.getMdwVersion() != null) {
        remoteProject.setRemote(false);
        updateProject(remoteProject);
    }
}
Also used : AppSummary(com.centurylink.mdw.designer.model.AppSummary)

Example 2 with AppSummary

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

the class WorkflowProject method getAuthenticator.

public Authenticator getAuthenticator() {
    if (isGitVcs() && isRemote()) {
        AppSummary appSummary = getRemoteAppSummary(true);
        if (appSummary == null)
            return null;
        String oauthTokenUrl = appSummary.getOAuthTokenUrl();
        if (oauthTokenUrl != null)
            return new OAuthAuthenticator(oauthTokenUrl);
        if ("mdw".equals(appSummary.getAuthMethod())) {
            try {
                return new MdwAuthenticator(appSummary.getAppId(), MdwPlugin.getSettings().getMdwCentralUrl() + "/services/com/centurylink/mdw/central/auth");
            } catch (Exception ex) {
                PluginMessages.uiError(ex, "Authentication", this);
            }
        }
    }
    // https://wiki.eclipse.org/Security:_KeyStore_support_for_Eclipse
    return new ClearTrustAuthenticator();
}
Also used : ClearTrustAuthenticator(com.centurylink.mdw.auth.ClearTrustAuthenticator) OAuthAuthenticator(com.centurylink.mdw.auth.OAuthAuthenticator) MdwAuthenticator(com.centurylink.mdw.designer.auth.MdwAuthenticator) AppSummary(com.centurylink.mdw.designer.model.AppSummary) CoreException(org.eclipse.core.runtime.CoreException) JSONException(org.json.JSONException) GeneralSecurityException(java.security.GeneralSecurityException) IOException(java.io.IOException) MdwSecurityException(com.centurylink.mdw.auth.MdwSecurityException) MalformedURLException(java.net.MalformedURLException)

Example 3 with AppSummary

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

the class WorkflowProject method isWar.

public boolean isWar() {
    if (isRemote()) {
        boolean war = false;
        AppSummary appSummary = getRemoteAppSummary(false);
        if (appSummary != null)
            war = NamingProvider.TOMCAT.equals(appSummary.getContainer());
        return war;
    } else {
        return getServerSettings().isWar();
    }
}
Also used : AppSummary(com.centurylink.mdw.designer.model.AppSummary)

Example 4 with AppSummary

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

the class WorkflowProject method isOsgi.

public boolean isOsgi() {
    if (isRemote()) {
        if (remoteOsgi == null) {
            boolean osgiCheck = false;
            AppSummary appSummary = getRemoteAppSummary(false);
            if (appSummary != null)
                osgiCheck = NamingProvider.OSGI.equals(appSummary.getContainer());
            remoteOsgi = Boolean.valueOf(osgiCheck);
        }
        return remoteOsgi;
    } else {
        return getServerSettings().isOsgi();
    }
}
Also used : AppSummary(com.centurylink.mdw.designer.model.AppSummary)

Example 5 with AppSummary

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

the class WorkflowProject method retrieveRemoteAppSummary.

public void retrieveRemoteAppSummary(final boolean errorDialogOnFailure) {
    Runnable runnable = new Runnable() {

        public void run() {
            // bypass designer proxy to delay lazy loading if project hasn't
            // been opened
            HttpHelper httpHelper;
            String url = getAppSummaryUrl() + "/Services/AppSummary?format=json";
            try {
                httpHelper = new HttpHelper(new URL(url));
                httpHelper.setConnectTimeout(MdwPlugin.getSettings().getHttpConnectTimeout());
                httpHelper.setReadTimeout(MdwPlugin.getSettings().getHttpReadTimeout());
                remoteAppSummary = new AppSummary(new JSONObject(httpHelper.get()));
            } catch (JSONException ex) {
                try {
                    url = getAppSummaryUrl() + "/Services/GetAppSummary";
                    httpHelper = new HttpHelper(new URL(url));
                    httpHelper.setConnectTimeout(MdwPlugin.getSettings().getHttpConnectTimeout());
                    httpHelper.setReadTimeout(MdwPlugin.getSettings().getHttpReadTimeout());
                    String response = httpHelper.get();
                    if (response != null && (response.trim().startsWith("<xs:MDWStatusMessage") || response.trim().startsWith("<bpm:MDWStatusMessage"))) {
                        MDWStatusMessageDocument msgDoc = MDWStatusMessageDocument.Factory.parse(response, Compatibility.namespaceOptions());
                        throw new IOException("Server error: " + msgDoc.getMDWStatusMessage().getStatusMessage());
                    }
                    ApplicationSummary docAppSummary = ApplicationSummaryDocument.Factory.parse(response, Compatibility.namespaceOptions()).getApplicationSummary();
                    remoteAppSummary = new AppSummary();
                    remoteAppSummary.setAppId(docAppSummary.getApplicationName());
                    remoteAppSummary.setMdwVersion(docAppSummary.getMdwVersion());
                    remoteAppSummary.setMdwBuild(docAppSummary.getBuild());
                    remoteAppSummary.setMdwHubUrl(docAppSummary.getMdwHubUrl());
                    remoteAppSummary.setServicesUrl(docAppSummary.getServicesUrl());
                    if (docAppSummary.getRepository() != null) {
                        Repository repo = new Repository();
                        remoteAppSummary.setRepository(repo);
                        repo.setBranch(docAppSummary.getRepository().getBranch());
                        repo.setCommit(docAppSummary.getRepository().getCommit());
                        repo.setProvider(docAppSummary.getRepository().getProvider());
                        repo.setUrl(docAppSummary.getRepository().getUrl());
                    }
                    DbInfo dbInfo = new DbInfo();
                    remoteAppSummary.setDbInfo(dbInfo);
                    dbInfo.setJdbcUrl(docAppSummary.getDbInfo().getJdbcUrl());
                    dbInfo.setUser(docAppSummary.getDbInfo().getUser());
                } catch (IOException e) {
                    PluginMessages.log(ex);
                    if (errorDialogOnFailure)
                        MessageDialog.openError(MdwPlugin.getShell(), "Authentication", "Server appears to be offline: " + e.getMessage());
                } catch (Exception e) {
                    PluginMessages.log(e);
                    if (errorDialogOnFailure)
                        PluginMessages.uiError(e, "Remote App Summary", WorkflowProject.this);
                }
            } catch (IOException ex) {
                PluginMessages.log(ex);
                if (errorDialogOnFailure)
                    MessageDialog.openError(MdwPlugin.getShell(), "Authentication", "Server appears to be offline: " + ex.getMessage());
            } catch (Exception ex) {
                PluginMessages.log(ex);
                if (errorDialogOnFailure)
                    PluginMessages.uiError(ex, "Remote App Summary", WorkflowProject.this);
            }
        }
    };
    if (MdwPlugin.isUiThread())
        BusyIndicator.showWhile(MdwPlugin.getDisplay(), runnable);
    else
        runnable.run();
}
Also used : JSONException(org.json.JSONException) IOException(java.io.IOException) ApplicationSummary(com.centurylink.mdw.service.ApplicationSummaryDocument.ApplicationSummary) URL(java.net.URL) CoreException(org.eclipse.core.runtime.CoreException) JSONException(org.json.JSONException) GeneralSecurityException(java.security.GeneralSecurityException) IOException(java.io.IOException) MdwSecurityException(com.centurylink.mdw.auth.MdwSecurityException) MalformedURLException(java.net.MalformedURLException) Repository(com.centurylink.mdw.designer.model.Repository) JSONObject(org.json.JSONObject) MDWStatusMessageDocument(com.centurylink.mdw.bpm.MDWStatusMessageDocument) AppSummary(com.centurylink.mdw.designer.model.AppSummary) DesignerHttpHelper(com.centurylink.mdw.designer.utils.DesignerHttpHelper) HttpHelper(com.centurylink.mdw.common.utilities.HttpHelper) DbInfo(com.centurylink.mdw.designer.model.DbInfo)

Aggregations

AppSummary (com.centurylink.mdw.designer.model.AppSummary)8 IOException (java.io.IOException)5 JSONException (org.json.JSONException)5 MdwSecurityException (com.centurylink.mdw.auth.MdwSecurityException)3 MalformedURLException (java.net.MalformedURLException)3 URL (java.net.URL)3 GeneralSecurityException (java.security.GeneralSecurityException)3 CoreException (org.eclipse.core.runtime.CoreException)3 JSONObject (org.json.JSONObject)3 HttpHelper (com.centurylink.mdw.common.utilities.HttpHelper)2 MdwAuthenticator (com.centurylink.mdw.designer.auth.MdwAuthenticator)2 RestfulServer (com.centurylink.mdw.designer.utils.RestfulServer)2 AuthenticationException (com.centurylink.mdw.auth.AuthenticationException)1 ClearTrustAuthenticator (com.centurylink.mdw.auth.ClearTrustAuthenticator)1 OAuthAuthenticator (com.centurylink.mdw.auth.OAuthAuthenticator)1 MDWStatusMessageDocument (com.centurylink.mdw.bpm.MDWStatusMessageDocument)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