1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.transport.xmpp; |
12 | |
|
13 | |
import org.mule.api.endpoint.MalformedEndpointException; |
14 | |
import org.mule.endpoint.UserInfoEndpointURIBuilder; |
15 | |
import org.mule.transport.xmpp.i18n.XmppMessages; |
16 | |
|
17 | |
import java.net.URI; |
18 | |
import java.util.Properties; |
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | 0 | public class XmppEndpointURIBuilder extends UserInfoEndpointURIBuilder |
25 | |
{ |
26 | |
@Override |
27 | |
protected void setEndpoint(URI uri, Properties props) throws MalformedEndpointException |
28 | |
{ |
29 | 0 | checkXmppMessageType(uri); |
30 | 0 | checkRecipient(uri); |
31 | 0 | super.setEndpoint(uri, props); |
32 | 0 | } |
33 | |
|
34 | |
private void checkXmppMessageType(URI uri) throws MalformedEndpointException |
35 | |
{ |
36 | |
|
37 | 0 | String host = uri.getHost(); |
38 | |
|
39 | 0 | if (host.length() == 0) |
40 | |
{ |
41 | 0 | throw new MalformedEndpointException(XmppMessages.noMessageTypeInUri(), uri.toString()); |
42 | |
} |
43 | |
|
44 | |
try |
45 | |
{ |
46 | 0 | XmppMessageType.valueOf(host); |
47 | |
} |
48 | 0 | catch (IllegalArgumentException e) |
49 | |
{ |
50 | 0 | throw new MalformedEndpointException(XmppMessages.invalidMessageTypeInUri(), |
51 | |
uri.toString()); |
52 | 0 | } |
53 | 0 | } |
54 | |
|
55 | |
private void checkRecipient(URI uri) throws MalformedEndpointException |
56 | |
{ |
57 | |
|
58 | 0 | if (uri.getPath().length() == 0) |
59 | |
{ |
60 | 0 | throw new MalformedEndpointException(XmppMessages.noRecipientInUri(), uri.toString()); |
61 | |
} |
62 | 0 | } |
63 | |
} |