View Javadoc
1   /*
2    * Copyright 2001-2008 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   */
17  package org.apache.juddi.api.impl;
18  
19  import java.util.ArrayList;
20  import java.util.List;
21  import javax.jws.WebService;
22  
23  import javax.xml.ws.Holder;
24  
25  import org.apache.commons.logging.Log;
26  import org.apache.commons.logging.LogFactory;
27  import org.apache.juddi.api.util.QueryStatus;
28  import org.apache.juddi.api.util.ValueSetCachingQuery;
29  import org.uddi.v3_service.DispositionReportFaultMessage;
30  import org.uddi.v3_service.UDDIValueSetCachingPortType;
31  import org.uddi.vscache_v3.ValidValue;
32  
33  @WebService(serviceName="UDDIValueSetCachingService", 
34  			endpointInterface="org.uddi.v3_service.UDDIValueSetCachingPortType",
35  			targetNamespace = "urn:uddi-org:v3_service")
36  public class UDDIValueSetCachingImpl extends AuthenticatedService implements UDDIValueSetCachingPortType {
37  
38          private static Log logger = LogFactory.getLog(UDDIValueSetCachingImpl.class);
39          private UDDIServiceCounter serviceCounter;
40  
41          public UDDIValueSetCachingImpl() {
42                  super();
43                  serviceCounter = ServiceCounterLifecycleResource.getServiceCounter(this.getClass());
44          }
45  
46          /**
47           *
48           * @param authInfo An optional element that contains an authentication
49           * token. Authentication tokens are obtained using the get_authToken API
50           * call or through some other means external to this specification.
51           * Providers of get_allValidValues Web services that serve multiple
52           * registries and providers that restrict who can use their service may
53           * require authInfo for this API.
54           * @param modelKey A required uddiKey value that identifies the specific
55           * instance of the tModel which describes the value set or category
56           * group system for which a Web service to get all valid values has been
57           * provided. It uniquely identifies the category, identifier, or
58           * category group system for which valid values are being requested.
59           * @param chunkToken Optional element used to retrieve subsequent groups
60           * of data when the first invocation of this API indicates more data is
61           * available. This occurs when a chunkToken is returned whose value is
62           * not "0" in the validValuesList structure described in the next
63           * section. To retrieve the next chunk of data, the chunkToken returned
64           * should be used as an argument to the next invocation of this API.
65           * @param validValue A validValuesList structure is returned containing
66           * the set of valid values for the external category or identifier
67           * system. The list MUST contain a chunkToken if the Web service
68           * provider wishes to provide the data in packets.
69           * @throws DispositionReportFaultMessage
70           */
71          @Override
72          public void getAllValidValues(String authInfo, String modelKey,
73                  Holder<String> chunkToken, Holder<List<ValidValue>> validValue)
74                  throws DispositionReportFaultMessage {
75  
76                  long startTime = System.currentTimeMillis();
77                  List<String> validValues = UDDIValueSetValidationImpl.getValidValues(modelKey);
78  
79                  Holder<List<ValidValue>> ret = new Holder<List<ValidValue>>(new ArrayList<ValidValue>());
80                  if (validValues != null) {
81                          for (int i = 0; i < validValues.size(); i++) {
82                                  ValidValue x = new ValidValue(validValues.get(i));
83                                  ret.value.add(x);
84                          }
85                  }
86                  //findbugs will flag the following as "UC_USELESS_OBJECT" when in fact
87                  //it is returned as part of the service call
88                  chunkToken = new Holder<String>();
89                  chunkToken.value ="0";
90  
91                  long procTime = System.currentTimeMillis() - startTime;
92                  serviceCounter.update(ValueSetCachingQuery.GET_ALLVALIDVALUES,
93                          QueryStatus.SUCCESS, procTime);
94  
95  
96          }
97  }