[wsas-java-dev] svn commit r1834 - in trunk/wsas/java/modules:
admin/src/org/wso2/wsas/admin/service
admin/src/org/wso2/wsas/admin/service/util
www/extensions/core/css www/extensions/core/images
www/extensions/core/js www/extensions/core/xslt
svn at wso2.org
svn at wso2.org
Mon Apr 16 04:11:01 PDT 2007
Author: saminda
Date: Mon Apr 16 04:10:41 2007
New Revision: 1834
Added:
trunk/wsas/java/modules/www/extensions/core/images/create_svc.gif (contents, props changed)
Modified:
trunk/wsas/java/modules/admin/src/org/wso2/wsas/admin/service/ServiceAdmin.java
trunk/wsas/java/modules/admin/src/org/wso2/wsas/admin/service/util/CreateArchive.java
trunk/wsas/java/modules/www/extensions/core/css/wso2wsas.css
trunk/wsas/java/modules/www/extensions/core/js/services.js
trunk/wsas/java/modules/www/extensions/core/xslt/list_service_main_info.xsl
Log:
Added to create service archive
Modified: trunk/wsas/java/modules/admin/src/org/wso2/wsas/admin/service/ServiceAdmin.java
==============================================================================
--- trunk/wsas/java/modules/admin/src/org/wso2/wsas/admin/service/ServiceAdmin.java (original)
+++ trunk/wsas/java/modules/admin/src/org/wso2/wsas/admin/service/ServiceAdmin.java Mon Apr 16 04:10:41 2007
@@ -944,7 +944,7 @@
* Creates and deploys a service. This AAR will contain all the classe from
* the jar/zip file corresponding to <code>archiveId</code>. In addition,
* a services.xml will be created, and all of the
- * <code>serviceClasses</code> will be added as services. TODO
+ * <code>serviceClasses</code> will be added as services.
*
* @param archiveId
* @param serviceClasses
@@ -1420,9 +1420,8 @@
}
/**
- * TODO
- * Get the information from ServiceDO and create the foo.aar and ask user to dump
- * it any place the uesrs wishes.
+ * Using the information from AxisService, a service archive will be created. A String will be
+ * returned with ID, that can be used to acess the AAR and dump it anywhere users wishes.
* @param serviceName
* @return
* @throws AxisFault
Modified: trunk/wsas/java/modules/admin/src/org/wso2/wsas/admin/service/util/CreateArchive.java
==============================================================================
--- trunk/wsas/java/modules/admin/src/org/wso2/wsas/admin/service/util/CreateArchive.java (original)
+++ trunk/wsas/java/modules/admin/src/org/wso2/wsas/admin/service/util/CreateArchive.java Mon Apr 16 04:10:41 2007
@@ -15,23 +15,28 @@
*/
package org.wso2.wsas.admin.service.util;
+import org.apache.axiom.om.*;
import org.apache.axis2.AxisFault;
+import org.apache.axis2.dataretrieval.DRConstants;
+import org.apache.axis2.wsdl.WSDLConstants;
import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.deployment.DeploymentConstants;
+import org.apache.axis2.description.*;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.wso2.wsas.ServerConstants;
+import org.apache.ws.java2wsdl.utils.TypeTable;
+import org.apache.neethi.PolicyRegistry;
+import org.apache.neethi.Policy;
+import org.apache.neethi.PolicyReference;
import org.wso2.utils.ArchiveManipulator;
import org.wso2.utils.WSO2Constants;
+import org.wso2.wsas.ServerConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.namespace.QName;
+import java.io.*;
import java.net.URL;
-import java.io.File;
-import java.io.IOException;
-import java.io.FileFilter;
-import java.util.Map;
-import java.util.Hashtable;
+import java.util.*;
/*
*
@@ -87,9 +92,13 @@
absoluteSf.createNewFile();
- //TODO fill the content of services.xml based on ServiceDO object
+ OMElement servicesXMLInfoset = createServicesXMLInfoset(axisService);
+ OutputStream os = new FileOutputStream(absoluteSf);
+ servicesXMLInfoset.serializeAndConsume(os);
+
- File fout = new File(workdir + File.separator + "dump_aar_output" + File.separator + uuid);
+ File fout =
+ new File(workdir + File.separator + "dump_aar_output" + File.separator + uuid);
fout.mkdirs();
String outAARFilename = fout.getAbsolutePath() + File.separator + serviceName + ".aar";
@@ -123,8 +132,369 @@
log.error(e);
throw AxisFault.makeFault(e);
+ } catch (XMLStreamException e) {
+ log.error(e);
+ throw AxisFault.makeFault(e);
+ }
+ }
+
+ /**
+ * This will create a services.xml with
+ * <service name="Foo">
+ * ...
+ * </service>
+ * This will create an independent service.
+ *
+ * @param axisService
+ * @return OMElement
+ */
+ private static OMElement createServicesXMLInfoset(AxisService axisService) {
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMNamespace ns = fac.createOMNamespace("", "");
+ OMElement serviceEle = createOMElement(fac, ns, DeploymentConstants.TAG_SERVICE);
+
+ OMAttribute nameAttr = createOMAttribute(fac, ns, DeploymentConstants.ATTRIBUTE_NAME,
+ axisService.getName());
+ OMAttribute wsAddAttr = createOMAttribute(fac, ns,
+ DeploymentConstants.ATTRIBUTE_WSADDRESSING,
+ axisService.getWSAddressingFlag());
+ OMAttribute targetNsAttr = createOMAttribute(fac, ns, DeploymentConstants.TARGET_NAME_SPACE,
+ axisService.getTargetNamespace());
+ OMAttribute scopeAttr = createOMAttribute(fac, ns, DeploymentConstants.ATTRIBUTE_SCOPE,
+ axisService.getScope());
+ serviceEle.addAttribute(nameAttr);
+ serviceEle.addAttribute(wsAddAttr);
+ serviceEle.addAttribute(targetNsAttr);
+ serviceEle.addAttribute(scopeAttr);
+
+ OMElement discEle = createOMElement(fac, ns, DeploymentConstants.TAG_DESCRIPTION,
+ axisService.getServiceDescription());
+
+ serviceEle.addChild(discEle);
+
+ OMElement schemaEle = createOMElement(fac, ns, DeploymentConstants.SCHEMA);
+ OMAttribute schemaNsAttr = createOMAttribute(fac, ns, DeploymentConstants.SCHEMA_NAME_SPACE,
+ axisService.getSchematargetNamespace());
+ OMAttribute schemaEleQualifiedAttr = createOMAttribute(fac, ns,
+ DeploymentConstants.SCHEMA_ELEMENT_QUALIFIED,
+ (axisService.isElementFormDefault() ?
+ "true" : "false"));
+ schemaEle.addAttribute(schemaNsAttr);
+ schemaEle.addAttribute(schemaEleQualifiedAttr);
+
+ serviceEle.addChild(schemaEle);
+
+ Map p2nMap = axisService.getP2nMap();
+ if (p2nMap != null) {
+ Set entrySet = p2nMap.entrySet();
+ for (Iterator iterator = entrySet.iterator(); iterator.hasNext();) {
+ Map.Entry me = (Map.Entry) iterator.next();
+ String packageKey = (String) me.getKey();
+ String namesapceValue = (String) me.getValue();
+ OMElement mapping = createOMElement(fac, ns, DeploymentConstants.MAPPING);
+ OMAttribute packageAttr = createOMAttribute(fac, ns,
+ DeploymentConstants.ATTRIBUTE_PACKAGE,
+ packageKey);
+ OMAttribute namespaceAttr = createOMAttribute(fac, ns,
+ DeploymentConstants.ATTRIBUTE_NAMESPACE,
+ namesapceValue);
+ mapping.addAttribute(packageAttr);
+ mapping.addAttribute(namespaceAttr);
+ schemaEle.addChild(mapping);
+ }
+ }
+
+ OMElement transportsEle = createOMElement(fac, ns, DeploymentConstants.TAG_TRANSPORTS);
+ serviceEle.addChild(transportsEle);
+ for (Iterator iterator = axisService.getExposedTransports().iterator();
+ iterator.hasNext();) {
+ String t = (String) iterator.next();
+ OMElement transportEle = createOMElement(fac, ns, DeploymentConstants.TAG_TRANSPORT, t);
+ transportsEle.addChild(transportEle);
+
+ }
+
+ //operations
+ for (Iterator iterator = axisService.getOperations(); iterator.hasNext();) {
+ AxisOperation ao = (AxisOperation) iterator.next();
+ OMElement operationEle = createOMElement(fac, ns, DeploymentConstants.TAG_OPERATION);
+ serviceEle.addChild(operationEle);
+ OMAttribute opNameAttr = createOMAttribute(fac, ns, DeploymentConstants.ATTRIBUTE_NAME,
+ ao.getName().getLocalPart());
+ OMAttribute opMEPAttr = createOMAttribute(fac, ns, DeploymentConstants.TAG_MEP,
+ ao.getMessageExchangePattern());
+ operationEle.addAttribute(opNameAttr);
+ operationEle.addAttribute(opMEPAttr);
+
+ OMElement opMREle = createOMElement(fac, ns, DeploymentConstants.TAG_MESSAGE_RECEIVER);
+ operationEle.addChild(opMREle);
+
+ OMAttribute opMRClassAttr = createOMAttribute(fac, ns,
+ DeploymentConstants.TAG_CLASS_NAME, ao
+ .getMessageReceiver().getClass().getName());
+ opMREle.addAttribute(opMRClassAttr);
+
+ List mappingList = ao.getWsamappingList();
+ if (mappingList != null) {
+ for (int i = 0; i < mappingList.size(); i++) {
+ OMElement mappingEle = createOMElement(fac, ns,
+ org.apache.axis2.Constants.ACTION_MAPPING,
+ (String) mappingList.get(i));
+ operationEle.addChild(mappingEle);
+
+ }
+ }
+ String outputAction = ao.getOutputAction();
+ if (outputAction != null) {
+ OMElement outputActionMappingEle = createOMElement(fac, ns,
+ org.apache.axis2.Constants.OUTPUT_ACTION_MAPPING,
+ outputAction);
+ operationEle.addChild(outputActionMappingEle);
+ }
+
+ String[] faultActions = ao.getFaultActionNames();
+ if (faultActions != null) {
+ for (int i = 0; i < faultActions.length; i++) {
+ OMElement faultActionEle =
+ createOMElement(fac, ns,
+ org.apache.axis2.Constants.FAULT_ACTION_MAPPING);
+ operationEle.addChild(faultActionEle);
+ OMAttribute faultActionAttr = createOMAttribute(fac, ns,
+ org.apache.axis2.Constants.FAULT_ACTION_NAME,
+ faultActions[i]);
+ faultActionEle.addAttribute(faultActionAttr);
+
+ }
+ }
+
+ List operationParameterList = ao.getParameters();
+ marshallingParameterList(operationParameterList, operationEle, fac, ns);
+
+ List operationLevelEngagedModulesList = ao.getModuleRefs();
+ marshallingModules(operationLevelEngagedModulesList, operationEle, fac, ns, ao);
+
+ Map axisMessagesMap = new AxisMessageLookup().lookup(ao);
+ Set axisMessagesSet = axisMessagesMap.entrySet();
+ for (Iterator iterator1 = axisMessagesSet.iterator(); iterator1.hasNext();) {
+ Map.Entry me = (Map.Entry) iterator1.next();
+ String lableKey = (String) me.getKey();
+ AxisMessage axisMessage = (AxisMessage) me.getValue();
+ OMElement axisMessageEle =
+ createOMElement(fac, ns, DeploymentConstants.TAG_MESSAGE);
+ OMAttribute axisMessageLableAttr =
+ createOMAttribute(fac, ns, DeploymentConstants.TAG_LABEL, lableKey);
+ axisMessageEle.addAttribute(axisMessageLableAttr);
+
+ List axisMessageParameterList = axisMessage.getParameters();
+ marshallingParameterList(axisMessageParameterList, axisMessageEle, fac, ns);
+
+ PolicyInclude policyInclude = ao.getPolicyInclude();
+ PolicyRegistry registry = policyInclude.getPolicyRegistry();
+ List policyList =
+ policyInclude.getPolicyElements(PolicyInclude.AXIS_MESSAGE_POLICY);
+ if (!policyList.isEmpty()) {
+ marshallingPolicyIncludes(axisMessageEle, policyList, registry);
+ }
+
+
+ }
+
+ PolicyInclude policyInclude = ao.getPolicyInclude();
+ PolicyRegistry registry = policyInclude.getPolicyRegistry();
+ List policyList = policyInclude.getPolicyElements(PolicyInclude.AXIS_OPERATION_POLICY);
+ if (!policyList.isEmpty()) {
+ marshallingPolicyIncludes(operationEle, policyList, registry);
+ }
+
+ }
+
+ List serviceParameterList = axisService.getParameters();
+ marshallingParameterList(serviceParameterList, serviceEle, fac, ns);
+
+ //service level engaged modules.
+ List serviceEngagedModuleList = axisService.getModules();
+ marshallingModules(serviceEngagedModuleList, serviceEle, fac, ns, axisService);
+
+ if (axisService.isCustomWsdl()) {
+ OMElement package2QName =
+ createOMElement(fac, ns, DeploymentConstants.TAG_PACKAGE2QNAME);
+ serviceEle.addChild(package2QName);
+ TypeTable typeTable = axisService.getTypeTable();
+ if (typeTable != null) {
+ Map complexSchemaMap = typeTable.getComplexSchemaMap();
+ Set complexSchemaSet = complexSchemaMap.entrySet();
+ for (Iterator iterator = complexSchemaSet.iterator(); iterator.hasNext();) {
+ Map.Entry me = (Map.Entry) iterator.next();
+ String packageKey = (String) me.getKey();
+ QName qName = (QName) me.getValue();
+ OMElement mapping = createOMElement(fac, ns, DeploymentConstants.TAG_MAPPING);
+ OMAttribute packageAttr = createOMAttribute(fac, ns,
+ DeploymentConstants.TAG_PACKAGE_NAME,
+ packageKey);
+ OMAttribute qNameAttr =
+ createOMAttribute(fac, ns, DeploymentConstants.TAG_QNAME,
+ qName.getNamespaceURI());
+ mapping.addAttribute(packageAttr);
+ mapping.addAttribute(qNameAttr);
+ package2QName.addChild(mapping);
+ }
+ }
+ }
+
+ PolicyInclude policyInclude = axisService.getPolicyInclude();
+ PolicyRegistry registry = policyInclude.getPolicyRegistry();
+
+ // services.xml
+ List policyList = policyInclude.getPolicyElements(PolicyInclude.AXIS_SERVICE_POLICY);
+ if (!policyList.isEmpty()) {
+ marshallingPolicyIncludes(serviceEle, policyList, registry);
+ }
+
+ //TODO - Datalocators
+ /*OMElement dataLocatorEle = createOMElement(fac,ns, DRConstants.DATA_LOCATOR_ELEMENT);
+ serviceEle.addChild(dataLocatorEle);*/
+
+
+ return serviceEle;
+ }
+
+ protected static void marshallingPolicyIncludes(OMElement parent, List policyList,
+ PolicyRegistry policyRegistry) {
+ for (Iterator iterator = policyList.iterator(); iterator.hasNext();) {
+ Object obj = iterator.next();
+ if (obj instanceof Policy) {
+ Policy policy = (Policy) obj;
+ parent.addChild((PolicyUtil.getPolicyAsOMElement(policy)));
+ } else if (obj instanceof PolicyReference) {
+ PolicyReference policyReference = (PolicyReference) obj;
+ Policy policy = policyRegistry.lookup(policyReference.getURI());
+ if (policy == null) {
+ log.error(CreateArchive.class.getName() + "policy object couldn't be NULL");
+ continue;
+ }
+ OMElement e = PolicyUtil.getPolicyAsOMElement(policy);
+ parent.addChild(e);
+ }
+
}
+ }
+
+ protected static void marshallingModules(List moduleList, OMElement parent, OMFactory fac,
+ OMNamespace ns, Object axisObject) {
+ if (moduleList != null) {
+ for (int i = 0; i < moduleList.size(); i++) {
+ OMElement moduleEle = createOMElement(fac, ns, DeploymentConstants.TAG_MODULE);
+ String moduleName = (String) moduleList.get(i);
+ OMAttribute moduleRefAttr = createOMAttribute(fac, ns,
+ DeploymentConstants.TAG_REFERENCE,
+ moduleName);
+ moduleEle.addAttribute(moduleRefAttr);
+ parent.addChild(moduleEle);
+
+ //module configs
+ ModuleConfiguration moduleConfig;
+ if (axisObject instanceof AxisService) {
+ moduleConfig = ((AxisService) axisObject).getModuleConfig(moduleName);
+ } else if (axisObject instanceof AxisOperation) {
+ moduleConfig = ((AxisOperation) axisObject).getModuleConfig(moduleName);
+ } else {
+ return;
+ }
+
+ if (moduleConfig != null) {
+ OMElement moduleConfigEle =
+ createOMElement(fac, ns, DeploymentConstants.TAG_MODULE_CONFIG);
+ OMAttribute moduleConfigNameAttr = createOMAttribute(fac, ns,
+ DeploymentConstants.ATTRIBUTE_NAME,
+ moduleConfig.getModuleName());
+ moduleConfigEle.addAttribute(moduleConfigNameAttr);
+ parent.addChild(moduleConfigEle);
+ List paramsList = moduleConfig.getParameters();
+ marshallingParameterList(paramsList, moduleConfigEle, fac, ns);
+ }
+ }
+ }
+
+
+ }
+ protected static void marshallingParameterList(List parameterList, OMElement parent,
+ OMFactory fac,
+ OMNamespace ns) {
+ if (parameterList != null) {
+ for (int j = 0; j < parameterList.size(); j++) {
+ Parameter parm = (Parameter) parameterList.get(j);
+ marshallingParameter(parm, parent, fac, ns);
+ }
+ }
+
+ }
+
+ protected static void marshallingParameter(Parameter param, OMElement parent, OMFactory fac,
+ OMNamespace ns) {
+ OMElement paramEle = createOMElement(fac, ns, DeploymentConstants.TAG_PARAMETER);
+ parent.addChild(paramEle);
+ OMAttribute paramNameAttr =
+ createOMAttribute(fac, ns, DeploymentConstants.ATTRIBUTE_NAME, param.getName());
+ OMAttribute paramLokedAttr = createOMAttribute(fac, ns,
+ DeploymentConstants.ATTRIBUTE_LOCKED,
+ param.isLocked() ? "true" : "false");
+ paramEle.addAttribute(paramNameAttr);
+ paramEle.addAttribute(paramLokedAttr);
+ int paramType = param.getParameterType();
+
+ if (paramType == Parameter.OM_PARAMETER) {
+ paramEle.addChild((OMElement) param.getValue());
+ } else if (paramType == Parameter.TEXT_PARAMETER) {
+ paramEle.setText(param.getValue().toString());
+ }
+
+ }
+
+ protected static OMElement createOMElement(OMFactory fac, OMNamespace ns, String localName) {
+ return fac.createOMElement(localName, ns);
+ }
+
+ protected static OMElement createOMElement(OMFactory fac, OMNamespace ns, String localName,
+ String text) {
+ OMElement omElement = fac.createOMElement(localName, ns);
+ omElement.setText(text);
+ return omElement;
+ }
+
+ protected static OMAttribute createOMAttribute(OMFactory fac, OMNamespace ns, String localName,
+ String value) {
+ return fac.createOMAttribute(localName, ns, value);
+ }
+
+ /**
+ * TODO Find better way via Axis2. Introduce a new method getMessages to AxisOperation.
+ */
+ protected static class AxisMessageLookup {
+ protected Map lookup(AxisOperation axisOperation) {
+ Map axisMessageMap = new HashMap();
+ if (axisOperation instanceof InOnlyAxisOperation) {
+ axisMessageMap.put(WSDLConstants.MESSAGE_LABEL_IN_VALUE,
+ axisOperation.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE));
+ return axisMessageMap;
+
+ } else if (axisOperation instanceof OutOnlyAxisOperation) {
+ axisMessageMap.put(WSDLConstants.MESSAGE_LABEL_OUT_VALUE,
+ axisOperation.getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE));
+ return axisMessageMap;
+
+ } else if (axisOperation instanceof TwoChannelAxisOperation) {
+ axisMessageMap.put(WSDLConstants.MESSAGE_LABEL_IN_VALUE,
+ axisOperation.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE));
+ axisMessageMap.put(WSDLConstants.MESSAGE_LABEL_OUT_VALUE,
+ axisOperation.getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE));
+ return axisMessageMap;
+
+ } else {
+ return axisMessageMap;
+ }
+
+ }
}
}
Modified: trunk/wsas/java/modules/www/extensions/core/css/wso2wsas.css
==============================================================================
--- trunk/wsas/java/modules/www/extensions/core/css/wso2wsas.css (original)
+++ trunk/wsas/java/modules/www/extensions/core/css/wso2wsas.css Mon Apr 16 04:10:41 2007
@@ -197,6 +197,12 @@
font-size: 10pt;
}
+a#create_svc_link{
+ background: url( ../images/create_svc.gif ) transparent no-repeat 0px 0px;
+ text-decoration: none;
+ font-size: 10pt;
+}
+
span.treeSpan a{
text-decoration: none;
Added: trunk/wsas/java/modules/www/extensions/core/images/create_svc.gif
==============================================================================
Binary file. No diff available.
Modified: trunk/wsas/java/modules/www/extensions/core/js/services.js
==============================================================================
--- trunk/wsas/java/modules/www/extensions/core/js/services.js (original)
+++ trunk/wsas/java/modules/www/extensions/core/js/services.js Mon Apr 16 04:10:41 2007
@@ -683,7 +683,7 @@
}
function generateCallBack() {
- cursorClear();
+// cursorClear();
if (!onError()) {
return;
}
@@ -1811,39 +1811,18 @@
function dumpAAR() {
var body_xml = '<req:dumpAAR xmlns:req="http://org.apache.axis2/xsd">\n' +
- '<serviceId>' + 'version' + '</serviceId>\n' +
+ '<serviceId>' + getServiceSpecificName() + '</serviceId>\n' +
'</req:dumpAAR>\n';
var callURL = serverURL + "/" + "ServiceAdmin" ;
- send("dumpAAR", body_xml, "", callURL, "", false, dumpAARCallback);
+ send("dumpAAR", body_xml, "", callURL, "", false, generateCallBack);
}
-function dumpAARCallback() {
+/*function dumpAARCallback() {
if (!onError()) {
return;
}
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+}*/
\ No newline at end of file
Modified: trunk/wsas/java/modules/www/extensions/core/xslt/list_service_main_info.xsl
==============================================================================
--- trunk/wsas/java/modules/www/extensions/core/xslt/list_service_main_info.xsl (original)
+++ trunk/wsas/java/modules/www/extensions/core/xslt/list_service_main_info.xsl Mon Apr 16 04:10:41 2007
@@ -169,6 +169,16 @@
</a>
</td>
</tr>
+ <!--TODO -->
+ <tr>
+ <td>
+ <a id="create_svc_link">
+ <xsl:attribute name="href">#</xsl:attribute>
+ <xsl:attribute name="onClick">javascript:dumpAAR(); return false;</xsl:attribute>
+ <xsl:text>     Create Service Archive</xsl:text>
+ </a>
+ </td>
+ </tr>
<xsl:if test="$webResourcesFound='true'">
<tr>
More information about the Wsas-java-dev
mailing list