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