Search in sources :

Example 6 with DesignerDataAccess

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

the class ProcessExplorerActionGroup method refreshRolePermissions.

private void refreshRolePermissions(WorkflowProject project) throws NamingException, RemoteException, DataAccessException {
    DesignerDataAccess dao = project.getDesignerDataAccess();
    boolean isVCS = project.isFilePersist();
    String user = project.getUser().getUsername();
    if (!dao.isRolesRefreshed() && isVCS) {
        DesignerDataAccess localDao = new DesignerDataAccess(restServer, null, user, null, project.isOldNamespaces(), isVCS);
        DesignerDataModel model = project.getDesignerDataModel();
        model.reloadRoleNames(localDao);
        model.reloadPriviledges(localDao, user);
        model.reloadGroups(localDao);
        dao.setRolesRefreshed(localDao.isRolesRefreshed());
    }
}
Also used : DesignerDataAccess(com.centurylink.mdw.designer.DesignerDataAccess) DesignerDataModel(com.centurylink.mdw.designer.display.DesignerDataModel)

Example 7 with DesignerDataAccess

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

the class LogWatcher method handleLogMessage.

private synchronized void handleLogMessage(String message) {
    Matcher matcher = pattern.matcher(message);
    if (matcher.matches()) {
        String time = matcher.group(1);
        final Long procId = new Long(matcher.group(2));
        final Long procInstId = new Long(matcher.group(3));
        String subtype = matcher.group(4);
        String id = matcher.group(5);
        String msg = matcher.group(6);
        try {
            ProcessInstanceVO processInstanceInfo = processInstances.get(procInstId);
            if (processInstanceInfo == null) {
                processInstanceInfo = new DesignerDataAccess(dataAccess).getProcessInstanceBase(procInstId, null);
                // only interested in one masterRequestId
                if (processInstanceInfo.getMasterRequestId().equals(masterRequestId))
                    processInstances.put(procInstId, processInstanceInfo);
            }
            if (!processInstanceInfo.getMasterRequestId().equals(masterRequestId))
                return;
            // log the message
            outputStream.println(message);
            if (watchProcess) {
                openInstance(processInstanceInfo);
                synchronized (this) {
                    ProcessInstancePage processInstancePage = processInstancePages.get(processInstanceInfo.getId());
                    accumulated.offer(new ProcessInstanceUpdater(procId, procInstId, processInstancePage, subtype, time, id, msg));
                }
            }
            if (msg.startsWith(WorkStatus.LOGMSG_PROC_COMPLETE) && procId.equals(process.getId()))
                scheduleShutdown = true;
        } catch (Exception ex) {
            PluginMessages.log(ex);
            shutdown();
        }
    }
}
Also used : Matcher(java.util.regex.Matcher) ProcessInstancePage(com.centurylink.mdw.designer.runtime.ProcessInstancePage) DesignerDataAccess(com.centurylink.mdw.designer.DesignerDataAccess) ProcessInstanceVO(com.centurylink.mdw.model.value.process.ProcessInstanceVO) IOException(java.io.IOException)

Example 8 with DesignerDataAccess

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

the class LogWatcher method startup.

public void startup(boolean watchProcess) {
    this.watchProcess = watchProcess;
    if (logListener != null)
        // already started
        return;
    pattern = Pattern.compile(MESSAGE_REG_EX, Pattern.DOTALL);
    processInstancePages = new HashMap<Long, ProcessInstancePage>();
    processInstances = new HashMap<Long, ProcessInstanceVO>();
    accumulated = new LinkedList<ProcessInstanceUpdater>();
    scheduleShutdown = false;
    MessageConsole console = MessageConsole.findConsole("Live View Log", icon, display);
    console.setRunnableEntity(this);
    console.setDefaultShowPref(true);
    console.setStatus(MessageConsole.STATUS_RUNNING);
    console.clearConsole();
    outputStream = console.newMessageStream();
    try {
        dataAccess = new DesignerDataAccess(process.getProject().getDesignerProxy().getDesignerDataAccess());
        logListener = new LogSubscriberSocket(dataAccess, serverSettings.getLogWatcherPort(), process.getProject().isOldNamespaces()) {

            protected void handleMessage(String message) {
                handleLogMessage(message);
            }
        };
        logListener.start(true);
        new Thread(new Runnable() {

            public void run() {
                processQueue();
            }
        }).start();
    } catch (Exception ex) {
        if (outputStream != null)
            ex.printStackTrace(new PrintStream(outputStream));
        if (logListener != null && !logListener.isClosed()) {
            logListener.shutdown();
            logListener = null;
        }
        PluginMessages.uiError(ex, "Monitor Logs", process.getProject());
    }
}
Also used : PrintStream(java.io.PrintStream) MessageConsole(com.centurylink.mdw.plugin.MessageConsole) IOException(java.io.IOException) LogSubscriberSocket(com.centurylink.mdw.designer.runtime.LogSubscriberSocket) ProcessInstancePage(com.centurylink.mdw.designer.runtime.ProcessInstancePage) DesignerDataAccess(com.centurylink.mdw.designer.DesignerDataAccess) ProcessInstanceVO(com.centurylink.mdw.model.value.process.ProcessInstanceVO)

Example 9 with DesignerDataAccess

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

the class ImageServletHelper method generateImageForTaskInstance.

/**
 * Generate a process image from the designer server.
 */
public BufferedImage generateImageForTaskInstance(Long pTaskInstId) throws ServletException {
    try {
        DesignerDataAccess dao = new DesignerDataAccess(new Server(), null, onServer);
        ProcessInstanceVO pi = dao.getCauseForTaskInstance(pTaskInstId);
        if (pi == null) {
            throw new ServletException("Failed to locate the ProcessInstance for TaskInstanceId:" + pTaskInstId);
        }
        return generateImage(pi, dao);
    } catch (Exception ex) {
        log(ex);
        throw new ServletException(ex);
    }
}
Also used : ServletException(javax.servlet.ServletException) Server(com.centurylink.mdw.designer.utils.Server) DesignerDataAccess(com.centurylink.mdw.designer.DesignerDataAccess) ProcessInstanceVO(com.centurylink.mdw.model.value.process.ProcessInstanceVO) ServletException(javax.servlet.ServletException)

Example 10 with DesignerDataAccess

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

the class WorkflowProject method getMdwVersion.

/**
 * Also populates appVersion to avoid two server calls if first one fails.
 * Does not attempt to populate if not initialized (ie not expanded in proc
 * exp view).
 */
public String getMdwVersion() {
    if (isRemote() && mdwVersion == null && designerProxy != null) {
        mdwVersion = "Unknown";
        appVersion = "Unknown";
        AppSummary appSummary = getRemoteAppSummary(false);
        if (appSummary != null && appSummary.getMdwVersion() != null) {
            mdwVersion = appSummary.getMdwVersion();
            appVersion = appSummary.getAppVersion();
            try {
                // force parse (triggering exception for unparseable -- eg:
                // @mdw.version@)
                MdwVersion vers = new MdwVersion(mdwVersion);
                vers.getMajorVersion();
                vers.getMinorVersion();
                vers.getBuildId();
            } catch (Exception ex) {
                mdwVersion = "Unknown";
                PluginMessages.log(ex);
            }
        } else {
            if (isFilePersist()) {
                // minimum supported version (TODO:
                mdwVersion = "5.5";
            // future versions)
            } else {
                // server may not be running -- infer version from db
                // structure
                String jdbcUrl = getMdwDataSource().getJdbcUrlWithCredentials();
                if (jdbcUrl != null) {
                    try {
                        // don't initialize designerProxy just to infer
                        // version from db
                        RestfulServer server = new RestfulServer(jdbcUrl, getUser().getUsername(), getServiceUrl());
                        DesignerDataAccess dao = new DesignerDataAccess(server, new ArrayList<Server>(), getUser().getUsername());
                        int dbSchemaVersion = dao.getDatabaseSchemaVersion();
                        int major = dbSchemaVersion / 1000;
                        int minor = dbSchemaVersion % 1000;
                        mdwVersion = major + "." + minor;
                    } catch (Exception ex) {
                        // dataAccessFailed
                        PluginMessages.log(ex);
                    }
                }
            }
        }
    }
    return mdwVersion;
}
Also used : Server(com.centurylink.mdw.designer.utils.Server) RestfulServer(com.centurylink.mdw.designer.utils.RestfulServer) RestfulServer(com.centurylink.mdw.designer.utils.RestfulServer) DesignerDataAccess(com.centurylink.mdw.designer.DesignerDataAccess) 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)

Aggregations

DesignerDataAccess (com.centurylink.mdw.designer.DesignerDataAccess)15 IOException (java.io.IOException)10 ProcessInstanceVO (com.centurylink.mdw.model.value.process.ProcessInstanceVO)6 Server (com.centurylink.mdw.designer.utils.Server)5 JSONException (org.json.JSONException)5 ProcessVO (com.centurylink.mdw.model.value.process.ProcessVO)4 HashMap (java.util.HashMap)4 AuthenticationException (com.centurylink.mdw.auth.AuthenticationException)3 DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)3 TranslationException (com.centurylink.mdw.common.exception.TranslationException)3 DataAccessOfflineException (com.centurylink.mdw.dataaccess.DataAccessOfflineException)3 RestfulServer (com.centurylink.mdw.designer.utils.RestfulServer)3 ValidationException (com.centurylink.mdw.designer.utils.ValidationException)3 File (java.io.File)3 FileNotFoundException (java.io.FileNotFoundException)3 VersionControl (com.centurylink.mdw.dataaccess.VersionControl)2 ProcessInstancePage (com.centurylink.mdw.designer.runtime.ProcessInstancePage)2 RuleSetVO (com.centurylink.mdw.model.value.attribute.RuleSetVO)2 ProcessList (com.centurylink.mdw.model.value.process.ProcessList)2 RemoteException (java.rmi.RemoteException)2