View Javadoc

1   /**
2    * Copyright 2005-2011 The Kuali Foundation
3    *
4    * Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php
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  package org.kuali.rice.ksb.api.registry;
17  
18  import java.util.ArrayList;
19  import java.util.Collection;
20  import java.util.Collections;
21  import java.util.List;
22  
23  import javax.xml.bind.annotation.XmlAccessType;
24  import javax.xml.bind.annotation.XmlAccessorType;
25  import javax.xml.bind.annotation.XmlAnyElement;
26  import javax.xml.bind.annotation.XmlElement;
27  import javax.xml.bind.annotation.XmlElementWrapper;
28  import javax.xml.bind.annotation.XmlRootElement;
29  import javax.xml.bind.annotation.XmlType;
30  
31  import org.kuali.rice.core.api.CoreConstants;
32  import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
33  import org.w3c.dom.Element;
34  
35  /**
36   * Wraps information resulting from a "removeAndPublish" operation on the
37   * registry.  Effectively contains a list of {@link ServiceEndpoint} instances
38   * for services that were published and those that were removed
39   * 
40   * @author Kuali Rice Team (rice.collab@kuali.org)
41   *
42   */
43  @XmlRootElement(name = RemoveAndPublishResult.Constants.ROOT_ELEMENT_NAME)
44  @XmlAccessorType(XmlAccessType.NONE)
45  @XmlType(name = RemoveAndPublishResult.Constants.TYPE_NAME, propOrder = {
46  		RemoveAndPublishResult.Elements.SERVICES_REMOVED,
47  		RemoveAndPublishResult.Elements.SERVICES_PUBLISHED,
48  		CoreConstants.CommonElements.FUTURE_ELEMENTS
49  })
50  public class RemoveAndPublishResult extends AbstractDataTransferObject {
51  
52  	private static final long serialVersionUID = 4279564869510247725L;
53  
54  	@XmlElementWrapper(name = Elements.SERVICES_REMOVED, required = false)
55  	@XmlElement(name = Elements.SERVICE_REMOVED, required = false)
56  	private final List<ServiceEndpoint> servicesRemoved;
57  	
58  	@XmlElementWrapper(name = Elements.SERVICES_PUBLISHED, required = false)
59  	@XmlElement(name = Elements.SERVICE_PUBLISHED, required = false)
60  	private final List<ServiceEndpoint> servicesPublished;
61  	
62      @SuppressWarnings("unused")
63      @XmlAnyElement
64      private final Collection<Element> _futureElements = null;
65  
66  	private RemoveAndPublishResult() {
67  		this.servicesRemoved = null;
68  		this.servicesPublished = null;
69  	}
70  	
71  	private RemoveAndPublishResult(List<ServiceEndpoint> servicesRemoved, List<ServiceEndpoint> servicesPublished) {
72  		this.servicesRemoved = servicesRemoved;
73  		this.servicesPublished = servicesPublished;
74  	}
75  	
76  	/**
77  	 * Creates a new {@code RemoveAndPublishResult} from the given lists of services removed and published.
78  	 * 
79  	 * @param servicesRemoved the list of services removed by the operation, can be a null or empty list
80  	 * @param servicesPublished the list of services published by the operation, can be a null or empty list
81  	 * 
82  	 * @return the constructed {@code RemoveAndPublishResult}, should never return null
83  	 */
84  	public static RemoveAndPublishResult create(List<ServiceEndpoint> servicesRemoved, List<ServiceEndpoint> servicesPublished) {
85  		return new RemoveAndPublishResult(new ArrayList<ServiceEndpoint>(servicesRemoved),
86  				new ArrayList<ServiceEndpoint>(servicesPublished));
87  	}
88  
89  	/**
90  	 * Returns an unmodifiable list of services that were removed as the result
91  	 * of a remove-and-publish operation.
92  	 * 
93  	 * @return an unmodifiable list of removed services, will never be null but
94  	 * may be empty if no services were removed
95  	 */
96  	public List<ServiceEndpoint> getServicesRemoved() {
97  		return Collections.unmodifiableList(servicesRemoved);
98  	}
99  
100 	/**
101 	 * Returns an unmodifiable list of services that were published as the result
102 	 * of a remove-and-publish operation.
103 	 * 
104 	 * @return an unmodifiable list of published services, will never be null but
105 	 * may be empty if no services were published
106 	 */
107 	public List<ServiceEndpoint> getServicesPublished() {
108 		return Collections.unmodifiableList(servicesPublished);
109 	}
110 	
111 	/**
112      * Defines some internal constants used on this class.
113      */
114     static class Constants {
115 
116     	final static String ROOT_ELEMENT_NAME = "removeAndPublishResult";
117         final static String TYPE_NAME = "RemoveAndPublishResultType";
118     }
119 	
120 	/**
121      * Exposes constants which define the XML element names to use when this object is marshalled to XML.
122      */
123     static class Elements {
124 
125         final static String SERVICES_REMOVED = "servicesRemoved";
126         final static String SERVICE_REMOVED = "serviceRemoved";
127         final static String SERVICES_PUBLISHED = "servicesPublished";
128         final static String SERVICE_PUBLISHED = "servicePublished";
129 
130     }
131     
132 }