Search in sources :

Example 86 with Project

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

the class ExportOptions method getServiceResult.

protected void getServiceResult(HttpServletRequest request, Document document) throws Exception {
    String projectName = request.getParameter("projectName");
    Project project = Engine.theApp.databaseObjectsManager.getOriginalProjectByName(projectName);
    File projectDir = project.getDirFile();
    Element root = document.getDocumentElement();
    Element options = document.createElement("options");
    for (ArchiveExportOption o : ArchiveExportOption.values()) {
        long size = o.size(projectDir);
        if (size > 0) {
            Element e = document.createElement("option");
            e.setAttribute("name", o.name());
            if (o == ArchiveExportOption.includeTestCase) {
                e.setAttribute("display", o.display());
            } else {
                e.setAttribute("display", o.display() + " [" + FileUtils.byteCountToDisplaySize(size) + "]");
            }
            options.appendChild(e);
        }
    }
    ;
    root.appendChild(options);
}
Also used : Project(com.twinsoft.convertigo.beans.core.Project) Element(org.w3c.dom.Element) ArchiveExportOption(com.twinsoft.convertigo.engine.enums.ArchiveExportOption) File(java.io.File)

Example 87 with Project

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

the class GetStoreContent method getServiceResult.

@Override
protected void getServiceResult(HttpServletRequest request, Document document) throws Exception {
    Element root = document.getDocumentElement();
    Element projectsListElement = document.createElement("projects");
    root.appendChild(projectsListElement);
    String requestedPlatform = ServiceUtils.getRequiredParameter(request, "platform");
    HttpSession httpSession = request.getSession();
    boolean bAdminRole = hasRole(httpSession, Role.WEB_ADMIN);
    boolean bAuthRole = hasRole(httpSession, Role.AUTHENTICATED);
    for (String projectName : Engine.theApp.databaseObjectsManager.getAllProjectNamesList()) {
        try {
            Project project = Engine.theApp.databaseObjectsManager.getOriginalProjectByName(projectName);
            Element projectElement = null;
            MobileApplication mobileApplication = project.getMobileApplication();
            if (mobileApplication != null) {
                Accessibility accessibylity = mobileApplication.getAccessibility();
                if (accessibylity == Accessibility.Public || (accessibylity == Accessibility.Private && bAuthRole) || bAdminRole) {
                    projectElement = createProjectElement(document, mobileApplication, projectName);
                    for (MobilePlatform platform : mobileApplication.getMobilePlatformList()) {
                        if (isRequestedPlatformValid(requestedPlatform, platform)) {
                            projectElement.getLastChild().appendChild(createPlatform(document, platform));
                        }
                    }
                    projectsListElement.appendChild(projectElement);
                }
            }
        } catch (EngineException e) {
            String message = "Unable to get project information ('" + projectName + "')";
            Engine.logAdmin.error(message, e);
        }
    }
}
Also used : Project(com.twinsoft.convertigo.beans.core.Project) MobilePlatform(com.twinsoft.convertigo.beans.core.MobilePlatform) Accessibility(com.twinsoft.convertigo.engine.enums.Accessibility) HttpSession(javax.servlet.http.HttpSession) MobileApplication(com.twinsoft.convertigo.beans.core.MobileApplication) Element(org.w3c.dom.Element) EngineException(com.twinsoft.convertigo.engine.EngineException)

Example 88 with Project

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

the class GetTestPlatform method getServiceResult.

protected void getServiceResult(HttpServletRequest request, Document document) throws Exception {
    Element root = document.getDocumentElement();
    String projectName = request.getParameter("projectName");
    Project project = Engine.theApp.databaseObjectsManager.getOriginalProjectByName(projectName);
    Element e_project = createDatabaseObjectElement(document, project);
    Connector defaultConnector = project.getDefaultConnector();
    e_project.setAttribute("defaultConnector", defaultConnector.getName());
    e_project.setAttribute("defaultTransaction", defaultConnector.getDefaultTransaction().getName());
    boolean bTpHiddenRole = Engine.authenticatedSessionManager.hasRole(request.getSession(), Role.TEST_PLATFORM_HIDDEN);
    boolean bTpPrivateRole = Engine.authenticatedSessionManager.hasRole(request.getSession(), Role.TEST_PLATFORM_PRIVATE);
    for (Connector connector : project.getConnectorsList()) {
        Element e_connector = createDatabaseObjectElement(document, connector);
        for (Transaction transaction : connector.getTransactionsList()) {
            // WEB_ADMIN role is allowed to execute all requestables
            if (transaction.isPublicAccessibility() || (transaction.isHiddenAccessibility() && bTpHiddenRole) || bTpPrivateRole) {
                e_connector.appendChild(createRequestableElement(document, transaction));
            }
        }
        e_project.appendChild(e_connector);
    }
    for (Sequence sequence : project.getSequencesList()) {
        // WEB_ADMIN role is allowed to execute all requestables
        if (sequence.isPublicAccessibility() || (sequence.isHiddenAccessibility() && bTpHiddenRole) || bTpPrivateRole) {
            e_project.appendChild(createRequestableElement(document, sequence));
        }
    }
    MobileApplication mobileApplication = project.getMobileApplication();
    if (mobileApplication != null && (mobileApplication.getAccessibility() == Accessibility.Public || (mobileApplication.getAccessibility() == Accessibility.Hidden && bTpHiddenRole) || bTpPrivateRole)) {
        Element e_mobileApplication = createDatabaseObjectElement(document, mobileApplication);
        String applicationID = mobileApplication.getComputedApplicationId();
        e_mobileApplication.setAttribute("applicationID", applicationID);
        String endpoint = mobileApplication.getComputedEndpoint(request);
        e_mobileApplication.setAttribute("endpoint", endpoint);
        String version = mobileApplication.getComputedApplicationVersion();
        e_mobileApplication.setAttribute("applicationVersion", version);
        e_project.appendChild(e_mobileApplication);
        for (MobilePlatform platform : mobileApplication.getMobilePlatformList()) {
            Element e_device = createDatabaseObjectElement(document, platform);
            e_device.setAttribute("classname", platform.getClass().getSimpleName());
            e_device.setAttribute("displayName", CachedIntrospector.getBeanInfo(platform.getClass()).getBeanDescriptor().getDisplayName());
            e_device.setAttribute("packageType", platform.getPackageType());
            e_device.setAttribute("revision", "computing...");
            e_mobileApplication.appendChild(e_device);
        }
        try {
            String mobileProjectName = mobileApplication.getComputedApplicationName();
            e_mobileApplication.setAttribute("mobileProjectName", mobileProjectName);
        } catch (Exception e) {
            Engine.logAdmin.error("Failed to retrieve the application mobile name", e);
        }
        IApplicationComponent app = mobileApplication.getApplicationComponent();
        String msg = app != null ? app.getUnbuiltMessage() : null;
        if (msg != null) {
            e_mobileApplication.setAttribute("unbuiltMessage", msg);
        }
    }
    root.appendChild(e_project);
}
Also used : Project(com.twinsoft.convertigo.beans.core.Project) Connector(com.twinsoft.convertigo.beans.core.Connector) MobilePlatform(com.twinsoft.convertigo.beans.core.MobilePlatform) Transaction(com.twinsoft.convertigo.beans.core.Transaction) MobileApplication(com.twinsoft.convertigo.beans.core.MobileApplication) Element(org.w3c.dom.Element) Sequence(com.twinsoft.convertigo.beans.core.Sequence) IApplicationComponent(com.twinsoft.convertigo.beans.core.IApplicationComponent)

Example 89 with Project

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

the class ImportURL method getServiceResult.

protected void getServiceResult(HttpServletRequest request, Document document) throws Exception {
    String error = null;
    try {
        String url = request.getParameter("url");
        ProjectUrlParser parser = new ProjectUrlParser(url);
        if (parser.isValid()) {
            Project project;
            if ((project = Engine.theApp.referencedProjectManager.importProject(parser, true)) == null) {
                error = "No project loaded with: " + url;
            } else {
                String projectName = project.getName();
                Project.executeAutoStartSequences(projectName);
            }
        } else {
            error = "The format is invalid";
        }
    } catch (Exception e) {
        error = "Failed to import project from URL, " + e.getClass().getSimpleName() + ": " + e.getMessage();
        Engine.logAdmin.warn(error, e);
    }
    Element root = document.getDocumentElement();
    Element elt;
    if (error == null) {
        elt = document.createElement("success");
        elt.setTextContent("true");
    } else {
        elt = document.createElement("error");
        elt.setTextContent(error);
    }
    root.appendChild(elt);
}
Also used : ProjectUrlParser(com.twinsoft.convertigo.engine.util.ProjectUrlParser) Project(com.twinsoft.convertigo.beans.core.Project) Element(org.w3c.dom.Element)

Example 90 with Project

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

the class List method getServiceResult.

protected void getServiceResult(HttpServletRequest request, Document document) throws Exception {
    Element root = document.getDocumentElement();
    Element projectsListElement = document.createElement("projects");
    root.appendChild(projectsListElement);
    boolean isStudio = Engine.isStudioMode();
    for (String projectName : Engine.theApp.databaseObjectsManager.getAllProjectNamesList()) {
        try {
            if (isStudio && projectName.startsWith("mobilebuilder_tpl_")) {
                continue;
            }
            Project project = Engine.theApp.databaseObjectsManager.getOriginalProjectByName(projectName);
            if (project == null) {
                continue;
            }
            String deployDate = "n/a";
            File file = new File(Engine.projectDir(projectName) + ".car");
            if (file.exists())
                deployDate = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT, request.getLocale()).format(new Date(file.lastModified()));
            String comment = project.getComment();
            if (comment.length() > 100)
                comment = comment.substring(0, 100) + "...";
            String version = project.getVersion();
            DateFormat df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT, request.getLocale());
            String exported = project.getInfoForProperty("exported", df, request.getLocale());
            Element projectElement = document.createElement("project");
            projectElement.setAttribute("name", projectName);
            projectElement.setAttribute("comment", comment);
            projectElement.setAttribute("version", version);
            projectElement.setAttribute("exported", exported);
            projectElement.setAttribute("exportedTs", "" + project.getExportTime());
            projectElement.setAttribute("deployDate", deployDate);
            projectElement.setAttribute("deployDateTs", "" + file.lastModified());
            if (Engine.theApp.databaseObjectsManager.symbolsProjectCheckUndefined(projectName)) {
                projectElement.setAttribute("undefined_symbols", "true");
            }
            for (Reference ref : project.getReferenceList()) {
                if (ref instanceof ProjectSchemaReference) {
                    ProjectSchemaReference prjRef = (ProjectSchemaReference) ref;
                    if (prjRef.getParser().isValid() && Engine.theApp.databaseObjectsManager.getOriginalProjectByName(prjRef.getParser().getProjectName(), true) == null) {
                        projectElement.setAttribute("missingDependencies", "true");
                        break;
                    }
                }
            }
            projectsListElement.appendChild(projectElement);
        } catch (EngineException e) {
            String message = "Unable to get project information ('" + projectName + "')";
            Engine.logAdmin.error(message, e);
        }
    }
}
Also used : Project(com.twinsoft.convertigo.beans.core.Project) ProjectSchemaReference(com.twinsoft.convertigo.beans.references.ProjectSchemaReference) ProjectSchemaReference(com.twinsoft.convertigo.beans.references.ProjectSchemaReference) Reference(com.twinsoft.convertigo.beans.core.Reference) Element(org.w3c.dom.Element) DateFormat(java.text.DateFormat) EngineException(com.twinsoft.convertigo.engine.EngineException) File(java.io.File) Date(java.util.Date)

Aggregations

Project (com.twinsoft.convertigo.beans.core.Project)148 EngineException (com.twinsoft.convertigo.engine.EngineException)56 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)47 IOException (java.io.IOException)39 File (java.io.File)37 Sequence (com.twinsoft.convertigo.beans.core.Sequence)35 Connector (com.twinsoft.convertigo.beans.core.Connector)33 ArrayList (java.util.ArrayList)29 ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)26 JSONException (org.codehaus.jettison.json.JSONException)26 Transaction (com.twinsoft.convertigo.beans.core.Transaction)24 TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)22 SAXException (org.xml.sax.SAXException)21 CoreException (org.eclipse.core.runtime.CoreException)20 Step (com.twinsoft.convertigo.beans.core.Step)19 Element (org.w3c.dom.Element)19 Shell (org.eclipse.swt.widgets.Shell)18 JSONObject (org.codehaus.jettison.json.JSONObject)17 IProject (org.eclipse.core.resources.IProject)17 Cursor (org.eclipse.swt.graphics.Cursor)17