001/* 002 * (C) Copyright 2015 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 * Anahide Tchertchian 018 */ 019package org.nuxeo.ecm.web.resources.core; 020 021import java.util.ArrayList; 022import java.util.List; 023 024import org.apache.commons.lang.StringUtils; 025import org.nuxeo.common.utils.FileUtils; 026import org.nuxeo.common.xmap.annotation.XNode; 027import org.nuxeo.common.xmap.annotation.XNodeList; 028import org.nuxeo.common.xmap.annotation.XObject; 029import org.nuxeo.ecm.web.resources.api.Resource; 030 031/** 032 * @since 7.3 033 */ 034@XObject("resource") 035public class ResourceDescriptor implements Resource { 036 037 private static final long serialVersionUID = 1L; 038 039 @XNode("@name") 040 public String name; 041 042 @XNode("@type") 043 public String type; 044 045 /** 046 * Target for this resource. 047 * <p> 048 * Currently only useful for JSF resources reallocation in the page. 049 * 050 * @since 7.10 051 */ 052 @XNode("@target") 053 public String target; 054 055 @XNode("path") 056 public String path; 057 058 @XNodeList(value = "require", type = ArrayList.class, componentType = String.class) 059 public List<String> dependencies; 060 061 @XNodeList(value = "processors/processor", type = ArrayList.class, componentType = String.class) 062 public List<String> processors; 063 064 @XNode("shrinkable") 065 public boolean shrinkable = true; 066 067 @XNode("uri") 068 protected String uri; 069 070 @Override 071 public String getName() { 072 return name; 073 } 074 075 @Override 076 public String getType() { 077 if (StringUtils.isBlank(type)) { 078 // try to infer it from name for easier declaration 079 return FileUtils.getFileExtension(name); 080 } 081 return type; 082 } 083 084 @Override 085 public List<String> getDependencies() { 086 return dependencies; 087 } 088 089 @Override 090 public List<String> getProcessors() { 091 return processors; 092 } 093 094 @Override 095 public String getPath() { 096 return path; 097 } 098 099 @Override 100 public String getURI() { 101 return uri; 102 } 103 104 @Override 105 public boolean isShrinkable() { 106 return shrinkable; 107 } 108 109 public void setURI(String uri) { 110 this.uri = uri; 111 } 112 113 /** 114 * @since 7.4 115 */ 116 public void setName(String name) { 117 this.name = name; 118 } 119 120 /** 121 * @since 7.4 122 */ 123 public void setType(String type) { 124 this.type = type; 125 } 126 127 /** 128 * @since 7.4 129 */ 130 public void setPath(String path) { 131 this.path = path; 132 } 133 134 /** 135 * @since 7.4 136 */ 137 public void setDependencies(List<String> dependencies) { 138 this.dependencies = dependencies; 139 } 140 141 /** 142 * @since 7.4 143 */ 144 public void setProcessors(List<String> processors) { 145 this.processors = processors; 146 } 147 148 /** 149 * @since 7.4 150 */ 151 public void setShrinkable(boolean shrinkable) { 152 this.shrinkable = shrinkable; 153 } 154 155 /** 156 * @since 7.4 157 */ 158 public void setUri(String uri) { 159 this.uri = uri; 160 } 161 162 /** 163 * @since 7.10 164 */ 165 public String getTarget() { 166 return target; 167 } 168 169 /** 170 * @since 7.10 171 */ 172 public void setTarget(String target) { 173 this.target = target; 174 } 175 176}