View Javadoc

1   /*
2   Copyright 2008 Members of the EGEE Collaboration.
3   Copyright 2008 University Corporation for Advanced Internet Development,
4   Inc.
5   
6   Licensed under the Apache License, Version 2.0 (the "License");
7   you may not use this file except in compliance with the License.
8   You may obtain a copy of the License at
9   
10      http://www.apache.org/licenses/LICENSE-2.0
11  
12  Unless required by applicable law or agreed to in writing, software
13  distributed under the License is distributed on an "AS IS" BASIS,
14  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  See the License for the specific language governing permissions and
16  limitations under the License.
17   */
18  
19  package org.opensaml.xacml.ctx.impl;
20  
21  import java.util.ArrayList;
22  import java.util.Collections;
23  import java.util.List;
24  
25  import org.opensaml.xacml.ctx.DecisionType;
26  import org.opensaml.xacml.ctx.ResultType;
27  import org.opensaml.xacml.ctx.StatusType;
28  import org.opensaml.xacml.policy.ObligationsType;
29  import org.opensaml.xml.XMLObject;
30  import org.opensaml.xml.validation.AbstractValidatingXMLObject;
31  
32  /** Concrete implementation of {@link ResultType}. */
33  public class ResultTypeImpl extends AbstractValidatingXMLObject implements ResultType {
34  
35      /** Attribute resource id. */
36      private String resourceId;
37  
38      /** The decision of the result. */
39      private DecisionType decision;
40  
41      /** List of the status of this result. */
42      private StatusType status;
43  
44      /** The obligations in this Result. */
45      private ObligationsType obligations;
46  
47      /**
48       * Constructor.
49       * 
50       * @param namespaceURI the namespace the element is in
51       * @param elementLocalName the local name of the XML element this Object represents
52       * @param namespacePrefix the prefix for the given namespace
53       */
54      protected ResultTypeImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
55          super(namespaceURI, elementLocalName, namespacePrefix);
56      }
57  
58      /** {@inheritDoc} */
59      public DecisionType getDecision() {
60          return decision;
61      }
62  
63      /** {@inheritDoc} */
64      public ObligationsType getObligations() {
65          return obligations;
66      }
67  
68      /** {@inheritDoc} */
69      public void setObligations(ObligationsType obligationsIn) {
70          this.obligations = prepareForAssignment(this.obligations, obligationsIn);
71      }
72  
73      /** {@inheritDoc} */
74      public String getResourceId() {
75          return resourceId;
76      }
77  
78      /** {@inheritDoc} */
79      public StatusType getStatus() {
80          return status;
81      }
82  
83      /** {@inheritDoc} */
84      public void setStatus(StatusType statusIn) {
85          this.status = prepareForAssignment(this.status, statusIn);
86      }
87  
88      /** {@inheritDoc} */
89      public void setDecision(DecisionType decisionIn) {
90          this.decision = prepareForAssignment(this.decision, decisionIn);
91      }
92  
93      /** {@inheritDoc} */
94      public void setResourceId(String newResourceId) {
95          resourceId = prepareForAssignment(this.resourceId, newResourceId);
96      }
97  
98      /** {@inheritDoc} */
99      public List<XMLObject> getOrderedChildren() {
100         ArrayList<XMLObject> children = new ArrayList<XMLObject>();
101 
102         if (decision != null) {
103             children.add(decision);
104         }
105 
106         if (status != null) {
107             children.add(status);
108         }
109 
110         if (obligations != null) {
111             children.add(obligations);
112         }
113         return Collections.unmodifiableList(children);
114     }
115 }