Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AIRAVATA-2385] Checking for duplicate gateway request #111

Merged
merged 3 commits into from Jun 12, 2017

Conversation

Projects
None yet
3 participants
@tilaks26
Copy link
Contributor

commented Jun 6, 2017

Modified TenantProfileServiceHandler.java to check for a duplicate add gateway request.
Checked if the gateway ID, name, URL was already present in the database with the status as approved.

@machristie
Copy link
Contributor

left a comment

Thanks for submitting this PR Sneha! Please see my comments on the PR.

@@ -72,7 +72,9 @@ public String getAPIVersion(AuthzToken authzToken) throws TenantProfileServiceEx
@SecurityCheck
public String addGateway(AuthzToken authzToken, Gateway gateway) throws TenantProfileServiceException, AuthorizationException, TException {
try {
gateway = tenantProfileRepository.create(gateway);
if (!checkDuplicate(gateway)) {

This comment has been minimized.

Copy link
@machristie

machristie Jun 7, 2017

Contributor

If there is a duplicate then I think the code should throw a TenantProfileServiceException with an error message explaining that there is a duplicate.

@@ -183,12 +185,25 @@ public boolean deleteGateway(AuthzToken authzToken, String gatewayId) throws Ten
public boolean isGatewayExist(AuthzToken authzToken, String gatewayId) throws TenantProfileServiceException, AuthorizationException, TException {
try {
Gateway gateway = tenantProfileRepository.getGateway(gatewayId);

This comment has been minimized.

Copy link
@machristie

machristie Jun 7, 2017

Contributor

This won't work as is. getGateway() should query by gatewayId where status is APPROVED. This way if there is an APPROVED gateway with the gatewayId getGateway() should return it. That means too that the checks on lines 188-189 are unnecessary.


private boolean checkDuplicate(Gateway gateway) throws TenantProfileServiceException {
try {
Gateway duplicateGateway = tenantProfileRepository.getGateway(gateway.getGatewayId());

This comment has been minimized.

Copy link
@machristie

machristie Jun 7, 2017

Contributor

Same concern here as above. This will work only if getGateway returns an APPROVED gateway with this gatewayId.

private boolean checkDuplicate(Gateway gateway) throws TenantProfileServiceException {
try {
Gateway duplicateGateway = tenantProfileRepository.getGateway(gateway.getGatewayId());
return ((duplicateGateway.getGatewayId() == gateway.getGatewayId()) && (duplicateGateway.getGatewayName() == gateway.getGatewayName()) && (duplicateGateway.getGatewayURL() == gateway.getGatewayURL()) && (duplicateGateway.getGatewayApprovalStatus().equals(GatewayApprovalStatus.APPROVED)));

This comment has been minimized.

Copy link
@machristie

machristie Jun 7, 2017

Contributor

Please use .equals() to compare strings instead of ==.

Sneha Tilak
@tilaks26

This comment has been minimized.

Copy link
Contributor Author

commented Jun 9, 2017

Changes made in the new commit -

Added new method checkDuplicateGateway() in TenantProfileServiceHandler.java to identify duplicate requests for Gateway Ids that have already been approved

Modified FIND_GATEWAY_BY_ID in QueryConstants.java to return only Approved Gateways

Added new method getAllGatewaysForUser() in TenantProfileServiceHandler.java as a Thrift service to display gateways belonging to a particular user
Added new method getAllGatewaysForUser() in TenantProfileRepository.java to retrieve the GET_USER_GATEWAYS query result
Modified profile_tenant_cpi.thrift to include getAllGatewaysForUser() and generated the stubs to reflect in Iface (TenantProfileService.java)
Added GET_USER_GATEWAYS in QueryContsants.java to return all Gateways belonging to a particular user

Modified workspace_model.thrift to expose the Gateway's airavataInternalId to Update and Delete Gateways and generated the stubs to reflect in Gateway.java
Modified deleteGateway() in profile_tenant_cpi.thrift to accept the airavataInternalId as a parameter and generated the stubs to reflect in Iface (TenantProfileService.java)

@machristie

This comment has been minimized.

Copy link
Contributor

commented Jun 12, 2017

👍

@asfgit asfgit merged commit b3e0754 into apache:develop Jun 12, 2017

1 check failed

continuous-integration/travis-ci/pr The Travis CI build could not complete due to an error
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.