GaOrtiga commented on code in PR #13598:
URL: https://github.com/apache/cloudstack/pull/13598#discussion_r3573344390
##########
api/src/main/java/org/apache/cloudstack/api/command/admin/host/AddSecondaryStorageCmd.java:
##########
@@ -89,20 +88,15 @@ public long getEntityOwnerId() {
@Override
public void execute(){
- try{
- ImageStore result = _storageService.discoverImageStore(null,
getUrl(), "NFS", getZoneId(), getDetails());
- ImageStoreResponse storeResponse = null;
- if (result != null ) {
- storeResponse =
_responseGenerator.createImageStoreResponse(result);
- storeResponse.setResponseName(getCommandName());
- storeResponse.setObjectName("secondarystorage");
- setResponseObject(storeResponse);
- } else {
- throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR,
"Failed to add secondary storage");
- }
- } catch (DiscoveryException ex) {
- logger.warn("Exception: ", ex);
- throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR,
ex.getMessage());
+ ImageStore result = _storageService.discoverImageStore(null, getUrl(),
"NFS", getZoneId(), getDetails());
+ ImageStoreResponse storeResponse = null;
+ if (result != null ) {
Review Comment:
@DaanHoogland can we invert the logic to reduce identation?
##########
api/src/main/java/org/apache/cloudstack/api/command/admin/storage/AddImageStoreCmd.java:
##########
@@ -123,20 +120,15 @@ public long getEntityOwnerId() {
@Override
public void execute(){
- try{
- ImageStore result = _storageService.discoverImageStore(getName(),
getUrl(), getProviderName(), getZoneId(), getDetails());
- ImageStoreResponse storeResponse = null;
- if (result != null) {
- storeResponse =
_responseGenerator.createImageStoreResponse(result);
- storeResponse.setResponseName(getCommandName());
- storeResponse.setObjectName("imagestore");
- setResponseObject(storeResponse);
- } else {
- throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR,
"Failed to add secondary storage");
- }
- } catch (DiscoveryException ex) {
- logger.warn("Exception: ", ex);
- throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR,
ex.getMessage());
+ ImageStore result = _storageService.discoverImageStore(getName(),
getUrl(), getProviderName(), getZoneId(), getDetails());
+ ImageStoreResponse storeResponse;
+ if (result != null) {
Review Comment:
same here
##########
api/src/main/java/org/apache/cloudstack/api/command/admin/swift/AddSwiftCmd.java:
##########
@@ -83,25 +82,20 @@ public long getEntityOwnerId() {
@Override
public void execute() {
- Map<String, String> dm = new HashMap<String, String>();
+ Map<String, String> dm = new HashMap<>();
dm.put(ApiConstants.ACCOUNT, getAccount());
dm.put(ApiConstants.USERNAME, getUsername());
dm.put(ApiConstants.KEY, getKey());
- try{
- ImageStore result = _storageService.discoverImageStore(null,
getUrl(), "Swift", null, dm);
- ImageStoreResponse storeResponse = null;
- if (result != null) {
- storeResponse =
_responseGenerator.createImageStoreResponse(result);
- storeResponse.setResponseName(getCommandName());
- storeResponse.setObjectName("secondarystorage");
- setResponseObject(storeResponse);
- } else {
- throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR,
"Failed to add Swift secondary storage");
- }
- } catch (DiscoveryException ex) {
- logger.warn("Exception: ", ex);
- throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR,
ex.getMessage());
+ ImageStore result = _storageService.discoverImageStore(null, getUrl(),
"Swift", null, dm);
+ ImageStoreResponse storeResponse;
+ if (result != null) {
Review Comment:
same here
##########
api/src/main/java/org/apache/cloudstack/api/command/admin/storage/AddImageStoreS3CMD.java:
##########
@@ -127,20 +126,15 @@ public void execute() throws
ResourceUnavailableException, InsufficientCapacityE
dm.put(ApiConstants.S3_USE_TCP_KEEPALIVE,
getUseTCPKeepAlive().toString());
}
- try{
- ImageStore result = _storageService.discoverImageStore(null, null,
"S3", null, dm);
- ImageStoreResponse storeResponse;
- if (result != null) {
- storeResponse =
_responseGenerator.createImageStoreResponse(result);
- storeResponse.setResponseName(getCommandName());
- storeResponse.setObjectName("imagestore");
- setResponseObject(storeResponse);
- } else {
- throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR,
"Failed to add S3 Image Store.");
- }
- } catch (DiscoveryException ex) {
- logger.warn("Exception: ", ex);
- throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR,
ex.getMessage());
+ ImageStore result = _storageService.discoverImageStore(null, null,
"S3", null, dm);
+ ImageStoreResponse storeResponse;
+ if (result != null) {
Review Comment:
same here
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]