View Javadoc

1   /*
2    * Copyright [2005] [University Corporation for Advanced Internet Development, Inc.]
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.opensaml.saml1.core.impl;
18  
19  import java.util.ArrayList;
20  import java.util.Collections;
21  import java.util.List;
22  
23  import org.opensaml.common.impl.AbstractSAMLObject;
24  import org.opensaml.saml1.core.Status;
25  import org.opensaml.saml1.core.StatusCode;
26  import org.opensaml.saml1.core.StatusDetail;
27  import org.opensaml.saml1.core.StatusMessage;
28  import org.opensaml.xml.XMLObject;
29  
30  /**
31   * Concrete Implementation {@link org.opensaml.saml1.core.Status}
32   */
33  public class StatusImpl extends AbstractSAMLObject implements Status {
34  
35      /** Representation of the StatusMessage element. */
36      private StatusMessage statusMessage;
37  
38      /** Representation of the StatusCode element. */
39      private StatusCode statusCode;
40  
41      /** Representation of the StatusDetail element. */
42      private StatusDetail statusDetail;
43  
44      /**
45       * Constructor
46       * 
47       * @param namespaceURI the namespace the element is in
48       * @param elementLocalName the local name of the XML element this Object represents
49       * @param namespacePrefix the prefix for the given namespace
50       */
51      protected StatusImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
52          super(namespaceURI, elementLocalName, namespacePrefix);
53      }
54  
55      /** {@inheritDoc} */
56      public StatusMessage getStatusMessage() {
57          return statusMessage;
58      }
59  
60      /** {@inheritDoc} */
61      public void setStatusMessage(StatusMessage statusMessage) throws IllegalArgumentException {
62          this.statusMessage = prepareForAssignment(this.statusMessage, statusMessage);
63      }
64  
65      /** {@inheritDoc} */
66      public StatusCode getStatusCode() {
67          return statusCode;
68      }
69  
70      /** {@inheritDoc} */
71      public void setStatusCode(StatusCode statusCode) throws IllegalArgumentException {
72          this.statusCode = prepareForAssignment(this.statusCode, statusCode);
73      }
74  
75      /** {@inheritDoc} */
76      public StatusDetail getStatusDetail() {
77          return statusDetail;
78      }
79  
80      /** {@inheritDoc} */
81      public void setStatusDetail(StatusDetail statusDetail) throws IllegalArgumentException {
82          this.statusDetail = prepareForAssignment(this.statusDetail, statusDetail);
83      }
84  
85      /** {@inheritDoc} */
86      public List<XMLObject> getOrderedChildren() {
87          ArrayList<XMLObject> children = new ArrayList<XMLObject>(3);
88  
89          if (statusCode != null) {
90              children.add(statusCode);
91          }
92  
93          if (statusMessage != null) {
94              children.add(statusMessage);
95          }
96  
97          if (statusDetail != null) {
98              children.add(statusDetail);
99          }
100 
101         if (children.size() == 0) {
102             return null;
103         }
104 
105         return Collections.unmodifiableList(children);
106     }
107 }