vayacondios-server 0.2.11 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. data/.gitignore +3 -1
  2. data/.travis.yml +2 -0
  3. data/Gemfile +15 -9
  4. data/LICENSE.md +2 -6
  5. data/Procfile +1 -1
  6. data/README.md +656 -111
  7. data/Rakefile +89 -6
  8. data/bin/vcd +10 -0
  9. data/bin/vcd-server +8 -0
  10. data/config/database.yml +6 -0
  11. data/config/spec.example.yml +18 -0
  12. data/config/vayacondios.example.yml +15 -0
  13. data/config/vcd-server.rb +37 -0
  14. data/examples/configuration.rb +56 -0
  15. data/examples/event_stream.rb +19 -0
  16. data/examples/simple.rb +61 -0
  17. data/features/event.feature +319 -0
  18. data/features/events.feature +208 -0
  19. data/features/stash.feature +840 -0
  20. data/features/stashes.feature +492 -0
  21. data/features/step_definitions/stash_steps.rb +113 -0
  22. data/features/stream.feature +30 -0
  23. data/features/support/em.rb +14 -0
  24. data/features/support/env.rb +13 -0
  25. data/lib/vayacondios/configuration.rb +63 -0
  26. data/lib/vayacondios/server/api.rb +126 -0
  27. data/lib/vayacondios/server/api_options.rb +56 -0
  28. data/lib/vayacondios/server/configuration.rb +23 -0
  29. data/lib/vayacondios/server/driver.rb +71 -0
  30. data/lib/vayacondios/server/drivers/mongo.rb +126 -0
  31. data/lib/vayacondios/server/handlers/document_handler.rb +81 -0
  32. data/lib/vayacondios/server/handlers/event_handler.rb +31 -26
  33. data/lib/vayacondios/server/handlers/events_handler.rb +31 -0
  34. data/lib/vayacondios/server/handlers/stash_handler.rb +69 -0
  35. data/lib/vayacondios/server/handlers/stashes_handler.rb +49 -0
  36. data/lib/vayacondios/server/handlers/stream_handler.rb +39 -0
  37. data/lib/vayacondios/server/models/document.rb +87 -0
  38. data/lib/vayacondios/server/models/event.rb +198 -0
  39. data/lib/vayacondios/server/models/stash.rb +100 -0
  40. data/lib/vayacondios/server.rb +35 -0
  41. data/lib/vayacondios-server.rb +19 -13
  42. data/lib/vayacondios.rb +22 -0
  43. data/pom.xml +124 -4
  44. data/spec/configuration_spec.rb +41 -0
  45. data/spec/server/api_options_spec.rb +32 -0
  46. data/spec/server/api_spec.rb +279 -0
  47. data/spec/server/configuration_spec.rb +27 -0
  48. data/spec/server/drivers/mongo_spec.rb +107 -0
  49. data/spec/server/handlers/event_handler_spec.rb +62 -0
  50. data/spec/server/handlers/events_handler_spec.rb +51 -0
  51. data/spec/server/handlers/stash_handler_spec.rb +68 -0
  52. data/spec/server/handlers/stashes_handler_spec.rb +50 -0
  53. data/spec/server/handlers/stream_handler_spec.rb +5 -0
  54. data/spec/server/models/document_spec.rb +9 -0
  55. data/spec/server/models/event_spec.rb +185 -0
  56. data/spec/server/models/stash_spec.rb +95 -0
  57. data/spec/spec_helper.rb +23 -3
  58. data/spec/support/database_helper.rb +42 -0
  59. data/spec/support/log_helper.rb +19 -0
  60. data/spec/support/shared_context_for_events.rb +22 -0
  61. data/spec/support/shared_context_for_stashes.rb +24 -0
  62. data/spec/support/shared_examples_for_handlers.rb +32 -0
  63. data/src/main/java/com/infochimps/vayacondios/BaseClient.java +342 -0
  64. data/src/main/java/com/infochimps/vayacondios/HTTPClient.java +426 -0
  65. data/src/main/java/com/infochimps/vayacondios/VayacondiosClient.java +487 -65
  66. data/src/main/java/com/infochimps/vayacondios/test/IntegrationTest.java +3 -0
  67. data/src/test/java/com/infochimps/vayacondios/BaseClientTest.java +50 -0
  68. data/src/test/java/com/infochimps/vayacondios/HTTPClientIT.java +267 -0
  69. data/vayacondios-server.gemspec +9 -9
  70. metadata +127 -122
  71. checksums.yaml +0 -15
  72. data/.rspec +0 -2
  73. data/.yardopts +0 -10
  74. data/Guardfile +0 -41
  75. data/app/http_shim.rb +0 -71
  76. data/bin/vcd.sh +0 -27
  77. data/config/http_shim.rb +0 -43
  78. data/config/vayacondios.example.yaml +0 -7
  79. data/config/vayacondios.yaml +0 -7
  80. data/examples/java/ItemSetTest.java +0 -76
  81. data/lib/tasks/publish.rake +0 -23
  82. data/lib/tasks/spec.rake +0 -11
  83. data/lib/tasks/yard.rake +0 -2
  84. data/lib/vayacondios/client/config.rb +0 -7
  85. data/lib/vayacondios/client/configliere.rb +0 -38
  86. data/lib/vayacondios/client/cube_client.rb +0 -39
  87. data/lib/vayacondios/client/http_client.rb +0 -49
  88. data/lib/vayacondios/client/itemset.rb +0 -130
  89. data/lib/vayacondios/client/legacy_switch.rb +0 -43
  90. data/lib/vayacondios/client/notifier.rb +0 -123
  91. data/lib/vayacondios/client/zabbix_client.rb +0 -148
  92. data/lib/vayacondios/legacy_switch.rb +0 -43
  93. data/lib/vayacondios/server/errors/bad_request.rb +0 -6
  94. data/lib/vayacondios/server/errors/not_found.rb +0 -6
  95. data/lib/vayacondios/server/handlers/config_handler.rb +0 -32
  96. data/lib/vayacondios/server/handlers/itemset_handler.rb +0 -60
  97. data/lib/vayacondios/server/legacy_switch.rb +0 -43
  98. data/lib/vayacondios/server/model/config_document.rb +0 -89
  99. data/lib/vayacondios/server/model/document.rb +0 -25
  100. data/lib/vayacondios/server/model/event_document.rb +0 -94
  101. data/lib/vayacondios/server/model/itemset_document.rb +0 -126
  102. data/lib/vayacondios/server/rack/extract_methods.rb +0 -35
  103. data/lib/vayacondios/server/rack/jsonize.rb +0 -43
  104. data/lib/vayacondios/server/rack/params.rb +0 -50
  105. data/lib/vayacondios/server/rack/path.rb +0 -23
  106. data/lib/vayacondios/server/rack/path_validation.rb +0 -22
  107. data/lib/vayacondios/version.rb +0 -3
  108. data/lib/vayacondios-client.rb +0 -22
  109. data/scripts/hadoop_monitor/configurable.rb +0 -66
  110. data/scripts/hadoop_monitor/hadoop_attempt_scraper.rb +0 -45
  111. data/scripts/hadoop_monitor/hadoop_client.rb +0 -273
  112. data/scripts/hadoop_monitor/hadoop_monitor.rb +0 -101
  113. data/scripts/hadoop_monitor/hadoopable.rb +0 -65
  114. data/scripts/hadoop_monitor/machine_monitor.rb +0 -115
  115. data/scripts/s3_cataloger/buckets +0 -33
  116. data/scripts/s3_cataloger/foreach_bucket +0 -88
  117. data/scripts/s3_cataloger/parse_ls.py +0 -391
  118. data/spec/client/itemset_legacy_spec.rb +0 -55
  119. data/spec/client/itemset_spec.rb +0 -60
  120. data/spec/client/notifier_spec.rb +0 -120
  121. data/spec/server/config_spec.rb +0 -113
  122. data/spec/server/event_spec.rb +0 -103
  123. data/spec/server/itemset_legacy_spec.rb +0 -320
  124. data/spec/server/itemset_spec.rb +0 -317
  125. data/spec/server/rack/extract_methods_spec.rb +0 -60
  126. data/spec/server/rack/path_spec.rb +0 -36
  127. data/spec/server/rack/path_validation_spec.rb +0 -22
  128. data/spec/server/server_spec.rb +0 -20
  129. data/spec/support/mongo_cleaner.rb +0 -32
  130. data/src/main/java/ItemSetTest.java +0 -76
  131. data/src/main/java/com/infochimps/util/CurrentClass.java +0 -26
  132. data/src/main/java/com/infochimps/util/DebugUtil.java +0 -38
  133. data/src/main/java/com/infochimps/util/HttpHelper.java +0 -181
  134. data/src/main/java/com/infochimps/vayacondios/ItemSets.java +0 -373
  135. data/src/main/java/com/infochimps/vayacondios/LinkToVCD.java +0 -18
  136. data/src/main/java/com/infochimps/vayacondios/MemoryVCDShim.java +0 -84
  137. data/src/main/java/com/infochimps/vayacondios/Organization.java +0 -62
  138. data/src/main/java/com/infochimps/vayacondios/PathBuilder.java +0 -13
  139. data/src/main/java/com/infochimps/vayacondios/StandardVCDLink.java +0 -218
  140. data/src/main/java/com/infochimps/vayacondios/VCDIntegrationTest.java +0 -108
  141. data/src/test/java/com/infochimps/vayacondios/TestVayacondiosInMemory.java +0 -78
  142. data/vayacondios-client.gemspec +0 -25
@@ -1,373 +0,0 @@
1
- package com.infochimps.vayacondios;
2
-
3
- import static com.infochimps.util.CurrentClass.getLogger;
4
- import com.infochimps.util.DebugUtil;
5
-
6
- import com.google.gson.Gson;
7
- import com.google.gson.GsonBuilder;
8
- import com.google.gson.JsonElement;
9
- import com.google.gson.JsonIOException;
10
- import com.google.gson.JsonObject;
11
- import com.google.gson.JsonParser;
12
- import com.google.gson.JsonPrimitive;
13
- import com.google.gson.JsonParseException;
14
- import com.google.gson.JsonSerializer;
15
- import com.google.gson.JsonSerializationContext;
16
- import com.google.gson.JsonSyntaxException;
17
-
18
- import java.io.BufferedReader;
19
- import java.util.HashMap;
20
- import java.io.FileNotFoundException;
21
- import java.io.InputStream;
22
- import java.io.OutputStream;
23
- import java.io.OutputStreamWriter;
24
- import java.io.IOException;
25
- import java.lang.reflect.Type;
26
- import java.lang.reflect.InvocationTargetException;
27
- import java.net.HttpURLConnection;
28
- import java.util.ArrayList;
29
- import java.util.List;
30
-
31
- import java.net.URL;
32
-
33
- import org.slf4j.Logger;
34
-
35
- /**
36
- * This is the first level of the Vayacondios path-building hierarchy
37
- * that is capable of directly manipulating itemsets.
38
- */
39
- public class ItemSets<LinkType extends LinkToVCD> extends Organization {
40
- public ItemSets(PathBuilder delegate) { super(delegate); }
41
-
42
- /**
43
- * @param linkClass for testing purposes. can be used to shim up a
44
- * dummy vayacondios session.
45
- */
46
- public ItemSets(Organization org, LinkType linkToVCD) {
47
- super(org);
48
- _org = org;
49
- (_vcdLink = linkToVCD).setParent(this);
50
- }
51
-
52
- //----------------------------------------------------------------------------
53
- // next in path hierarchy
54
- //----------------------------------------------------------------------------
55
-
56
- /**
57
- * @param topic Vayacondios topic. see Vayacondios documentation for
58
- * details.
59
- * @return new Topic path builder for this organization
60
- */
61
- public Topic topic(String topic) { return new Topic(this, topic); }
62
-
63
- //----------------------------------------------------------------------------
64
- // public operations
65
- //----------------------------------------------------------------------------
66
-
67
- /**
68
- * Fetches the current value of an itemset.
69
- *
70
- * @param topic A Vayacondios topic has many ids. See vayacondios
71
- * documentation for further details.
72
- * @param id A Vayacondios id, together with the server,
73
- * organization, and topic, specifies a unique
74
- * itemset.
75
- * @return a collection of items
76
- */
77
- public List<Item> fetch(String topic, String id) throws IOException {
78
- return _vcdLink.fetch(topic, id);
79
- }
80
-
81
- /**
82
- * Creates a new itemset with the specified topic and id, clobbering
83
- * any existing itemset with the same topic and id.
84
- *
85
- * @param topic A Vayacondios topic has many ids. See vayacondios
86
- * documentation for further details.
87
- * @param id A Vayacondios id, together with the server,
88
- * organization, and topic, specifies a unique
89
- * itemset.
90
- * @param items items whose existence should be ensured in the set.
91
- */
92
- public void create(String topic,
93
- String id,
94
- List<Item> items) throws IOException {
95
- mutate("PUT", topic, id, items);
96
- }
97
-
98
- /**
99
- * Ensures the absence of the specified items from the specified itemset.q
100
- *
101
- * @param topic A Vayacondios topic has many ids. See vayacondios
102
- * documentation for further details.
103
- * @param id A Vayacondios id, together with the server,
104
- * organization, and topic, specifies a unique
105
- * itemset.
106
- * @param items items whose absence should be ensured in the set.
107
- */
108
- public void remove(String topic,
109
- String id,
110
- List<Item> items) throws IOException {
111
- mutate("DELETE", topic, id, items);
112
- }
113
-
114
- /**
115
- * Updates the current value of an itemset, ensuring the existence
116
- * of the specified items.
117
- *
118
- * @param topic A Vayacondios topic has many ids. See vayacondios
119
- * documentation for further details.
120
- * @param id A Vayacondios id, together with the server,
121
- * organization, and topic, specifies a unique
122
- * itemset.
123
- * @param items items whose existence should be ensured in the set.
124
- */
125
- public void update(String topic,
126
- String id,
127
- List<Item> items) throws IOException {
128
- mutate("PATCH", topic, id, items);
129
- }
130
-
131
- //----------------------------------------------------------------------------
132
- // API HTTP path components
133
- //----------------------------------------------------------------------------
134
-
135
- String getOrganization() {
136
- return ((Organization)getDelegate()).getOrganization();
137
- }
138
-
139
- //----------------------------------------------------------------------------
140
-
141
- protected void mutate(String method,
142
- String topic,
143
- String id,
144
- List<Item> items) throws IOException {
145
- _vcdLink.mutate(method, topic, id, items);
146
- }
147
-
148
- private LinkType _vcdLink;
149
- private Organization _org;
150
-
151
- private static final Logger LOG = getLogger();
152
-
153
- //============================================================================
154
- // Topic
155
- //============================================================================
156
-
157
- /**
158
- * A Topic may have many ids, each of which points to a unique
159
- * Vayacondios itemset.
160
- */
161
- public static class Topic extends ItemSets {
162
- public Topic(PathBuilder delegate) { super(delegate); }
163
-
164
- public Topic(ItemSets sets, String topic) {
165
- super(sets);
166
- _sets = sets;
167
- _topic = topic;
168
- }
169
-
170
- //--------------------------------------------------------------------------
171
- // next in path hierarchy
172
- //--------------------------------------------------------------------------
173
-
174
- /**
175
- * @param id Vayacondios id. see Vayacondios documentation for
176
- * details.
177
- * @return new itemset for this topic
178
- */
179
- public ItemSet itemSet(String id) { return new ItemSet(this, id); }
180
-
181
- //--------------------------------------------------------------------------
182
- // public operations
183
- //--------------------------------------------------------------------------
184
-
185
- /**
186
- * @see ItemSets#fetch
187
- */
188
- public List<Item> fetch(String id) throws IOException {
189
- return fetch(getTopic(), id);
190
- }
191
-
192
- /**
193
- * @see ItemSets::create
194
- */
195
- public void create(String id, List<Item> items) throws IOException {
196
- create(getTopic(), id, items);
197
- }
198
-
199
- /**
200
- * @see ItemSets#remove
201
- */
202
- public void remove(String id, List<Item> items) throws IOException {
203
- remove(getTopic(), id, items);
204
- }
205
-
206
- /**
207
- * @see ItemSets#update
208
- */
209
- public void update(String id, List<Item> items) throws IOException {
210
- update(getTopic(), id, items);
211
- }
212
-
213
- //--------------------------------------------------------------------------
214
- // API HTTP path components
215
- //--------------------------------------------------------------------------
216
-
217
- protected String getTopic() { return _topic; }
218
-
219
- //--------------------------------------------------------------------------
220
- // fields
221
- //--------------------------------------------------------------------------
222
-
223
- private ItemSets _sets;
224
- private String _topic;
225
- }
226
-
227
- //============================================================================
228
- // ItemSet
229
- //============================================================================
230
-
231
- /**
232
- * A Vayacodios Itemset is manipulated using four API methods
233
- * implemented in terms of the Vayacondios API.
234
- */
235
- public static class ItemSet extends Topic {
236
- public ItemSet(PathBuilder delegate) { super(delegate); }
237
-
238
- public ItemSet(Topic topic, String id) {
239
- super(topic);
240
- _topic = topic;
241
- _id = id;
242
- }
243
-
244
- //--------------------------------------------------------------------------
245
- // public operations
246
- //--------------------------------------------------------------------------
247
-
248
- /**
249
- * @see ItemSets#fetch
250
- */
251
- public List<Item> fetch() throws IOException {
252
- return fetch(getId());
253
- }
254
-
255
- /**
256
- * @see ItemSets#create
257
- */
258
- public void create(List<Item> items) throws IOException {
259
- create(getId(), items);
260
- }
261
-
262
- /**
263
- * @see ItemSets#remove
264
- */
265
- public void remove(List<Item> items) throws IOException {
266
- remove(getId(), items);
267
- }
268
-
269
- /**
270
- * @see ItemSets#update
271
- */
272
- public void update(List<Item> items) throws IOException {
273
- update(getId(), items);
274
- }
275
-
276
- //--------------------------------------------------------------------------
277
- // API HTTP path components
278
- //--------------------------------------------------------------------------
279
-
280
- protected String getId() {
281
- return _id;
282
- }
283
-
284
- protected String getTopic() {
285
- return ((Topic)getDelegate()).getTopic();
286
- }
287
-
288
- //--------------------------------------------------------------------------
289
- // fields
290
- //--------------------------------------------------------------------------
291
-
292
- private Topic _topic;
293
- private String _id;
294
- }
295
-
296
- //============================================================================
297
- // Item
298
- //============================================================================
299
-
300
- /**
301
- * A Vayacondios item can be a boolean, a number, or a string.
302
- */
303
- public static class Item {
304
- public static class Serializer implements JsonSerializer {
305
- public JsonElement serialize(Object item,
306
- Type typeOfId,
307
- JsonSerializationContext context) {
308
- return GSON.toJsonTree(Item.class.isAssignableFrom(item.getClass()) ?
309
- ((Item)item).getObject() : item);
310
- }
311
- private static final Gson GSON = new Gson();
312
- private static final Logger LOG = getLogger();
313
- }
314
-
315
- public Item(Boolean b) {
316
- _item = b;
317
- _type = TYPE.BOOLEAN;
318
- }
319
-
320
- public Item(Number n) {
321
- _item = n;
322
- _type = TYPE.NUMBER;
323
- }
324
-
325
- public Item(String s) {
326
- _item = s;
327
- _type = TYPE.STRING;
328
- }
329
-
330
- public Boolean getAsBoolean() {
331
- if (_type != TYPE.BOOLEAN)
332
- throw new ClassCastException("item is not a boolean");
333
- return (Boolean)_item;
334
- }
335
-
336
- public Number getAsNumber() {
337
- if (_type != TYPE.NUMBER)
338
- throw new ClassCastException("item is not a number");
339
- return (Number)_item;
340
- }
341
-
342
- public String getAsString() {
343
- if (_type != TYPE.STRING)
344
- throw new ClassCastException("item is not a string");
345
- return (String)_item;
346
- }
347
-
348
- public Boolean isBoolean() { return (_type == TYPE.BOOLEAN); }
349
- public Boolean isNumber() { return (_type == TYPE.NUMBER ); }
350
- public Boolean isString() { return (_type == TYPE.STRING ); }
351
-
352
- public Object getObject() { return _item; }
353
-
354
- public TYPE getType() { return _type; }
355
-
356
- public String toString() {
357
- return _item.toString() + ":" + _type;
358
- }
359
-
360
- public boolean equals(Object other) {
361
- return (Item.class.isAssignableFrom(other.getClass())) ?
362
- _item.equals(((Item)other).getObject()) : _item.equals(other);
363
- }
364
-
365
- //--------------------------------------------------------------------------
366
- // fields
367
- //--------------------------------------------------------------------------
368
-
369
- private Object _item;
370
- private TYPE _type;
371
- private enum TYPE {BOOLEAN, NUMBER, STRING}
372
- }
373
- }
@@ -1,18 +0,0 @@
1
- package com.infochimps.vayacondios;
2
-
3
- import java.util.List;
4
- import java.io.IOException;
5
- import static com.infochimps.vayacondios.ItemSets.Item;
6
-
7
- public abstract class LinkToVCD {
8
- public abstract List<Item> fetch(String topic, String id) throws IOException;
9
- public abstract void mutate(String method,
10
- String topic,
11
- String id,
12
- List<Item> items) throws IOException;
13
-
14
- protected ItemSets getParent() { return _parent; }
15
- public void setParent(ItemSets parent) { _parent = parent; }
16
-
17
- private ItemSets _parent;
18
- }
@@ -1,84 +0,0 @@
1
- package com.infochimps.vayacondios;
2
-
3
- import com.google.gson.Gson;
4
- import com.google.gson.GsonBuilder;
5
- import com.google.gson.JsonElement;
6
- import com.google.gson.JsonIOException;
7
- import com.google.gson.JsonObject;
8
- import com.google.gson.JsonParser;
9
- import com.google.gson.JsonPrimitive;
10
- import com.google.gson.JsonParseException;
11
- import com.google.gson.JsonSerializer;
12
- import com.google.gson.JsonSerializationContext;
13
- import com.google.gson.JsonSyntaxException;
14
-
15
- import java.io.BufferedReader;
16
- import java.io.FileNotFoundException;
17
- import java.io.InputStream;
18
- import java.io.OutputStream;
19
- import java.io.IOException;
20
- import java.net.HttpURLConnection;
21
- import java.nio.charset.Charset;
22
- import java.util.ArrayList;
23
- import java.util.HashMap;
24
- import java.util.List;
25
- import java.util.Map;
26
-
27
- import java.net.URL;
28
-
29
- import org.slf4j.Logger;
30
-
31
- import static com.infochimps.util.CurrentClass.getLogger;
32
- import static com.infochimps.vayacondios.ItemSets.Item;
33
-
34
- public class MemoryVCDShim extends LinkToVCD {
35
- public MemoryVCDShim() {
36
- _topics = new HashMap<String, Map<String, List<Item>>>();
37
- }
38
-
39
- public List<Item> fetch(String topicName, String id) {
40
- Map<String, List<Item>> topic = _topics.get(topicName);
41
- List<Item> result;
42
-
43
- LOG.trace("topics before fetch: {}", _topics);
44
-
45
- if (topic == null || (result = topic.get(id)) == null) {
46
- LOG.debug("couldn't find {}.{}. returning empty list", topicName, id);
47
- return new ArrayList<Item>();
48
- } else {
49
- LOG.debug("returning {}.{} => {}", topicName, id, result);
50
- return result;
51
- }
52
- }
53
-
54
- public void mutate(String method,
55
- String topicName,
56
- String id,
57
- List<Item> items) {
58
- LOG.trace("topics before mutate: {}", _topics);
59
-
60
- Map<String, List<Item>> topic = _topics.get(topicName);
61
- if (topic == null) {
62
- LOG.debug("creating topic {}.", topicName);
63
- _topics.put(topicName, topic = new HashMap<String, List<Item>>());
64
- }
65
-
66
- if (method.equals("DELETE")) {
67
- LOG.trace("removing {} from {}.{}", items, topicName, id);
68
- topic.get(id).removeAll(items);
69
- }
70
- else if (method.equals("PATCH")) {
71
- LOG.trace("adding {} to {}.{}", items, topicName, id);
72
- topic.get(id).addAll(items);
73
- }
74
- else if (method.equals("PUT")) {
75
- LOG.trace("creating {}.{} with {}", topicName, id, items);
76
- topic.put(id, items);
77
- }
78
-
79
- LOG.trace("topics after mutate: {}", _topics);
80
- }
81
-
82
- private Map<String, Map<String, List<Item>>> _topics;
83
- private static final Logger LOG = getLogger();
84
- }
@@ -1,62 +0,0 @@
1
- package com.infochimps.vayacondios;
2
-
3
- import java.util.Collection;
4
-
5
- /**
6
- * An organization is the last commmon class in the Vayacondios
7
- * hierarchy between the itemset and stash interface.
8
- */
9
- public class Organization<LinkType extends LinkToVCD>
10
- extends VayacondiosClient {
11
- public Organization(PathBuilder delegate) { super(delegate); }
12
-
13
- public Organization(VayacondiosClient server, String organization) {
14
- super(server);
15
- _server = server;
16
- _organization = organization;
17
- }
18
-
19
- //----------------------------------------------------------------------------
20
- // next in path hierarchy
21
- //----------------------------------------------------------------------------
22
-
23
- /**
24
- * @return new ItemSets path builder for this organization
25
- */
26
- public ItemSets<LinkType> itemsets() {
27
- return itemsets(new StandardVCDLink());
28
- }
29
-
30
-
31
- /**
32
- * @param linkType link type to use to
33
- *
34
- * @return new ItemSets path builder for this organization
35
- */
36
- public ItemSets<LinkType> itemsets(LinkToVCD linkToVCD) {
37
- return new ItemSets(this, linkToVCD);
38
- }
39
-
40
- //----------------------------------------------------------------------------
41
- // API HTTP path components
42
- //----------------------------------------------------------------------------
43
-
44
- protected String urlString(String type, String topic, String id) {
45
- return urlString(getOrganization(), type, topic, id);
46
- }
47
-
48
- protected int getPort() {
49
- return ((VayacondiosClient)getDelegate()).getPort();
50
- }
51
- protected String getServerName() {
52
- return ((VayacondiosClient)getDelegate()).getServerName();
53
- }
54
- String getOrganization() { return _organization; }
55
-
56
- //----------------------------------------------------------------------------
57
- // fields
58
- //----------------------------------------------------------------------------
59
-
60
- private VayacondiosClient _server;
61
- private String _organization;
62
- }
@@ -1,13 +0,0 @@
1
- package com.infochimps.vayacondios;
2
-
3
- class PathBuilder {
4
- public PathBuilder() {}
5
-
6
- public PathBuilder(PathBuilder delegate) {
7
- _delegate = delegate;
8
- }
9
-
10
- protected PathBuilder getDelegate() { return _delegate; }
11
-
12
- private PathBuilder _delegate;
13
- }