AMBARI-21077: Fix build issues after reverting patch for AMBARI-21077 and merging latest trunk (jluniya)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/ba7b5cbe Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/ba7b5cbe Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/ba7b5cbe Branch: refs/heads/branch-feature-AMBARI-14714 Commit: ba7b5cbe8296c0d3bf26bc7648d58de57aee3f39 Parents: f491f7b Author: Jayush Luniya <[email protected]> Authored: Mon Jul 10 12:53:08 2017 -0700 Committer: Jayush Luniya <[email protected]> Committed: Mon Jul 10 12:53:08 2017 -0700 ---------------------------------------------------------------------- .../api/services/AbstractVersionService.java | 370 ------------------- .../api/services/MpackRequestSwagger.java | 30 ++ .../server/api/services/MpacksService.java | 77 +++- .../api/services/RegistryRequestSwagger.java | 30 ++ .../server/api/services/RegistryService.java | 66 +++- .../ambari/server/controller/MpackResponse.java | 9 + .../server/controller/RegistryResponse.java | 9 + .../internal/MpackResourceProvider.java | 19 +- .../internal/RegistryResourceProvider.java | 11 +- .../server/upgrade/UpgradeCatalog251.java | 5 - .../server/api/services/MpacksServiceTest.java | 3 +- 11 files changed, 226 insertions(+), 403 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/ba7b5cbe/ambari-server/src/main/java/org/apache/ambari/server/api/services/AbstractVersionService.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/AbstractVersionService.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/AbstractVersionService.java deleted file mode 100644 index a5712d4..0000000 --- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/AbstractVersionService.java +++ /dev/null @@ -1,370 +0,0 @@ -/** - * 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.ambari.server.api.services; - -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; - -import org.apache.ambari.server.api.rest.BootStrapResource; -import org.apache.ambari.server.api.rest.HealthCheck; -import org.apache.ambari.server.api.rest.KdcServerReachabilityCheck; -import org.apache.ambari.server.api.util.ApiVersion; - -/** - * Abstract class for single entry point for an API version - */ -public abstract class AbstractVersionService { - - /** - * Handles /actions request. - * - * @return action service - */ - @Path("/actions") - public ActionService getActionService(@PathParam("apiVersion") String apiVersion) { - return new ActionService(ApiVersion.valueOf(apiVersion)); - } - - /** - * Handles /alert_targets request. - * - * @return alert targets service - */ - @Path("/alert_targets") - public AlertTargetService getAlertTargetService(@PathParam("apiVersion") String apiVersion) { - return new AlertTargetService(ApiVersion.valueOf(apiVersion)); - } - - /** - * Handles /privileges request. - * - * @return privileges service - */ - @Path("/privileges") - public AmbariPrivilegeService getAmbariPrivilegeService(@PathParam("apiVersion") String apiVersion) { - return new AmbariPrivilegeService(ApiVersion.valueOf(apiVersion)); - } - - /** - * Handles /blueprints request. - * - * @return blueprints service - */ - @Path("/blueprints") - public BlueprintService getBlueprintService(@PathParam("apiVersion") String apiVersion) { - return new BlueprintService(ApiVersion.valueOf(apiVersion)); - } - - - /** - * Handles /links request. - * - * @return extension links service - */ - @Path("/links") - public ExtensionLinksService getExtensionLinksService(@PathParam("apiVersion") String apiVersion) { - return new ExtensionLinksService(ApiVersion.valueOf(apiVersion)); - } - - /** - * Handles /extensions request. - * - * @return extensions service - */ - @Path("/extensions") - public ExtensionsService getExtensionsService(@PathParam("apiVersion") String apiVersion) { - return new ExtensionsService(ApiVersion.valueOf(apiVersion)); - } - - - /** - * Handles /clusters request. - * - * @return cluster service - */ - @Path("/clusters") - public ClusterService getClusterService(@PathParam("apiVersion") String apiVersion) { - return new ClusterService(ApiVersion.valueOf(apiVersion)); - } - - /** - * Handles /feeds request. - * TODO: Cleanup? - * - * @return feed service - */ - @Path("/feeds") - public FeedService getFeedService(@PathParam("apiVersion") String apiVersion) { - return new FeedService(ApiVersion.valueOf(apiVersion)); - } - - /** - * Handles /groups request. - * - * @return group service - */ - @Path("/groups") - public GroupService getGroupService(@PathParam("apiVersion") String apiVersion) { - return new GroupService(ApiVersion.valueOf(apiVersion)); - } - - /** - * Handles /hosts request. - * - * @return host service - */ - @Path("/hosts") - public HostService getHostService(@PathParam("apiVersion") String apiVersion) { - return new HostService(ApiVersion.valueOf(apiVersion)); - } - - /** - * Handles /instances request. - * TODO: Cleanup? - * - * @return instance service - */ - @Path("/instances") - public InstanceService getInstanceService(@PathParam("apiVersion") String apiVersion) { - return new InstanceService(ApiVersion.valueOf(apiVersion)); - } - - /** - * Handles /kerberos_descriptors request. - * - * @return kerberos descriptor service - */ - @Path("/kerberos_descriptors") - public KerberosDescriptorService getKerberosDescriptorService(@PathParam("apiVersion") String apiVersion) { - return new KerberosDescriptorService(ApiVersion.valueOf(apiVersion)); - } - - /** - * Handles /keys request. - * - * @return key service - */ - @Path("/keys") - public KeyService getKeyService(@PathParam("apiVersion") String apiVersion) { - return new KeyService(); - } - - /** - * Handles /ldap_sync_events request. - * - * @return Ldap sync event service - */ - @Path("/ldap_sync_events") - public LdapSyncEventService getLdapSyncEventService(@PathParam("apiVersion") String apiVersion) { - return new LdapSyncEventService(ApiVersion.valueOf(apiVersion)); - } - - /** - * Handles /logout request. - * - * @return logout service - */ - @Path("/logout") - public LogoutService getLogoutService(@PathParam("apiVersion") String apiVersion) { - return new LogoutService(); - } - - /** - * Handles /permissions request. - * - * @return permission service - */ - @Path("/permissions") - public PermissionService getPermissionService(@PathParam("apiVersion") String apiVersion) { - return new PermissionService(ApiVersion.valueOf(apiVersion)); - } - - /** - * Handles /persist request. - * - * @return persist service - */ - @Path("/persist") - public PersistKeyValueService getPersistKeyValueService(@PathParam("apiVersion") String apiVersion) { - return new PersistKeyValueService(); - } - - /** - * Handles /remoteclusters request - * - * @return remote clusters service - */ - @Path("/remoteclusters") - public RemoteClustersService getRemoteClustersService(@PathParam("apiVersion") String apiVersion) { - return new RemoteClustersService(ApiVersion.valueOf(apiVersion)); - } - - /** - * Handles /requests request. - * - * @return request service - */ - @Path("/requests") - public RequestService getRequestService(@PathParam("apiVersion") String apiVersion) { - return new RequestService(ApiVersion.valueOf(apiVersion)); - } - - /** - * Handles /settings request. - * - * @return request service - */ - @Path("/settings") - public SettingService getSettingService(@PathParam("apiVersion") String apiVersion) { - return new SettingService(ApiVersion.valueOf(apiVersion)); - } - - /** - * Handles /authorizations request. - * - * @return role authorization service - */ - @Path("/authorizations") - public RoleAuthorizationService getRoleAuthorizationService(@PathParam("apiVersion") String apiVersion) { - return new RoleAuthorizationService(ApiVersion.valueOf(apiVersion)); - } - - /** - * Handles /services request. - * - * @return root service service - */ - @Path("/services") - public RootServiceService getRootServiceService(@PathParam("apiVersion") String apiVersion) { - return new RootServiceService(ApiVersion.valueOf(apiVersion)); - } - - /** - * Handles /targets request. - * TODO: Cleanup? - * - * @return target cluster service - */ - @Path("/targets") - public TargetClusterService getTargetClusterService(@PathParam("apiVersion") String apiVersion) { - return new TargetClusterService(ApiVersion.valueOf(apiVersion)); - } - - /** - * Handles /users request. - * - * @return user service - */ - @Path("/users") - public UserService getUserService(@PathParam("apiVersion") String apiVersion) { - return new UserService(ApiVersion.valueOf(apiVersion)); - } - - /** - * Handles /version_definitions request. - * - * @return version definition service - */ - @Path("/version_definitions") - public VersionDefinitionService getVersionDefinitionService(@PathParam("apiVersion") String apiVersion) { - return new VersionDefinitionService(ApiVersion.valueOf(apiVersion)); - } - - /** - * Handles /views request. - * - * @return view service - */ - @Path("/views") - public ViewService getViewService(@PathParam("apiVersion") String apiVersion) { - return new ViewService(ApiVersion.valueOf(apiVersion)); - } - - /** - * Handles /view/urls request. - * - * @return view urls service - */ - @Path("/view/urls") - public ViewUrlsService getViewUrlsService(@PathParam("apiVersion") String apiVersion) { - return new ViewUrlsService(ApiVersion.valueOf(apiVersion)); - } - - /** - * Handles /stacks request. - * - * @return stacks service - */ - @Path("/stacks") - public StacksService getStacksService(@PathParam("apiVersion") String apiVersion) { - return new StacksService(ApiVersion.valueOf(apiVersion)); - } - - - /** - * Handles /bootstrap request. - * - * @return bootstrap service - */ - @Path("/bootstrap") - public BootStrapResource getBootStrapResource(@PathParam("apiVersion") String apiVersion) { - return new BootStrapResource(); - } - - - /** - * Handles /check request. - * - * @return health check service - */ - @Path("/check") - public HealthCheck getHealthCheck(@PathParam("apiVersion") String apiVersion) { - return new HealthCheck(); - } - - /** - * Handles /kdc_check request. - * - * @return kdc server reachability service - */ - @Path("/kdc_check") - public KdcServerReachabilityCheck getKdcServerReachabilityCheck(@PathParam("apiVersion") String apiVersion) { - return new KdcServerReachabilityCheck(); - } - - /** - * Handles /registries request. - * - * @return registry service - */ - @Path("/registries") - public RegistryService getRegistryService(@PathParam("apiVersion") String apiVersion) { - return new RegistryService(ApiVersion.valueOf(apiVersion)); - } - - /** - * Handles /mpacks request. - * - * @return mpacks service - */ - @Path("/mpacks") - public MpacksService getMpacksService(@PathParam("apiVersion") String apiVersion) { - return new MpacksService(ApiVersion.valueOf(apiVersion)); - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/ba7b5cbe/ambari-server/src/main/java/org/apache/ambari/server/api/services/MpackRequestSwagger.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/MpackRequestSwagger.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/MpackRequestSwagger.java new file mode 100644 index 0000000..5fe5693 --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/MpackRequestSwagger.java @@ -0,0 +1,30 @@ +/* + * 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.ambari.server.api.services; + +import org.apache.ambari.server.controller.ApiModel; +import org.apache.ambari.server.controller.MpackRequest; +import org.apache.ambari.server.controller.internal.MpackResourceProvider; + +import io.swagger.annotations.ApiModelProperty; + +@SuppressWarnings("unused") // for Swagger +public interface MpackRequestSwagger extends ApiModel { + @ApiModelProperty(name = MpackResourceProvider.RESPONSE_KEY) + MpackRequest getMpackRequest(); +} http://git-wip-us.apache.org/repos/asf/ambari/blob/ba7b5cbe/ambari-server/src/main/java/org/apache/ambari/server/api/services/MpacksService.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/MpacksService.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/MpacksService.java index 47c1af4..4b7e025 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/MpacksService.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/MpacksService.java @@ -26,22 +26,35 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.Context; import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; import org.apache.ambari.server.api.resources.ResourceInstance; -import org.apache.ambari.server.api.util.ApiVersion; +import org.apache.ambari.server.controller.MpackResponse.MpackResponseWrapper; +import org.apache.ambari.server.controller.internal.MpackResourceProvider; import org.apache.ambari.server.controller.spi.Resource; +import org.apache.http.HttpStatus; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; /** * Service for Mpacks Management. * Endpoint for Mpack Data */ - +@Path("/mpacks/") +@Api(value = "Mpacks", description = "Endpoint for mpack-specific operations") public class MpacksService extends BaseService { - public MpacksService(ApiVersion apiVersion) { - super(apiVersion); + private static final String MPACK_REQUEST_TYPE = "org.apache.ambari.server.api.services.MpackRequestSwagger"; + + public MpacksService() { + super(); } /** @@ -54,7 +67,28 @@ public class MpacksService extends BaseService { * */ @GET - @Produces("text/plain") + @Produces(MediaType.TEXT_PLAIN) + @ApiOperation(value = "Returns all mpacks registered with this Ambari instance", + response = MpackResponseWrapper.class, responseContainer = RESPONSE_CONTAINER_LIST) + @ApiImplicitParams({ + @ApiImplicitParam(name = QUERY_FIELDS, value = QUERY_FILTER_DESCRIPTION, dataType = DATA_TYPE_STRING, + paramType = PARAM_TYPE_QUERY, defaultValue = MpackResourceProvider.MPACK_ID), + @ApiImplicitParam(name = QUERY_SORT, value = QUERY_SORT_DESCRIPTION, dataType = DATA_TYPE_STRING, + paramType = PARAM_TYPE_QUERY), + @ApiImplicitParam(name = QUERY_PAGE_SIZE, value = QUERY_PAGE_SIZE_DESCRIPTION, defaultValue = DEFAULT_PAGE_SIZE, + dataType = DATA_TYPE_INT, paramType = PARAM_TYPE_QUERY), + @ApiImplicitParam(name = QUERY_FROM, value = QUERY_FROM_DESCRIPTION, allowableValues = QUERY_FROM_VALUES, + defaultValue = DEFAULT_FROM, dataType = DATA_TYPE_INT, paramType = PARAM_TYPE_QUERY), + @ApiImplicitParam(name = QUERY_TO, value = QUERY_TO_DESCRIPTION, allowableValues = QUERY_TO_VALUES, + dataType = DATA_TYPE_INT, paramType = PARAM_TYPE_QUERY), + }) + @ApiResponses({ + @ApiResponse(code = HttpStatus.SC_OK, message = MSG_SUCCESSFUL_OPERATION), + @ApiResponse(code = HttpStatus.SC_NOT_FOUND, message = MSG_RESOURCE_NOT_FOUND), + @ApiResponse(code = HttpStatus.SC_UNAUTHORIZED, message = MSG_NOT_AUTHENTICATED), + @ApiResponse(code = HttpStatus.SC_FORBIDDEN, message = MSG_PERMISSION_DENIED), + @ApiResponse(code = HttpStatus.SC_INTERNAL_SERVER_ERROR, message = MSG_SERVER_ERROR), + }) public Response getMpacks(String body, @Context HttpHeaders headers, @Context UriInfo ui) { return handleRequest(headers, body, ui, Request.Type.GET, createMpackResource(null)); @@ -69,7 +103,20 @@ public class MpacksService extends BaseService { * @return information regarding the created mpack */ @POST - @Produces("text/plain") + @Produces(MediaType.TEXT_PLAIN) + @ApiOperation(value = "Registers an mpack with this Ambari mpack") + @ApiImplicitParams({ + @ApiImplicitParam(dataType = MPACK_REQUEST_TYPE, paramType = PARAM_TYPE_BODY) + }) + @ApiResponses({ + @ApiResponse(code = HttpStatus.SC_CREATED, message = MSG_SUCCESSFUL_OPERATION), + @ApiResponse(code = HttpStatus.SC_ACCEPTED, message = MSG_REQUEST_ACCEPTED), + @ApiResponse(code = HttpStatus.SC_BAD_REQUEST, message = MSG_INVALID_ARGUMENTS), + @ApiResponse(code = HttpStatus.SC_CONFLICT, message = MSG_RESOURCE_ALREADY_EXISTS), + @ApiResponse(code = HttpStatus.SC_UNAUTHORIZED, message = MSG_NOT_AUTHENTICATED), + @ApiResponse(code = HttpStatus.SC_FORBIDDEN, message = MSG_PERMISSION_DENIED), + @ApiResponse(code = HttpStatus.SC_INTERNAL_SERVER_ERROR, message = MSG_SERVER_ERROR), + }) public Response createMpacks(String body, @Context HttpHeaders headers, @Context UriInfo ui) { return handleRequest(headers, body, ui, Request.Type.POST, createMpackResource(null)); } @@ -82,8 +129,22 @@ public class MpacksService extends BaseService { */ @GET @Path("{mpack_id}") - @Produces("text/plain") - public Response getMpack(String body, @Context HttpHeaders headers, @Context UriInfo ui, @PathParam("mpack_id") String mpackId) { + @Produces(MediaType.TEXT_PLAIN) + @ApiOperation(value = "Returns information about a specific mpack that is registered with this Ambari instance", + response = MpackResponseWrapper.class) + @ApiImplicitParams({ + @ApiImplicitParam(name = QUERY_FIELDS, value = QUERY_FILTER_DESCRIPTION, dataType = DATA_TYPE_STRING, + paramType = PARAM_TYPE_QUERY, defaultValue = MpackResourceProvider.ALL_PROPERTIES), + }) + @ApiResponses({ + @ApiResponse(code = HttpStatus.SC_OK, message = MSG_SUCCESSFUL_OPERATION), + @ApiResponse(code = HttpStatus.SC_NOT_FOUND, message = MSG_RESOURCE_NOT_FOUND), + @ApiResponse(code = HttpStatus.SC_UNAUTHORIZED, message = MSG_NOT_AUTHENTICATED), + @ApiResponse(code = HttpStatus.SC_FORBIDDEN, message = MSG_PERMISSION_DENIED), + @ApiResponse(code = HttpStatus.SC_INTERNAL_SERVER_ERROR, message = MSG_SERVER_ERROR), + }) + public Response getMpack(String body, @Context HttpHeaders headers, @Context UriInfo ui, + @PathParam("mpack_id") String mpackId) { return handleRequest(headers, body, ui, Request.Type.GET, createMpackResource(mpackId)); http://git-wip-us.apache.org/repos/asf/ambari/blob/ba7b5cbe/ambari-server/src/main/java/org/apache/ambari/server/api/services/RegistryRequestSwagger.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/RegistryRequestSwagger.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/RegistryRequestSwagger.java new file mode 100644 index 0000000..4399418 --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/RegistryRequestSwagger.java @@ -0,0 +1,30 @@ +/* + * 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.ambari.server.api.services; + +import org.apache.ambari.server.controller.ApiModel; +import org.apache.ambari.server.controller.RegistryRequest; +import org.apache.ambari.server.controller.internal.RegistryResourceProvider; + +import io.swagger.annotations.ApiModelProperty; + +@SuppressWarnings("unused") // for Swagger +public interface RegistryRequestSwagger extends ApiModel { + @ApiModelProperty(name = RegistryResourceProvider.RESPONSE_KEY) + RegistryRequest getRegistryRequest(); +} http://git-wip-us.apache.org/repos/asf/ambari/blob/ba7b5cbe/ambari-server/src/main/java/org/apache/ambari/server/api/services/RegistryService.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/RegistryService.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/RegistryService.java index 5f1a0e4..8f5437d 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/RegistryService.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/RegistryService.java @@ -26,17 +26,31 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.Context; import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; import org.apache.ambari.server.api.resources.ResourceInstance; -import org.apache.ambari.server.api.util.ApiVersion; +import org.apache.ambari.server.controller.RegistryResponse.RegistryResponseWrapper; +import org.apache.ambari.server.controller.internal.RegistryResourceProvider; import org.apache.ambari.server.controller.spi.Resource; +import org.apache.http.HttpStatus; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; + +@Path("/registries/") +@Api(value = "Registries", description = "Endpoint for software registry specific operations") public class RegistryService extends BaseService { - public RegistryService(final ApiVersion apiVersion) { - super(apiVersion); + private static final String REGISTRY_REQUEST_TYPE = "org.apache.ambari.server.api.services.RegistryRequestSwagger"; + + public RegistryService() { + super(); } /** @@ -48,7 +62,20 @@ public class RegistryService extends BaseService { * @return information regarding the softare registry */ @POST - @Produces("text/plain") + @Produces(MediaType.TEXT_PLAIN) + @ApiOperation(value = "Connect a software registry with this Ambari instance") + @ApiImplicitParams({ + @ApiImplicitParam(dataType = REGISTRY_REQUEST_TYPE, paramType = PARAM_TYPE_BODY) + }) + @ApiResponses({ + @ApiResponse(code = HttpStatus.SC_CREATED, message = MSG_SUCCESSFUL_OPERATION), + @ApiResponse(code = HttpStatus.SC_ACCEPTED, message = MSG_REQUEST_ACCEPTED), + @ApiResponse(code = HttpStatus.SC_BAD_REQUEST, message = MSG_INVALID_ARGUMENTS), + @ApiResponse(code = HttpStatus.SC_CONFLICT, message = MSG_RESOURCE_ALREADY_EXISTS), + @ApiResponse(code = HttpStatus.SC_UNAUTHORIZED, message = MSG_NOT_AUTHENTICATED), + @ApiResponse(code = HttpStatus.SC_FORBIDDEN, message = MSG_PERMISSION_DENIED), + @ApiResponse(code = HttpStatus.SC_INTERNAL_SERVER_ERROR, message = MSG_SERVER_ERROR), + }) public Response createRegistries(String body, @Context HttpHeaders headers, @Context UriInfo ui) { return handleRequest(headers, body, ui, Request.Type.POST, createRegistryResource(null)); } @@ -63,7 +90,21 @@ public class RegistryService extends BaseService { * */ @GET - @Produces("text/plain") + @Produces(MediaType.TEXT_PLAIN) + @ApiOperation(value = "Returns all software registry connected with this Ambari instance", + response = RegistryResponseWrapper.class, responseContainer = RESPONSE_CONTAINER_LIST) + @ApiImplicitParams({ + @ApiImplicitParam(name = QUERY_FIELDS, value = QUERY_FILTER_DESCRIPTION, dataType = DATA_TYPE_STRING, + paramType = PARAM_TYPE_QUERY, defaultValue = RegistryResourceProvider.REGISTRY_ID), + @ApiImplicitParam(name = QUERY_SORT, value = QUERY_SORT_DESCRIPTION, dataType = DATA_TYPE_STRING, + paramType = PARAM_TYPE_QUERY), + @ApiImplicitParam(name = QUERY_PAGE_SIZE, value = QUERY_PAGE_SIZE_DESCRIPTION, defaultValue = DEFAULT_PAGE_SIZE, + dataType = DATA_TYPE_INT, paramType = PARAM_TYPE_QUERY), + @ApiImplicitParam(name = QUERY_FROM, value = QUERY_FROM_DESCRIPTION, allowableValues = QUERY_FROM_VALUES, + defaultValue = DEFAULT_FROM, dataType = DATA_TYPE_INT, paramType = PARAM_TYPE_QUERY), + @ApiImplicitParam(name = QUERY_TO, value = QUERY_TO_DESCRIPTION, allowableValues = QUERY_TO_VALUES, + dataType = DATA_TYPE_INT, paramType = PARAM_TYPE_QUERY), + }) public Response getRegistries(String body, @Context HttpHeaders headers, @Context UriInfo ui) { return handleRequest(headers, body, ui, Request.Type.GET, createRegistryResource(null)); @@ -78,7 +119,20 @@ public class RegistryService extends BaseService { */ @GET @Path("{registry_id}") - @Produces("text/plain") + @Produces(MediaType.TEXT_PLAIN) + @ApiOperation(value = "Returns information about a specific software registry that is connected with this Ambari instance", + response = RegistryResponseWrapper.class) + @ApiImplicitParams({ + @ApiImplicitParam(name = QUERY_FIELDS, value = QUERY_FILTER_DESCRIPTION, dataType = DATA_TYPE_STRING, + paramType = PARAM_TYPE_QUERY, defaultValue = RegistryResourceProvider.ALL_PROPERTIES), + }) + @ApiResponses({ + @ApiResponse(code = HttpStatus.SC_OK, message = MSG_SUCCESSFUL_OPERATION), + @ApiResponse(code = HttpStatus.SC_NOT_FOUND, message = MSG_RESOURCE_NOT_FOUND), + @ApiResponse(code = HttpStatus.SC_UNAUTHORIZED, message = MSG_NOT_AUTHENTICATED), + @ApiResponse(code = HttpStatus.SC_FORBIDDEN, message = MSG_PERMISSION_DENIED), + @ApiResponse(code = HttpStatus.SC_INTERNAL_SERVER_ERROR, message = MSG_SERVER_ERROR), + }) public Response getRegistry(String body, @Context HttpHeaders headers, @Context UriInfo ui, @PathParam("registry_id") String registryId) { http://git-wip-us.apache.org/repos/asf/ambari/blob/ba7b5cbe/ambari-server/src/main/java/org/apache/ambari/server/controller/MpackResponse.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/MpackResponse.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/MpackResponse.java index 76b0aba..ff42fde 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/MpackResponse.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/MpackResponse.java @@ -17,8 +17,11 @@ */ package org.apache.ambari.server.controller; +import org.apache.ambari.server.controller.internal.MpackResourceProvider; import org.apache.ambari.server.state.Mpack; +import io.swagger.annotations.ApiModelProperty; + /** * Represents a mpack response. */ @@ -106,4 +109,10 @@ public class MpackResponse { MpackResponse MpackResponse = (MpackResponse) obj; return getMpackId().equals(MpackResponse.getMpackId()); } + + public interface MpackResponseWrapper extends ApiModel { + @ApiModelProperty(name = MpackResourceProvider.RESPONSE_KEY) + @SuppressWarnings("unused") + MpackResponse getMpackResponse(); + } } http://git-wip-us.apache.org/repos/asf/ambari/blob/ba7b5cbe/ambari-server/src/main/java/org/apache/ambari/server/controller/RegistryResponse.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/RegistryResponse.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/RegistryResponse.java index adb512c..729451f 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/RegistryResponse.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/RegistryResponse.java @@ -17,9 +17,12 @@ */ package org.apache.ambari.server.controller; +import org.apache.ambari.server.controller.internal.RegistryResourceProvider; import org.apache.ambari.server.registry.Registry; import org.apache.ambari.server.registry.RegistryType; +import io.swagger.annotations.ApiModelProperty; + /** * Represents a software registry response. */ @@ -87,4 +90,10 @@ public class RegistryResponse { RegistryResponse registryResponse = (RegistryResponse) obj; return getRegistryId().equals(registryResponse.getRegistryId()); } + + public interface RegistryResponseWrapper extends ApiModel { + @ApiModelProperty(name = RegistryResourceProvider.RESPONSE_KEY) + @SuppressWarnings("unused") + RegistryResponse getRegistryResponse(); + } } http://git-wip-us.apache.org/repos/asf/ambari/blob/ba7b5cbe/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/MpackResourceProvider.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/MpackResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/MpackResourceProvider.java index 99a28cb..1bef4cd 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/MpackResourceProvider.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/MpackResourceProvider.java @@ -43,6 +43,7 @@ import org.apache.ambari.server.controller.spi.ResourceAlreadyExistsException; import org.apache.ambari.server.controller.spi.SystemException; import org.apache.ambari.server.controller.spi.UnsupportedPropertyException; import org.apache.ambari.server.controller.utilities.PredicateHelper; +import org.apache.ambari.server.controller.utilities.PropertyHelper; import org.apache.ambari.server.orm.dao.MpackDAO; import org.apache.ambari.server.orm.dao.StackDAO; import org.apache.ambari.server.orm.entities.MpackEntity; @@ -57,14 +58,16 @@ import com.google.inject.Inject; @StaticallyInject public class MpackResourceProvider extends AbstractControllerResourceProvider { - public static final String MPACK_ID = "MpackInfo/mpack_id"; - public static final String REGISTRY_ID = "MpackInfo/registry_id"; - public static final String MPACK_NAME = "MpackInfo/mpack_name"; - public static final String MPACK_VERSION = "MpackInfo/mpack_version"; - public static final String MPACK_URI = "MpackInfo/mpack_uri"; - public static final String PACKLETS = "MpackInfo/packlets"; - public static final String STACK_NAME_PROPERTY_ID = "MpackInfo/stack_name"; - public static final String STACK_VERSION_PROPERTY_ID = "MpackInfo/stack_version"; + public static final String RESPONSE_KEY = "MpackInfo"; + public static final String ALL_PROPERTIES = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "*"; + public static final String MPACK_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "mpack_id"; + public static final String REGISTRY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "registry_id"; + public static final String MPACK_NAME = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "mpack_name"; + public static final String MPACK_VERSION = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "mpack_version"; + public static final String MPACK_URI = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "mpack_uri"; + public static final String PACKLETS = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "packlets"; + public static final String STACK_NAME_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "stack_name"; + public static final String STACK_VERSION_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "stack_version"; private static Set<String> pkPropertyIds = new HashSet<>( Arrays.asList(MPACK_ID, STACK_NAME_PROPERTY_ID, STACK_VERSION_PROPERTY_ID)); http://git-wip-us.apache.org/repos/asf/ambari/blob/ba7b5cbe/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RegistryResourceProvider.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RegistryResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RegistryResourceProvider.java index 112b30f..715cd96 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RegistryResourceProvider.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RegistryResourceProvider.java @@ -38,6 +38,7 @@ import org.apache.ambari.server.controller.spi.Resource; import org.apache.ambari.server.controller.spi.ResourceAlreadyExistsException; import org.apache.ambari.server.controller.spi.SystemException; import org.apache.ambari.server.controller.spi.UnsupportedPropertyException; +import org.apache.ambari.server.controller.utilities.PropertyHelper; import org.apache.ambari.server.registry.RegistryType; import org.apache.commons.lang.Validate; @@ -46,10 +47,12 @@ import org.apache.commons.lang.Validate; */ @StaticallyInject public class RegistryResourceProvider extends AbstractControllerResourceProvider { - public static final String REGISTRY_ID = "RegistryInfo/registry_id"; - public static final String REGISTRY_NAME = "RegistryInfo/registry_name"; - public static final String REGISTRY_TYPE = "RegistryInfo/registry_type"; - public static final String REGISTRY_URI = "RegistryInfo/registry_uri"; + public static final String RESPONSE_KEY = "RegistryInfo"; + public static final String ALL_PROPERTIES = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "*"; + public static final String REGISTRY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "registry_id"; + public static final String REGISTRY_NAME = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "registry_name"; + public static final String REGISTRY_TYPE = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "registry_type"; + public static final String REGISTRY_URI = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "registry_uri"; private static Set<String> pkPropertyIds = new HashSet<>( Arrays.asList(REGISTRY_ID, REGISTRY_NAME)); http://git-wip-us.apache.org/repos/asf/ambari/blob/ba7b5cbe/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog251.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog251.java b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog251.java index 87c4972..6200915 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog251.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog251.java @@ -31,8 +31,6 @@ import org.apache.ambari.server.state.Clusters; import org.apache.ambari.server.state.Config; import org.apache.ambari.server.state.SecurityType; import org.apache.commons.lang.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -40,9 +38,6 @@ import org.slf4j.LoggerFactory; import com.google.inject.Inject; import com.google.inject.Injector; -import com.google.inject.Inject; -import com.google.inject.Injector; - /** * The {@link UpgradeCatalog251} upgrades Ambari from 2.5.0 to 2.5.1. */ http://git-wip-us.apache.org/repos/asf/ambari/blob/ba7b5cbe/ambari-server/src/test/java/org/apache/ambari/server/api/services/MpacksServiceTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/services/MpacksServiceTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/services/MpacksServiceTest.java index d2c655a..3c3184c 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/api/services/MpacksServiceTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/api/services/MpacksServiceTest.java @@ -29,7 +29,6 @@ import org.apache.ambari.server.api.resources.ResourceInstance; import org.apache.ambari.server.api.services.parsers.RequestBodyParser; import org.apache.ambari.server.api.services.serializers.ResultSerializer; -import org.apache.ambari.server.api.util.ApiVersion; import org.apache.ambari.server.controller.spi.Resource; /** @@ -65,7 +64,7 @@ public class MpacksServiceTest extends BaseServiceTest{ private String m_mpackId; private TestMpacksService(String mpackId) { - super(ApiVersion.Default); + super(); m_mpackId = mpackId; }
