View Javadoc
1   /**
2    * This file Copyright (c) 2017 Magnolia International
3    * Ltd.  (http://www.magnolia-cms.com). All rights reserved.
4    *
5    *
6    * This file is dual-licensed under both the Magnolia
7    * Network Agreement and the GNU General Public License.
8    * You may elect to use one or the other of these licenses.
9    *
10   * This file is distributed in the hope that it will be
11   * useful, but AS-IS and WITHOUT ANY WARRANTY; without even the
12   * implied warranty of MERCHANTABILITY or FITNESS FOR A
13   * PARTICULAR PURPOSE, TITLE, or NONINFRINGEMENT.
14   * Redistribution, except as permitted by whichever of the GPL
15   * or MNA you select, is prohibited.
16   *
17   * 1. For the GPL license (GPL), you can redistribute and/or
18   * modify this file under the terms of the GNU General
19   * Public License, Version 3, as published by the Free Software
20   * Foundation.  You should have received a copy of the GNU
21   * General Public License, Version 3 along with this program;
22   * if not, write to the Free Software Foundation, Inc., 51
23   * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24   *
25   * 2. For the Magnolia Network Agreement (MNA), this file
26   * and the accompanying materials are made available under the
27   * terms of the MNA which accompanies this distribution, and
28   * is available at http://www.magnolia-cms.com/mna.html
29   *
30   * Any modifications to this file must keep this entire header
31   * intact.
32   *
33   */
34  package info.magnolia.rest.delivery.jcr.v1;
35  
36  import info.magnolia.jcr.util.NodeTypes;
37  import info.magnolia.rest.reference.ReferenceDefinition;
38  
39  import java.util.ArrayList;
40  import java.util.Collections;
41  import java.util.List;
42  
43  /**
44   * Default parameters for a specific workspace, for use by the JCR delivery endpoint.
45   */
46  public class WorkspaceParameters {
47  
48      private String workspace;
49      private String rootPath;
50      private int depth = 0;
51      private boolean includeSystemProperties = true;
52      private List<String> nodeTypes = Collections.singletonList(NodeTypes.Content.NAME);
53      private List<String> childNodeTypes = Collections.singletonList(NodeTypes.ContentNode.NAME);
54      private long limit = 10;
55      private boolean bypassWorkspaceAcls = false;
56      private List<ReferenceDefinition> references = new ArrayList<>();
57  
58      /**
59       * Defines the target workspace to serve content from.
60       *
61       * @return a logical workspace name; if empty the {@link JcrDeliveryEndpoint} will try to use the workspace-params key
62       * as both endpoint prefix and workspace name.
63       */
64      public String getWorkspace() {
65          return workspace;
66      }
67  
68      public void setWorkspace(String workspace) {
69          this.workspace = workspace;
70      }
71  
72      /**
73       * Defines the root path used to resolve the given node path parameter, and to execute queries.
74       */
75      public String getRootPath() {
76          return rootPath;
77      }
78  
79      public void setRootPath(String rootPath) {
80          this.rootPath = rootPath;
81      }
82  
83      /**
84       * Defines the depth for child-nodes to be included in the responses.
85       *
86       * @return the depth, relative to result nodes; by default, child-nodes are not included.
87       */
88      public int getDepth() {
89          return depth;
90      }
91  
92      public void setDepth(int depth) {
93          this.depth = depth;
94      }
95  
96      /**
97       * Defines whether jcr:—and mgnl:-prefixed properties will be included in responses.
98       *
99       * @return false by default.
100      */
101     public boolean isIncludeSystemProperties() {
102         return includeSystemProperties;
103     }
104 
105     public void setIncludeSystemProperties(boolean includeSystemProperties) {
106         this.includeSystemProperties = includeSystemProperties;
107     }
108 
109     public List<String> getNodeTypes() {
110         return nodeTypes;
111     }
112 
113     public void setNodeTypes(List<String> nodeTypes) {
114         this.nodeTypes = nodeTypes;
115     }
116 
117     public List<String> getChildNodeTypes() {
118         return childNodeTypes;
119     }
120 
121     public void setChildNodeTypes(List<String> childNodeTypes) {
122         this.childNodeTypes = childNodeTypes;
123     }
124 
125     /**
126      * Defines the amount of results to return in a paginated result set.
127      *
128      * @return 10 by default
129      */
130     public long getLimit() {
131         return limit;
132     }
133 
134     public void setLimit(long limit) {
135         this.limit = limit;
136     }
137 
138     /**
139      * Defines whether or not workspace permissions (ACLs) should be evaluated.
140      *
141      * <p>This may be used to serve all content for the given workspace params to anonymous users;
142      * until relevant JCR permissions for the anonymous user are set up.<br/>
143      * Mind however that URI permissions are still evaluated.
144      * The <em>rest-anonymous</em> role has a GET permission to '/.rest/delivery/*'.
145      */
146     public boolean isBypassWorkspaceAcls() {
147         return bypassWorkspaceAcls;
148     }
149 
150     public void setBypassWorkspaceAcls(boolean bypassWorkspaceAcls) {
151         this.bypassWorkspaceAcls = bypassWorkspaceAcls;
152     }
153 
154     public List<ReferenceDefinition> getReferences() {
155         return references;
156     }
157 
158     public void setReferences(List<ReferenceDefinition> references) {
159         this.references = references;
160     }
161 }