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 com.fatwire.assetapi.data.AssetId;
19  import com.fatwire.gst.foundation.facade.assetapi.listener.RunOnceAssetEventListener;
20  import com.fatwire.gst.foundation.facade.ics.ICSFactory;
21  
22  /**
23   * Sends asset events to the tagging service.
24   * 
25   * @author Tony Field
26   * @author Dolf Dijkstra
27   * @since Jul 28, 2010
28   */
29  public final class TaggedAssetEventListener extends RunOnceAssetEventListener {
30  
31     
32      public TaggedAssetEventListener() {
33      }
34  
35      AssetTaggingService getService() {
36          try {
37              return AssetTaggingServiceFactory.getService(ICSFactory.getOrCreateICS());
38          } catch (Exception e) {
39              throw new IllegalStateException("Could not create ICS", e);
40          }
41  
42      }
43  
44      @Override
45      public void doAssetAdded(AssetId assetId) {
46          if (LOG.isTraceEnabled()) {
47              LOG.trace("Heard assetAdded event for " + assetId);
48          }
49          getService().addAsset(assetId);
50      }
51  
52      @Override
53      public void doAssetUpdated(AssetId assetId) {
54          if (LOG.isTraceEnabled()) {
55              LOG.trace("Heard assetUpdated event for " + assetId);
56          }
57          getService().updateAsset(assetId);
58      }
59  
60      @Override
61      public void doAssetDeleted(AssetId assetId) {
62          if (LOG.isTraceEnabled()) {
63              LOG.trace("Heard assetDeleted event for " + assetId);
64          }
65          getService().deleteAsset(assetId);
66      }
67  
68     
69  
70  }