Author: keith
Date: Wed Jan 16 21:29:38 2008
New Revision: 12369
Log:
Adding MashupAdminService to add services that should be secured
Added:
trunk/mashup/java/modules/admin/service/src/org/wso2/mashup/admin/service/MashupAdminService.java
Modified:
trunk/mashup/java/modules/admin/service/META-INF/services.xml
Modified: trunk/mashup/java/modules/admin/service/META-INF/services.xml
==============================================================================
--- trunk/mashup/java/modules/admin/service/META-INF/services.xml
(original)
+++ trunk/mashup/java/modules/admin/service/META-INF/services.xml Wed Jan
16 21:29:38 2008
@@ -22,7 +22,7 @@
Once this is called user can invoke othjer operations under this
serviceGroup.
</Description>
<parameter
name="ServiceClass">org.wso2.mashup.admin.service.MashupLoginService</parameter>
- <schema schemaNamespace="http://admin.mashup.wso2.org/xsd"/>
+ <schema schemaNamespace="http://service.admin.mashup.wso2.org/xsd"/>
</service>
<service name="MashupLoginServiceIC" scope="transportsession">
<Description>
@@ -30,6 +30,14 @@
Once this is called user can invoke othjer operations under this
serviceGroup.
</Description>
<parameter
name="ServiceClass">org.wso2.mashup.admin.service.MashupLoginService</parameter>
- <schema schemaNamespace="http://admin.mashup.wso2.org/xsd"/>
+ <schema schemaNamespace="http://service.admin.mashup.wso2.org/xsd"/>
+ </service>
+ <service name="MashupAdminService" scope="transportsession">
+ <Description>
+ This service holds the admin operation of the Mashup server. A
user should be logged in to call this service
+ This is handled by the mashup-admin module.
+ </Description>
+ <parameter
name="ServiceClass">org.wso2.mashup.admin.service.MashupAdminService</parameter>
+ <schema schemaNamespace="http://service.admin.mashup.wso2.org/xsd"/>
</service>
</serviceGroup>
\ No newline at end of file
Added:
trunk/mashup/java/modules/admin/service/src/org/wso2/mashup/admin/service/MashupAdminService.java
==============================================================================
--- (empty file)
+++
trunk/mashup/java/modules/admin/service/src/org/wso2/mashup/admin/service/MashupAdminService.java
Wed Jan 16 21:29:38 2008
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2006,2007 WSO2, Inc. http://www.wso2.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.wso2.mashup.admin.service;
+
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.Parameter;
+import org.wso2.javascript.rhino.JavaScriptEngineConstants;
+
+import java.io.File;
+
+public class MashupAdminService {
+
+ public Boolean deleteService(String serviceName) {
+ boolean success = false;
+
+ MessageContext currentMessageContext =
MessageContext.getCurrentMessageContext();
+ AxisConfiguration configuration =
+ currentMessageContext.getAxisService().getAxisConfiguration();
+
+ try {
+ AxisService mashupService = configuration.getService(serviceName);
+
+ Parameter serviceJSParameter = mashupService
+ .getParameter(JavaScriptEngineConstants.SERVICE_JS);
+ Parameter serviceResourcesDir =
+
mashupService.getParameter(JavaScriptEngineConstants.RESOURCES_FOLDER);
+
+ if (serviceJSParameter != null && serviceJSParameter.getValue() !=
null) {
+ File serviceJS = (File) serviceJSParameter.getValue();
+ File serviceReources = (File) serviceResourcesDir.getValue();
+ success = serviceJS.delete();
+
+ //On successful deletion of the service, deleting the
resources directory
+ if (success) {
+ success = deleteDir(serviceReources);
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ return Boolean.valueOf(success);
+ }
+
+ private static boolean deleteDir(File dir) {
+ if (dir.isDirectory()) {
+ String[] children = dir.list();
+ for (int i = 0; i < children.length; i++) {
+ boolean success = deleteDir(new File(dir, children[i]));
+ if (!success) {
+ return false;
+ }
+ }
+ }
+
+ // The directory is now empty so delete it
+ return dir.delete();
+ }
+}
_______________________________________________
Mashup-dev mailing list
[email protected]
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev