1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.chemistry.opencmis.client.bindings.webservices;
20
21 import java.util.HashMap;
22 import java.util.Locale;
23 import java.util.Map;
24
25 import org.apache.chemistry.opencmis.client.bindings.CmisBindingFactory;
26 import org.apache.chemistry.opencmis.commons.SessionParameter;
27 import org.apache.chemistry.opencmis.commons.spi.CmisBinding;
28
29
30
31
32 public class WebServicesTestBindingFactory {
33
34 private WebServicesTestBindingFactory() {
35 }
36
37 public static CmisBinding createBinding(String url, String username, String password) {
38 boolean isPrefix = true;
39
40 url = url.trim();
41 String urlLower = url.toLowerCase(Locale.ENGLISH);
42
43 if (urlLower.endsWith("?wsdl")) {
44 isPrefix = false;
45 } else if (urlLower.endsWith(".wsdl")) {
46 isPrefix = false;
47 } else if (urlLower.endsWith(".xml")) {
48 isPrefix = false;
49 } else if (urlLower.endsWith(".aspx")) {
50 isPrefix = false;
51 } else if (urlLower.endsWith("/wsdl")) {
52 isPrefix = false;
53 }
54
55 return createBinding(url, isPrefix, username, password);
56 }
57
58 public static CmisBinding createBinding(String url, boolean isPrefix, String username, String password) {
59
60 Map<String, String> parameters = new HashMap<String, String>();
61 parameters.put(SessionParameter.USER, username);
62 parameters.put(SessionParameter.PASSWORD, password);
63
64 if (!isPrefix) {
65 parameters.put(SessionParameter.WEBSERVICES_REPOSITORY_SERVICE, url);
66 parameters.put(SessionParameter.WEBSERVICES_NAVIGATION_SERVICE, url);
67 parameters.put(SessionParameter.WEBSERVICES_OBJECT_SERVICE, url);
68 parameters.put(SessionParameter.WEBSERVICES_VERSIONING_SERVICE, url);
69 parameters.put(SessionParameter.WEBSERVICES_DISCOVERY_SERVICE, url);
70 parameters.put(SessionParameter.WEBSERVICES_RELATIONSHIP_SERVICE, url);
71 parameters.put(SessionParameter.WEBSERVICES_MULTIFILING_SERVICE, url);
72 parameters.put(SessionParameter.WEBSERVICES_POLICY_SERVICE, url);
73 parameters.put(SessionParameter.WEBSERVICES_ACL_SERVICE, url);
74 } else {
75 parameters.put(SessionParameter.WEBSERVICES_REPOSITORY_SERVICE, url + "RepositoryService?wsdl");
76 parameters.put(SessionParameter.WEBSERVICES_NAVIGATION_SERVICE, url + "NavigationService?wsdl");
77 parameters.put(SessionParameter.WEBSERVICES_OBJECT_SERVICE, url + "ObjectService?wsdl");
78 parameters.put(SessionParameter.WEBSERVICES_VERSIONING_SERVICE, url + "VersioningService?wsdl");
79 parameters.put(SessionParameter.WEBSERVICES_DISCOVERY_SERVICE, url + "DiscoveryService?wsdl");
80 parameters.put(SessionParameter.WEBSERVICES_RELATIONSHIP_SERVICE, url + "RelationshipService?wsdl");
81 parameters.put(SessionParameter.WEBSERVICES_MULTIFILING_SERVICE, url + "MultiFilingService?wsdl");
82 parameters.put(SessionParameter.WEBSERVICES_POLICY_SERVICE, url + "PolicyService?wsdl");
83 parameters.put(SessionParameter.WEBSERVICES_ACL_SERVICE, url + "ACLService?wsdl");
84 }
85
86
87 CmisBindingFactory factory = CmisBindingFactory.newInstance();
88 CmisBinding binding = factory.createCmisWebServicesBinding(parameters);
89
90 return binding;
91 }
92 }