View Javadoc

1   /*
2    * Copyright 2010 FatWire Corporation. All Rights Reserved.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *    http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package com.fatwire.gst.foundation.tagging;
17  
18  import java.util.Collection;
19  
20  import com.fatwire.assetapi.data.AssetId;
21  
22  /**
23   * Provides core tagging support systems. Note that add, update, and delete
24   * methods are smart enough to not fail if passed a non-tagged asset.
25   * 
26   * @author Tony Field
27   * @since Jul 28, 2010
28   */
29  public interface AssetTaggingService {
30  
31      /**
32       * Look up the tags for an asset. Returns an empty list if none or set or if
33       * the asset does not have a tag attribute or field
34       * 
35       * @param id asset id
36       * @return collection of tags. Never null
37       */
38      Collection<Tag> getTags(AssetId id);
39  
40      /**
41       * Get the tags corresponding to a whole collection of AssetIds. There is no
42       * way to determine which tags correspond to each of the input asset.
43       * 
44       * @param ids asset ids, some of which may be tagged
45       * @return tags, never null
46       */
47      Collection<Tag> getTags(Collection<AssetId> ids);
48  
49      /**
50       * Clear any pagelets containing the specified tags.
51       * 
52       * @param tags tags
53       */
54      void clearCacheForTag(Collection<Tag> tags);
55  
56      /**
57       * Record the specified tag as a dependency on the current pagelet
58       * 
59       * @param tag tag
60       */
61      void recordCacheDependency(Tag tag);
62  
63      /**
64       * Handle adding a tagged asset. If the asset is not tagged, nothing
65       * happens.
66       * 
67       * @param id asset with tag
68       */
69      void addAsset(AssetId id);
70  
71      /**
72       * Handle updating tagged asset. If the asset is not tagged, nothing
73       * happens.
74       * 
75       * @param id asset with tag
76       */
77      void updateAsset(AssetId id);
78  
79      /**
80       * Handle deleting tagged asset. If the asset is not tagged, nothing
81       * happens.
82       * 
83       * @param id tagged asset
84       */
85      void deleteAsset(AssetId id);
86  
87      /**
88       * Return a collection of assets that are tagged with the specified tag.
89       * 
90       * @param tag tag to use to look up assets
91       * @return collection of assets that have the specified tag set. May return
92       *         an empty list; never returns null.
93       */
94      Collection<AssetId> lookupTaggedAssets(Tag tag);
95  
96      /**
97       * Returns true if an asset is tagged, false otherwise
98       * 
99       * @param id id of asset
100      * @return true if it's tagged, false otherwise
101      */
102     boolean isTagged(AssetId id);
103 }