You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2019/06/27 21:43:29 UTC
[airavata] branch staging updated: Some description fields longer
than allowed Entity description, so cap at 255
This is an automated email from the ASF dual-hosted git repository.
machristie pushed a commit to branch staging
in repository https://gitbox.apache.org/repos/asf/airavata.git
The following commit(s) were added to refs/heads/staging by this push:
new bb2f150 Some description fields longer than allowed Entity description, so cap at 255
bb2f150 is described below
commit bb2f1503e8f5595e8aba9017315d33450ee760f2
Author: Marcus Christie <ma...@iu.edu>
AuthorDate: Thu Jun 27 17:43:16 2019 -0400
Some description fields longer than allowed Entity description, so cap at 255
---
.../registry/migrator/airavata/AiravataDataMigrator.java | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/modules/sharing-registry/sharing-data-migrator/src/main/java/org/apache/airavata/sharing/registry/migrator/airavata/AiravataDataMigrator.java b/modules/sharing-registry/sharing-data-migrator/src/main/java/org/apache/airavata/sharing/registry/migrator/airavata/AiravataDataMigrator.java
index 19c7e86..57857fd 100644
--- a/modules/sharing-registry/sharing-data-migrator/src/main/java/org/apache/airavata/sharing/registry/migrator/airavata/AiravataDataMigrator.java
+++ b/modules/sharing-registry/sharing-data-migrator/src/main/java/org/apache/airavata/sharing/registry/migrator/airavata/AiravataDataMigrator.java
@@ -344,7 +344,7 @@ public class AiravataDataMigrator {
entity.setEntityTypeId(entity.getDomainId() + ":" + ResourceType.CREDENTIAL_TOKEN.name());
entity.setOwnerId(domainOwnerMap.get(domainID));
entity.setName(credentialSummary.getToken());
- entity.setDescription(credentialSummary.getDescription());
+ entity.setDescription(maxLengthString(credentialSummary.getDescription(), 255));
if (!sharingRegistryServerHandler.isEntityExists(entity.getDomainId(), entity.getEntityId()))
sharingRegistryServerHandler.createEntity(entity);
if (gatewayGroupsMap.containsKey(entity.getDomainId())) {
@@ -372,7 +372,8 @@ public class AiravataDataMigrator {
entity.setEntityTypeId(entity.getDomainId() + ":" + ResourceType.CREDENTIAL_TOKEN.name());
entity.setOwnerId(userId);
entity.setName(credentialSummary.getToken());
- entity.setDescription(credentialSummary.getDescription());
+ // Cap description length at max 255 characters
+ entity.setDescription(maxLengthString(credentialSummary.getDescription(), 255));
if (!sharingRegistryServerHandler.isEntityExists(entity.getDomainId(), entity.getEntityId()))
sharingRegistryServerHandler.createEntity(entity);
// Don't need to share USER SSH tokens with any group
@@ -389,7 +390,7 @@ public class AiravataDataMigrator {
entity.setEntityTypeId(entity.getDomainId() + ":" + ResourceType.CREDENTIAL_TOKEN.name());
entity.setOwnerId(domainOwnerMap.get(domainID));
entity.setName(gatewayPasswordEntry.getKey());
- entity.setDescription(gatewayPasswordEntry.getValue());
+ entity.setDescription(maxLengthString(gatewayPasswordEntry.getValue(), 255));
if (!sharingRegistryServerHandler.isEntityExists(entity.getDomainId(), entity.getEntityId()))
sharingRegistryServerHandler.createEntity(entity);
if (gatewayGroupsMap.containsKey(entity.getDomainId())) {
@@ -627,6 +628,15 @@ public class AiravataDataMigrator {
return s != null && !"".equals(s.trim());
}
+ private static String maxLengthString(String s, int maxLength) {
+
+ if (s != null) {
+ return s.substring(0, Math.min(maxLength, s.length()));
+ } else {
+ return null;
+ }
+ }
+
private static CredentialStoreService.Client getCredentialStoreServiceClient() throws TException, ApplicationSettingsException {
final int serverPort = Integer.parseInt(ServerSettings.getCredentialStoreServerPort());
final String serverHost = ServerSettings.getCredentialStoreServerHost();