Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2008-05-14 05:54:55 +0000
committerslewis2008-05-14 05:54:55 +0000
commitca28e56059e28b378ca912510b7ab9b85da370f8 (patch)
tree99b588851ad8f65a4620547ea5f8b2d2f6087e51
parent5fdb8c1f09b293e1a9836ab39903a91ec5cdd774 (diff)
downloadorg.eclipse.ecf-ca28e56059e28b378ca912510b7ab9b85da370f8.tar.gz
org.eclipse.ecf-ca28e56059e28b378ca912510b7ab9b85da370f8.tar.xz
org.eclipse.ecf-ca28e56059e28b378ca912510b7ab9b85da370f8.zip
Fix for 231969
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/identity/XMPPFileID.java8
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/identity/XMPPFileNamespace.java15
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/identity/XMPPID.java12
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/identity/XMPPNamespace.java27
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/identity/XMPPRoomID.java14
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/identity/XMPPRoomNamespace.java11
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/identity/XMPPSNamespace.java29
7 files changed, 84 insertions, 32 deletions
diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/identity/XMPPFileID.java b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/identity/XMPPFileID.java
index 018eead76..2b6abcf78 100644
--- a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/identity/XMPPFileID.java
+++ b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/identity/XMPPFileID.java
@@ -16,6 +16,7 @@ import java.net.URL;
import org.eclipse.core.runtime.Assert;
import org.eclipse.ecf.core.identity.BaseID;
+import org.eclipse.ecf.core.identity.Namespace;
import org.eclipse.ecf.filetransfer.identity.IFileID;
import org.eclipse.ecf.internal.provider.xmpp.Messages;
@@ -41,6 +42,13 @@ public class XMPPFileID extends BaseID implements IFileID {
}
/* (non-Javadoc)
+ * @see org.eclipse.ecf.core.identity.BaseID#namespaceToExternalForm()
+ */
+ protected String namespaceToExternalForm() {
+ return namespace.getScheme() + Namespace.SCHEME_SEPARATOR + xmppid.toExternalForm() + "*" + filename;
+ }
+
+ /* (non-Javadoc)
* @see org.eclipse.ecf.core.identity.BaseID#namespaceCompareTo(org.eclipse.ecf.core.identity.BaseID)
*/
protected int namespaceCompareTo(BaseID o) {
diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/identity/XMPPFileNamespace.java b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/identity/XMPPFileNamespace.java
index 4bc50d8d0..45ac8f4f7 100644
--- a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/identity/XMPPFileNamespace.java
+++ b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/identity/XMPPFileNamespace.java
@@ -15,6 +15,7 @@ import org.eclipse.ecf.core.identity.ID;
import org.eclipse.ecf.core.identity.IDCreateException;
import org.eclipse.ecf.core.identity.Namespace;
import org.eclipse.ecf.internal.provider.xmpp.Messages;
+import org.eclipse.osgi.util.NLS;
/**
*
@@ -33,13 +34,13 @@ public class XMPPFileNamespace extends Namespace {
public ID createInstance(Object[] parameters) throws IDCreateException {
if (parameters == null || parameters.length < 2 || !(parameters[0] instanceof XMPPID || !(parameters[1] instanceof String)))
throw new IDCreateException(Messages.XMPPFileNamespace_EXCEPTION_INVALID_FILEID_PARAMETERS);
- final XMPPID target = (XMPPID) parameters[0];
- final String filename = (String) parameters[1];
- if (target == null)
- throw new IDCreateException(Messages.XMPPFileNamespace_EXCEPTION_FILEID_TARGETID_NOT_NULL);
- if (filename == null)
- throw new IDCreateException(Messages.XMPPFileNamespace_EXCEPTION_FILEID_FILENAME_NOT_NULL);
- return new XMPPFileID(target, filename);
+ try {
+ final XMPPID target = (XMPPID) parameters[0];
+ final String filename = (String) parameters[1];
+ return new XMPPFileID(target, filename);
+ } catch (final Exception e) {
+ throw new IDCreateException(NLS.bind("{0} createInstance()", getName()), e); //$NON-NLS-1$
+ }
}
/* (non-Javadoc)
diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/identity/XMPPID.java b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/identity/XMPPID.java
index a9242ecbb..c27a4ffc5 100644
--- a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/identity/XMPPID.java
+++ b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/identity/XMPPID.java
@@ -96,6 +96,18 @@ public class XMPPID extends BaseID implements IChatID {
return getUsernameAtHost().hashCode();
}
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.core.identity.BaseID#toExternalForm()
+ */
+ public String toExternalForm() {
+ final StringBuffer buf = new StringBuffer(namespace.getScheme());
+ buf.append(Namespace.SCHEME_SEPARATOR);
+ buf.append(USER_HOST_DELIMITER).append(hostname);
+ buf.append((port == -1) ? "" : PORT_DELIMITER + "" + port);
+ buf.append(resourcename);
+ return buf.toString();
+ }
+
public String getUsername() {
return username;
}
diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/identity/XMPPNamespace.java b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/identity/XMPPNamespace.java
index 04085b076..c0ff58215 100644
--- a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/identity/XMPPNamespace.java
+++ b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/identity/XMPPNamespace.java
@@ -20,12 +20,29 @@ public class XMPPNamespace extends Namespace {
private static final long serialVersionUID = 3257569499003041590L;
private static final String XMPP_PROTOCOL = "xmpp"; //$NON-NLS-1$
-
- public ID createInstance(Object[] args)
- throws IDCreateException {
+
+ private String getInitFromExternalForm(Object[] args) {
+ if (args == null || args.length < 1 || args[0] == null)
+ return null;
+ if (args[0] instanceof String) {
+ final String arg = (String) args[0];
+ if (arg.startsWith(getScheme() + Namespace.SCHEME_SEPARATOR)) {
+ final int index = arg.indexOf(Namespace.SCHEME_SEPARATOR);
+ if (index >= arg.length())
+ return null;
+ return arg.substring(index + 1);
+ }
+ }
+ return null;
+ }
+
+ public ID createInstance(Object[] args) throws IDCreateException {
try {
+ final String init = getInitFromExternalForm(args);
+ if (init != null)
+ return new XMPPID(this, init);
return new XMPPID(this, (String) args[0]);
- } catch (Exception e) {
+ } catch (final Exception e) {
throw new IDCreateException(Messages.XMPPNamespace_EXCEPTION_ID_CREATE, e);
}
}
@@ -38,6 +55,6 @@ public class XMPPNamespace extends Namespace {
* @see org.eclipse.ecf.core.identity.Namespace#getSupportedParameterTypesForCreateInstance()
*/
public Class[][] getSupportedParameterTypes() {
- return new Class[][] { { String.class } };
+ return new Class[][] {{String.class}};
}
}
diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/identity/XMPPRoomID.java b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/identity/XMPPRoomID.java
index 6f0b715b8..f1b62ca7a 100644
--- a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/identity/XMPPRoomID.java
+++ b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/identity/XMPPRoomID.java
@@ -94,13 +94,6 @@ public class XMPPRoomID extends BaseID implements IChatID {
return fieldEquals(other);
}
- protected String fixPath(String path) {
- while (path.startsWith(SLASH)) {
- path = path.substring(1);
- }
- return path;
- }
-
protected String namespaceGetName() {
return this.roomname;
}
@@ -109,6 +102,13 @@ public class XMPPRoomID extends BaseID implements IChatID {
return this.domain.hashCode() ^ this.host.hashCode() ^ this.nickname.hashCode() ^ this.roomname.hashCode() ^ this.username.hashCode();
}
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.core.identity.BaseID#namespaceToExternalForm()
+ */
+ protected String namespaceToExternalForm() {
+ return namespace.getScheme() + Namespace.SCHEME_SEPARATOR + this.longName;
+ }
+
public String getMucString() {
return this.roomname + AT_SIGN + this.domain + DOT + this.host;
}
diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/identity/XMPPRoomNamespace.java b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/identity/XMPPRoomNamespace.java
index 3bce1f16e..997d5c64e 100644
--- a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/identity/XMPPRoomNamespace.java
+++ b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/identity/XMPPRoomNamespace.java
@@ -24,12 +24,10 @@ public class XMPPRoomNamespace extends Namespace {
public ID createInstance(Object[] args) throws IDCreateException {
try {
if (args.length == 5) {
- return new XMPPRoomID(this, (String) args[0], (String) args[1],
- (String) args[2], (String) args[3], (String) args[4]);
+ return new XMPPRoomID(this, (String) args[0], (String) args[1], (String) args[2], (String) args[3], (String) args[4]);
}
- throw new IllegalArgumentException(
- Messages.XMPPRoomNamespace_EXCEPTION_INVALID_ARGUMENTS);
- } catch (Exception e) {
+ throw new IllegalArgumentException(Messages.XMPPRoomNamespace_EXCEPTION_INVALID_ARGUMENTS);
+ } catch (final Exception e) {
throw new IDCreateException(Messages.XMPPRoomNamespace_EXCEPTION_ID_CREAT, e);
}
}
@@ -44,7 +42,6 @@ public class XMPPRoomNamespace extends Namespace {
* @see org.eclipse.ecf.core.identity.Namespace#getSupportedParameterTypesForCreateInstance()
*/
public Class[][] getSupportedParameterTypes() {
- return new Class[][] { { String.class, String.class, String.class,
- String.class, String.class } };
+ return new Class[][] {{String.class, String.class, String.class, String.class, String.class}};
}
}
diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/identity/XMPPSNamespace.java b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/identity/XMPPSNamespace.java
index 428ca7633..e47820f98 100644
--- a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/identity/XMPPSNamespace.java
+++ b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/identity/XMPPSNamespace.java
@@ -18,14 +18,31 @@ import org.eclipse.ecf.internal.provider.xmpp.Messages;
public class XMPPSNamespace extends Namespace {
private static final long serialVersionUID = -820087396161230667L;
-
+
private static final String XMPPS_PROTOCOL = "xmpps"; //$NON-NLS-1$
-
- public ID createInstance(Object[] args)
- throws IDCreateException {
+
+ private String getInitFromExternalForm(Object[] args) {
+ if (args == null || args.length < 1 || args[0] == null)
+ return null;
+ if (args[0] instanceof String) {
+ final String arg = (String) args[0];
+ if (arg.startsWith(getScheme() + Namespace.SCHEME_SEPARATOR)) {
+ final int index = arg.indexOf(Namespace.SCHEME_SEPARATOR);
+ if (index >= arg.length())
+ return null;
+ return arg.substring(index + 1);
+ }
+ }
+ return null;
+ }
+
+ public ID createInstance(Object[] args) throws IDCreateException {
try {
+ final String init = getInitFromExternalForm(args);
+ if (init != null)
+ return new XMPPSID(this, init);
return new XMPPSID(this, (String) args[0]);
- } catch (Exception e) {
+ } catch (final Exception e) {
throw new IDCreateException(Messages.XMPPSNamespace_EXCEPTION_ID_CREATE, e);
}
}
@@ -38,6 +55,6 @@ public class XMPPSNamespace extends Namespace {
* @see org.eclipse.ecf.core.identity.Namespace#getSupportedParameterTypesForCreateInstance()
*/
public Class[][] getSupportedParameterTypes() {
- return new Class[][] { { String.class } };
+ return new Class[][] {{String.class}};
}
}

Back to the top