1 /*------------------------------------------------------------------------------
2 Name: PublishKey.java
3 Project: xmlBlaster.org
4 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
5 ------------------------------------------------------------------------------*/
6 package org.xmlBlaster.client.key;
7
8 import org.xmlBlaster.util.Global;
9 import org.xmlBlaster.util.key.MsgKeyData;
10 import org.xmlBlaster.util.XmlBlasterException;
11
12 /**
13 * Wrap the XML key data for publish() invocations.
14 * <p>
15 * See MsgKeySaxFactory for a syntax description of the allowed xml structure
16 * </p>
17 * @see org.xmlBlaster.util.key.MsgKeySaxFactory
18 * @see <a href="http://www.xmlBlaster.org/xmlBlaster/doc/requirements/interface.publish.html" target="others">the interface.publish requirement</a>
19 */
20 public class PublishKey
21 {
22 private final static String ME = "PublishKey";
23 private final MsgKeyData msgKeyData;
24
25 /**
26 * Create a key data holder, the message oid is randomly generated.
27 */
28 public PublishKey(Global glob) {
29 this.msgKeyData = new MsgKeyData(glob);
30 }
31
32 /**
33 * Create a key data holder with the given message oid.
34 */
35 public PublishKey(Global glob, String oid) {
36 this.msgKeyData = new MsgKeyData(glob);
37 setOid(oid);
38 }
39
40 /**
41 * Create a key data holder with the given message oid and its mime type.
42 */
43 public PublishKey(Global glob, String oid, String contentMime) {
44 this.msgKeyData = new MsgKeyData(glob);
45 setOid(oid);
46 setContentMime(contentMime);
47 }
48
49 /**
50 * Create a key data holder with the given message oid and its mime types.
51 */
52 public PublishKey(Global glob, String oid, String contentMime, String contentMimeExtended) {
53 this.msgKeyData = new MsgKeyData(glob);
54 setOid(oid);
55 setContentMime(contentMime);
56 setContentMimeExtended(contentMimeExtended);
57 }
58
59 /**
60 * Create a key data holder with the given message oid and its mime types.
61 * @param domain The cluster domain
62 */
63 public PublishKey(Global glob, String oid, String contentMime, String contentMimeExtended, String domain) {
64 this.msgKeyData = new MsgKeyData(glob);
65 setOid(oid);
66 setContentMime(contentMime);
67 setContentMimeExtended(contentMimeExtended);
68 setDomain(domain);
69 }
70
71 /**
72 * Pass a pre filled data object.
73 */
74 public PublishKey(Global glob, MsgKeyData msgKeyData) {
75 this.msgKeyData = msgKeyData;
76 //glob.getMsgKeyFactory().readObject(xmlKey);
77 }
78
79 public MsgKeyData getData() {
80 return this.msgKeyData;
81 }
82
83 /**
84 * Set the <key oid="...">.
85 * @param The unique key oid
86 */
87 public void setOid(String oid) {
88 this.msgKeyData.setOid(oid);
89 }
90
91 /**
92 * Access the <key oid="...">.
93 * @return The unique key oid
94 */
95 public String getOid() {
96 return this.msgKeyData.getOid();
97 }
98
99 /**
100 * A MIME type like "image/gif"
101 */
102 public void setContentMime(String contentMime) {
103 this.msgKeyData.setContentMime(contentMime);
104 }
105
106 /**
107 * A MIME type like "image/gif"
108 */
109 public String getContentMime() {
110 return this.msgKeyData.getContentMime();
111 }
112
113 /**
114 * For example a version number of the mime type
115 */
116 public void setContentMimeExtended(String contentMimeExtended) {
117 this.msgKeyData.setContentMimeExtended(contentMimeExtended);
118 }
119
120 /**
121 * For example a version number of the mime type
122 */
123 public String getContentMimeExtended() {
124 return this.msgKeyData.getContentMimeExtended();
125 }
126
127 /**
128 * Allows to give cluster a hint about who is the master
129 * or can be used for your own purposes
130 */
131 public void setDomain(String domain) {
132 this.msgKeyData.setDomain(domain);
133 }
134
135 /**
136 * Access the domain setting
137 * @return A domain string or null
138 */
139 public String getDomain() {
140 return this.msgKeyData.getDomain();
141 }
142
143 /**
144 * May be used to integrate your application tags.
145 * <p />
146 * @param str The ASCII XML key containing your tags
147 */
148 public void setClientTags(String clientTags) {
149 this.msgKeyData.setClientTags(clientTags);
150 }
151
152 /**
153 * Your specific application tags.
154 */
155 public String getClientTags() {
156 return this.msgKeyData.getClientTags();
157 }
158
159 public Global getGlobal() {
160 return this.msgKeyData.getGlobal();
161 }
162
163 /**
164 * Converts the data in XML ASCII string.
165 * @return An XML ASCII string
166 */
167 public String toXml() {
168 return this.msgKeyData.toXml();
169 }
170 }
syntax highlighted by Code2HTML, v. 0.9.1