1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package com.fatwire.gst.foundation.facade.runtag.asset;
21
22 import java.util.ArrayList;
23 import java.util.Enumeration;
24 import java.util.List;
25
26 import COM.FutureTense.Interfaces.ICS;
27
28 import com.fatwire.gst.foundation.facade.runtag.TagRunner;
29
30
31
32
33
34
35
36
37 public class LoadAndExport implements TagRunner {
38
39 private final String assetType;
40
41 private final long assetId;
42
43 public LoadAndExport(final String assetType, final long assetId) {
44 super();
45 this.assetType = assetType;
46 this.assetId = assetId;
47 }
48
49 public String execute(final ICS ics) {
50 final String name = "asset" + ics.genID(true);
51 try {
52 final AssetLoadById al = new AssetLoadById();
53 al.setName(name);
54 al.setAssetType(assetType);
55 al.setAssetId(assetId);
56
57 al.setOption(AssetLoadById.OPTION_READ_ONLY_COMPLETE);
58
59 al.execute(ics);
60
61 new AssetScatter(name, "as", "PubList").execute(ics);
62 new AssetScatter(name, "as", true).execute(ics);
63 new AssetExport(name, "as", "xml").execute(ics);
64
65 final String xml = ics.GetVar("xml");
66 ics.RemoveVar("xml");
67 return xml;
68 } finally {
69
70 ics.SetObj(name, null);
71 final List<String> toClean = new ArrayList<String>();
72 for (final Enumeration<?> e = ics.GetVars(); e.hasMoreElements();) {
73 final String k = (String) e.nextElement();
74 if (k.startsWith("as:")) {
75 toClean.add(k);
76 }
77 }
78
79 for (String n : toClean) {
80 ics.RemoveVar(n);
81 }
82
83 }
84 }
85
86 public long getAssetId() {
87 return assetId;
88 }
89
90 public String getAssetType() {
91 return assetType;
92 }
93
94 }