You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by am...@apache.org on 2019/06/05 15:09:31 UTC
[ambari] branch branch-2.7 updated: [AMBARI-25286] : Avoid
conditional logic for creating ViewURLResource (Backport to branch-2.7)
(#2999)
This is an automated email from the ASF dual-hosted git repository.
amagyar pushed a commit to branch branch-2.7
in repository https://gitbox.apache.org/repos/asf/ambari.git
The following commit(s) were added to refs/heads/branch-2.7 by this push:
new ffd89ff [AMBARI-25286] : Avoid conditional logic for creating ViewURLResource (Backport to branch-2.7) (#2999)
ffd89ff is described below
commit ffd89ff5262f2b54329805e6900c6e815b54ca1c
Author: virajjasani <34...@users.noreply.github.com>
AuthorDate: Wed Jun 5 20:39:26 2019 +0530
[AMBARI-25286] : Avoid conditional logic for creating ViewURLResource (Backport to branch-2.7) (#2999)
---
.../server/api/services/views/ViewUrlsService.java | 37 +++++++++-------------
1 file changed, 15 insertions(+), 22 deletions(-)
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/views/ViewUrlsService.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/views/ViewUrlsService.java
index afaf9c8..1dd0b94 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/views/ViewUrlsService.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/views/ViewUrlsService.java
@@ -38,12 +38,9 @@ import org.apache.ambari.server.api.services.BaseService;
import org.apache.ambari.server.api.services.Request;
import org.apache.ambari.server.controller.ViewUrlResponseSwagger;
import org.apache.ambari.server.controller.spi.Resource;
-import org.apache.ambari.server.security.authorization.AuthorizationException;
import org.apache.http.HttpStatus;
-import com.google.common.base.Optional;
-
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
@@ -58,7 +55,7 @@ import io.swagger.annotations.ApiResponses;
@Api(value = "Views", description = "Endpoint for view specific operations")
public class ViewUrlsService extends BaseService {
- public static final String VIEW_URL_INFO_TYPE = "org.apache.ambari.server.controller.ViewUrlResponseSwagger";
+ private static final String VIEW_URL_INFO_TYPE = "org.apache.ambari.server.controller.ViewUrlResponseSwagger";
/**
* Get the list of all registered view URLs
@@ -86,7 +83,7 @@ public class ViewUrlsService extends BaseService {
@ApiResponse(code = HttpStatus.SC_BAD_REQUEST, message = MSG_INVALID_ARGUMENTS),
})
public Response getViewUrls(@Context HttpHeaders headers, @Context UriInfo ui) {
- return handleRequest(headers, null, ui, Request.Type.GET, createViewUrlResource(Optional.absent()));
+ return handleRequest(headers, null, ui, Request.Type.GET, createViewUrlResource(null));
}
/**
@@ -96,8 +93,7 @@ public class ViewUrlsService extends BaseService {
* @param ui
* @param urlName
* @return
- * @throws AuthorizationException
- */
+ */
@POST
@Path("{urlName}")
@Produces(MediaType.TEXT_PLAIN)
@@ -112,8 +108,8 @@ public class ViewUrlsService extends BaseService {
@ApiResponse(code = HttpStatus.SC_INTERNAL_SERVER_ERROR, message = MSG_SERVER_ERROR),
})
public Response createUrl(String body, @Context HttpHeaders headers, @Context UriInfo ui,
- @PathParam("urlName") String urlName) throws AuthorizationException {
- return handleRequest(headers, body, ui, Request.Type.POST, createViewUrlResource(Optional.of(urlName)));
+ @PathParam("urlName") String urlName) {
+ return handleRequest(headers, body, ui, Request.Type.POST, createViewUrlResource(urlName));
}
/**
@@ -123,8 +119,7 @@ public class ViewUrlsService extends BaseService {
* @param ui
* @param urlName
* @return
- * @throws AuthorizationException
- */
+ */
@PUT
@Path("{urlName}")
@Produces(MediaType.TEXT_PLAIN)
@@ -142,8 +137,8 @@ public class ViewUrlsService extends BaseService {
@ApiResponse(code = HttpStatus.SC_INTERNAL_SERVER_ERROR, message = MSG_SERVER_ERROR),
})
public Response updateUrl(String body, @Context HttpHeaders headers, @Context UriInfo ui,
- @PathParam("urlName") String urlName) throws AuthorizationException {
- return handleRequest(headers, body, ui, Request.Type.PUT, createViewUrlResource(Optional.of(urlName)));
+ @PathParam("urlName") String urlName) {
+ return handleRequest(headers, body, ui, Request.Type.PUT, createViewUrlResource(urlName));
}
/**
@@ -152,7 +147,6 @@ public class ViewUrlsService extends BaseService {
* @param ui
* @param urlName
* @return
- * @throws AuthorizationException
*/
@GET
@Path("{urlName}")
@@ -170,8 +164,8 @@ public class ViewUrlsService extends BaseService {
@ApiResponse(code = HttpStatus.SC_BAD_REQUEST, message = MSG_INVALID_ARGUMENTS),
})
public Response getUrl(@Context HttpHeaders headers, @Context UriInfo ui,
- @PathParam("urlName") String urlName) throws AuthorizationException {
- return handleRequest(headers, null, ui, Request.Type.GET, createViewUrlResource(Optional.of(urlName)));
+ @PathParam("urlName") String urlName) {
+ return handleRequest(headers, null, ui, Request.Type.GET, createViewUrlResource(urlName));
}
/**
@@ -181,8 +175,7 @@ public class ViewUrlsService extends BaseService {
* @param ui
* @param urlName
* @return
- * @throws AuthorizationException
- */
+ */
@DELETE
@Path("{urlName}")
@Produces(MediaType.TEXT_PLAIN)
@@ -195,8 +188,8 @@ public class ViewUrlsService extends BaseService {
@ApiResponse(code = HttpStatus.SC_INTERNAL_SERVER_ERROR, message = MSG_SERVER_ERROR),
})
public Response deleteUrl(String body, @Context HttpHeaders headers, @Context UriInfo ui,
- @PathParam("urlName") String urlName) throws AuthorizationException {
- return handleRequest(headers, body, ui, Request.Type.DELETE, createViewUrlResource(Optional.of(urlName)));
+ @PathParam("urlName") String urlName) {
+ return handleRequest(headers, body, ui, Request.Type.DELETE, createViewUrlResource(urlName));
}
// ----- helper methods ----------------------------------------------------
@@ -208,7 +201,7 @@ public class ViewUrlsService extends BaseService {
*
* @return a view URL resource instance
*/
- private ResourceInstance createViewUrlResource(Optional<String> urlName) {
- return createResource(Resource.Type.ViewURL,Collections.singletonMap(Resource.Type.ViewURL, urlName.isPresent()?urlName.get().toString():null));
+ private ResourceInstance createViewUrlResource(final String urlName) {
+ return createResource(Resource.Type.ViewURL, Collections.singletonMap(Resource.Type.ViewURL, urlName));
}
}