1 /* 2 * Copyright 2001-2004 The Apache Software Foundation. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package org.apache.ws.scout.registry; 18 19 import java.util.ArrayList; 20 import java.util.Collection; 21 import java.util.LinkedHashSet; 22 23 import javax.xml.registry.BulkResponse; 24 import javax.xml.registry.JAXRException; 25 26 /** 27 * Implements JAXR BulkResponse Interface. 28 * For futher details, look into the JAXR API Javadoc. 29 * 30 * @author <a href="mailto:anil@apache.org">Anil Saldhana</a> 31 * @author <a href="mailto:geirm@apache.org">Geir Magnusson Jr.</a> 32 */ 33 public class BulkResponseImpl extends JAXRResponseImpl implements BulkResponse 34 { 35 private boolean partialResponse = false; 36 37 private Collection<Exception> exceptions = new ArrayList<Exception>(); 38 private Collection<? extends Object> collection = new ArrayList<Object>(); 39 /** 40 * Creates a new instance of BulkResponseImpl 41 */ 42 public BulkResponseImpl() 43 { 44 } 45 46 BulkResponseImpl(LinkedHashSet<? extends Object> collection) 47 { 48 this.collection = collection; 49 } 50 51 /** 52 * Get Collection of RegistryObjects * 53 */ 54 public Collection<? extends Object> getCollection() throws JAXRException 55 { 56 return this.collection; 57 } 58 59 /** 60 * The javadoc is unclear. it says for getExceptions() : 61 * "Get the Collection of RegistryException instances in case of partial 62 * commit. Caller thread will block here if result is not yet available. 63 * Return null if result is available and there is no RegistryException(s)." 64 * Yet the return javadoc says : 65 * "Collection of RegistryException instances. The Collection may be empty but not null." 66 * 67 * So my interpretation is return null if result avail, and empty collection otherwise 68 * 69 * @return Collection Exceptions 70 * @throws JAXRException 71 */ 72 public Collection getExceptions() throws JAXRException 73 { 74 return (this.exceptions.size() == 0 ? null : exceptions); 75 } 76 77 public boolean isPartialResponse() throws JAXRException 78 { 79 if (exceptions.size() > 0) { 80 this.partialResponse = true; 81 } 82 return this.partialResponse; 83 } 84 85 public void setPartialResponse(boolean b) throws JAXRException 86 { 87 this.partialResponse = b; 88 } 89 90 public void setCollection(Collection<? extends Object> coll) throws JAXRException 91 { 92 this.collection = coll; 93 } 94 95 /** 96 * Setter for property exceptions. 97 * 98 * @param exceptions New value of property exceptions. 99 */ 100 public void setExceptions(Collection<Exception> exceptions) 101 { 102 this.exceptions = exceptions; 103 } 104 105 }