View Javadoc
1   /**
2    * This file Copyright (c) 2013-2015 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.dam.asset;
35  
36  import info.magnolia.dam.api.AssetQuery;
37  import info.magnolia.dam.api.Folder;
38  
39  import java.util.Collections;
40  import java.util.List;
41  
42  import org.slf4j.Logger;
43  import org.slf4j.LoggerFactory;
44  
45  import com.google.common.net.MediaType;
46  
47  /**
48   * Simple Pojo defining Assets/Folder properties used to filter Assets.
49   * @deprecated since 2.0 use {@link info.magnolia.dam.api.AssetQuery} and {@link info.magnolia.dam.api.AssetQuery.Builder} - included here for backwards compatibility.
50   */
51  @Deprecated
52  public class AssetFilter implements AssetQuery {
53      private static final Logger log = LoggerFactory.getLogger(AssetFilter.class);
54  
55      // ===== New 2.1 methods (added or renamed), delegate to 1.x method or return defaults
56      @Override
57      public long getOffset() {
58          return 0;
59      }
60  
61      public List<OrderBy> getSorters() {
62          return Collections.<OrderBy>emptyList();
63      }
64  
65      // ===== New 2.0 methods (added or renamed), delegate to 1.x method or return defaults
66      @Override
67      public String getRootPath() {
68          return getFolderPath();
69      }
70  
71      @Override
72      public Folder getRootFolder() {
73         return null;
74      }
75  
76      @Override
77      public boolean includesChildren() {
78          return true;
79      }
80  
81      @Override
82      public boolean includesDescendants() {
83          return true;
84      }
85  
86      @Override
87      public List<MediaType> getMediaTypes() {
88          return Collections.emptyList();
89      }
90  
91      @Override
92      public String getKeywordSearchTerm() {
93          return null;
94      }
95  
96      @Override
97      public boolean includesFolders() {
98          return false;
99      }
100 
101     @Override
102     public boolean includesAssets() {
103         return true;
104     }
105 
106     @Override
107     public long getMaxResults() {
108         return getMaxResult();
109     }
110 
111     // ===== The 1.x API methods
112 
113     private String folderPath;
114     private String folderIdentifier;
115     private String extension;
116     private String additionalQueryStatement;
117     private long maxResult = 100;
118 
119     public String getFolderPath() {
120         return folderPath;
121     }
122 
123     /**
124      * folderPath example: '/demo-project/img/bk/Opener'.
125      */
126     public void setFolderPath(String folderPath) {
127         this.folderPath = folderPath;
128     }
129 
130     public String getFolderIdentifier() {
131         return folderIdentifier;
132     }
133 
134     /**
135      * folderIdentifier example: 'jcr:cafebabe-cafe-babe-cafe-babecafebabe'.
136      */
137     public void setFolderIdentifier(String folderIdentifier) {
138         // this.folderIdentifier = folderIdentifier;
139         log.warn("AssetFiler#setFolderIdentifier was called but that property is no longer considered. Use info.magnolia.dam.api.AssetQuery instead.");
140     }
141 
142     @Override
143     public String getAdditionalQueryStatement() {
144         return additionalQueryStatement;
145     }
146 
147     /**
148      * additionalQueryStatement example: "[mgnl:lastModified] > '2013-06-20T12:00:00.000+02:00'".
149      */
150     public void setAdditionalQueryStatement(String additionalQueryStatement) {
151         this.additionalQueryStatement = additionalQueryStatement;
152     }
153 
154     @Override
155     public String getExtension() {
156         return extension;
157     }
158 
159     public void setExtension(String extension) {
160         this.extension = extension;
161     }
162 
163     public long getMaxResult() {
164         return maxResult;
165     }
166 
167     public void setMaxResult(long maxResult) {
168         this.maxResult = maxResult;
169     }
170 
171     public boolean includeDeleted() {
172         log.warn("AssetFiler#includeDeleted was called but that property is no longer considered. Use info.magnolia.dam.api.AssetQuery instead.");
173         return false;
174     }
175 
176     public void setIncludeDeleted(boolean includeDeleted) {
177         log.warn("AssetFiler#setIncludeDeleted was called but that property is no longer considered. Use info.magnolia.dam.api.AssetQuery instead.");
178     }
179 
180 }