View Javadoc

1   /*
2    * Copyright 2001-2004 The Apache Software Foundation.
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  package org.apache.geronimo.ews.ws4j2ee.context.webservices.server.xmlbeans;
17  
18  import com.sun.java.xml.ns.j2Ee.IconType;
19  import com.sun.java.xml.ns.j2Ee.WebserviceDescriptionType;
20  import com.sun.java.xml.ns.j2Ee.WebservicesType;
21  import org.apache.geronimo.ews.ws4j2ee.context.webservices.server.AbstractWSCFWebservices;
22  import org.apache.geronimo.ews.ws4j2ee.context.webservices.server.WSCFException;
23  import org.apache.geronimo.ews.ws4j2ee.context.webservices.server.interfaces.WSCFWebserviceDescription;
24  import org.apache.geronimo.ews.ws4j2ee.context.webservices.server.interfaces.WSCFWebservices;
25  
26  /***
27   * This is the class that will represent the webservices element in the runtime.
28   * This is the root element of the webservices.xml file. The parsing of elements will be initiated from here and will be
29   * parsed in a depth first manner
30   */
31  public class WSCFWebservicesImpl extends AbstractWSCFWebservices implements WSCFWebservices {
32      /***
33       * Constructor
34       * This is the constructor that was written to make the code jaxb complient. THis class
35       * basically wrap the jaxb webservides element.
36       */
37      public WSCFWebservicesImpl(WebservicesType webservices) throws WSCFException {
38          this.description = XMLBeansUtils.getStringValue(webservices.getDescriptionArray());
39          this.displayName = XMLBeansUtils.getStringValue(webservices.getDisplayNameArray());
40          IconType[] icons = webservices.getIconArray();
41          if (icons.length > 0) {
42              this.smallIcon = XMLBeansUtils.getStringValue(icons[0].getSmallIcon());
43              this.largeIcon = XMLBeansUtils.getStringValue(icons[0].getLargeIcon());
44          }
45          WebserviceDescriptionType[] wsdes = webservices.getWebserviceDescriptionArray();
46          if (0 == wsdes.length) {
47              throw new WSCFException("The webservices description element does not exist");
48          }
49          for (int i = 0; i < wsdes.length; i++) {
50              WSCFWebserviceDescription webservicesDescription = new WSCFWebserviceDescriptionImpl(wsdes[i]);
51              this.webServiceDescriptions.put(webservicesDescription.getDisplayName(), webservicesDescription);
52          }
53      }
54  }