1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
package org.apache.ws.scout.registry; |
18 | |
|
19 | |
import javax.xml.registry.BulkResponse; |
20 | |
import javax.xml.registry.BusinessLifeCycleManager; |
21 | |
import javax.xml.registry.BusinessQueryManager; |
22 | |
import javax.xml.registry.CapabilityProfile; |
23 | |
import javax.xml.registry.DeclarativeQueryManager; |
24 | |
import javax.xml.registry.InvalidRequestException; |
25 | |
import javax.xml.registry.JAXRException; |
26 | |
import javax.xml.registry.RegistryService; |
27 | |
import javax.xml.registry.UnsupportedCapabilityException; |
28 | |
import javax.xml.registry.infomodel.ClassificationScheme; |
29 | |
|
30 | |
import org.apache.ws.scout.registry.infomodel.ClassificationSchemeImpl; |
31 | |
import org.apache.ws.scout.registry.infomodel.KeyImpl; |
32 | |
import org.apache.ws.scout.transport.TransportException; |
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
public class RegistryServiceImpl implements RegistryService |
43 | |
{ |
44 | |
private final IRegistryBase registry; |
45 | |
private final BusinessQueryManager queryManager; |
46 | |
private final BusinessLifeCycleManager lifeCycleManager; |
47 | |
|
48 | |
private final ClassificationSchemeImpl postalScheme; |
49 | |
private final int maxRows; |
50 | |
private final String uddiVersion; |
51 | |
|
52 | |
private ConnectionImpl connection; |
53 | |
|
54 | |
public RegistryServiceImpl(IRegistryBase registry, String postalScheme, int maxRows, String uddiVersion) |
55 | 0 | { |
56 | 0 | this.registry = registry; |
57 | 0 | this.maxRows = maxRows; |
58 | 0 | this.uddiVersion = uddiVersion; |
59 | 0 | if ("3.0".equals(uddiVersion)) { |
60 | 0 | queryManager = new BusinessQueryManagerV3Impl(this); |
61 | 0 | lifeCycleManager = new BusinessLifeCycleManagerV3Impl(this); |
62 | |
} else { |
63 | 0 | queryManager = new BusinessQueryManagerImpl(this); |
64 | 0 | lifeCycleManager = new BusinessLifeCycleManagerImpl(this); |
65 | |
} |
66 | 0 | if (postalScheme == null) |
67 | |
{ |
68 | 0 | this.postalScheme = null; |
69 | |
} else |
70 | |
{ |
71 | 0 | this.postalScheme = new ClassificationSchemeImpl(lifeCycleManager); |
72 | 0 | this.postalScheme.setKey(new KeyImpl(postalScheme)); |
73 | |
} |
74 | 0 | } |
75 | |
|
76 | |
IRegistryBase getRegistry() |
77 | |
{ |
78 | 0 | return registry; |
79 | |
} |
80 | |
|
81 | |
BusinessLifeCycleManager getLifeCycleManagerImpl() |
82 | |
{ |
83 | 0 | return lifeCycleManager; |
84 | |
} |
85 | |
|
86 | |
int getMaxRows() |
87 | |
{ |
88 | 0 | return maxRows; |
89 | |
} |
90 | |
|
91 | |
public CapabilityProfile getCapabilityProfile() |
92 | |
{ |
93 | 0 | return new CapabilityProfileImpl(); |
94 | |
} |
95 | |
|
96 | |
public String getUddiVersion() { |
97 | 0 | return uddiVersion; |
98 | |
} |
99 | |
|
100 | |
public BusinessQueryManager getBusinessQueryManager() throws JAXRException |
101 | |
{ |
102 | 0 | return queryManager; |
103 | |
} |
104 | |
|
105 | |
public BusinessLifeCycleManager getBusinessLifeCycleManager() throws JAXRException |
106 | |
{ |
107 | 0 | return lifeCycleManager; |
108 | |
} |
109 | |
|
110 | |
public BulkResponse getBulkResponse(String s) throws JAXRException, InvalidRequestException |
111 | |
{ |
112 | 0 | if (s == "" || s == null) |
113 | 0 | throw new InvalidRequestException(); |
114 | 0 | return null; |
115 | |
} |
116 | |
|
117 | |
public DeclarativeQueryManager getDeclarativeQueryManager() throws JAXRException, UnsupportedCapabilityException |
118 | |
{ |
119 | 0 | throw new UnsupportedCapabilityException(); |
120 | |
} |
121 | |
|
122 | |
public ClassificationScheme getDefaultPostalScheme() throws JAXRException |
123 | |
{ |
124 | 0 | return postalScheme; |
125 | |
} |
126 | |
|
127 | |
public String makeRegistrySpecificRequest(String s) throws JAXRException |
128 | |
{ |
129 | 0 | String inquiry = "INQUIRY"; |
130 | 0 | String publish = "PUBLISH"; |
131 | 0 | String type = ""; |
132 | |
|
133 | |
|
134 | 0 | String snippet = s.substring(0,20); |
135 | 0 | if( snippet.indexOf("save") > -1) type = publish; |
136 | |
else |
137 | 0 | type = inquiry; |
138 | |
|
139 | |
try { |
140 | 0 | return registry.execute(s,type); |
141 | 0 | } catch (TransportException e) { |
142 | 0 | throw new JAXRException(e.getLocalizedMessage()); |
143 | |
} |
144 | |
} |
145 | |
|
146 | |
public ConnectionImpl getConnection() |
147 | |
{ |
148 | 0 | return connection; |
149 | |
} |
150 | |
|
151 | |
public void setConnection(ConnectionImpl connection) |
152 | |
{ |
153 | 0 | this.connection = connection; |
154 | 0 | } |
155 | |
|
156 | |
} |