Skip to content

Commit

Permalink
Fix for REGISTRY-2619
Browse files Browse the repository at this point in the history
  • Loading branch information
shazni committed Jun 26, 2015
1 parent ab21d86 commit f5d3873
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 = "";

Expand All @@ -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) {
Expand Down

0 comments on commit f5d3873

Please sign in to comment.