001 /** 002 * Copyright 2005-2014 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 */ 016 package org.kuali.rice.kew.api.action; 017 018 import javax.xml.bind.annotation.XmlAccessType; 019 import javax.xml.bind.annotation.XmlAccessorType; 020 import javax.xml.bind.annotation.XmlElement; 021 import javax.xml.bind.annotation.XmlRootElement; 022 import javax.xml.bind.annotation.XmlType; 023 024 import org.apache.commons.lang.StringUtils; 025 026 @XmlRootElement(name = AdHocToPrincipal.Constants.ROOT_ELEMENT_NAME) 027 @XmlAccessorType(XmlAccessType.NONE) 028 @XmlType(name = AdHocToPrincipal.Constants.TYPE_NAME, propOrder = { 029 AdHocToPrincipal.Elements.TARGET_PRINCIPAL_ID 030 }) 031 public final class AdHocToPrincipal extends AdHocCommand { 032 033 private static final long serialVersionUID = -4512561589558793736L; 034 035 @XmlElement(name = Elements.TARGET_PRINCIPAL_ID, required = true) 036 private final String targetPrincipalId; 037 038 private AdHocToPrincipal() { 039 this.targetPrincipalId = null; 040 } 041 042 private AdHocToPrincipal(Builder builder) { 043 super(builder); 044 this.targetPrincipalId = builder.getTargetPrincipalId(); 045 } 046 047 public String getTargetPrincipalId() { 048 return targetPrincipalId; 049 } 050 051 public static final class Builder extends AdHocCommand.Builder<AdHocToPrincipal> { 052 053 private static final long serialVersionUID = 5288681963619747957L; 054 055 private String targetPrincipalId; 056 057 private Builder(ActionRequestType actionRequested, String nodeName, String targetPrincipalId) { 058 super(actionRequested, nodeName); 059 setTargetPrincipalId(targetPrincipalId); 060 } 061 062 public static Builder create(ActionRequestType actionRequested, String nodeName, String targetPrincipalId) { 063 return new Builder(actionRequested, nodeName, targetPrincipalId); 064 } 065 066 public String getTargetPrincipalId() { 067 return targetPrincipalId; 068 } 069 070 public void setTargetPrincipalId(String targetPrincipalId) { 071 if (StringUtils.isBlank(targetPrincipalId)) { 072 throw new IllegalArgumentException("targetPrincipalId was null or blank"); 073 } 074 this.targetPrincipalId = targetPrincipalId; 075 } 076 077 @Override 078 public AdHocToPrincipal build() { 079 return new AdHocToPrincipal(this); 080 } 081 082 } 083 084 /** 085 * Defines some internal constants used on this class. 086 */ 087 static class Constants { 088 final static String ROOT_ELEMENT_NAME = "adHocPrincipal_v2_1_3"; 089 final static String TYPE_NAME = "AdHocToPrincipalType_v2_1_3"; 090 } 091 092 /** 093 * A private class which exposes constants which define the XML element names to use when this object is marshalled to XML. 094 */ 095 static class Elements { 096 final static String TARGET_PRINCIPAL_ID = "targetPrincipalId"; 097 } 098 099 100 }