Commit e805a60c authored by Rucha Deshpande's avatar Rucha Deshpande
Browse files

AWS bulk-acl implementation

commit 43f2dd43 
Author: Rucha Deshpande <deshruch@amazon.com> 
Date: Thu Sep 03 2020 10:48:18 GMT-0500 (Central Daylight Time) 

    Adding copyright stmt/ year


commit a3ec5500 
Author: Rucha Deshpande <deshruch@amazon.com> 
Date: Tue Sep 01 2020 16:23:35 GMT-0500 (Central Daylight Time) 

    bulk acl update 2


commit 8390b69f 
Author: Rucha Deshpande <deshruch@amazon.com> 
Date: Tue Sep 01 2020 11:17:28 GMT-0500 (Central Daylight Time) 

    bulk acl update
parent 4caabd02
Pipeline #7378 passed with stages
in 46 minutes and 54 seconds
# Copyright © Amazon Web Services
# Copyright © 2020 Amazon Web Services
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
......
# Copyright © 2020 Amazon Web Services
#
# Licensed 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.
import boto3
import json
import os
......
......@@ -27,7 +27,6 @@ phases:
- apt-get install -y maven
- java -version
- mvn -version
- echo $JAVA_HOME #WHY
- mkdir -p /root/.m2
- cp ./provider/storage-aws/maven/settings.xml /root/.m2/settings.xml # copy the AWS-specific settings.xml to the CodeBuild instance's .m2 folder
- export AWS_ACCOUNT_ID=`aws sts get-caller-identity | grep Account | cut -d':' -f 2 | cut -d'"' -f 2`
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright © 2020 Amazon Web Services
Licensed 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
......
// Copyright © Amazon Web Services
// Copyright © 2020 Amazon Web Services
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
......
// Copyright © Amazon Web Services
// Copyright © 2020 Amazon Web Services
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
......
// Copyright © Amazon Web Services
// Copyright © 2020 Amazon Web Services
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
......
// Copyright © Amazon Web Services
// Copyright © 2020 Amazon Web Services
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
......
// Copyright © Amazon Web Services
// Copyright © 2020 Amazon Web Services
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
......
// Copyright © Amazon Web Services
// Copyright © 2020 Amazon Web Services
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
......
// Copyright © Amazon Web Services
// Copyright © 2020 Amazon Web Services
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
......
// Copyright © Amazon Web Services
// Copyright © 2020 Amazon Web Services
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
......
// Copyright © Amazon Web Services
// Copyright © 2020 Amazon Web Services
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
......
// Copyright © Amazon Web Services
// Copyright © 2020 Amazon Web Services
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
......
// Copyright © Amazon Web Services
// Copyright © 2020 Amazon Web Services
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
......
#Copyright © Amazon Web Services
#Copyright © 2020 Amazon Web Services
#
#Licensed under the Apache License, Version 2.0 (the "License");
#you may not use this file except in compliance with the License.
......
// Copyright © Amazon Web Services
// Copyright © 2020 Amazon Web Services
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
......@@ -16,6 +16,7 @@ package org.opengroup.osdu.storage.provider.aws;
import com.google.gson.Gson;
import org.opengroup.osdu.core.aws.dynamodb.DynamoDBQueryHelper;
import org.opengroup.osdu.core.common.model.entitlements.Acl;
import org.opengroup.osdu.core.common.model.http.AppException;
import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
import org.opengroup.osdu.core.common.model.storage.RecordData;
......@@ -249,4 +250,45 @@ public class CloudStorageImpl implements ICloudStorage {
return false;
}
}
@Override
public Map<String, org.opengroup.osdu.core.common.model.entitlements.Acl> updateObjectMetadata(List<RecordMetadata> recordsMetadata, List<String> recordsId, List<RecordMetadata> validMetadata, List<String> lockedRecords, Map<String, String> recordsIdMap) {
Map<String, org.opengroup.osdu.core.common.model.entitlements.Acl> originalAcls = new HashMap<>();
Map<String, RecordMetadata> currentRecords = this.recordsMetadataRepository.get(recordsId);
for (RecordMetadata recordMetadata : recordsMetadata) {
String id = recordMetadata.getId();
String idWithVersion = recordsIdMap.get(id);
if (!id.equalsIgnoreCase(idWithVersion)) {
long previousVersion = Long.parseLong(idWithVersion.split(":")[3]);
long currentVersion = currentRecords.get(id).getLatestVersion();
if (previousVersion != currentVersion) {
lockedRecords.add(idWithVersion);
continue;
}
}
validMetadata.add(recordMetadata);
originalAcls.put(recordMetadata.getId(), currentRecords.get(id).getAcl());
}
return originalAcls;
}
@Override
public void revertObjectMetadata(List<RecordMetadata> recordsMetadata, Map<String, org.opengroup.osdu.core.common.model.entitlements.Acl> originalAcls) {
List<RecordMetadata> originalAclRecords = new ArrayList<>();
for (RecordMetadata recordMetadata : recordsMetadata) {
Acl acl = originalAcls.get(recordMetadata.getId());
recordMetadata.setAcl(acl);
originalAclRecords.add(recordMetadata);
}
try {
this.recordsMetadataRepository.createOrUpdate(originalAclRecords);
} catch (Exception e) {
throw new AppException(HttpStatus.SC_INTERNAL_SERVER_ERROR, "Error while reverting metadata: in revertObjectMetadata.","Internal server error.", e);
}
}
}
// Copyright © Amazon Web Services
// Copyright © 2020 Amazon Web Services
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
......
// Copyright © Amazon Web Services
// Copyright © 2020 Amazon Web Services
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
......
// Copyright © Amazon Web Services
// Copyright © 2020 Amazon Web Services
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment