Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
Storage
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OSDU
OSDU Data Platform
System
Storage
Commits
ea52b6ba
Commit
ea52b6ba
authored
2 years ago
by
Alok Joshi
Browse files
Options
Downloads
Patches
Plain Diff
bump core lib azure version
parent
dfc922c3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
4 merge requests
!760
Vulnerability fixes
,
!745
Draft: M18 Upgraded packages to mitigate vulns in netty, guava, snakeyaml
,
!744
Upgraded packages to mitigated vulns in netty, guava, snakeyaml
,
!639
Extend patch API to support data block modification
Pipeline
#175725
passed
2 years ago
Stage: build
Stage: scan
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
provider/storage-azure/pom.xml
+1
-1
1 addition, 1 deletion
provider/storage-azure/pom.xml
storage-core/src/main/java/org/opengroup/osdu/storage/service/PatchRecordsServiceImpl.java
+4
-21
4 additions, 21 deletions
...engroup/osdu/storage/service/PatchRecordsServiceImpl.java
with
5 additions
and
22 deletions
provider/storage-azure/pom.xml
+
1
−
1
View file @
ea52b6ba
...
...
@@ -34,7 +34,7 @@
<azure.appservice.appname
/>
<azure.appservice.subscription
/>
<!-- below corelibazure version will be updated to a release candidate once the associated MR is merged -->
<osdu.corelibazure.version>
0.20.0-
SNAPSHOT-patch-doc
</osdu.corelibazure.version>
<osdu.corelibazure.version>
0.20.0-
rc8
</osdu.corelibazure.version>
<osdu.storage-core.version>
0.20.0-SNAPSHOT
</osdu.storage-core.version>
<junit.version>
4.12
</junit.version>
<mockito.version>
1.10.19
</mockito.version>
...
...
This diff is collapsed.
Click to expand it.
storage-core/src/main/java/org/opengroup/osdu/storage/service/PatchRecordsServiceImpl.java
+
4
−
21
View file @
ea52b6ba
...
...
@@ -168,13 +168,12 @@ public class PatchRecordsServiceImpl implements PatchRecordsService {
}
else
{
this
.
validateUserAccessAndComplianceConstraints
(
jsonPatch
,
recordIds
,
existingRecords
);
}
List
<
RecordMetadata
>
recordMetadataToBePatched
=
new
ArrayList
<>();
long
currentTime
=
System
.
currentTimeMillis
();
Map
<
RecordMetadata
,
JsonPatch
>
patchPerRecord
=
new
HashMap
<>();
for
(
String
recordId
:
recordIds
)
{
RecordMetadata
metadata
=
existingRecords
.
get
(
CollaborationUtil
.
getIdWithNamespace
(
recordId
,
collaborationContext
));
try
{
if
(
checkIfResultingAclOrLegalTagsAreEmpty
(
metadata
,
jsonPatch
))
{
if
(
isEmptyAclOrLegal
(
patchRecordMetadataWithJsonPatch
(
metadata
,
jsonPatch
))
)
{
failedRecordIds
.
add
(
recordId
);
errors
.
add
(
"Patch operation for record: "
+
recordId
+
" aborted. Potentially empty value of legaltags or acl/owners or acl/viewers"
);
}
else
{
...
...
@@ -228,7 +227,7 @@ public class PatchRecordsServiceImpl implements PatchRecordsService {
ArrayNode
arrayNode
=
JsonNodeFactory
.
instance
.
arrayNode
(
1
);
arrayNode
.
add
(
currentNode
);
JsonPatch
currentPatch
=
JsonPatch
.
fromJson
(
arrayNode
);
if
(!
checkIfResultingAclHasDuplicates
(
recordMetadata
,
currentPatch
))
{
if
(!
hasDuplicateAcl
(
patchRecordMetadataWithJsonPatch
(
recordMetadata
,
currentPatch
)
.
getAcl
())
)
{
resultNode
.
add
(
currentNode
);
}
}
...
...
@@ -295,7 +294,7 @@ public class PatchRecordsServiceImpl implements PatchRecordsService {
return
false
;
}
private
boolean
chec
kIfResultingAclHasDuplicates
(
RecordMetadata
recordMetadata
,
JsonPatch
jsonPatch
)
{
private
RecordMetadata
pat
ch
R
ec
ordMetadataWithJsonPatch
(
RecordMetadata
recordMetadata
,
JsonPatch
jsonPatch
)
{
try
{
objectMapper
.
configure
(
DeserializationFeature
.
FAIL_ON_UNKNOWN_PROPERTIES
,
false
);
objectMapper
.
setVisibility
(
PropertyAccessor
.
GETTER
,
JsonAutoDetect
.
Visibility
.
NONE
);
...
...
@@ -303,23 +302,7 @@ public class PatchRecordsServiceImpl implements PatchRecordsService {
objectMapper
.
setVisibility
(
PropertyAccessor
.
FIELD
,
JsonAutoDetect
.
Visibility
.
ANY
);
JsonNode
patched
=
jsonPatch
.
apply
(
objectMapper
.
convertValue
(
recordMetadata
,
JsonNode
.
class
));
RecordMetadata
patchedRecordMetadata
=
objectMapper
.
treeToValue
(
patched
,
RecordMetadata
.
class
);
return
hasDuplicateAcl
(
patchedRecordMetadata
.
getAcl
());
}
catch
(
JsonPatchException
e
)
{
throw
new
AppException
(
HttpStatus
.
SC_BAD_REQUEST
,
"Bad input"
,
"JsonPatchException during patch operation"
);
}
catch
(
JsonProcessingException
e
)
{
throw
new
AppException
(
HttpStatus
.
SC_BAD_REQUEST
,
"Bad input"
,
"JsonProcessingException during patch operation"
);
}
}
private
boolean
checkIfResultingAclOrLegalTagsAreEmpty
(
RecordMetadata
recordMetadata
,
JsonPatch
jsonPatch
)
{
try
{
objectMapper
.
configure
(
DeserializationFeature
.
FAIL_ON_UNKNOWN_PROPERTIES
,
false
);
objectMapper
.
setVisibility
(
PropertyAccessor
.
GETTER
,
JsonAutoDetect
.
Visibility
.
NONE
);
objectMapper
.
setVisibility
(
PropertyAccessor
.
SETTER
,
JsonAutoDetect
.
Visibility
.
NONE
);
objectMapper
.
setVisibility
(
PropertyAccessor
.
FIELD
,
JsonAutoDetect
.
Visibility
.
ANY
);
JsonNode
patched
=
jsonPatch
.
apply
(
objectMapper
.
convertValue
(
recordMetadata
,
JsonNode
.
class
));
RecordMetadata
patchedRecordMetadata
=
objectMapper
.
treeToValue
(
patched
,
RecordMetadata
.
class
);
return
isEmptyAclOrLegal
(
patchedRecordMetadata
);
return
patchedRecordMetadata
;
}
catch
(
JsonPatchException
e
)
{
throw
new
AppException
(
HttpStatus
.
SC_BAD_REQUEST
,
"Bad input"
,
"JsonPatchException during patch operation"
);
}
catch
(
JsonProcessingException
e
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment