diff --git a/components/registry/org.wso2.carbon.registry.extensions/src/main/java/org/wso2/carbon/registry/extensions/handlers/utils/RESTServiceUtils.java b/components/registry/org.wso2.carbon.registry.extensions/src/main/java/org/wso2/carbon/registry/extensions/handlers/utils/RESTServiceUtils.java index e5b8e8586..a2f7ebf02 100644 --- a/components/registry/org.wso2.carbon.registry.extensions/src/main/java/org/wso2/carbon/registry/extensions/handlers/utils/RESTServiceUtils.java +++ b/components/registry/org.wso2.carbon.registry.extensions/src/main/java/org/wso2/carbon/registry/extensions/handlers/utils/RESTServiceUtils.java @@ -30,7 +30,6 @@ import org.wso2.carbon.registry.core.RegistryConstants; import org.wso2.carbon.registry.core.Resource; import org.wso2.carbon.registry.core.ResourceImpl; -import org.wso2.carbon.registry.core.config.Mount; import org.wso2.carbon.registry.core.config.RegistryContext; import org.wso2.carbon.registry.core.exceptions.RegistryException; import org.wso2.carbon.registry.core.jdbc.handlers.RequestContext; @@ -216,8 +215,6 @@ public static String addServiceToRegistry(RequestContext requestContext, OMEleme throw new IllegalArgumentException("Some or all of the arguments may be null. Cannot add the rest service to registry. "); } - - Registry registry = requestContext.getRegistry(); //Creating new resource. Resource serviceResource = new ResourceImpl(); @@ -254,7 +251,14 @@ public static String addServiceToRegistry(RequestContext requestContext, OMEleme RegistryConstants.PATH_SEPARATOR + serviceVersion + RegistryConstants.PATH_SEPARATOR + apiName + "-rest_service"; //saving the api resource to repository. + registry.put(pathExpression, serviceResource); + + String defaultLifeCycle = CommonUtil.getDefaultLifecycle(registry, "restservice"); + if (defaultLifeCycle != null && !defaultLifeCycle.isEmpty()) { + registry.associateAspect(serviceResource.getId(), defaultLifeCycle); + } + if (log.isDebugEnabled()){ log.debug("REST Service created at " + pathExpression); } diff --git a/components/registry/org.wso2.carbon.registry.extensions/src/main/java/org/wso2/carbon/registry/extensions/utils/CommonUtil.java b/components/registry/org.wso2.carbon.registry.extensions/src/main/java/org/wso2/carbon/registry/extensions/utils/CommonUtil.java index a6c813c61..911eac878 100644 --- a/components/registry/org.wso2.carbon.registry.extensions/src/main/java/org/wso2/carbon/registry/extensions/utils/CommonUtil.java +++ b/components/registry/org.wso2.carbon.registry.extensions/src/main/java/org/wso2/carbon/registry/extensions/utils/CommonUtil.java @@ -535,7 +535,7 @@ public static void addService(OMElement service, RequestContext context)throws R resource.setProperty(CommonConstants.SOURCE_PROPERTY, CommonConstants.SOURCE_AUTO); resource.setProperty("registry.DefinitionImport","true"); registry.put(path, resource); - String defaultLifeCycle = getDefaultServiceLifecycle(registry); + String defaultLifeCycle = getDefaultLifecycle(registry, "service"); if(defaultLifeCycle != null && !defaultLifeCycle.isEmpty()) registry.associateAspect(resource.getId(),defaultLifeCycle); } finally { @@ -590,7 +590,7 @@ public static void addSoapService(OMElement service, RequestContext context) thr resource.setProperty(CommonConstants.SOURCE_PROPERTY, CommonConstants.SOURCE_AUTO); resource.setProperty("registry.DefinitionImport", "true"); registry.put(path, resource); - String defaultLifeCycle = getDefaultServiceLifecycle(registry); + String defaultLifeCycle = getDefaultLifecycle(registry, "soapservice"); if (defaultLifeCycle != null && !defaultLifeCycle.isEmpty()) registry.associateAspect(resource.getId(), defaultLifeCycle); } finally { @@ -743,7 +743,7 @@ private static String getChrootedServiceLocation(Registry registry, RegistryCont registry.getRegistryContext().getServicePath()); // service path contains the base } - private static String getDefaultServiceLifecycle(Registry registry) throws RegistryException { + public static String getDefaultLifecycle(Registry registry, String shortName) throws RegistryException { String[] rxtList = null; String lifecycle = ""; @@ -764,7 +764,7 @@ private static String getDefaultServiceLifecycle(Registry registry) throws Regis } catch (XMLStreamException e) { throw new RegistryException("Error while serializing to OM content from String", e); } - if ("service".equals(configElement.getAttributeValue(new QName("shortName")))) { + if (shortName.equals(configElement.getAttributeValue(new QName("shortName")))) { OMElement lifecycleElement = configElement.getFirstChildWithName( new QName("lifecycle")); if (lifecycleElement != null) {