You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@labs.apache.org by be...@apache.org on 2008/04/23 22:41:56 UTC
svn commit: r651050 -
/labs/vysper/src/main/java/org/apache/vysper/xmpp/resourcebinding/ResourceRegistry.java
Author: berndf
Date: Wed Apr 23 13:41:53 2008
New Revision: 651050
URL: http://svn.apache.org/viewvc?rev=651050&view=rev
Log:
[vysper] handle unknown resource ids gracefully
Modified:
labs/vysper/src/main/java/org/apache/vysper/xmpp/resourcebinding/ResourceRegistry.java
Modified: labs/vysper/src/main/java/org/apache/vysper/xmpp/resourcebinding/ResourceRegistry.java
URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/resourcebinding/ResourceRegistry.java?rev=651050&r1=651049&r2=651050&view=diff
==============================================================================
--- labs/vysper/src/main/java/org/apache/vysper/xmpp/resourcebinding/ResourceRegistry.java (original)
+++ labs/vysper/src/main/java/org/apache/vysper/xmpp/resourcebinding/ResourceRegistry.java Wed Apr 23 13:41:53 2008
@@ -50,12 +50,14 @@
protected final Map<Entity, List<String>> entityResources = new HashMap<Entity, List<String>>();
public String bindSession(SessionContext sessionContext) {
- if (sessionContext == null)
- throw new IllegalArgumentException("session context cannot be NULL");
- if (sessionContext.getInitiatingEntity() == null)
- throw new IllegalStateException(
- "session context must have a initiating entity set");
- String resourceId = resourceIdGenerator.create();
+ if (sessionContext == null) {
+ throw new IllegalArgumentException("session context cannot be NULL");
+ }
+ if (sessionContext.getInitiatingEntity() == null) {
+ throw new IllegalStateException(
+ "session context must have a initiating entity set");
+ }
+ String resourceId = resourceIdGenerator.create();
synchronized (boundResources) {
synchronized (entityResources) {
@@ -136,12 +138,12 @@
public SessionContext getSessionContext(String resourceId) {
SessionData data = boundResources.get(resourceId);
- return data.context;
+ if (data == null) return null;
+ return data.context;
}
private Entity getBareEntity(Entity entity) {
- if (!entity.isResourceSet())
- return entity; // bare already
+ if (!entity.isResourceSet()) return entity; // bare already
return new EntityImpl(entity.getNode(), entity.getDomain(), null);
}
@@ -201,7 +203,8 @@
*/
public void setResourceState(String resourceId, ResourceState state) {
SessionData data = boundResources.get(resourceId);
- data.state = state;
+ if (data == null) throw new IllegalArgumentException("resource not registered: " + resourceId);
+ data.state = state;
}
/**
@@ -213,7 +216,8 @@
*/
public ResourceState getResourceState(String resourceId) {
SessionData data = boundResources.get(resourceId);
- return data.state;
+ if (data == null) return null;
+ return data.state;
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org