Skip to content

Commit 2430f23

Browse files
author
Lloyd Watkin
committed
Merge branch 'issue-98' of github.com:surevine/buddycloud-server-java
2 parents 599241c + 742b992 commit 2430f23

42 files changed

Lines changed: 1452 additions & 414 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

pom.xml

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -139,31 +139,49 @@
139139
<build>
140140
<plugins>
141141
<plugin>
142-
<groupId>org.apache.maven.plugins</groupId>
143-
<artifactId>maven-antrun-plugin</artifactId>
144-
<version>1.6</version>
142+
<!-- Extended Maven antrun plugin -->
143+
<!-- https://maven-antrun-extended-plugin.dev.java.net/ -->
144+
<groupId>org.jvnet.maven-antrun-extended-plugin</groupId>
145+
<artifactId>maven-antrun-extended-plugin</artifactId>
145146
<executions>
146-
<execution>
147-
<id>buddycloud-server-start</id>
148-
<phase>server-start</phase>
149-
<configuration>
150-
<tasks>
151-
<ant antfile="build.xml" target="run" />
152-
</tasks>
153-
</configuration>
154-
<goals>
155-
<goal>run</goal>
156-
</goals>
157-
</execution>
147+
<execution>
148+
<id>test-reports</id>
149+
<phase>test</phase>
150+
<configuration>
151+
<tasks>
152+
<junitreport todir="target/surefire-reports">
153+
<fileset dir="target/surefire-reports">
154+
<include name="**/*.xml"/>
155+
</fileset>
156+
<report format="noframes" todir="target/surefire-reports"/>
157+
</junitreport>
158+
</tasks>
159+
</configuration>
160+
<goals>
161+
<goal>run</goal>
162+
</goals>
163+
</execution>
158164
</executions>
165+
<dependencies>
166+
<dependency>
167+
<groupId>org.apache.ant</groupId>
168+
<artifactId>ant-junit</artifactId>
169+
<version>1.8.0</version>
170+
</dependency>
171+
<dependency>
172+
<groupId>org.apache.ant</groupId>
173+
<artifactId>ant-trax</artifactId>
174+
<version>1.8.0</version>
175+
</dependency>
176+
</dependencies>
159177
</plugin>
160178
<plugin>
161179
<groupId>org.apache.maven.plugins</groupId>
162180
<artifactId>maven-surefire-plugin</artifactId>
163181
<version>2.5</version>
164182
<configuration>
165183
<skipTests>false</skipTests>
166-
<!-- <testFailureIgnore>true</testFailureIgnore> -->
184+
<testFailureIgnore>true</testFailureIgnore>
167185
<forkMode>once</forkMode>
168186
<includes>
169187
<include>**/*Test.java</include>

src/main/java/org/buddycloud/channelserver/channel/ChannelManagerImpl.java

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ public Map<String, String> getNodeConf(String nodeId)
8383
throws NodeStoreException {
8484
return nodeStore.getNodeConf(nodeId);
8585
}
86+
87+
88+
@Override
89+
public boolean isCachedNodeConfig(String nodeId) throws NodeStoreException {
90+
return nodeStore.isCachedNodeConfig(nodeId);
91+
}
8692

8793
@Override
8894
public boolean nodeExists(String nodeId) throws NodeStoreException {
@@ -132,15 +138,15 @@ public int countUserAffiliations(JID jid) throws NodeStoreException {
132138
}
133139

134140
@Override
135-
public ResultSet<NodeAffiliation> getNodeAffiliations(String nodeId)
141+
public ResultSet<NodeAffiliation> getNodeAffiliations(String nodeId, boolean isOwnerModerator)
136142
throws NodeStoreException {
137-
return nodeStore.getNodeAffiliations(nodeId);
143+
return nodeStore.getNodeAffiliations(nodeId, isOwnerModerator);
138144
}
139145

140146
@Override
141-
public ResultSet<NodeAffiliation> getNodeAffiliations(String nodeId,
147+
public ResultSet<NodeAffiliation> getNodeAffiliations(String nodeId, boolean isOwnerModerator,
142148
String afterItemId, int maxItemsToReturn) throws NodeStoreException {
143-
return nodeStore.getNodeAffiliations(nodeId, afterItemId,
149+
return nodeStore.getNodeAffiliations(nodeId, isOwnerModerator, afterItemId,
144150
maxItemsToReturn);
145151
}
146152

@@ -150,8 +156,8 @@ public ArrayList<JID> getNodeOwners(String node) throws NodeStoreException {
150156
}
151157

152158
@Override
153-
public int countNodeAffiliations(String nodeId) throws NodeStoreException {
154-
return nodeStore.countNodeAffiliations(nodeId);
159+
public int countNodeAffiliations(String nodeId, boolean isOwnerModerator) throws NodeStoreException {
160+
return nodeStore.countNodeAffiliations(nodeId, isOwnerModerator);
155161
}
156162

157163
@Override
@@ -185,21 +191,23 @@ public int countUserSubscriptions(JID user) throws NodeStoreException {
185191
}
186192

187193
@Override
188-
public ResultSet<NodeSubscription> getNodeSubscriptions(String nodeId)
189-
throws NodeStoreException {
190-
return nodeStore.getNodeSubscriptions(nodeId);
194+
public ResultSet<NodeSubscription> getNodeSubscriptions(String nodeId,
195+
boolean isOwnerModerator) throws NodeStoreException {
196+
return nodeStore.getNodeSubscriptions(nodeId, isOwnerModerator);
191197
}
192198

193199
@Override
194200
public ResultSet<NodeSubscription> getNodeSubscriptions(String nodeId,
195-
JID afterItemId, int maxItemsToReturn) throws NodeStoreException {
196-
return nodeStore.getNodeSubscriptions(nodeId, afterItemId,
197-
maxItemsToReturn);
201+
boolean isOwnerModerator, JID afterItemId, int maxItemsToReturn)
202+
throws NodeStoreException {
203+
return nodeStore.getNodeSubscriptions(nodeId, isOwnerModerator,
204+
afterItemId, maxItemsToReturn);
198205
}
199206

200207
@Override
201-
public int countNodeSubscriptions(String nodeId) throws NodeStoreException {
202-
return nodeStore.countNodeSubscriptions(nodeId);
208+
public int countNodeSubscriptions(String nodeId, boolean isOwnerModerator)
209+
throws NodeStoreException {
210+
return nodeStore.countNodeSubscriptions(nodeId, isOwnerModerator);
203211
}
204212

205213
@Override
@@ -258,7 +266,7 @@ public boolean isCachedNode(String nodeId) throws NodeStoreException {
258266
@Override
259267
public boolean nodeHasSubscriptions(String nodeId)
260268
throws NodeStoreException {
261-
return (nodeStore.countNodeSubscriptions(nodeId) > 0);
269+
return (nodeStore.countNodeSubscriptions(nodeId, false) > 0);
262270
}
263271

264272
public boolean isCachedJID(JID jid) throws NodeStoreException {
@@ -366,7 +374,7 @@ public ResultSet<NodeSubscription> getNodeSubscriptionListeners(
366374
String nodeId) throws NodeStoreException {
367375
return nodeStore.getNodeSubscriptionListeners(nodeId);
368376
}
369-
377+
370378
@Override
371379
public ResultSet<NodeSubscription> getNodeSubscriptionListeners()
372380
throws NodeStoreException {
@@ -431,28 +439,31 @@ public int getFirehoseItemCount(boolean isAdmin) throws NodeStoreException {
431439
@Override
432440
public Affiliations getDefaultNodeAffiliation(String nodeId)
433441
throws NodeStoreException {
434-
String affiliationString = getNodeConfValue(nodeId, Conf.DEFAULT_AFFILIATION);
435-
436-
if(affiliationString != null) {
442+
String affiliationString = getNodeConfValue(nodeId,
443+
Conf.DEFAULT_AFFILIATION);
444+
445+
if (affiliationString != null) {
437446
try {
438447
return Affiliations.valueOf(affiliationString);
439-
}
440-
catch(IllegalArgumentException e) {
441-
logger.error("Invalid default affiliation stored for node " + nodeId + ": " + affiliationString, e);
448+
} catch (IllegalArgumentException e) {
449+
logger.error("Invalid default affiliation stored for node "
450+
+ nodeId + ": " + affiliationString, e);
442451
}
443452
}
444-
453+
445454
return Affiliations.member;
446455
}
447456

448457
@Override
449458
public CloseableIterator<NodeItem> performSearch(JID searcher,
450-
List content, JID author, int page, int rpp) throws NodeStoreException {
459+
List content, JID author, int page, int rpp)
460+
throws NodeStoreException {
451461
return nodeStore.performSearch(searcher, content, author, page, rpp);
452462
}
453463

454464
@Override
455-
public ResultSet<NodeItem> getUserItems(JID userJid) throws NodeStoreException {
465+
public ResultSet<NodeItem> getUserItems(JID userJid)
466+
throws NodeStoreException {
456467
return nodeStore.getUserItems(userJid);
457468
}
458469

@@ -481,5 +492,4 @@ public ResultSet<NodeThread> getNodeThreads(String node, String afterId,
481492
public int countNodeThreads(String node) throws NodeStoreException {
482493
return nodeStore.countNodeThreads(node);
483494
}
484-
485495
}

src/main/java/org/buddycloud/channelserver/channel/node/configuration/field/AccessModel.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@ public class AccessModel extends Field
55
public static final String FIELD_NAME = "pubsub#access_model";
66
public static final String DEFAULT_VALUE = AccessModel.models.OPEN.toString();
77

8+
public static final models open = models.OPEN;
9+
public static final models authorize = models.AUTHORIZE;
10+
public static final models whitelist = models.WHITELIST;
11+
public static final models local = models.LOCAL;
12+
813
public enum models {
9-
OPEN("open"), WHITELIST("whitelist"), AUTHORIZE("authorize");
14+
OPEN("open"), WHITELIST("whitelist"), AUTHORIZE("authorize"), LOCAL("local");
1015
String model = null;
1116
private models(String model) {
1217
this.model = model;
@@ -26,6 +31,7 @@ public boolean isValid()
2631
return (getValue().equals(AccessModel.models.OPEN.toString())
2732
|| getValue().equals(AccessModel.models.WHITELIST.toString())
2833
|| getValue().equals(AccessModel.models.AUTHORIZE.toString())
34+
|| getValue().equals(AccessModel.models.LOCAL.toString())
2935
);
3036
}
3137
}

src/main/java/org/buddycloud/channelserver/db/NodeStore.java

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ ResultSet<NodeAffiliation> getAffiliationChanges(JID user, Date startDate, Date
219219
* the node id
220220
* @return
221221
*/
222-
ResultSet<NodeAffiliation> getNodeAffiliations(String nodeId)
222+
ResultSet<NodeAffiliation> getNodeAffiliations(String nodeId, boolean isOwnerModerator)
223223
throws NodeStoreException;
224224

225225
/**
@@ -229,8 +229,8 @@ ResultSet<NodeAffiliation> getNodeAffiliations(String nodeId)
229229
* @param afterItemId
230230
* @return
231231
*/
232-
ResultSet<NodeAffiliation> getNodeAffiliations(String node
233-
, String afterItemId, int maxItemsToReturn) throws NodeStoreException;
232+
ResultSet<NodeAffiliation> getNodeAffiliations(String node, boolean isOwnerModerator,
233+
String afterItemId, int maxItemsToReturn) throws NodeStoreException;
234234

235235
/**
236236
* Get a list of node owners
@@ -246,7 +246,7 @@ ResultSet<NodeAffiliation> getNodeAffiliations(String node
246246
* @param nodeId
247247
* @return
248248
*/
249-
int countNodeAffiliations(String nodeId) throws NodeStoreException;
249+
int countNodeAffiliations(String nodeId, boolean isOwnerModerator) throws NodeStoreException;
250250

251251
/**
252252
* Gets the set of nodes to which the user is subscribed.
@@ -289,9 +289,10 @@ ResultSet<NodeSubscription> getSubscriptionChanges(JID user,
289289
*
290290
* @param nodeId
291291
* the node reference.
292+
* @param isOwnerModerator
292293
* @return
293294
*/
294-
ResultSet<NodeSubscription> getNodeSubscriptions(String nodeId)
295+
ResultSet<NodeSubscription> getNodeSubscriptions(String nodeId, boolean isOwnerModerator)
295296
throws NodeStoreException;
296297

297298

@@ -304,7 +305,7 @@ ResultSet<NodeSubscription> getNodeSubscriptions(String nodeId)
304305
* after this JID
305306
* @return
306307
*/
307-
ResultSet<NodeSubscription> getNodeSubscriptions(String nodeId, JID afterItemId,
308+
ResultSet<NodeSubscription> getNodeSubscriptions(String nodeId, boolean isOwnerModerator, JID afterItemId,
308309
int maxItemsToReturn) throws NodeStoreException;
309310

310311
/**
@@ -467,10 +468,11 @@ CloseableIterator<NodeItem> getRecentItems(JID user, Date since,
467468
*
468469
* @param nodeId
469470
* the node id from which to retrieve the item count.
471+
* @param isOwnerModerator
470472
* @return the entries count.
471473
* @throws NodeStoreException
472474
*/
473-
int countNodeSubscriptions(String nodeId) throws NodeStoreException;
475+
int countNodeSubscriptions(String nodeId, boolean isOwnerModerator) throws NodeStoreException;
474476

475477
/**
476478
* Retrieves a single node item by the node item id.
@@ -534,6 +536,14 @@ void deleteNodeItemById(String nodeId, String nodeItemId)
534536
*/
535537
boolean isCachedJID(JID jid) throws NodeStoreException;
536538

539+
/**
540+
* Return whether node config is cached locally
541+
*
542+
* @param nodeId
543+
* @return
544+
* @throws NodeStoreException
545+
*/
546+
boolean isCachedNodeConfig(String nodeId) throws NodeStoreException;
537547

538548
/**
539549
* Allows the server to determine if the requested (subscriptions) node

0 commit comments

Comments
 (0)