Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Register
Sign in
Toggle navigation
Menu
UPSMF
knowledge-platform
Commits
1c89c0a3
Unverified
Commit
1c89c0a3
authored
3 years ago
by
Anil Gupta
Committed by
GitHub
3 years ago
Browse files
Options
Download
Plain Diff
Issue #SB-28558 merge: Merge pull request #787 from Jayaprakash8887/SB22864
Issue #SB-28558 fix: key not found error
parents
4a9ee368
bc797a64
s-debug
AmiableAnil-patch-1
Gcloud_copy
Gcloud_fix
Remove_unwantedCode_Gcloud_fix
bulk-upload-comptenecy-mapping
bulk-upload-excelsheet
bulk-upload-test_excel
bulk_upload
csp-migration
dependabot/maven/platform-core/platform-telemetry/ch.qos.logback-logback-core-1.2.9
dependabot/maven/search-api/search-core/org.apache.httpcomponents-httpclient-4.5.13
knowlg-friday
knowlg-oneclick
local-setup-kube
master
patch-1
patch-2
patch-3
poc_bulk_upload
qs-schema
rahul_bulk_upload_postgres
release-4.10.0
release-4.10.1
release-4.7.0
release-4.7.0-debug
release-4.8.0
release-4.8.0-debug
release-4.9.0
release-4.9.1
release-5.0.0
release-5.0.1
release-5.1.0
release-5.1.0-content
release-5.2.0
release-5.3.0
release-5.2.0_RC2
release-5.2.0_RC1
release-5.1.0_RC1
release-5.0.0_RC2
release-5.0.0_RC1
release-4.10.0_RC2
release-4.10.0_RC1
release-4.9.1_RC1
release-4.9.0_RC8
release-4.9.0_RC7
release-4.9.0_RC6
release-4.9.0_RC5
release-4.9.0_RC4
release-4.9.0_RC3
release-4.9.0_RC2
release-4.9.0_RC1
release-4.8.0_RC5
release-4.8.0_RC4
release-4.8.0_RC3
release-4.8.0_RC2
release-4.8.0_RC1
release-4.7.0_RC6
release-4.7.0_RC5
release-4.7.0_RC4
release-4.7.0_RC3
release-4.7.0_RC2
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
content-api/hierarchy-manager/src/main/scala/org/sunbird/managers/HierarchyManager.scala
+26
-22
...rc/main/scala/org/sunbird/managers/HierarchyManager.scala
platform-modules/url-manager/src/test/java/org/sunbird/url/mgr/impl/GoogleDriveURLManagerImplTest.java
+3
-3
...g/sunbird/url/mgr/impl/GoogleDriveURLManagerImplTest.java
platform-modules/url-manager/src/test/java/org/sunbird/url/util/GoogleDriveUtilTest.java
+5
-5
...c/test/java/org/sunbird/url/util/GoogleDriveUtilTest.java
with
34 additions
and
30 deletions
+34
-30
content-api/hierarchy-manager/src/main/scala/org/sunbird/managers/HierarchyManager.scala
+
26
−
22
View file @
1c89c0a3
...
...
@@ -67,11 +67,11 @@ object HierarchyManager {
val
updateResponse
=
updateHierarchy
(
unitId
,
hierarchy
,
leafNodes
,
node
,
request
,
"add"
)
updateResponse
.
map
(
response
=>
{
if
(!
ResponseHandler
.
checkError
(
response
))
{
ResponseHandler
.
OK
.
put
(
"rootId"
,
node
.
getIdentifier
.
replaceAll
(
imgSuffix
,
""
))
.
put
(
unitId
,
request
.
get
(
"children"
))
ResponseHandler
.
OK
.
put
(
"rootId"
,
node
.
getIdentifier
.
replaceAll
(
imgSuffix
,
""
))
.
put
(
unitId
,
request
.
get
(
"children"
))
}
else
{
response
response
}
})
}).
flatMap
(
f
=>
f
)
...
...
@@ -331,31 +331,35 @@ object HierarchyManager {
fetchRelationalMetadata
(
request
,
rootNode
.
getIdentifier
).
map
(
collRelationalMetadata
=>
{
val
children
=
hierarchy
.
get
(
"children"
).
asInstanceOf
[
java.util.List
[
java.util.Map
[
String
,
AnyRef
]]]
val
leafNodeIds
=
request
.
get
(
"children"
).
asInstanceOf
[
java.util.List
[
String
]]
val
unitsHierarchyMetadata
=
collRelationalMetadata
(
unitId
).
asInstanceOf
[
java.util.Map
[
String
,
AnyRef
]]
val
unitsHierarchyMetadata
=
if
(
collRelationalMetadata
.
contains
(
unitId
))
collRelationalMetadata
(
unitId
).
asInstanceOf
[
java.util.Map
[
String
,
AnyRef
]]
else
new
java
.
util
.
HashMap
[
String
,
AnyRef
]()
if
(
"add"
.
equalsIgnoreCase
(
operation
))
{
val
leafNodesMap
:
java.util.List
[
java.util.Map
[
String
,
AnyRef
]]
=
convertNodeToMap
(
leafNodes
)
addChildrenToUnit
(
children
,
unitId
,
leafNodesMap
,
leafNodeIds
,
request
)
//add relationalMetadata for unit
unitsHierarchyMetadata
.
get
(
"children"
).
asInstanceOf
[
java.util.List
[
String
]].
addAll
(
leafNodeIds
)
if
(
request
.
get
(
"relationalMetadata"
)
!=
null
)
{
val
rmSchemaValidator
=
SchemaValidatorFactory
.
getInstance
(
HierarchyConstants
.
RELATIONAL_METADATA
.
toLowerCase
(),
"1.0"
)
val
requestRM
=
request
.
get
(
"relationalMetadata"
).
asInstanceOf
[
java.util.Map
[
String
,
AnyRef
]]
requestRM
.
foreach
(
rmChild
=>{
rmSchemaValidator
.
validate
(
rmChild
.
_2
.
asInstanceOf
[
Map
[
String
,
AnyRef
]])
})
if
(
unitsHierarchyMetadata
.
containsKey
(
"relationalMetadata"
))
{
unitsHierarchyMetadata
.
get
(
"relationalMetadata"
).
asInstanceOf
[
java.util.Map
[
String
,
AnyRef
]].
putAll
(
requestRM
)
}
else
{
unitsHierarchyMetadata
.
put
(
"relationalMetadata"
,
requestRM
)
if
(
collRelationalMetadata
.
nonEmpty
&&
unitsHierarchyMetadata
.
nonEmpty
)
{
unitsHierarchyMetadata
.
get
(
"children"
).
asInstanceOf
[
java.util.List
[
String
]].
addAll
(
leafNodeIds
)
if
(
request
.
get
(
"relationalMetadata"
)
!=
null
)
{
val
rmSchemaValidator
=
SchemaValidatorFactory
.
getInstance
(
HierarchyConstants
.
RELATIONAL_METADATA
.
toLowerCase
(),
"1.0"
)
val
requestRM
=
request
.
get
(
"relationalMetadata"
).
asInstanceOf
[
java.util.Map
[
String
,
AnyRef
]]
requestRM
.
foreach
(
rmChild
=>
{
rmSchemaValidator
.
validate
(
rmChild
.
_2
.
asInstanceOf
[
Map
[
String
,
AnyRef
]])
})
if
(
unitsHierarchyMetadata
.
containsKey
(
"relationalMetadata"
))
{
unitsHierarchyMetadata
.
get
(
"relationalMetadata"
).
asInstanceOf
[
java.util.Map
[
String
,
AnyRef
]].
putAll
(
requestRM
)
}
else
{
unitsHierarchyMetadata
.
put
(
"relationalMetadata"
,
requestRM
)
}
}
}
}
if
(
"remove"
.
equalsIgnoreCase
(
operation
))
{
removeChildrenFromUnit
(
children
,
unitId
,
leafNodeIds
)
//remove relationalMetadata for unit
unitsHierarchyMetadata
.
get
(
"children"
).
asInstanceOf
[
java.util.List
[
String
]].
removeAll
(
leafNodeIds
)
leafNodeIds
.
foreach
(
rec
=>
unitsHierarchyMetadata
.
get
(
"relationalMetadata"
).
asInstanceOf
[
java.util.Map
[
String
,
AnyRef
]].
remove
(
rec
))
if
(
unitsHierarchyMetadata
.
get
(
"relationalMetadata"
).
asInstanceOf
[
java.util.Map
[
String
,
AnyRef
]].
size
()==
0
)
unitsHierarchyMetadata
.
remove
(
"relationalMetadata"
)
if
(
collRelationalMetadata
.
nonEmpty
&&
unitsHierarchyMetadata
.
nonEmpty
)
{
unitsHierarchyMetadata
.
get
(
"children"
).
asInstanceOf
[
java.util.List
[
String
]].
removeAll
(
leafNodeIds
)
leafNodeIds
.
foreach
(
rec
=>
unitsHierarchyMetadata
.
get
(
"relationalMetadata"
).
asInstanceOf
[
java.util.Map
[
String
,
AnyRef
]].
remove
(
rec
))
if
(
unitsHierarchyMetadata
.
get
(
"relationalMetadata"
).
asInstanceOf
[
java.util.Map
[
String
,
AnyRef
]].
size
()
==
0
)
unitsHierarchyMetadata
.
remove
(
"relationalMetadata"
)
}
}
val
rootId
=
rootNode
.
getIdentifier
.
replaceAll
(
imgSuffix
,
""
)
val
updatedHierarchy
=
new
java
.
util
.
HashMap
[
String
,
AnyRef
]()
...
...
@@ -386,9 +390,9 @@ object HierarchyManager {
if
(
null
!=
childList
&&
!
childList
.
isEmpty
)
{
val
childMap
:
Map
[
String
,
java.util.Map
[
String
,
AnyRef
]]
=
childList
.
toList
.
map
(
f
=>
f
.
get
(
"identifier"
).
asInstanceOf
[
String
]
->
f
).
toMap
val
existingLeafNodes
=
childMap
.
filter
(
p
=>
leafNodeIds
.
contains
(
p
.
_1
))
existingLeafNodes
.
map
(
en
=>
{
leafNodeMap
.
get
(
en
.
_1
).
put
(
"index"
,
en
.
_2
.
get
(
"index"
).
asInstanceOf
[
Integer
])
})
existingLeafNodes
.
map
(
en
=>
{
leafNodeMap
.
get
(
en
.
_1
).
put
(
"index"
,
en
.
_2
.
get
(
"index"
).
asInstanceOf
[
Integer
])
})
filteredLeafNodes
=
bufferAsJavaList
(
childList
.
filter
(
existingLeafNode
=>
{
!
leafNodeIds
.
contains
(
existingLeafNode
.
get
(
"identifier"
).
asInstanceOf
[
String
])
}))
...
...
This diff is collapsed.
Click to expand it.
platform-modules/url-manager/src/test/java/org/sunbird/url/mgr/impl/GoogleDriveURLManagerImplTest.java
+
3
−
3
View file @
1c89c0a3
...
...
@@ -27,7 +27,7 @@ public class GoogleDriveURLManagerImplTest {
@Test
public
void
testValidateUrlWithValidUrlValidCriteria
()
{
String
driveUrl
=
"https://drive.google.com/file/d/1
az_AFAoRwu9cXlr1R5pO9fNhHexzJKXo
/view?usp=sharing"
;
String
driveUrl
=
"https://drive.google.com/file/d/1
ZUSXrODwNK52pzDJZ_fuNKK9lXBzxCsS
/view?usp=sharing"
;
Map
<
String
,
Object
>
result
=
gdMgr
.
validateURL
(
driveUrl
,
"size"
);
assertTrue
(
MapUtils
.
isNotEmpty
(
result
));
assertTrue
(
result
.
size
()
==
2
);
...
...
@@ -41,7 +41,7 @@ public class GoogleDriveURLManagerImplTest {
public
void
testValidateUrlWithValidUrlInvalidCriteria
()
{
exception
.
expect
(
ClientException
.
class
);
exception
.
expectMessage
(
"Please Provide Valid Criteria For Validation. Supported Criteria : [size]"
);
String
driveUrl
=
"https://drive.google.com/file/d/1
az_AFAoRwu9cXlr1R5pO9fNhHexzJKXo
/view?usp=sharing"
;
String
driveUrl
=
"https://drive.google.com/file/d/1
ZUSXrODwNK52pzDJZ_fuNKK9lXBzxCsS
/view?usp=sharing"
;
Map
<
String
,
Object
>
result
=
gdMgr
.
validateURL
(
driveUrl
,
"name"
);
}
...
...
@@ -56,7 +56,7 @@ public class GoogleDriveURLManagerImplTest {
@Test
public
void
testReadMetadataWithValidUrl
()
{
String
driveUrl
=
"https://drive.google.com/file/d/1
az_AFAoRwu9cXlr1R5pO9fNhHexzJKXo
/view?usp=sharing"
;
String
driveUrl
=
"https://drive.google.com/file/d/1
ZUSXrODwNK52pzDJZ_fuNKK9lXBzxCsS
/view?usp=sharing"
;
Map
<
String
,
Object
>
result
=
gdMgr
.
readMetadata
(
driveUrl
);
assertTrue
(
MapUtils
.
isNotEmpty
(
result
));
assertTrue
(
result
.
size
()
==
3
);
...
...
This diff is collapsed.
Click to expand it.
platform-modules/url-manager/src/test/java/org/sunbird/url/util/GoogleDriveUtilTest.java
+
5
−
5
View file @
1c89c0a3
...
...
@@ -29,9 +29,9 @@ public class GoogleDriveUtilTest {
@Test
public
void
testGetDriveUrlWithValidUrl
()
{
String
driveUrl
=
"https://drive.google.com/file/d/1
az_AFAoRwu9cXlr1R5pO9fNhHexzJKXo
/view?usp=sharing"
;
String
driveUrl
=
"https://drive.google.com/file/d/1
ZUSXrODwNK52pzDJZ_fuNKK9lXBzxCsS
/view?usp=sharing"
;
String
output
=
GoogleDriveUrlUtil
.
getDriveFileId
(
driveUrl
);
assertEquals
(
"1
az_AFAoRwu9cXlr1R5pO9fNhHexzJKXo
"
,
output
);
assertEquals
(
"1
ZUSXrODwNK52pzDJZ_fuNKK9lXBzxCsS
"
,
output
);
}
@Test
...
...
@@ -43,7 +43,7 @@ public class GoogleDriveUtilTest {
@Test
public
void
testGetDriveFileWithValidUrl
()
{
String
driveUrl
=
"https://drive.google.com/file/d/1
az_AFAoRwu9cXlr1R5pO9fNhHexzJKXo
/view?usp=sharing"
;
String
driveUrl
=
"https://drive.google.com/file/d/1
ZUSXrODwNK52pzDJZ_fuNKK9lXBzxCsS
/view?usp=sharing"
;
String
fileId
=
GoogleDriveUrlUtil
.
getDriveFileId
(
driveUrl
);
File
driveFile
=
GoogleDriveUrlUtil
.
getDriveFile
(
fileId
);
assertNotNull
(
driveFile
);
...
...
@@ -70,7 +70,7 @@ public class GoogleDriveUtilTest {
@Test
public
void
testGetMetadataWithValidUrl
()
{
String
driveUrl
=
"https://drive.google.com/file/d/1
az_AFAoRwu9cXlr1R5pO9fNhHexzJKXo
/view?usp=sharing"
;
String
driveUrl
=
"https://drive.google.com/file/d/1
ZUSXrODwNK52pzDJZ_fuNKK9lXBzxCsS
/view?usp=sharing"
;
Map
<
String
,
Object
>
result
=
GoogleDriveUrlUtil
.
getMetadata
(
driveUrl
);
assertTrue
(
MapUtils
.
isNotEmpty
(
result
));
assertTrue
(
result
.
size
()
==
3
);
...
...
@@ -92,7 +92,7 @@ public class GoogleDriveUtilTest {
@Test
public
void
testGetSizeWithValidUrl
()
{
String
driveUrl
=
"https://drive.google.com/file/d/1
az_AFAoRwu9cXlr1R5pO9fNhHexzJKXo
/view?usp=sharing"
;
String
driveUrl
=
"https://drive.google.com/file/d/1
ZUSXrODwNK52pzDJZ_fuNKK9lXBzxCsS
/view?usp=sharing"
;
Long
result
=
GoogleDriveUrlUtil
.
getSize
(
driveUrl
);
assertTrue
(
result
>
0
);
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
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
Menu
Explore
Projects
Groups
Topics
Snippets