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.url;
17  
18  import com.fatwire.assetapi.data.AssetId;
19  import com.fatwire.gst.foundation.facade.assetapi.listener.RunOnceAssetEventListener;
20  import com.fatwire.gst.foundation.url.db.UrlRegistry2;
21  
22  /**
23   * Asset event for ensuring that a WRA is properly prepared for rendering.
24   * Includes ensuring that the asset is accessible through the
25   * WraPathTranslationService, among other things.
26   * 
27   * @author Tony Field
28   * @author Dolf Dijkstra
29   * @since Jul 21, 2010
30   */
31  public class WraAssetEventListener extends RunOnceAssetEventListener {
32  
33      @Override
34      protected void doAssetAdded(final AssetId assetId) {
35          if (LOG.isTraceEnabled()) {
36              LOG.trace("Heard assetAdded event for " + assetId);
37          }
38          getService().addAsset(assetId);
39      }
40  
41      @Override
42      protected void doAssetUpdated(final AssetId assetId) {
43          if (LOG.isTraceEnabled()) {
44              LOG.trace("Heard assetUpdated event for " + assetId);
45          }
46          getService().updateAsset(assetId);
47      }
48  
49      @Override
50      protected void doAssetDeleted(final AssetId assetId) {
51          if (LOG.isTraceEnabled()) {
52              LOG.trace("Heard assetDeleted event for " + assetId);
53          }
54          getService().deleteAsset(assetId);
55      }
56  
57      protected WraPathTranslationService getService() {
58          return UrlRegistry2.lookup(getICS());
59      }
60  
61  }