001: /**
002: *
003: * Copyright 2004 The Apache Software Foundation
004: *
005: * Licensed under the Apache License, Version 2.0 (the "License");
006: * you may not use this file except in compliance with the License.
007: * You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */package org.apache.ws.scout.registry;
017:
018: import javax.xml.registry.BulkResponse;
019: import javax.xml.registry.BusinessLifeCycleManager;
020: import javax.xml.registry.BusinessQueryManager;
021: import javax.xml.registry.CapabilityProfile;
022: import javax.xml.registry.DeclarativeQueryManager;
023: import javax.xml.registry.InvalidRequestException;
024: import javax.xml.registry.JAXRException;
025: import javax.xml.registry.RegistryService;
026: import javax.xml.registry.UnsupportedCapabilityException;
027: import javax.xml.registry.infomodel.ClassificationScheme;
028:
029: import org.apache.ws.scout.registry.infomodel.ClassificationSchemeImpl;
030: import org.apache.ws.scout.registry.infomodel.KeyImpl;
031:
032: /**
033: * Scout implementation of javax.xml.registry.RegistryService
034: * For futher details, look into the JAXR API Javadoc.
035: *
036: * @author Anil Saldhana <anil@apache.org>
037: * @author Jeremy Boynes <jboynes@apache.org>
038: */
039: public class RegistryServiceImpl implements RegistryService {
040: private final RegistryImpl registry;
041: private final BusinessQueryManagerImpl queryManager;
042: private final BusinessLifeCycleManagerImpl lifeCycleManager;
043:
044: private final ClassificationSchemeImpl postalScheme;
045: private final int maxRows;
046:
047: private ConnectionImpl connection;
048:
049: public RegistryServiceImpl(RegistryImpl registry,
050: String postalScheme, int maxRows) {
051: this .registry = registry;
052: this .maxRows = maxRows;
053: queryManager = new BusinessQueryManagerImpl(this );
054: lifeCycleManager = new BusinessLifeCycleManagerImpl(this );
055: if (postalScheme == null) {
056: this .postalScheme = null;
057: } else {
058: this .postalScheme = new ClassificationSchemeImpl(
059: lifeCycleManager);
060: this .postalScheme.setKey(new KeyImpl(postalScheme));
061: }
062: }
063:
064: IRegistry getRegistry() {
065: return registry;
066: }
067:
068: BusinessLifeCycleManagerImpl getLifeCycleManagerImpl() {
069: return lifeCycleManager;
070: }
071:
072: int getMaxRows() {
073: return maxRows;
074: }
075:
076: public CapabilityProfile getCapabilityProfile() {
077: return new CapabilityProfileImpl();
078: }
079:
080: public BusinessQueryManager getBusinessQueryManager()
081: throws JAXRException {
082: return queryManager;
083: }
084:
085: public BusinessLifeCycleManager getBusinessLifeCycleManager()
086: throws JAXRException {
087: return lifeCycleManager;
088: }
089:
090: public BulkResponse getBulkResponse(String s) throws JAXRException,
091: InvalidRequestException {
092: if (s == "" || s == null)
093: throw new InvalidRequestException();
094: return null;
095: }
096:
097: public DeclarativeQueryManager getDeclarativeQueryManager()
098: throws JAXRException, UnsupportedCapabilityException {
099: throw new UnsupportedCapabilityException();
100: }
101:
102: public ClassificationScheme getDefaultPostalScheme()
103: throws JAXRException {
104: return postalScheme;
105: }
106:
107: public String makeRegistrySpecificRequest(String s)
108: throws JAXRException {
109: String inquiry = "INQUIRY";
110: String publish = "PUBLISH";
111: String type = "";
112:
113: //TODO: Need a better way to do this
114: String snippet = s.substring(0, 20);
115: if (snippet.indexOf("save") > -1)
116: type = publish;
117: else
118: type = inquiry;
119:
120: try {
121: return registry.execute(s, type);
122: } catch (RegistryException e) {
123: throw new JAXRException(e.getLocalizedMessage());
124: }
125: }
126:
127: public ConnectionImpl getConnection() {
128: return connection;
129: }
130:
131: public void setConnection(ConnectionImpl connection) {
132: this.connection = connection;
133: }
134:
135: }
|