001: /**
002: *
003: * Copyright 2004 The Apache Software Foundation
004: *
005: * Licensed under the Apache License, Version 2.0 (the "License");
006: * you may not use this file except in compliance with the License.
007: * You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */package org.apache.ws.scout;
017:
018: import java.util.ArrayList;
019: import java.util.Collection;
020: import java.util.Iterator;
021:
022: import javax.xml.registry.BulkResponse;
023: import javax.xml.registry.BusinessLifeCycleManager;
024: import javax.xml.registry.JAXRException;
025: import javax.xml.registry.infomodel.ClassificationScheme;
026: import javax.xml.registry.infomodel.Concept;
027: import javax.xml.registry.infomodel.Key;
028: import javax.xml.registry.infomodel.Organization;
029: import javax.xml.registry.infomodel.Service;
030: import javax.xml.registry.infomodel.ServiceBinding;
031:
032: /**
033: * Remove Registry Objects
034: *
035: */
036: public class Remover extends BaseTestCase {
037: BusinessLifeCycleManager blm = null;
038:
039: public Remover(BusinessLifeCycleManager blm) {
040: super ();
041: this .blm = blm;
042: }
043:
044: public void removeOrganization(Organization org)
045: throws JAXRException {
046:
047: Key key = org.getKey();
048:
049: String id = key.getId();
050: System.out.println("Deleting organization with id " + id);
051: Collection<Key> keys = new ArrayList<Key>();
052: keys.add(key);
053: BulkResponse response = blm.deleteOrganizations(keys);
054: Collection exceptions = response.getExceptions();
055: if (exceptions == null) {
056: System.out.println("Organization deleted");
057: Collection retKeys = response.getCollection();
058: Iterator keyIter = retKeys.iterator();
059: javax.xml.registry.infomodel.Key orgKey = null;
060: if (keyIter.hasNext()) {
061: orgKey = (javax.xml.registry.infomodel.Key) keyIter
062: .next();
063: id = orgKey.getId();
064: System.out.println("Organization key was " + id);
065: }
066: }
067: }
068:
069: public void removeClassificationScheme(ClassificationScheme cs)
070: throws JAXRException {
071: Key key = cs.getKey();
072: String id = key.getId();
073:
074: System.out.println("Deleting concept with id " + id);
075:
076: Collection<Key> keys = new ArrayList<Key>();
077: keys.add(key);
078: BulkResponse response = blm.deleteConcepts(keys);
079:
080: Collection exceptions = response.getExceptions();
081: if (exceptions == null) {
082: Collection retKeys = response.getCollection();
083: Iterator keyIter = retKeys.iterator();
084: javax.xml.registry.infomodel.Key orgKey = null;
085: if (keyIter.hasNext()) {
086: orgKey = (javax.xml.registry.infomodel.Key) keyIter
087: .next();
088: id = orgKey.getId();
089: System.out.println("Concept with ID=" + id
090: + " was deleted");
091: }
092: }
093: }
094:
095: public void removeConcept(Concept concept) throws JAXRException {
096: Key key = concept.getKey();
097: String id = key.getId();
098:
099: System.out.println("Deleting concept with id " + id);
100:
101: Collection<Key> keys = new ArrayList<Key>();
102: keys.add(key);
103: BulkResponse response = blm.deleteConcepts(keys);
104:
105: Collection exceptions = response.getExceptions();
106: if (exceptions == null) {
107: Collection retKeys = response.getCollection();
108: Iterator keyIter = retKeys.iterator();
109: javax.xml.registry.infomodel.Key orgKey = null;
110: if (keyIter.hasNext()) {
111: orgKey = (javax.xml.registry.infomodel.Key) keyIter
112: .next();
113: id = orgKey.getId();
114: System.out.println("Concept with ID=" + id
115: + " was deleted");
116: }
117: }
118: }
119:
120: public void removeService(Service service) throws JAXRException {
121: Key key = service.getKey();
122: String id = key.getId();
123:
124: System.out.println("Deleting service with id " + id);
125:
126: Collection<Key> keys = new ArrayList<Key>();
127: keys.add(key);
128: BulkResponse response = blm.deleteConcepts(keys);
129:
130: Collection exceptions = response.getExceptions();
131: if (exceptions == null) {
132: Collection retKeys = response.getCollection();
133: Iterator keyIter = retKeys.iterator();
134: javax.xml.registry.infomodel.Key orgKey = null;
135: if (keyIter.hasNext()) {
136: orgKey = (javax.xml.registry.infomodel.Key) keyIter
137: .next();
138: id = orgKey.getId();
139: System.out.println("Service with ID=" + id
140: + " was deleted");
141: }
142: }
143: }
144:
145: public void removeServiceBinding(ServiceBinding serviceBinding)
146: throws JAXRException {
147: Key key = serviceBinding.getKey();
148: String id = key.getId();
149:
150: System.out.println("Deleting serviceBinding with id " + id);
151:
152: Collection<Key> keys = new ArrayList<Key>();
153: keys.add(key);
154: BulkResponse response = blm.deleteConcepts(keys);
155:
156: Collection exceptions = response.getExceptions();
157: if (exceptions == null) {
158: Collection retKeys = response.getCollection();
159: Iterator keyIter = retKeys.iterator();
160: javax.xml.registry.infomodel.Key orgKey = null;
161: if (keyIter.hasNext()) {
162: orgKey = (javax.xml.registry.infomodel.Key) keyIter
163: .next();
164: id = orgKey.getId();
165: System.out.println("ServiceBinding with ID=" + id
166: + " was deleted");
167: }
168: }
169: }
170:
171: }
|