Modified CommentManagerImpl ,CommentManagementAPIImpl,CommentManagementAPI

Modified the exceptions.
feature/appm-store/pbac
nishadi 7 years ago
parent c1dca737f7
commit 1bbd0b1aa5

@ -1,3 +1,21 @@
/*
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. 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.wso2.carbon.device.application.mgt.api.services;
import io.swagger.annotations.ApiParam;
@ -14,7 +32,6 @@ import org.wso2.carbon.apimgt.annotations.api.Scope;
import org.wso2.carbon.apimgt.annotations.api.Scopes;
import org.wso2.carbon.device.application.mgt.api.beans.ErrorResponse;
import org.wso2.carbon.device.application.mgt.common.Comment;
import javax.validation.Valid;
import javax.ws.rs.Path;
import javax.ws.rs.Consumes;
@ -27,7 +44,6 @@ import javax.ws.rs.POST;
import javax.ws.rs.DELETE;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.sql.SQLException;
import java.util.List;
/**
@ -395,5 +411,5 @@ public interface CommentManagementAPI {
value="uuid of the release version of the application",
required=true)
@PathParam("uuid")
String uuid) throws SQLException;
String uuid);
}

@ -28,9 +28,7 @@ import org.wso2.carbon.device.application.mgt.common.Comment;
import org.wso2.carbon.device.application.mgt.common.PaginationRequest;
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException;
import org.wso2.carbon.device.application.mgt.common.exception.CommentManagementException;
import org.wso2.carbon.device.application.mgt.common.exception.DBConnectionException;
import org.wso2.carbon.device.application.mgt.common.services.CommentsManager;
import javax.ws.rs.Path;
import javax.ws.rs.Consumes;
import javax.ws.rs.PathParam;
@ -41,7 +39,6 @@ import javax.ws.rs.POST;
import javax.ws.rs.DELETE;
import javax.ws.rs.NotFoundException;
import javax.ws.rs.core.Response;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
@ -79,9 +76,6 @@ public class CommentManagementAPIImpl implements CommentManagementAPI{
String msg = "Error occurred while retrieving comments.";
log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
} catch (SQLException e) {
log.error("SQL Exception occurs", e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
}
return Response.status(Response.Status.OK).entity(comments).build();
}
@ -138,12 +132,6 @@ public class CommentManagementAPIImpl implements CommentManagementAPI{
String msg = "Error occurred while retrieving comments.";
log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
} catch (SQLException e) {
log.error("SQL Exception occurs", e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
}catch (DBConnectionException e) {
log.error("DB Connection Exception occurs", e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
}
}
@ -181,8 +169,11 @@ public class CommentManagementAPIImpl implements CommentManagementAPI{
try {
Stars= commentsManager.getStars(uuid);
} catch (SQLException e) {
log.error("SQL Exception occurs", e);
} catch (CommentManagementException e) {
log.error("Comment Management Exception occurs",e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
} catch (ApplicationManagementException e) {
log.error("Application Management Exception occurs",e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
}
return Response.status(Response.Status.OK).entity(Stars).build();
@ -200,8 +191,11 @@ public class CommentManagementAPIImpl implements CommentManagementAPI{
try {
ratedUsers= commentsManager.getRatedUser(uuid);
} catch (SQLException e) {
log.error("SQL Exception occurs", e);
} catch (CommentManagementException e) {
log.error("Comment Management Exception occurs",e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
} catch (ApplicationManagementException e) {
log.error("Application Management Exception occurs",e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
}
return Response.status(Response.Status.OK).entity(ratedUsers).build();
@ -212,10 +206,10 @@ public class CommentManagementAPIImpl implements CommentManagementAPI{
@Consumes("uuid/stars/json")
public Response updateStars(
@ApiParam int stars,
@PathParam("uuid") String uuid) throws SQLException {
@PathParam("uuid") String uuid) {
CommentsManager commentsManager = APIUtil.getCommentsManager();
int newStars=commentsManager.getStars(uuid);
int newStars=0;
try {
newStars = commentsManager.updateStars(stars,uuid);
@ -229,8 +223,8 @@ public class CommentManagementAPIImpl implements CommentManagementAPI{
}
} catch (ApplicationManagementException e) {
log.error("Application Management Exception occurs", e);
log.error("Application Management Exception occurs",e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
}
return Response.status(Response.Status.OK).entity(newStars).build();
}
}

@ -85,7 +85,7 @@ public class CommentsManagerImpl implements CommentsManager {
* @param CommentId ID of the comment.
* @param comment comment needed to be validate.
* @return Application related with the UUID.
*
* @throws CommentManagementException Exceptions of the comment management.
*
*/
@ -274,8 +274,5 @@ public class CommentsManagerImpl implements CommentsManager {
} finally {
ConnectionManagerUtil.closeDBConnection();
}
}
}
Loading…
Cancel
Save