Search in sources :

Example 56 with Transaction

use of com.twinsoft.convertigo.beans.core.Transaction in project convertigo by convertigo.

the class ReferencesView method handleCallStepselection.

private void handleCallStepselection(Object firstElement) {
    try {
        ProjectExplorerView projectExplorerView = ConvertigoPlugin.getDefault().getProjectExplorerView();
        StepTreeObject stepTreeObject = (StepTreeObject) firstElement;
        Step step = stepTreeObject.getObject();
        RootNode root = new RootNode();
        if (step instanceof TransactionStep) {
            TransactionStep transactionStep = (TransactionStep) step;
            String transactionStepName = transactionStep.getName();
            TransactionStepNode transactionStepNode = new TransactionStepNode(root, transactionStepName, transactionStep);
            RequiresNode requiresNode = new RequiresNode(transactionStepNode, "Requires");
            String transactionName = transactionStep.getTransactionName();
            String connectorName = transactionStep.getConnectorName();
            String projectName = transactionStep.getProjectName();
            Project project = getProject(projectName, projectExplorerView);
            ProjectNode projectNode = new ProjectNode(requiresNode, projectName, project);
            Connector connector = null;
            Transaction transaction = null;
            try {
                if (project != null) {
                    connector = project.getConnectorByName(connectorName);
                    if (connector != null) {
                        transaction = connector.getTransactionByName(transactionName);
                    }
                }
            } catch (EngineException e) {
                connector = null;
                transaction = null;
            }
            ConnectorNode connectorNode = getConnectorNode(projectNode, connector);
            if (connectorNode == null)
                connectorNode = new ConnectorNode(projectNode, connectorName, connector);
            projectNode.addChild(connectorNode);
            TransactionNode transactionNode = new TransactionNode(projectNode, transactionName, transaction);
            connectorNode.addChild(transactionNode);
            requiresNode.addChild(projectNode);
            transactionStepNode.addChild(requiresNode);
            root.addChild(transactionStepNode);
        } else if (step instanceof SequenceStep) {
            SequenceStep sequenceStep = (SequenceStep) step;
            String sequenceStepName = sequenceStep.getName();
            SequenceStepNode sequenceStepNode = new SequenceStepNode(root, sequenceStepName, sequenceStep);
            RequiresNode requiresNode = new RequiresNode(sequenceStepNode, "Requires");
            String sequenceName = sequenceStep.getSequenceName();
            String projectName = sequenceStep.getProjectName();
            Project project = getProject(projectName, projectExplorerView);
            ProjectNode projectNode = new ProjectNode(requiresNode, projectName, project);
            Sequence sequence = null;
            try {
                if (project != null)
                    sequence = project.getSequenceByName(sequenceName);
            } catch (EngineException e) {
                sequence = null;
            }
            projectNode.addChild(new SequenceNode(projectNode, sequenceName, sequence));
            requiresNode.addChild(projectNode);
            sequenceStepNode.addChild(requiresNode);
            root.addChild(sequenceStepNode);
        } else {
            root.addChild(new InformationNode(root, "References are not handled for this object"));
            treeViewer.setInput(root);
        }
        treeViewer.setInput(root);
        treeViewer.expandAll();
    } catch (Exception e) {
        ConvertigoPlugin.logException(e, "Error while analyzing the projects hierarchy", true);
    }
}
Also used : RootNode(com.twinsoft.convertigo.eclipse.views.references.model.RootNode) HtmlConnector(com.twinsoft.convertigo.beans.connectors.HtmlConnector) JavelinConnector(com.twinsoft.convertigo.beans.connectors.JavelinConnector) HttpConnector(com.twinsoft.convertigo.beans.connectors.HttpConnector) ProxyHttpConnector(com.twinsoft.convertigo.beans.connectors.ProxyHttpConnector) Connector(com.twinsoft.convertigo.beans.core.Connector) CicsConnector(com.twinsoft.convertigo.beans.connectors.CicsConnector) SiteClipperConnector(com.twinsoft.convertigo.beans.connectors.SiteClipperConnector) SqlConnector(com.twinsoft.convertigo.beans.connectors.SqlConnector) SequenceStep(com.twinsoft.convertigo.beans.steps.SequenceStep) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) StepTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.StepTreeObject) EngineException(com.twinsoft.convertigo.engine.EngineException) Step(com.twinsoft.convertigo.beans.core.Step) ElseStep(com.twinsoft.convertigo.beans.steps.ElseStep) RequestableStep(com.twinsoft.convertigo.beans.core.RequestableStep) ThenStep(com.twinsoft.convertigo.beans.steps.ThenStep) SequenceStep(com.twinsoft.convertigo.beans.steps.SequenceStep) BranchStep(com.twinsoft.convertigo.beans.steps.BranchStep) XMLComplexStep(com.twinsoft.convertigo.beans.steps.XMLComplexStep) BlockStep(com.twinsoft.convertigo.beans.steps.BlockStep) TransactionStep(com.twinsoft.convertigo.beans.steps.TransactionStep) Sequence(com.twinsoft.convertigo.beans.core.Sequence) SequenceStepNode(com.twinsoft.convertigo.eclipse.views.references.model.SequenceStepNode) ConnectorNode(com.twinsoft.convertigo.eclipse.views.references.model.ConnectorNode) SiteClipperConnectorNode(com.twinsoft.convertigo.eclipse.views.references.model.SiteClipperConnectorNode) HtmlConnectorNode(com.twinsoft.convertigo.eclipse.views.references.model.HtmlConnectorNode) JavelinConnectorNode(com.twinsoft.convertigo.eclipse.views.references.model.JavelinConnectorNode) CicsConnectorNode(com.twinsoft.convertigo.eclipse.views.references.model.CicsConnectorNode) SqlConnectorNode(com.twinsoft.convertigo.eclipse.views.references.model.SqlConnectorNode) ProxyHttpConnectorNode(com.twinsoft.convertigo.eclipse.views.references.model.ProxyHttpConnectorNode) HttpConnectorNode(com.twinsoft.convertigo.eclipse.views.references.model.HttpConnectorNode) SequenceNode(com.twinsoft.convertigo.eclipse.views.references.model.SequenceNode) EngineException(com.twinsoft.convertigo.engine.EngineException) TransactionStep(com.twinsoft.convertigo.beans.steps.TransactionStep) Project(com.twinsoft.convertigo.beans.core.Project) TransactionStepNode(com.twinsoft.convertigo.eclipse.views.references.model.TransactionStepNode) Transaction(com.twinsoft.convertigo.beans.core.Transaction) HtmlTransaction(com.twinsoft.convertigo.beans.transactions.HtmlTransaction) JavelinTransaction(com.twinsoft.convertigo.beans.transactions.JavelinTransaction) RequiresNode(com.twinsoft.convertigo.eclipse.views.references.model.RequiresNode) TransactionNode(com.twinsoft.convertigo.eclipse.views.references.model.TransactionNode) InformationNode(com.twinsoft.convertigo.eclipse.views.references.model.InformationNode) ProjectNode(com.twinsoft.convertigo.eclipse.views.references.model.ProjectNode)

Example 57 with Transaction

use of com.twinsoft.convertigo.beans.core.Transaction in project convertigo by convertigo.

the class ReferencesView method getUsedRequestables.

private void getUsedRequestables(Step step, Project projectSelected, AbstractParentNode parentNode) {
    try {
        if (step instanceof SequenceStep) {
            SequenceStep sequenceStep = (SequenceStep) step;
            String sourceProjectName = sequenceStep.getProjectName();
            if (sourceProjectName.equals(projectSelected.getName())) {
                Sequence sourceSequence = null;
                String sourceSequenceName = sequenceStep.getSequenceName();
                try {
                    if (projectSelected != null)
                        sourceSequence = projectSelected.getSequenceByName(sourceSequenceName);
                } catch (EngineException e) {
                    sourceSequence = null;
                }
                SequenceStepNode sequenceStepNode = new SequenceStepNode(parentNode, step.getName() + " -> " + sequenceStep.getSourceSequence(), sourceSequence);
                parentNode.addChild(sequenceStepNode);
            }
        } else if (step instanceof TransactionStep) {
            TransactionStep transactionStep = (TransactionStep) step;
            String sourceProjectName = transactionStep.getProjectName();
            if (sourceProjectName.equals(projectSelected.getName())) {
                Transaction sourceTransaction = null;
                Connector connectorSelected = projectSelected.getConnectorByName(transactionStep.getConnectorName());
                try {
                    if (connectorSelected != null)
                        sourceTransaction = connectorSelected.getTransactionByName(transactionStep.getTransactionName());
                } catch (Exception e) {
                    sourceTransaction = null;
                }
                TransactionStepNode transactionStepNode = new TransactionStepNode(parentNode, step.getName() + " -> " + ((TransactionStep) step).getSourceTransaction(), sourceTransaction);
                parentNode.addChild(transactionStepNode);
            }
        } else if (isStepContainer(step)) {
            List<Step> steps = getStepList(step);
            if (steps != null) {
                for (Step s : steps) {
                    getUsedRequestables(s, projectSelected, parentNode);
                }
            }
        }
    } catch (EngineException e) {
        ConvertigoPlugin.logException(e, "Unable to load the project", true);
    }
}
Also used : TransactionStep(com.twinsoft.convertigo.beans.steps.TransactionStep) HtmlConnector(com.twinsoft.convertigo.beans.connectors.HtmlConnector) JavelinConnector(com.twinsoft.convertigo.beans.connectors.JavelinConnector) HttpConnector(com.twinsoft.convertigo.beans.connectors.HttpConnector) ProxyHttpConnector(com.twinsoft.convertigo.beans.connectors.ProxyHttpConnector) Connector(com.twinsoft.convertigo.beans.core.Connector) CicsConnector(com.twinsoft.convertigo.beans.connectors.CicsConnector) SiteClipperConnector(com.twinsoft.convertigo.beans.connectors.SiteClipperConnector) SqlConnector(com.twinsoft.convertigo.beans.connectors.SqlConnector) SequenceStep(com.twinsoft.convertigo.beans.steps.SequenceStep) Transaction(com.twinsoft.convertigo.beans.core.Transaction) HtmlTransaction(com.twinsoft.convertigo.beans.transactions.HtmlTransaction) JavelinTransaction(com.twinsoft.convertigo.beans.transactions.JavelinTransaction) TransactionStepNode(com.twinsoft.convertigo.eclipse.views.references.model.TransactionStepNode) EngineException(com.twinsoft.convertigo.engine.EngineException) Sequence(com.twinsoft.convertigo.beans.core.Sequence) Step(com.twinsoft.convertigo.beans.core.Step) ElseStep(com.twinsoft.convertigo.beans.steps.ElseStep) RequestableStep(com.twinsoft.convertigo.beans.core.RequestableStep) ThenStep(com.twinsoft.convertigo.beans.steps.ThenStep) SequenceStep(com.twinsoft.convertigo.beans.steps.SequenceStep) BranchStep(com.twinsoft.convertigo.beans.steps.BranchStep) XMLComplexStep(com.twinsoft.convertigo.beans.steps.XMLComplexStep) BlockStep(com.twinsoft.convertigo.beans.steps.BlockStep) TransactionStep(com.twinsoft.convertigo.beans.steps.TransactionStep) SequenceStepNode(com.twinsoft.convertigo.eclipse.views.references.model.SequenceStepNode) EngineException(com.twinsoft.convertigo.engine.EngineException)

Example 58 with Transaction

use of com.twinsoft.convertigo.beans.core.Transaction in project convertigo by convertigo.

the class ReferencesView method handleTargetRequestable.

private void handleTargetRequestable(String targetRequestableName, ProjectExplorerView projectExplorerView, RequiresNode requiresNode) throws EngineException {
    StringTokenizer st = new StringTokenizer(targetRequestableName, ".");
    int count = st.countTokens();
    String projectName = st.nextToken();
    Project project = getProject(projectName, projectExplorerView);
    if (project != null) {
        ProjectNode requiresProjectNode = new ProjectNode(requiresNode, projectName, project);
        if (count == 2) {
            String sequenceName = count == 2 ? st.nextToken() : "";
            Sequence sequence = project.getSequenceByName(sequenceName);
            SequenceNode sequenceNode = new SequenceNode(requiresProjectNode, sequenceName, sequence);
            requiresProjectNode.addChild(sequenceNode);
        } else if (count == 3) {
            String connectorName = count == 3 ? st.nextToken() : "";
            Connector connector = project.getConnectorByName(connectorName);
            ConnectorNode connectorNode = new ConnectorNode(requiresProjectNode, connectorName, connector);
            requiresProjectNode.addChild(connectorNode);
            String transactionName = count == 3 ? st.nextToken() : "";
            Transaction transaction = connector.getTransactionByName(transactionName);
            TransactionNode transactionNode = new TransactionNode(connectorNode, transactionName, transaction);
            connectorNode.addChild(transactionNode);
        }
        if (requiresProjectNode.hasChildren()) {
            requiresNode.addChild(requiresProjectNode);
        }
    }
}
Also used : Project(com.twinsoft.convertigo.beans.core.Project) HtmlConnector(com.twinsoft.convertigo.beans.connectors.HtmlConnector) JavelinConnector(com.twinsoft.convertigo.beans.connectors.JavelinConnector) HttpConnector(com.twinsoft.convertigo.beans.connectors.HttpConnector) ProxyHttpConnector(com.twinsoft.convertigo.beans.connectors.ProxyHttpConnector) Connector(com.twinsoft.convertigo.beans.core.Connector) CicsConnector(com.twinsoft.convertigo.beans.connectors.CicsConnector) SiteClipperConnector(com.twinsoft.convertigo.beans.connectors.SiteClipperConnector) SqlConnector(com.twinsoft.convertigo.beans.connectors.SqlConnector) StringTokenizer(java.util.StringTokenizer) Transaction(com.twinsoft.convertigo.beans.core.Transaction) HtmlTransaction(com.twinsoft.convertigo.beans.transactions.HtmlTransaction) JavelinTransaction(com.twinsoft.convertigo.beans.transactions.JavelinTransaction) TransactionNode(com.twinsoft.convertigo.eclipse.views.references.model.TransactionNode) ProjectNode(com.twinsoft.convertigo.eclipse.views.references.model.ProjectNode) Sequence(com.twinsoft.convertigo.beans.core.Sequence) SequenceNode(com.twinsoft.convertigo.eclipse.views.references.model.SequenceNode) ConnectorNode(com.twinsoft.convertigo.eclipse.views.references.model.ConnectorNode) SiteClipperConnectorNode(com.twinsoft.convertigo.eclipse.views.references.model.SiteClipperConnectorNode) HtmlConnectorNode(com.twinsoft.convertigo.eclipse.views.references.model.HtmlConnectorNode) JavelinConnectorNode(com.twinsoft.convertigo.eclipse.views.references.model.JavelinConnectorNode) CicsConnectorNode(com.twinsoft.convertigo.eclipse.views.references.model.CicsConnectorNode) SqlConnectorNode(com.twinsoft.convertigo.eclipse.views.references.model.SqlConnectorNode) ProxyHttpConnectorNode(com.twinsoft.convertigo.eclipse.views.references.model.ProxyHttpConnectorNode) HttpConnectorNode(com.twinsoft.convertigo.eclipse.views.references.model.HttpConnectorNode)

Example 59 with Transaction

use of com.twinsoft.convertigo.beans.core.Transaction in project convertigo by convertigo.

the class XmlSchemaBuilder method preBuildSchema.

private void preBuildSchema() throws EngineException {
    try {
        schema.setElementFormDefault(new XmlSchemaForm(project.getSchemaElementForm().name()));
        schema.setAttributeFormDefault(new XmlSchemaForm(project.getSchemaElementForm().name()));
        ConvertigoError.addXmlSchemaObjects(schema);
        EngineStatistics.addXmlSchemaObjects(schema);
        // static and read-only generation : references, transactions, sequences declaration
        new WalkHelper() {

            @Override
            protected void walk(DatabaseObject databaseObject) throws Exception {
                if (databaseObject instanceof ISchemaGenerator) {
                    // generate itself and add to the caller list
                    if (databaseObject instanceof ISchemaImportGenerator) {
                        // Import case
                        if (databaseObject instanceof ProjectSchemaReference) {
                        // done further in buildSchema
                        } else {
                            XmlSchemaImport schemaImport = ((ISchemaImportGenerator) databaseObject).getXmlSchemaObject(collection, schema);
                            if (schemaImport != null) {
                                SchemaMeta.setXmlSchemaObject(schema, databaseObject, schemaImport);
                                XmlSchemaUtils.add(schema, schemaImport);
                            }
                        }
                    } else if (databaseObject instanceof ISchemaIncludeGenerator) {
                        // Include case
                        if (databaseObject instanceof Transaction) {
                            XmlSchemaInclude schemaInclude = ((ISchemaIncludeGenerator) databaseObject).getXmlSchemaObject(collection, schema);
                            addSchemaIncludeObjects(databaseObject, schemaInclude.getSchema());
                        } else {
                            XmlSchemaInclude schemaInclude = ((ISchemaIncludeGenerator) databaseObject).getXmlSchemaObject(collection, schema);
                            SchemaMeta.setXmlSchemaObject(schema, databaseObject, schemaInclude);
                            XmlSchemaUtils.add(schema, schemaInclude);
                        }
                    } else if (databaseObject instanceof Sequence) {
                        // Sequence case
                        XmlSchemaElement element = ((Sequence) databaseObject).getXmlSchemaObject(collection, schema);
                        SchemaMeta.setXmlSchemaObject(schema, databaseObject, element);
                        XmlSchemaUtils.add(schema, element);
                    }
                } else {
                    // doesn't generate schema, just deep walk
                    super.walk(databaseObject);
                }
            }

            @Override
            protected boolean before(DatabaseObject databaseObject, Class<? extends DatabaseObject> dboClass) {
                // just walk references, transactions, sequences declaration
                return Step.class.isAssignableFrom(dboClass) || Transaction.class.isAssignableFrom(dboClass) || Sequence.class.isAssignableFrom(dboClass) || Reference.class.isAssignableFrom(dboClass) || Connector.class.isAssignableFrom(dboClass);
            }

            protected void addSchemaIncludeObjects(DatabaseObject databaseObject, XmlSchema xmlSchema) {
                if (xmlSchema != null) {
                    XmlSchemaObjectCollection c = xmlSchema.getItems();
                    Iterator<XmlSchemaObject> it = GenericUtils.cast(c.getIterator());
                    while (it.hasNext()) {
                        XmlSchemaObject xmlSchemaObject = it.next();
                        SchemaMeta.getReferencedDatabaseObjects(xmlSchemaObject).add(databaseObject);
                        if (xmlSchemaObject instanceof XmlSchemaImport) {
                        // ignore
                        } else if (xmlSchemaObject instanceof XmlSchemaInclude) {
                            XmlSchemaInclude schemaInclude = (XmlSchemaInclude) xmlSchemaObject;
                            addSchemaIncludeObjects(databaseObject, schemaInclude.getSchema());
                        } else if (xmlSchemaObject instanceof XmlSchemaAttribute) {
                            XmlSchemaAttribute attribute = (XmlSchemaAttribute) xmlSchemaObject;
                            if (schema.getAttributes().getItem(attribute.getQName()) == null) {
                                schema.getAttributes().add(attribute.getQName(), attribute);
                                schema.getItems().add(attribute);
                            }
                        } else if (xmlSchemaObject instanceof XmlSchemaAttributeGroup) {
                            XmlSchemaAttributeGroup attributeGroup = (XmlSchemaAttributeGroup) xmlSchemaObject;
                            if (schema.getAttributeGroups().getItem(attributeGroup.getName()) == null) {
                                schema.getAttributeGroups().add(attributeGroup.getName(), attributeGroup);
                                schema.getItems().add(attributeGroup);
                            }
                        } else if (xmlSchemaObject instanceof XmlSchemaGroup) {
                            XmlSchemaGroup group = (XmlSchemaGroup) xmlSchemaObject;
                            if (schema.getGroups().getItem(group.getName()) == null) {
                                schema.getGroups().add(group.getName(), group);
                                schema.getItems().add(group);
                            }
                        } else if (xmlSchemaObject instanceof XmlSchemaElement) {
                            XmlSchemaElement element = (XmlSchemaElement) xmlSchemaObject;
                            if (collection.getElementByQName(element.getQName()) == null && schema.getElementByName(element.getQName()) == null) {
                                schema.getElements().add(element.getQName(), element);
                                schema.getItems().add(element);
                            }
                        } else if (xmlSchemaObject instanceof XmlSchemaType) {
                            XmlSchemaType schemaType = (XmlSchemaType) xmlSchemaObject;
                            if (collection.getTypeByQName(schemaType.getQName()) == null && schema.getTypeByName(schemaType.getQName()) == null) {
                                schema.addType(schemaType);
                                schema.getItems().add(schemaType);
                            }
                        } else {
                            schema.getItems().add(xmlSchemaObject);
                        }
                    }
                }
            }
        }.init(project);
    } catch (Exception e) {
        throw new EngineException("preBuildSchema failed", e);
    }
}
Also used : ProjectSchemaReference(com.twinsoft.convertigo.beans.references.ProjectSchemaReference) WalkHelper(com.twinsoft.convertigo.engine.helpers.WalkHelper) Step(com.twinsoft.convertigo.beans.core.Step) RequestableStep(com.twinsoft.convertigo.beans.core.RequestableStep) SequenceStep(com.twinsoft.convertigo.beans.steps.SequenceStep) XMLCopyStep(com.twinsoft.convertigo.beans.steps.XMLCopyStep) TransactionStep(com.twinsoft.convertigo.beans.steps.TransactionStep) XmlSchemaObject(org.apache.ws.commons.schema.XmlSchemaObject) Iterator(java.util.Iterator) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) XmlSchemaImport(org.apache.ws.commons.schema.XmlSchemaImport) XmlSchemaObjectCollection(org.apache.ws.commons.schema.XmlSchemaObjectCollection) ISchemaIncludeGenerator(com.twinsoft.convertigo.beans.core.ISchemaIncludeGenerator) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) Reference(com.twinsoft.convertigo.beans.core.Reference) ProjectSchemaReference(com.twinsoft.convertigo.beans.references.ProjectSchemaReference) XmlSchemaAttributeGroup(org.apache.ws.commons.schema.XmlSchemaAttributeGroup) XmlSchemaForm(org.apache.ws.commons.schema.XmlSchemaForm) XmlSchemaSequence(org.apache.ws.commons.schema.XmlSchemaSequence) Sequence(com.twinsoft.convertigo.beans.core.Sequence) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) XmlSchemaAttribute(org.apache.ws.commons.schema.XmlSchemaAttribute) XmlSchemaGroup(org.apache.ws.commons.schema.XmlSchemaGroup) Transaction(com.twinsoft.convertigo.beans.core.Transaction) XmlSchema(org.apache.ws.commons.schema.XmlSchema) ISchemaImportGenerator(com.twinsoft.convertigo.beans.core.ISchemaImportGenerator) XmlSchemaInclude(org.apache.ws.commons.schema.XmlSchemaInclude) ISchemaGenerator(com.twinsoft.convertigo.beans.core.ISchemaGenerator)

Example 60 with Transaction

use of com.twinsoft.convertigo.beans.core.Transaction in project convertigo by convertigo.

the class List method getServiceResult.

protected void getServiceResult(HttpServletRequest request, Document document) throws Exception {
    HttpSession currentSession = request.getSession();
    Element rootElement = document.getDocumentElement();
    Element connectionsListElement = document.createElement("connections");
    rootElement.appendChild(connectionsListElement);
    Element sessionsListElement = document.createElement("sessions");
    rootElement.appendChild(sessionsListElement);
    Element contextsInUseElement = document.createElement("contextsInUse");
    contextsInUseElement.setTextContent("" + Math.max(0, Engine.theApp.contextManager.getNumberOfContexts()));
    rootElement.appendChild(contextsInUseElement);
    Element contextsNumberElement = document.createElement("contextsNumber");
    contextsNumberElement.setTextContent("" + EnginePropertiesManager.getProperty(PropertyName.CONVERTIGO_MAX_CONTEXTS));
    rootElement.appendChild(contextsNumberElement);
    Element sessionsInUseElement = document.createElement("sessionsInUse");
    sessionsInUseElement.setTextContent("" + HttpSessionListener.countSessions());
    rootElement.appendChild(sessionsInUseElement);
    Element sessionsIsOverflowElement = document.createElement("sessionsIsOverflow");
    sessionsIsOverflowElement.setTextContent(KeyManager.isOverflow(Session.EmulIDSE) ? "true" : "false");
    rootElement.appendChild(sessionsIsOverflowElement);
    Element sessionsNumberElement = document.createElement("sessionsNumber");
    sessionsNumberElement.setTextContent("" + Math.max(0, KeyManager.getMaxCV(Session.EmulIDSE)));
    rootElement.appendChild(sessionsNumberElement);
    Element threadsInUseElement = document.createElement("threadsInUse");
    threadsInUseElement.setTextContent("" + Math.max(0, com.twinsoft.convertigo.beans.core.RequestableObject.nbCurrentWorkerThreads));
    rootElement.appendChild(threadsInUseElement);
    Element threadsNumberElement = document.createElement("threadsNumber");
    threadsNumberElement.setTextContent(EnginePropertiesManager.getProperty(PropertyName.DOCUMENT_THREADING_MAX_WORKER_THREADS));
    rootElement.appendChild(threadsNumberElement);
    Element httpTimeoutElement = document.createElement("httpTimeout");
    httpTimeoutElement.setTextContent(formatTime(currentSession.getMaxInactiveInterval()));
    rootElement.appendChild(httpTimeoutElement);
    long now = System.currentTimeMillis();
    Collection<Context> contexts = null;
    String sessionToFilter = request.getParameter("session");
    if (StringUtils.isNotBlank(sessionToFilter)) {
        HttpSession session = HttpSessionListener.getHttpSession(sessionToFilter);
        if (session != null) {
            contexts = Engine.theApp.contextManager.getContexts(session);
        }
    }
    if (contexts == null) {
        contexts = Engine.theApp.contextManager.getContexts();
    }
    for (Context context : contexts) {
        String authenticatedUser = null;
        try {
            authenticatedUser = context.getAuthenticatedUser();
        } catch (Exception e) {
            Engine.logAdmin.trace("connection.List failed to get the authenticated user: " + e);
        }
        com.twinsoft.api.Session apiSession = Engine.theApp.sessionManager.getSession(context.contextID);
        boolean bConnected = ((apiSession != null) && apiSession.isConnected());
        Element connectionElement = document.createElement("connection");
        connectionElement.setAttribute("connected", Boolean.toString(bConnected));
        connectionElement.setAttribute("contextName", context.contextID);
        connectionElement.setAttribute("project", context.projectName);
        connectionElement.setAttribute("connector", context.connectorName);
        connectionElement.setAttribute("requested", (context.requestedObject instanceof Transaction) ? context.transactionName : context.sequenceName);
        connectionElement.setAttribute("status", (context.requestedObject == null || context.requestedObject.runningThread == null ? "finished" : (context.requestedObject.runningThread.bContinue ? "in progress" : "finished")) + "(" + context.waitingRequests + ")");
        connectionElement.setAttribute("user", authenticatedUser == null ? "" : authenticatedUser);
        connectionElement.setAttribute("contextCreationDate", DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM).format(new Date(context.creationTime)));
        connectionElement.setAttribute("lastContextAccessDate", DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM).format(new Date(context.lastAccessTime)));
        try {
            connectionElement.setAttribute("contextInactivityTime", formatTime((now - context.lastAccessTime) / 1000) + " / " + formatTime(Engine.theApp.databaseObjectsManager.getOriginalProjectByName(context.projectName).getContextTimeout()));
        } catch (Exception e) {
        // TODO: document = DOMUtils.handleError(e); << USELESS
        }
        connectionElement.setAttribute("clientComputer", context.remoteHost + " (" + context.remoteAddr + "), " + context.userAgent);
        connectionsListElement.appendChild(connectionElement);
    }
    if (!"false".equals(request.getParameter("sessions"))) {
        for (HttpSession session : HttpSessionListener.getSessions()) {
            Element sessionElement = document.createElement("session");
            java.util.List<Context> ctxs = Engine.theApp.contextManager.getContexts(session);
            sessionElement.setAttribute("sessionID", session.getId());
            sessionElement.setAttribute("authenticatedUser", SessionAttribute.authenticatedUser.string(session));
            sessionElement.setAttribute("contexts", Integer.toString(ctxs == null ? 0 : ctxs.size()));
            sessionElement.setAttribute("clientIP", SessionAttribute.clientIP.string(session));
            sessionElement.setAttribute("deviceUUID", SessionAttribute.deviceUUID.string(session));
            sessionElement.setAttribute("lastSessionAccessDate", DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM).format(new Date(session.getLastAccessedTime())));
            sessionElement.setAttribute("sessionInactivityTime", formatTime((now - session.getLastAccessedTime()) / 1000) + " / " + formatTime(session.getMaxInactiveInterval()));
            Role[] r = (Role[]) session.getAttribute(SessionKey.ADMIN_ROLES.toString());
            sessionElement.setAttribute("adminRoles", Integer.toString(r == null ? 0 : r.length));
            if (session == currentSession) {
                sessionElement.setAttribute("isCurrentSession", "true");
            }
            Set<HttpServletRequest> set = SessionAttribute.fullSyncRequests.get(session);
            sessionElement.setAttribute("isFullSyncActive", Boolean.toString(set != null && !set.isEmpty()));
            sessionsListElement.appendChild(sessionElement);
        }
    }
}
Also used : Context(com.twinsoft.convertigo.engine.Context) Session(com.twinsoft.api.Session) HttpSession(javax.servlet.http.HttpSession) Element(org.w3c.dom.Element) Date(java.util.Date) Role(com.twinsoft.convertigo.engine.AuthenticatedSessionManager.Role) HttpServletRequest(javax.servlet.http.HttpServletRequest) Transaction(com.twinsoft.convertigo.beans.core.Transaction)

Aggregations

Transaction (com.twinsoft.convertigo.beans.core.Transaction)67 Connector (com.twinsoft.convertigo.beans.core.Connector)43 Sequence (com.twinsoft.convertigo.beans.core.Sequence)29 EngineException (com.twinsoft.convertigo.engine.EngineException)27 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)24 Project (com.twinsoft.convertigo.beans.core.Project)23 HtmlTransaction (com.twinsoft.convertigo.beans.transactions.HtmlTransaction)21 Step (com.twinsoft.convertigo.beans.core.Step)17 ScreenClass (com.twinsoft.convertigo.beans.core.ScreenClass)16 TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)16 HtmlConnector (com.twinsoft.convertigo.beans.connectors.HtmlConnector)15 JavelinConnector (com.twinsoft.convertigo.beans.connectors.JavelinConnector)15 TransactionStep (com.twinsoft.convertigo.beans.steps.TransactionStep)13 ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)13 RequestableStep (com.twinsoft.convertigo.beans.core.RequestableStep)12 Statement (com.twinsoft.convertigo.beans.core.Statement)12 ElseStep (com.twinsoft.convertigo.beans.steps.ElseStep)12 SequenceStep (com.twinsoft.convertigo.beans.steps.SequenceStep)12 ThenStep (com.twinsoft.convertigo.beans.steps.ThenStep)12 JavelinTransaction (com.twinsoft.convertigo.beans.transactions.JavelinTransaction)12