001/* 002 * (C) Copyright 2012 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * bjalon 018 */ 019package org.nuxeo.ecm.mobile; 020 021import java.util.ArrayList; 022import java.util.List; 023 024import org.nuxeo.common.xmap.annotation.XNode; 025import org.nuxeo.common.xmap.annotation.XNodeList; 026import org.nuxeo.common.xmap.annotation.XObject; 027 028/** 029 * Descriptor that represent a definition of an application and a handler that will detect request context that will 030 * make the user redirect to this application. 031 * 032 * @author <a href="mailto:bjalon@nuxeo.com">Benjamin JALON</a> 033 * @since 5.5 034 */ 035@XObject("application") 036public class ApplicationDefinitionDescriptor { 037 038 @XNode("@name") 039 public String name; 040 041 @XNode("@order") 042 public Integer order; 043 044 @XNode("@disabled") 045 public boolean disabled; 046 047 @XNode("requestHandlerName") 048 public String requestHandlerName; 049 050 @XNode("applicationRelativePath") 051 public String applicationRelativePath; 052 053 @XNode("loginPage") 054 public String loginPage; 055 056 @XNode("logoutPage") 057 public String logoutPage; 058 059 @XNodeList(value = "resources/resourcesBaseURL", type = ArrayList.class, componentType = String.class) 060 public List<String> resourcesBaseUrl = new ArrayList<String>(); 061 062 /** 063 * Application name described 064 */ 065 public String getName() { 066 return name; 067 } 068 069 /** 070 * Return true if the given Application is enabled. 071 */ 072 public boolean isDisable() { 073 return disabled; 074 } 075 076 /** 077 * Return the name of the handler that implements the logic of redirection to the application described into this 078 * descriptor. Definition of the handler is defined into the handler extension point. 079 */ 080 public String getRequestHandlerName() { 081 return requestHandlerName; 082 } 083 084 /** 085 * Order is used to sort {@code RequestHandler} executed to find the target application given a request. 086 */ 087 public Integer getOrder() { 088 return order; 089 } 090 091 /** 092 * Base URL of the described application (without the Nuxeo Context Path) 093 */ 094 public String getApplicationRelativePath() { 095 return applicationRelativePath; 096 } 097 098 /** 099 * relative path of the login page 100 */ 101 public String getLoginPage() { 102 return loginPage; 103 } 104 105 /** 106 * relative path of the logout page 107 */ 108 public String getLogoutPage() { 109 return logoutPage; 110 } 111 112 private boolean isResourcesBaseUrlChecked = false; 113 114 /** 115 * Resource Base URL of the resources needed by the application described (without the Nuxeo Context Path) add a 116 * slash at the end of the base url. 117 */ 118 public List<String> getResourcesBaseUrl() { 119 if (!isResourcesBaseUrlChecked) { 120 List<String> result = new ArrayList<String>(); 121 isResourcesBaseUrlChecked = true; 122 for (String url : resourcesBaseUrl) { 123 if (!url.endsWith("/")) { 124 result.add(url + "/"); 125 } 126 } 127 resourcesBaseUrl = result; 128 } 129 return resourcesBaseUrl; 130 } 131 132}