From b35ea66dbcd246e314e078c390c058c33670e288 Mon Sep 17 00:00:00 2001 From: Shiro Date: Tue, 13 Jan 2015 11:53:13 +0530 Subject: [PATCH] Removed unwanted methods in REST API and urls from CLI --- .../stratos/cli/RestCommandLineService.java | 4 - .../rest/endpoint/api/StratosApiV41.java | 179 +++++++----------- .../rest/endpoint/api/StratosApiV41Utils.java | 65 +------ 3 files changed, 65 insertions(+), 183 deletions(-) diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestCommandLineService.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestCommandLineService.java index 37895f87de..baac666274 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestCommandLineService.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestCommandLineService.java @@ -70,7 +70,6 @@ public class RestCommandLineService { private static final String ENDPOINT_ADD_USER = API_CONTEXT + "/users"; private static final String ENDPOINT_DEPLOY_CARTRIDGE = API_CONTEXT + "/cartridges"; - private static final String ENDPOINT_DEPLOY_PARTITION = API_CONTEXT + "/partitions"; private static final String ENDPOINT_DEPLOY_AUTOSCALING_POLICY = API_CONTEXT + "/autoscalingPolicies"; private static final String ENDPOINT_DEPLOY_DEPLOYMENT_POLICY = API_CONTEXT + "/deploymentPolicies"; private static final String ENDPOINT_DEPLOY_KUBERNETES_CLUSTER = API_CONTEXT + "/kubernetesCluster"; @@ -84,7 +83,6 @@ public class RestCommandLineService { private static final String ENDPOINT_UNDEPLOY_APPLICATION = API_CONTEXT + "/applications/{id}"; private static final String ENDPOINT_UNDEPLOY_CARTRIDGE = API_CONTEXT + "/cartridges/{id}"; - private static final String ENDPOINT_LIST_PARTITIONS = API_CONTEXT + "/partitions"; private static final String ENDPOINT_LIST_AUTOSCALING_POLICIES = API_CONTEXT + "/autoscalingPolicies"; private static final String ENDPOINT_LIST_DEPLOYMENT_POLICIES = API_CONTEXT + "/deploymentPolicies"; private static final String ENDPOINT_LIST_CARTRIDGES = API_CONTEXT + "/cartridges"; @@ -100,7 +98,6 @@ public class RestCommandLineService { private static final String ENDPOINT_GET_DEPLOYMENT_POLICY = API_CONTEXT + "/applications/{applicationId}/deploymentPolicy"; private static final String ENDPOINT_GET_CARTRIDGE = API_CONTEXT + "/cartridges/{cartridgeType}"; private static final String ENDPOINT_GET_CARTRIDGE_OF_TENANT = API_CONTEXT + "/subscriptions/{id}/cartridges"; - private static final String ENDPOINT_GET_CLUSTER_OF_TENANT = API_CONTEXT + "/clusters/"; private static final String ENDPOINT_GET_KUBERNETES_GROUP = API_CONTEXT + "/kubernetesCluster/{kubernetesClusterId}"; private static final String ENDPOINT_GET_KUBERNETES_MASTER = API_CONTEXT + "/kubernetesCluster/{kubernetesClusterId}/master"; private static final String ENDPOINT_GET_KUBERNETES_HOST = API_CONTEXT + "/kubernetesCluster/{kubernetesClusterId}/hosts"; @@ -112,7 +109,6 @@ public class RestCommandLineService { private static final String ENDPOINT_ACTIVATE_TENANT = API_CONTEXT + "/tenants/activate/{tenantDomain}"; private static final String ENDPOINT_DEACTIVATE_TENANT = API_CONTEXT + "/tenants/deactivate/{tenantDomain}"; - private static final String ENDPOINT_UPDATE_SUBSCRIPTION_PROPERTIES = API_CONTEXT + "/subscriptions/{subscriptionAlias}/properties"; private static final String ENDPOINT_UPDATE_DEPLOYMENT_POLICY = API_CONTEXT + "/deploymentPolicies"; private static final String ENDPOINT_UPDATE_AUTOSCALING_POLICY = API_CONTEXT + "/autoscalePolicies"; diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java index bddba05a1f..1ff28a2bff 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java @@ -371,6 +371,13 @@ public Response getApplications() throws RestAPIException { return Response.ok(applicationDefinitionsArray).build(); } + /** + * Gets the application. + * + * @param applicationId the application id + * @return the application + * @throws RestAPIException the rest api exception + */ @GET @Path("/applications/{applicationId}") @Produces("application/json") @@ -403,6 +410,13 @@ public Response deployApplication(@PathParam("applicationId") String application return Response.accepted().build(); } + /** + * Gets the application's deployment policy. + * + * @param applicationId the application id + * @return the application deployment policy + * @throws RestAPIException the rest api exception + */ @GET @Path("/applications/{applicationId}/deploymentPolicy") @Produces("application/json") @@ -417,6 +431,14 @@ public Response getApplicationDeploymentPolicy(@PathParam("applicationId") Strin return Response.ok(deploymentPolicy).build(); } + /** + * Signs up for an application. + * + * @param applicationId the application id + * @param applicationSignUpBean the application sign up bean + * @return the response + * @throws RestAPIException the rest api exception + */ @POST @Path("/applications/{applicationId}/signup") @Produces("application/json") @@ -428,6 +450,14 @@ public Response addApplicationSignUp(@PathParam("applicationId") String applicat return Response.ok().build(); } + /** + * Gets the application sign up. + * + * @param applicationId the application id + * @param signUpId the sign up id + * @return the application sign up + * @throws RestAPIException the rest api exception + */ @GET @Path("/applications/{applicationId}/signup") @Produces("application/json") @@ -442,6 +472,13 @@ public Response getApplicationSignUp(@PathParam("applicationId") String applicat return Response.ok(applicationSignUpBean).build(); } + /** + * Removes the application sign up. + * + * @param applicationId the application id + * @return the response + * @throws RestAPIException the rest api exception + */ @DELETE @Path("/applications/{applicationId}/signup") @Produces("application/json") @@ -452,6 +489,14 @@ public Response removeApplicationSignUp(@PathParam("applicationId") String appli return Response.ok().build(); } + /** + * Adds the domain mappings for an application. + * + * @param applicationId the application id + * @param domainMapppingsBean the domain mapppings bean + * @return the response + * @throws RestAPIException the rest api exception + */ @POST @Path("/applications/{applicationId}/domainMappings") @Produces("application/json") @@ -463,6 +508,14 @@ public Response addDomainMappings(@PathParam("applicationId") String application return Response.ok().build(); } + /** + * Removes the domain mappings for an application. + * + * @param applicationId the application id + * @param domainMapppingsBean the domain mapppings bean + * @return the response + * @throws RestAPIException the rest api exception + */ @DELETE @Path("/applications/{applicationId}/domainMappings") @Produces("application/json") @@ -474,6 +527,13 @@ public Response removeDomainMappings(@PathParam("applicationId") String applicat return Response.ok().build(); } + /** + * Gets the domain mappings for an application. + * + * @param applicationId the application id + * @return the domain mappings + * @throws RestAPIException the rest api exception + */ @GET @Path("/applications/{applicationId}/domainMappings") @Produces("application/json") @@ -487,7 +547,7 @@ public Response getDomainMappings(@PathParam("applicationId") String application } /** - * Undeploy application. + * Undeploy an application. * * @param applicationId the application id * @return the response @@ -504,28 +564,6 @@ public Response undeployApplication(@PathParam("applicationId") String applicati return Response.accepted().build(); } - /** - * This API resource provides information about the application denoted by the given appId. Details includes, - * Application details, top level cluster details, details of the group and sub groups. - * - * @param applicationId Id of the application. - * @return Json representing the application details with 200 as HTTP status. HTTP 404 is returned when there is - * no application with given Id. - * @throws RestAPIException is thrown in case of failure occurs. - *//* - @GET - @Path("/applications/{applicationId}/runtime") - @Consumes("application/json") - @AuthorizationAction("/permission/protected/manage/monitor/tenants") - public Response getApplicationRuntime(@PathParam("applicationId") String applicationId) throws RestAPIException { - ApplicationBean applicationRuntime = StratosApiV41Utils.getApplicationRuntime(applicationId); - if (applicationRuntime == null) { - return Response.status(Response.Status.NOT_FOUND).build(); - } else { - return Response.ok().entity(applicationRuntime).build(); - } - }*/ - /** * This API resource provides information about the application denoted by the given appId. Details includes, * Application details, top level cluster details, details of the group and sub groups. @@ -649,96 +687,6 @@ public Response updateAutoscalingPolicyDefintion(AutoscalePolicyBean autoscalePo return Response.ok().build(); } - // API methods for subscriptions - -// /** -// * Gets the subscriptions of an application. -// * -// * @param applicationId the application id -// * @return the subscriptions of application -// * @throws RestAPIException the rest api exception -// */ -// @GET -// @Path("/subscriptions/{applicationId}") -// @Produces("application/json") -// @Consumes("application/json") -// @AuthorizationAction("/permission/protected/manage/monitor/tenants") -// public Response getSubscriptionsForApplication(@PathParam("applicationId") String applicationId) throws RestAPIException { -// List subscriptions = StratosApiV41Utils.getApplicationSubscriptions(applicationId); -// if (subscriptions == null) { -// return Response.status(Response.Status.NOT_FOUND).build(); -// } -// return Response.ok().entity(subscriptions).build(); -// } - - /** - * Gets the subscribed cartridges of service group. - * - * @param serviceGroup the service group - * @return the subscribed cartridges of service group - * @throws RestAPIException the rest api exception - */ - @GET - @Path("/subscriptions/cartridges/groups/{serviceGroupId}") - @Produces("application/json") - @Consumes("application/json") - @AuthorizationAction("/permission/admin/manage/view/cartridge") - public Response getSubscribedCartridgesForServiceGroup(@PathParam("serviceGroupId") String serviceGroup) throws RestAPIException { - throw new RestAPIException("Not implemented"); - } - - // API methods for clusters - - @GET - @Path("/clusters") - @Produces("application/json") - @Consumes("application/json") - @AuthorizationAction("/permission/admin/manage/view/cluster") - public Response getClustersForTenant() throws RestAPIException { -// return Response.ok().entity(StratosApiV41Utils.getClustersForTenant(getConfigContext())).build(); - throw new RestAPIException("Not implemented"); - } - - @GET - @Path("/clusters/{cartridgeType}/") - @Produces("application/json") - @Consumes("application/json") - @AuthorizationAction("/permission/admin/manage/view/cluster") - public Response getClustersForCartridge(@PathParam("cartridgeType") String cartridgeType) throws RestAPIException { - -// ResponseBuilder rb = Response.ok(); -// rb.entity(StratosApiV41Utils.getClustersForTenantAndCartridgeType(getConfigContext(), cartridgeType)); -// return rb.build(); - throw new RestAPIException("Not implemented"); - } - - @GET - @Path("/clusters/{clusterId}") - @Produces("application/json") - @Consumes("application/json") - @AuthorizationAction("/permission/admin/manage/view/cluster") - public Response getClusterForTenant(@PathParam("clusterId") String clusterId) throws RestAPIException { -// Cluster cluster = null; -// if (log.isDebugEnabled()) { -// log.debug("Finding cluster for [id]: " + clusterId); -// } -// Cluster[] clusters = StratosApiV41Utils.getClustersForTenant(getConfigContext()); -// if (log.isDebugEnabled()) { -// log.debug("Clusters retrieved from backend for cluster [id]: " + clusterId); -// for (Cluster c : clusters) { -// log.debug(c + "\n"); -// } -// } -// for (Cluster clusterObj : clusters) { -// if (clusterObj.getClusterId().equals(clusterId)) { -// cluster = clusterObj; -// break; -// } -// } -// return Response.ok().entity(cluster).build(); - throw new RestAPIException("Not implemented"); - } - // API methods for tenants /** @@ -777,12 +725,13 @@ public Response addTenant(org.apache.stratos.common.beans.TenantInfoBean tenantI if (userRegistry == null) { log.error("Security alert! User registry is null. A user is trying create a tenant " + " without an authenticated session."); - throw new RestAPIException("Invalid data"); // obscure error message. + throw new RestAPIException("Security alert! User registry is null. A user is trying create a tenant " + + " without an authenticated session."); } if (userRegistry.getTenantId() != MultitenantConstants.SUPER_TENANT_ID) { log.error("Security alert! None super tenant trying to create a tenant."); - throw new RestAPIException("Invalid data"); // obscure error message. + throw new RestAPIException("Security alert! None super tenant trying to create a tenant."); } Tenant tenant = TenantMgtUtil.initializeTenant( diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java index 0f76bd8ff3..4a6d474bf2 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java @@ -542,8 +542,7 @@ public static AutoscalePolicyBean getAutoScalePolicy(String autoscalePolicyId) t return ObjectConverter.convertStubAutoscalePolicyToAutoscalePolicy(autoscalePolicy); } - public static DeploymentPolicyBean - getDeploymentPolicy(String applicationId) throws RestAPIException { + public static DeploymentPolicyBean getDeploymentPolicy(String applicationId) throws RestAPIException { try { AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient(); @@ -576,39 +575,6 @@ public static ApplicationLevelNetworkPartitionBean[] getPartitionGroups(String d return ObjectConverter.convertStubApplicationLevelNetworkPartitionsToApplicationLevelNetworkPartitions(partitionGroups); } -// public static org.apache.stratos.common.beans.topology.Cluster[] getClustersForTenant(ConfigurationContext configurationContext) { -// -// Set clusterSet = TopologyClusterInformationModel.getInstance().getClusters(ApplicationManagementUtil. -// getTenantId(configurationContext), null); -// ArrayList clusters = -// new ArrayList(); -// for (Cluster cluster : clusterSet) { -// clusters.add(ObjectConverter.convertClusterToClusterBean(cluster, null)); -// } -// org.apache.stratos.common.beans.topology.Cluster[] arrCluster = -// new org.apache.stratos.common.beans.topology.Cluster[clusters.size()]; -// arrCluster = clusters.toArray(arrCluster); -// return arrCluster; -// -// } - -// public static org.apache.stratos.common.beans.topology.Cluster[] getClustersForTenantAndCartridgeType(ConfigurationContext configurationContext, -// String cartridgeType) { -// -// Set clusterSet = TopologyClusterInformationModel.getInstance().getClusters(ApplicationManagementUtil. -// getTenantId(configurationContext), cartridgeType); -// List clusters = -// new ArrayList(); -// for (Cluster cluster : clusterSet) { -// clusters.add(ObjectConverter.convertClusterToClusterBean(cluster, null)); -// } -// org.apache.stratos.common.beans.topology.Cluster[] arrCluster = -// new org.apache.stratos.common.beans.topology.Cluster[clusters.size()]; -// arrCluster = clusters.toArray(arrCluster); -// return arrCluster; -// -// } - // Util methods for repo actions public static void notifyArtifactUpdatedEvent(GitNotificationPayloadBean payload) throws RestAPIException { @@ -983,23 +949,6 @@ public static ApplicationInfoBean[] getApplicationRuntimes() { return applicationBeanList.toArray(new ApplicationInfoBean[applicationBeanList.size()]); } - /*public static ApplicationBean getApplicationRuntime(String applicationId) { - ApplicationBean applicationBean = null; - try { - ApplicationManager.acquireReadLockForApplication(applicationId); - Application application = ApplicationManager.getApplications().getApplication(applicationId); - if (application == null) { - return null; - } - applicationBean = ObjectConverter.convertApplicationToApplicationBean(application); - addClustersToApplicationBean(applicationBean, application); - addGroupsToApplicationBean(applicationBean, application); - } finally { - ApplicationManager.releaseReadLockForApplication(applicationId); - } - return applicationBean; - }*/ - public static ApplicationInfoBean getApplicationInstanceRuntime(String applicationId) { ApplicationInfoBean applicationBean = null; try { @@ -1035,18 +984,6 @@ private static void addGroupsInstancesToApplicationInstanceBean(ApplicationInsta } -// private static void addClustersToApplicationBean(ApplicationBean applicationBean, Application application) { -// Map topLevelClusterDataMap = application.getClusterDataMap(); -// for (Map.Entry entry : topLevelClusterDataMap.entrySet()) { -// ClusterDataHolder clusterDataHolder = entry.getValue(); -// String clusterId = clusterDataHolder.getClusterId(); -// String serviceType = clusterDataHolder.getServiceType(); -// TopologyManager.acquireReadLockForCluster(serviceType, clusterId); -// Cluster topLevelCluster = TopologyManager.getTopology().getService(serviceType).getCluster(clusterId); -// applicationBean.getClusters().add(ObjectConverter.convertClusterToClusterBean(topLevelCluster, entry.getKey())); -// } -// } - private static void addClustersInstancesToApplicationInstanceBean( ApplicationInstanceBean applicationInstanceBean, Application application) {