Author: keith Date: Mon Jun 2 01:14:35 2008 New Revision: 17754 URL: http://wso2.org/svn/browse/wso2?view=rev&revision=17754
Log: Fixing Mashup-831 Modified: trunk/mashup/java/modules/admin/service/src/org/wso2/mashup/admin/service/MashupAdminService.java Modified: trunk/mashup/java/modules/admin/service/src/org/wso2/mashup/admin/service/MashupAdminService.java URL: http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/admin/service/src/org/wso2/mashup/admin/service/MashupAdminService.java?rev=17754&r1=17753&r2=17754&view=diff ============================================================================== --- trunk/mashup/java/modules/admin/service/src/org/wso2/mashup/admin/service/MashupAdminService.java (original) +++ trunk/mashup/java/modules/admin/service/src/org/wso2/mashup/admin/service/MashupAdminService.java Mon Jun 2 01:14:35 2008 @@ -23,6 +23,8 @@ import org.apache.axis2.description.AxisService; import org.apache.axis2.description.Parameter; import org.apache.axis2.engine.AxisConfiguration; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.javascript.rhino.JavaScriptEngineConstants; import org.wso2.mashup.MashupConstants; import org.wso2.mashup.MashupFault; @@ -36,12 +38,15 @@ import org.wso2.ws.dataservice.DBConstants; import org.wso2.wsas.ServerConstants; import org.wso2.wsas.ServerManager; +import org.wso2.wsas.transport.util.TransportSummary; import org.wso2.wsas.admin.service.ServiceAdmin; +import org.wso2.wsas.admin.service.TransportAdmin; import org.wso2.wsas.admin.service.util.ServiceMetaData; import org.wso2.wsas.persistence.PersistenceManager; import org.wso2.wsas.persistence.dataobject.OperationDO; import org.wso2.wsas.persistence.dataobject.ServiceDO; import org.wso2.wsas.persistence.dataobject.ServiceIdentifierDO; +import org.wso2.wsas.persistence.dataobject.TransportDO; import org.wso2.wsas.persistence.exception.ServiceNotFoundException; import javax.activation.DataHandler; @@ -59,7 +64,6 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; -import java.util.List; import java.security.KeyStore; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; @@ -69,6 +73,10 @@ public class MashupAdminService { + private PersistenceManager pm = new PersistenceManager(); + + private static final Log log = LogFactory.getLog(MashupAdminService.class); + public Boolean saveServiceSource(String path, String modifiedSource) throws MashupFault { boolean success; @@ -509,26 +517,110 @@ throws AxisFault { boolean success = false; + if (transportName == null || transportName.trim().length() == 0) { + return Boolean.valueOf(success); + } ServerManager serverManager = ServerManager.getInstance(); ConfigurationContext configContext = serverManager.configContext; - configContext.getAxisConfiguration().getService(serviceName) - .addExposedTransport(transportName); - success = true; + AxisService axisService = configContext.getAxisConfiguration().getService(serviceName); + + if (axisService.isExposedTransport(transportName)) { + return Boolean.valueOf(success); + } + + ServiceDO serviceDO = pm.getService(axisService.getName(), + ServiceIdentifierDO.EMPTY_SERVICE_VERSION); + if (serviceDO.getIsUTAuthEnabled()) { + if (!transportName + .equalsIgnoreCase(ServerConstants.HTTPS_TRANSPORT)) { + throw new AxisFault( + "Cannot add non-HTTPS transport binding for Service [" + + serviceName + + "] since a security scenario which requires the " + + "service to contain only the HTTPS transport binding" + + " has been applied to this service."); + } + } + + if (!axisService.isEnableAllTransports()) { + axisService.addExposedTransport(transportName); + } else { + return Boolean.valueOf(success); + } + + TransportDO transportDO = pm.getTransport(transportName); + if (transportDO != null) { + serviceDO.setIsExposedOnAllTransports(false); + serviceDO.addTransport(transportDO); + + try { + pm.updateService(serviceDO); + pm.updateEntity(transportDO); + } catch (ServiceNotFoundException e) { + String msg = "Service with name " + serviceName + " not found."; + log.error(msg); + throw new AxisFault(msg, e); + } + } + success = true; return Boolean.valueOf(success); } public Boolean disableServiceTransport(String serviceName, String transportName) throws AxisFault { boolean success = false; - + ServerManager serverManager = ServerManager.getInstance(); ConfigurationContext configContext = serverManager.configContext; - configContext.getAxisConfiguration().getService(serviceName) - .removeExposedTransport(transportName); - success = true; + AxisService axisService = configContext.getAxisConfiguration().getService(serviceName); + ServiceDO serviceDO = pm.getService(axisService.getName(), + ServiceIdentifierDO.EMPTY_SERVICE_VERSION); + if (serviceDO.getIsUTAuthEnabled()) { + if (transportName + .equalsIgnoreCase(ServerConstants.HTTPS_TRANSPORT)) { + throw new AxisFault( + "HTTPS transport binding for Service [" + + serviceName + + "] cannot be removed since a security scenario which requires" + + " HTTPS has been applied to this service."); + } + } + TransportDO transportDO = pm.getTransport(transportName); + if (!axisService.isEnableAllTransports()) { + + serviceDO.getTransports().remove(transportDO); + transportDO.getServices().remove(serviceDO); + axisService.removeExposedTransport(transportName); + pm.updateEntity(transportDO); + } else { + TransportSummary[] transports = new TransportAdmin() + .listTransports(); + + for (int i = 0; i < transports.length; i++) { + String protocol = transports[i].getProtocol(); + + if (!protocol.equals(transportName)) { + axisService.addExposedTransport(protocol); + TransportDO addTransportDO = pm.getTransport(protocol); + serviceDO.addTransport(addTransportDO); + pm.updateEntity(addTransportDO); + } + } + } + + serviceDO.setIsExposedOnAllTransports(false); + try { + pm.updateService(serviceDO); + } catch (ServiceNotFoundException e) { + String msg = "Service with name " + serviceName + " not found."; + log.error(msg); + throw new AxisFault(msg, e); + } + + success = true; return Boolean.valueOf(success); } _______________________________________________ Mashup-dev mailing list [email protected] http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev
