This project has retired. For details please refer to its
Attic page.
Remover xref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.ws.scout;
18
19 import java.util.ArrayList;
20 import java.util.Collection;
21 import java.util.Iterator;
22
23 import javax.xml.registry.BulkResponse;
24 import javax.xml.registry.BusinessLifeCycleManager;
25 import javax.xml.registry.JAXRException;
26 import javax.xml.registry.infomodel.ClassificationScheme;
27 import javax.xml.registry.infomodel.Concept;
28 import javax.xml.registry.infomodel.Key;
29 import javax.xml.registry.infomodel.Organization;
30 import javax.xml.registry.infomodel.Service;
31 import javax.xml.registry.infomodel.ServiceBinding;
32
33
34
35
36
37 public class Remover extends BaseTestCase
38 {
39 BusinessLifeCycleManager blm = null;
40
41 public Remover(BusinessLifeCycleManager blm) {
42 super();
43 this.blm = blm;
44 }
45
46 public void removeOrganization(Organization org) throws JAXRException {
47
48 Key key = org.getKey();
49
50 String id = key.getId();
51 System.out.println("Deleting organization with id " + id);
52 Collection<Key> keys = new ArrayList<Key>();
53 keys.add(key);
54 BulkResponse response = blm.deleteOrganizations(keys);
55 Collection exceptions = response.getExceptions();
56 if (exceptions == null) {
57 System.out.println("Organization deleted");
58 Collection retKeys = response.getCollection();
59 Iterator keyIter = retKeys.iterator();
60 javax.xml.registry.infomodel.Key orgKey = null;
61 if (keyIter.hasNext()) {
62 orgKey =
63 (javax.xml.registry.infomodel.Key) keyIter.next();
64 id = orgKey.getId();
65 System.out.println("Organization key was " + id);
66 }
67 }
68 }
69
70 public void removeClassificationScheme(ClassificationScheme cs)
71 throws JAXRException
72 {
73 Key key = cs.getKey();
74 String id = key.getId();
75
76 System.out.println("Deleting concept with id " + id);
77
78 Collection<Key> keys = new ArrayList<Key>();
79 keys.add(key);
80 BulkResponse response = blm.deleteClassificationSchemes(keys);
81
82 Collection exceptions = response.getExceptions();
83 if (exceptions == null) {
84 Collection retKeys = response.getCollection();
85 Iterator keyIter = retKeys.iterator();
86 javax.xml.registry.infomodel.Key orgKey = null;
87 if (keyIter.hasNext()) {
88 orgKey =
89 (javax.xml.registry.infomodel.Key) keyIter.next();
90 id = orgKey.getId();
91 System.out.println("Concept with ID=" + id + " was deleted");
92 }
93 }
94 }
95
96 public void removeConcept(Concept concept)
97 throws JAXRException
98 {
99 Key key = concept.getKey();
100 String id = key.getId();
101
102 System.out.println("Deleting concept with id " + id);
103
104 Collection<Key> keys = new ArrayList<Key>();
105 keys.add(key);
106 BulkResponse response = blm.deleteConcepts(keys);
107
108 Collection exceptions = response.getExceptions();
109 if (exceptions == null) {
110 Collection retKeys = response.getCollection();
111 Iterator keyIter = retKeys.iterator();
112 javax.xml.registry.infomodel.Key orgKey = null;
113 if (keyIter.hasNext()) {
114 orgKey =
115 (javax.xml.registry.infomodel.Key) keyIter.next();
116 id = orgKey.getId();
117 System.out.println("Concept with ID=" + id + " was deleted");
118 }
119 }
120 }
121
122 public void removeService(Service service)
123 throws JAXRException
124 {
125 Key key = service.getKey();
126 String id = key.getId();
127
128 System.out.println("Deleting service with id " + id);
129
130 Collection<Key> keys = new ArrayList<Key>();
131 keys.add(key);
132 BulkResponse response = blm.deleteServices(keys);
133
134 Collection exceptions = response.getExceptions();
135 if (exceptions == null) {
136 Collection retKeys = response.getCollection();
137 Iterator keyIter = retKeys.iterator();
138 javax.xml.registry.infomodel.Key orgKey = null;
139 if (keyIter.hasNext()) {
140 orgKey =
141 (javax.xml.registry.infomodel.Key) keyIter.next();
142 id = orgKey.getId();
143 System.out.println("Service with ID=" + id + " was deleted");
144 }
145 }
146 }
147
148 public void removeServiceBinding(ServiceBinding serviceBinding)
149 throws JAXRException
150 {
151 Key key = serviceBinding.getKey();
152 String id = key.getId();
153
154 System.out.println("Deleting serviceBinding with id " + id);
155
156 Collection<Key> keys = new ArrayList<Key>();
157 keys.add(key);
158 BulkResponse response = blm.deleteServiceBindings(keys);
159
160 Collection exceptions = response.getExceptions();
161 if (exceptions == null) {
162 Collection retKeys = response.getCollection();
163 Iterator keyIter = retKeys.iterator();
164 javax.xml.registry.infomodel.Key orgKey = null;
165 if (keyIter.hasNext()) {
166 orgKey =
167 (javax.xml.registry.infomodel.Key) keyIter.next();
168 id = orgKey.getId();
169 System.out.println("ServiceBinding with ID=" + id + " was deleted");
170 }
171 }
172 }
173
174
175
176 }