001/** 002 * Copyright 2005-2016 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.rice.ksb.api.registry; 017 018import java.util.ArrayList; 019import java.util.Collection; 020import java.util.Collections; 021import java.util.List; 022 023import javax.xml.bind.annotation.XmlAccessType; 024import javax.xml.bind.annotation.XmlAccessorType; 025import javax.xml.bind.annotation.XmlAnyElement; 026import javax.xml.bind.annotation.XmlElement; 027import javax.xml.bind.annotation.XmlElementWrapper; 028import javax.xml.bind.annotation.XmlRootElement; 029import javax.xml.bind.annotation.XmlType; 030 031import org.kuali.rice.core.api.CoreConstants; 032import org.kuali.rice.core.api.mo.AbstractDataTransferObject; 033import org.w3c.dom.Element; 034 035/** 036 * Wraps information resulting from a "removeAndPublish" operation on the 037 * registry. Effectively contains a list of {@link ServiceEndpoint} instances 038 * for services that were published and those that were removed 039 * 040 * @author Kuali Rice Team (rice.collab@kuali.org) 041 * 042 */ 043@XmlRootElement(name = RemoveAndPublishResult.Constants.ROOT_ELEMENT_NAME) 044@XmlAccessorType(XmlAccessType.NONE) 045@XmlType(name = RemoveAndPublishResult.Constants.TYPE_NAME, propOrder = { 046 RemoveAndPublishResult.Elements.SERVICES_REMOVED, 047 RemoveAndPublishResult.Elements.SERVICES_PUBLISHED, 048 CoreConstants.CommonElements.FUTURE_ELEMENTS 049}) 050public class RemoveAndPublishResult extends AbstractDataTransferObject { 051 052 private static final long serialVersionUID = 4279564869510247725L; 053 054 @XmlElementWrapper(name = Elements.SERVICES_REMOVED, required = false) 055 @XmlElement(name = Elements.SERVICE_REMOVED, required = false) 056 private final List<ServiceEndpoint> servicesRemoved; 057 058 @XmlElementWrapper(name = Elements.SERVICES_PUBLISHED, required = false) 059 @XmlElement(name = Elements.SERVICE_PUBLISHED, required = false) 060 private final List<ServiceEndpoint> servicesPublished; 061 062 @SuppressWarnings("unused") 063 @XmlAnyElement 064 private final Collection<Element> _futureElements = null; 065 066 private RemoveAndPublishResult() { 067 this.servicesRemoved = null; 068 this.servicesPublished = null; 069 } 070 071 private RemoveAndPublishResult(List<ServiceEndpoint> servicesRemoved, List<ServiceEndpoint> servicesPublished) { 072 this.servicesRemoved = servicesRemoved; 073 this.servicesPublished = servicesPublished; 074 } 075 076 /** 077 * Creates a new {@code RemoveAndPublishResult} from the given lists of services removed and published. 078 * 079 * @param servicesRemoved the list of services removed by the operation, can be a null or empty list 080 * @param servicesPublished the list of services published by the operation, can be a null or empty list 081 * 082 * @return the constructed {@code RemoveAndPublishResult}, should never return null 083 */ 084 public static RemoveAndPublishResult create(List<ServiceEndpoint> servicesRemoved, List<ServiceEndpoint> servicesPublished) { 085 return new RemoveAndPublishResult(new ArrayList<ServiceEndpoint>(servicesRemoved), 086 new ArrayList<ServiceEndpoint>(servicesPublished)); 087 } 088 089 /** 090 * Returns an unmodifiable list of services that were removed as the result 091 * of a remove-and-publish operation. 092 * 093 * @return an unmodifiable list of removed services, will never be null but 094 * may be empty if no services were removed 095 */ 096 public List<ServiceEndpoint> getServicesRemoved() { 097 return Collections.unmodifiableList(servicesRemoved); 098 } 099 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}