Repository: incubator-stratos Updated Branches: refs/heads/4.0.0-incubating 57bffdf61 -> 33471692b refs/heads/master 5eee96dbb -> f888f854c
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6c34420d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/tenant/SubscriptionDomainsAddedMessageProcessor.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/tenant/SubscriptionDomainsAddedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/tenant/SubscriptionDomainsAddedMessageProcessor.java new file mode 100644 index 0000000..aeea6bf --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/tenant/SubscriptionDomainsAddedMessageProcessor.java @@ -0,0 +1,96 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.stratos.messaging.message.processor.tenant; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.domain.tenant.Subscription; +import org.apache.stratos.messaging.domain.tenant.Tenant; +import org.apache.stratos.messaging.event.tenant.SubscriptionDomainsAddedEvent; +import org.apache.stratos.messaging.event.tenant.TenantSubscribedEvent; +import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.receiver.tenant.TenantManager; +import org.apache.stratos.messaging.util.Util; + +/** + * Tenant subscribed message processor for adding domains to tenant subscriptions. + */ +public class SubscriptionDomainsAddedMessageProcessor extends MessageProcessor { + + private static final Log log = LogFactory.getLog(SubscriptionDomainsAddedMessageProcessor.class); + + private MessageProcessor nextProcessor; + + @Override + public void setNext(MessageProcessor nextProcessor) { + this.nextProcessor = nextProcessor; + } + + @Override + public boolean process(String type, String message, Object object) { + if (SubscriptionDomainsAddedEvent.class.getName().equals(type)) { + // Return if tenant manager has not initialized + if(!TenantManager.getInstance().isInitialized()) { + return false; + } + + // Parse complete message and build event + SubscriptionDomainsAddedEvent event = (SubscriptionDomainsAddedEvent) Util.jsonToObject(message, TenantSubscribedEvent.class); + + try { + TenantManager.acquireWriteLock(); + Tenant tenant = TenantManager.getInstance().getTenant(event.getTenantId()); + if(tenant == null) { + if(log.isWarnEnabled()) { + log.warn(String.format("Tenant not found: [tenant-id] %d", event.getTenantId())); + } + return false; + } + Subscription subscription = tenant.getSubscription(event.getServiceName()); + if(subscription == null) { + if(log.isWarnEnabled()) { + log.warn(String.format("Subscription not found: [tenant-id] %d", event.getTenantId())); + } + return false; + } + subscription.addDomains(event.getDomains()); + if(log.isInfoEnabled()) { + log.info(String.format("Domains added to tenant subscription: [tenant-id] %d [tenant-domain] %s [service] %s [domains] %s", + tenant.getTenantId(), tenant.getTenantDomain(), event.getServiceName(), event.getDomains())); + } + + // Notify event listeners + notifyEventListeners(event); + return true; + } + finally { + TenantManager.releaseWriteLock(); + } + } + else { + if(nextProcessor != null) { + return nextProcessor.process(type, message, object); + } + else { + throw new RuntimeException(String.format("Failed to process tenant message using available message processors: [type] %s [body] %s", type, message)); + } + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6c34420d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/tenant/SubscriptionDomainsRemovedMessageProcessor.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/tenant/SubscriptionDomainsRemovedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/tenant/SubscriptionDomainsRemovedMessageProcessor.java new file mode 100644 index 0000000..fc08357 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/tenant/SubscriptionDomainsRemovedMessageProcessor.java @@ -0,0 +1,96 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.stratos.messaging.message.processor.tenant; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.domain.tenant.Subscription; +import org.apache.stratos.messaging.domain.tenant.Tenant; +import org.apache.stratos.messaging.event.tenant.SubscriptionDomainsAddedEvent; +import org.apache.stratos.messaging.event.tenant.TenantSubscribedEvent; +import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.receiver.tenant.TenantManager; +import org.apache.stratos.messaging.util.Util; + +/** + * Tenant subscribed message processor for removing domains from tenant subscriptions. + */ +public class SubscriptionDomainsRemovedMessageProcessor extends MessageProcessor { + + private static final Log log = LogFactory.getLog(SubscriptionDomainsRemovedMessageProcessor.class); + + private MessageProcessor nextProcessor; + + @Override + public void setNext(MessageProcessor nextProcessor) { + this.nextProcessor = nextProcessor; + } + + @Override + public boolean process(String type, String message, Object object) { + if (SubscriptionDomainsAddedEvent.class.getName().equals(type)) { + // Return if tenant manager has not initialized + if(!TenantManager.getInstance().isInitialized()) { + return false; + } + + // Parse complete message and build event + SubscriptionDomainsAddedEvent event = (SubscriptionDomainsAddedEvent) Util.jsonToObject(message, TenantSubscribedEvent.class); + + try { + TenantManager.acquireWriteLock(); + Tenant tenant = TenantManager.getInstance().getTenant(event.getTenantId()); + if(tenant == null) { + if(log.isWarnEnabled()) { + log.warn(String.format("Tenant not found: [tenant-id] %d", event.getTenantId())); + } + return false; + } + Subscription subscription = tenant.getSubscription(event.getServiceName()); + if(subscription == null) { + if(log.isWarnEnabled()) { + log.warn(String.format("Subscription not found: [tenant-id] %d", event.getTenantId())); + } + return false; + } + subscription.removeDomains(event.getDomains()); + if(log.isInfoEnabled()) { + log.info(String.format("Domains removed from tenant subscription: [tenant-id] %d [tenant-domain] %s [service] %s [domains] %s", + tenant.getTenantId(), tenant.getTenantDomain(), event.getServiceName(), event.getDomains())); + } + + // Notify event listeners + notifyEventListeners(event); + return true; + } + finally { + TenantManager.releaseWriteLock(); + } + } + else { + if(nextProcessor != null) { + return nextProcessor.process(type, message, object); + } + else { + throw new RuntimeException(String.format("Failed to process tenant message using available message processors: [type] %s [body] %s", type, message)); + } + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6c34420d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/tenant/TenantMessageProcessorChain.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/tenant/TenantMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/tenant/TenantMessageProcessorChain.java index d4c008e..725ad0f 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/tenant/TenantMessageProcessorChain.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/tenant/TenantMessageProcessorChain.java @@ -37,6 +37,8 @@ public class TenantMessageProcessorChain extends MessageProcessorChain { private TenantRemovedMessageProcessor tenantRemovedMessageProcessor; private TenantSubscribedMessageProcessor tenantSubscribedMessageProcessor; private TenantUnSubscribedMessageProcessor tenantUnSubscribedMessageProcessor; + private SubscriptionDomainsAddedMessageProcessor subscriptionDomainsAddedMessageProcessor; + private SubscriptionDomainsRemovedMessageProcessor subscriptionDomainsRemovedMessageProcessor; public void initialize() { // Add tenant event processors @@ -58,6 +60,12 @@ public class TenantMessageProcessorChain extends MessageProcessorChain { tenantUnSubscribedMessageProcessor = new TenantUnSubscribedMessageProcessor(); add(tenantUnSubscribedMessageProcessor); + subscriptionDomainsAddedMessageProcessor = new SubscriptionDomainsAddedMessageProcessor(); + add(subscriptionDomainsAddedMessageProcessor); + + subscriptionDomainsRemovedMessageProcessor = new SubscriptionDomainsRemovedMessageProcessor(); + add(subscriptionDomainsRemovedMessageProcessor); + if (log.isDebugEnabled()) { log.debug("Tenant message processor chain initialized"); } @@ -76,6 +84,10 @@ public class TenantMessageProcessorChain extends MessageProcessorChain { tenantSubscribedMessageProcessor.addEventListener(eventListener); } else if (eventListener instanceof TenantUnSubscribedEventListener) { tenantUnSubscribedMessageProcessor.addEventListener(eventListener); + } else if (eventListener instanceof SubscriptionDomainsAddedEventListener) { + subscriptionDomainsAddedMessageProcessor.addEventListener(eventListener); + } else if (eventListener instanceof SubscriptionDomainsRemovedEventListener) { + subscriptionDomainsRemovedMessageProcessor.addEventListener(eventListener); } else { throw new RuntimeException("Unknown event listener"); http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6c34420d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/tenant/TenantSubscribedMessageProcessor.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/tenant/TenantSubscribedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/tenant/TenantSubscribedMessageProcessor.java index aae074b..147ebde 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/tenant/TenantSubscribedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/tenant/TenantSubscribedMessageProcessor.java @@ -21,6 +21,7 @@ package org.apache.stratos.messaging.message.processor.tenant; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.domain.tenant.Subscription; import org.apache.stratos.messaging.domain.tenant.Tenant; import org.apache.stratos.messaging.event.tenant.TenantSubscribedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; @@ -62,10 +63,11 @@ public class TenantSubscribedMessageProcessor extends MessageProcessor { } return false; } - tenant.addServiceSubscription(event.getServiceName()); + Subscription subscription = new Subscription(event.getServiceName(), event.getClusterIds(), event.getDomains()); + tenant.addSubscription(subscription); if(log.isInfoEnabled()) { - log.info(String.format("Tenant subscribed to service: [tenant-id] %d [tenant-domain] %s [service] %s", - tenant.getTenantId(), tenant.getTenantDomain(), event.getServiceName())); + log.info(String.format("Tenant subscribed to service: [tenant-id] %d [tenant-domain] %s [service] %s [domains] %s", + tenant.getTenantId(), tenant.getTenantDomain(), event.getServiceName(), event.getDomains())); } // Notify event listeners http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6c34420d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/tenant/TenantUnSubscribedMessageProcessor.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/tenant/TenantUnSubscribedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/tenant/TenantUnSubscribedMessageProcessor.java index 6c4157c..ee929a3 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/tenant/TenantUnSubscribedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/tenant/TenantUnSubscribedMessageProcessor.java @@ -62,7 +62,7 @@ public class TenantUnSubscribedMessageProcessor extends MessageProcessor { } return false; } - tenant.removeServiceSubscription(event.getServiceName()); + tenant.removeSubscription(event.getServiceName()); if(log.isInfoEnabled()) { log.info(String.format("Tenant un-subscribed from service: [tenant-id] %d [tenant-domain] %s [service] %s", tenant.getTenantId(), tenant.getTenantDomain(), event.getServiceName())); http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6c34420d/components/org.apache.stratos.messaging/src/test/java/org/apache/stratos/messaging/test/TenantDomainTest.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.messaging/src/test/java/org/apache/stratos/messaging/test/TenantDomainTest.java b/components/org.apache.stratos.messaging/src/test/java/org/apache/stratos/messaging/test/TenantDomainTest.java new file mode 100644 index 0000000..adb11e1 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/test/java/org/apache/stratos/messaging/test/TenantDomainTest.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.stratos.messaging.test; + +import junit.framework.Assert; +import org.apache.stratos.messaging.domain.tenant.Subscription; +import org.apache.stratos.messaging.domain.tenant.Tenant; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import java.util.HashSet; + +/** + * Tenant domain model test. + */ +@RunWith(JUnit4.class) +public class TenantDomainTest { + @Test + public void testSubscriptionModel() { + Tenant tenant = new Tenant(1, "domain.org"); + Subscription subscription = new Subscription("subscription1", new HashSet<String>(), new HashSet<String>()); + tenant.addSubscription(subscription); + Assert.assertTrue("Subscription not added", tenant.isSubscribed("subscription1")); + tenant.removeSubscription("subscription1"); + Assert.assertTrue("Subscription not removed", !tenant.isSubscribed("subscription1")); + } +} http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6c34420d/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/CartridgeInfoBean.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/CartridgeInfoBean.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/CartridgeInfoBean.java index e29d028..48fd5ce 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/CartridgeInfoBean.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/CartridgeInfoBean.java @@ -19,6 +19,8 @@ package org.apache.stratos.rest.endpoint.bean; import javax.xml.bind.annotation.XmlRootElement; +import java.util.ArrayList; +import java.util.List; @XmlRootElement public class CartridgeInfoBean { @@ -38,6 +40,11 @@ public class CartridgeInfoBean { private String size; private boolean removeOnTermination; private String serviceGroup; + private List<String> domains; + + public CartridgeInfoBean() { + this.domains = new ArrayList<String>(); + } public String getCartridgeType() { return cartridgeType; @@ -158,5 +165,8 @@ public class CartridgeInfoBean { public void setServiceGroup(String serviceGroup) { this.serviceGroup = serviceGroup; } - + + public List<String> getDomains() { return domains; } + + public void setDomains(List<String> domains) { this.domains = domains; } } http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6c34420d/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java index 44b2c26..554accf 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java @@ -52,8 +52,7 @@ import org.apache.stratos.messaging.domain.topology.Member; import org.apache.stratos.messaging.domain.topology.MemberStatus; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import org.apache.stratos.messaging.util.Constants; -import org.apache.stratos.rest.endpoint.bean.CartridgeInfoBean; -import org.apache.stratos.rest.endpoint.bean.StratosAdminResponse; +import org.apache.stratos.rest.endpoint.bean.*; import org.apache.stratos.rest.endpoint.bean.autoscaler.partition.Partition; import org.apache.stratos.rest.endpoint.bean.autoscaler.partition.PartitionGroup; import org.apache.stratos.rest.endpoint.bean.autoscaler.policy.autoscale.AutoscalePolicy; @@ -992,6 +991,7 @@ public class ServiceUtils { subscriptionData.setRepositoryPassword(cartridgeInfoBean.getRepoPassword()); subscriptionData.setCommitsEnabled(cartridgeInfoBean.isCommitsEnabled()); subscriptionData.setServiceGroup(cartridgeInfoBean.getServiceGroup()); + subscriptionData.addDomains(new HashSet<String>(cartridgeInfoBean.getDomains())); if (cartridgeInfoBean.isPersistanceRequired()) { // Add persistence related properties to PersistenceContext @@ -1187,4 +1187,44 @@ public class ServiceUtils { return stratosAdminResponse; } + public static StratosAdminResponse addSubscriptionDomains(ConfigurationContext configurationContext, String cartridgeType, + String subscriptionAlias, List<String> domains) throws RestAPIException { + try { + int tenantId = ApplicationManagementUtil.getTenantId(configurationContext); + cartridgeSubsciptionManager.addSubscriptionDomains(tenantId, subscriptionAlias, domains); + } catch (Exception e) { + log.error(e.getMessage(), e); + throw new RestAPIException(e.getMessage(), e); + } + + StratosAdminResponse stratosAdminResponse = new StratosAdminResponse(); + stratosAdminResponse.setMessage("Successfully added domains to cartridge subscription"); + return stratosAdminResponse; + } + + public static List<String> getSubscriptionDomains(ConfigurationContext configurationContext, String cartridgeType, + String subscriptionAlias) throws RestAPIException { + try { + int tenantId = ApplicationManagementUtil.getTenantId(configurationContext); + return cartridgeSubsciptionManager.getSubscriptionDomains(tenantId, subscriptionAlias); + } catch (Exception e) { + log.error(e.getMessage(), e); + throw new RestAPIException(e.getMessage(), e); + } + } + + public static StratosAdminResponse removeSubscriptionDomains(ConfigurationContext configurationContext, String cartridgeType, + String subscriptionAlias, List<String> domains) throws RestAPIException { + try { + int tenantId = ApplicationManagementUtil.getTenantId(configurationContext); + cartridgeSubsciptionManager.removeSubscriptionDomains(tenantId, subscriptionAlias, domains); + } catch (Exception e) { + log.error(e.getMessage(), e); + throw new RestAPIException(e.getMessage(), e); + } + + StratosAdminResponse stratosAdminResponse = new StratosAdminResponse(); + stratosAdminResponse.setMessage("Successfully removed domains from cartridge subscription"); + return stratosAdminResponse; + } } http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6c34420d/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java index 7b744a5..c5db7ff 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java @@ -33,6 +33,7 @@ import org.apache.stratos.rest.endpoint.annotation.AuthorizationAction; import org.apache.stratos.rest.endpoint.annotation.SuperTenantService; import org.apache.stratos.rest.endpoint.bean.CartridgeInfoBean; import org.apache.stratos.rest.endpoint.bean.StratosAdminResponse; +import org.apache.stratos.rest.endpoint.bean.SubscriptionDomainRequest; import org.apache.stratos.rest.endpoint.bean.autoscaler.partition.Partition; import org.apache.stratos.rest.endpoint.bean.autoscaler.partition.PartitionGroup; import org.apache.stratos.rest.endpoint.bean.autoscaler.policy.autoscale.AutoscalePolicy; @@ -40,7 +41,6 @@ import org.apache.stratos.rest.endpoint.bean.autoscaler.policy.deployment.Deploy import org.apache.stratos.rest.endpoint.bean.cartridge.definition.CartridgeDefinitionBean; import org.apache.stratos.rest.endpoint.bean.cartridge.definition.ServiceDefinitionBean; import org.apache.stratos.rest.endpoint.bean.repositoryNotificationInfoBean.Payload; -import org.apache.stratos.rest.endpoint.bean.repositoryNotificationInfoBean.Repository; import org.apache.stratos.rest.endpoint.bean.topology.Cluster; import org.apache.stratos.rest.endpoint.exception.RestAPIException; import org.apache.stratos.tenant.mgt.core.TenantPersistor; @@ -1018,4 +1018,36 @@ public class StratosAdmin extends AbstractAdmin { } return tenantList; } + + @POST + @Path("/cartridge/{cartridgeType}/subscription/{subscriptionAlias}/domain/") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + public StratosAdminResponse addSubscriptionDomains(@PathParam("cartridgeType") String cartridgeType, + @PathParam("subscriptionAlias") String subscriptionAlias, + SubscriptionDomainRequest request) throws RestAPIException { + + return ServiceUtils.addSubscriptionDomains(getConfigContext(), cartridgeType, subscriptionAlias, request.getDomains()); + } + + @GET + @Path("/cartridge/{cartridgeType}/subscription/{subscriptionAlias}/domain/") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + public String[] getSubscriptionDomains(@PathParam("cartridgeType") String cartridgeType, + @PathParam("subscriptionAlias") String subscriptionAlias) throws RestAPIException { + + return (String[]) ServiceUtils.getSubscriptionDomains(getConfigContext(), cartridgeType, subscriptionAlias).toArray(); + } + + @DELETE + @Path("/cartridge/{cartridgeType}/subscription/{subscriptionAlias}/domain/") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + public StratosAdminResponse removeSubscriptionDomains(@PathParam("cartridgeType") String cartridgeType, + @PathParam("subscriptionAlias") String subscriptionAlias, + SubscriptionDomainRequest request) throws RestAPIException { + + return ServiceUtils.removeSubscriptionDomains(getConfigContext(), cartridgeType, subscriptionAlias, request.getDomains()); + } } http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6c34420d/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/cxf-servlet.xml ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/cxf-servlet.xml b/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/cxf-servlet.xml index fbb8b10..fac0fb9 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/cxf-servlet.xml +++ b/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/cxf-servlet.xml @@ -68,6 +68,7 @@ <value>hostNames</value> <value>portMappings</value> <value>volumes</value> + <value>domains</value> </list> </property> </bean>
