Search in sources :

Example 1 with Accessibility

use of com.twinsoft.convertigo.engine.enums.Accessibility 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)

Aggregations

MobileApplication (com.twinsoft.convertigo.beans.core.MobileApplication)1 MobilePlatform (com.twinsoft.convertigo.beans.core.MobilePlatform)1 Project (com.twinsoft.convertigo.beans.core.Project)1 EngineException (com.twinsoft.convertigo.engine.EngineException)1 Accessibility (com.twinsoft.convertigo.engine.enums.Accessibility)1 HttpSession (javax.servlet.http.HttpSession)1 Element (org.w3c.dom.Element)1