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
UPHRH-lms-service
Commits
ce0a33d1
Unverified
Commit
ce0a33d1
authored
2 years ago
by
Reshmi V Nair
Committed by
GitHub
2 years ago
Browse files
Options
Download
Plain Diff
Merge pull request #506 from Sunbird-Lern/release-5.0.1
Release 5.0.1 changes applying on master.
parents
9e6e616b
70af98f4
master
bootcamp
helmchart
release-5.1.0
release-5.2.0
release-5.2.1
release-5.3.0
release-5.3.1
release-5.4.0
release-5.3.1_RC1
release-5.3.0_RC1
release-5.2.0_RC2
release-5.2.0_RC1
release-5.1.0_RC2
release-5.1.0_RC1
No related merge requests found
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
course-mw/course-actors-common/src/main/java/org/sunbird/learner/actors/certificate/service/CourseBatchCertificateActor.java
+6
-5
...tors/certificate/service/CourseBatchCertificateActor.java
course-mw/course-actors-common/src/main/java/org/sunbird/learner/actors/qrcodedownload/QRCodeDownloadManagementActor.java
+11
-4
.../actors/qrcodedownload/QRCodeDownloadManagementActor.java
course-mw/sunbird-util/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/JsonKey.java
+3
-0
...src/main/java/org/sunbird/common/models/util/JsonKey.java
course-mw/sunbird-util/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/util/CloudStorageUtil.java
+13
-0
...c/main/java/org/sunbird/common/util/CloudStorageUtil.java
course-mw/sunbird-util/sunbird-platform-core/common-util/src/main/resources/externalresource.properties
+4
-2
...ommon-util/src/main/resources/externalresource.properties
service/app/filters/ResponseFilter.scala
+9
-1
service/app/filters/ResponseFilter.scala
with
46 additions
and
12 deletions
+46
-12
course-mw/course-actors-common/src/main/java/org/sunbird/learner/actors/certificate/service/CourseBatchCertificateActor.java
+
6
−
5
View file @
ce0a33d1
...
...
@@ -18,14 +18,14 @@ import org.sunbird.common.models.util.TelemetryEnvKey;
import
org.sunbird.common.request.Request
;
import
org.sunbird.common.request.RequestContext
;
import
org.sunbird.common.responsecode.ResponseCode
;
import
org.sunbird.common.util.CloudStorageUtil
;
import
org.sunbird.learner.actors.coursebatch.dao.CourseBatchDao
;
import
org.sunbird.learner.actors.coursebatch.dao.impl.CourseBatchDaoImpl
;
import
org.sunbird.learner.constants.CourseJsonKey
;
import
org.sunbird.learner.util.CourseBatchUtil
;
import
org.sunbird.learner.util.Util
;
import
static
org
.
sunbird
.
common
.
models
.
util
.
JsonKey
.
CLOUD_STORE_BASE_PATH
;
import
static
org
.
sunbird
.
common
.
models
.
util
.
JsonKey
.
CLOUD_STORE_BASE_PATH_PLACEHOLDER
;
import
static
org
.
sunbird
.
common
.
models
.
util
.
JsonKey
.*;
import
static
org
.
sunbird
.
common
.
models
.
util
.
ProjectUtil
.
getConfigValue
;
public
class
CourseBatchCertificateActor
extends
BaseActor
{
...
...
@@ -123,6 +123,7 @@ public class CourseBatchCertificateActor extends BaseActor {
if
(
MapUtils
.
isNotEmpty
((
Map
<
String
,
Object
>)
template
.
get
(
CourseJsonKey
.
NOTIFY_TEMPLATE
)))
{
// We need to change stateImgUrl in notifyTemplate
Map
<
String
,
Object
>
notifyData
=
(
Map
<
String
,
Object
>)
template
.
get
(
CourseJsonKey
.
NOTIFY_TEMPLATE
);
//TODO cross check the data in environments and remove this check if not required
String
notifyTemplateUrl
=
getPlaceholderUrl
(
notifyData
,
JsonKey
.
stateImgUrl
);
notifyData
.
replace
(
JsonKey
.
stateImgUrl
,
notifyTemplateUrl
);
template
.
put
(
...
...
@@ -146,8 +147,8 @@ public class CourseBatchCertificateActor extends BaseActor {
if
(
MapUtils
.
isNotEmpty
(
templateDetails
)
&&
templateDetails
.
containsKey
(
key
))
{
// replace the actual cloud url with the template value
templateUrl
=
(
String
)
templateDetails
.
get
(
key
);
if
(
templateUrl
.
contains
(
getConfigValue
(
CLOUD_STOR
E_BASE_PATH
)))
templateUrl
=
templateUrl
.
replace
(
getConfigValue
(
CLOUD_STOR
E_BASE_PATH
),
getConfigValue
(
CLOUD_STORE_BASE_PATH_PLACEHOLDER
));
if
(
templateUrl
.
contains
(
CloudStorageUtil
.
getBaseUrl
()
+
"/"
+
getConfigValue
(
CONTENT_
CLOUD_STOR
AGE_CONTAINER
)))
templateUrl
=
templateUrl
.
replace
(
CloudStorageUtil
.
getBaseUrl
()+
"/"
+
getConfigValue
(
CONTENT_
CLOUD_STOR
AGE_CONTAINER
),
getConfigValue
(
CLOUD_STORE_BASE_PATH_PLACEHOLDER
));
}
return
templateUrl
;
}
...
...
@@ -196,7 +197,7 @@ public class CourseBatchCertificateActor extends BaseActor {
String
notifyTemplateData
=
(
String
)
template
.
get
(
CourseJsonKey
.
NOTIFY_TEMPLATE
);
//Modify the placeholder with the actual configured cloud base path as ES should have the actual cloud path
if
(
notifyTemplateData
.
contains
(
getConfigValue
(
CLOUD_STORE_BASE_PATH_PLACEHOLDER
)))
notifyTemplateData
=
notifyTemplateData
.
replace
(
getConfigValue
(
CLOUD_STORE_BASE_PATH_PLACEHOLDER
),
getConfigValue
(
CLOUD_STOR
E_BASE_PATH
));
notifyTemplateData
=
notifyTemplateData
.
replace
(
getConfigValue
(
CLOUD_STORE_BASE_PATH_PLACEHOLDER
),
CloudStorageUtil
.
getBaseUrl
()+
"/"
+
getConfigValue
(
CONTENT_
CLOUD_STOR
AGE_CONTAINER
));
template
.
put
(
CourseJsonKey
.
NOTIFY_TEMPLATE
,
mapper
.
readValue
(
notifyTemplateData
,
...
...
This diff is collapsed.
Click to expand it.
course-mw/course-actors-common/src/main/java/org/sunbird/learner/actors/qrcodedownload/QRCodeDownloadManagementActor.java
+
11
−
4
View file @
ce0a33d1
...
...
@@ -232,11 +232,10 @@ public class QRCodeDownloadManagementActor extends BaseActor {
if
(
null
!=
obj
&&
obj
instanceof
List
)
{
List
<
Map
<
String
,
Object
>>
listOfMap
=
(
List
<
Map
<
String
,
Object
>>)
obj
;
if
(
CollectionUtils
.
isNotEmpty
(
listOfMap
))
{
//
TODO Resolve it and store. Assuming dial code db will have the template url with data migration script
//
check if template url contains dail storage base path placeholder,if yes then append it with cname url and dial bucket name
String
templateUrl
=
(
String
)
listOfMap
.
get
(
0
).
get
(
"url"
);
//replace template url with the actual cloud url
if
(
templateUrl
.
contains
(
getConfigValue
(
CLOUD_STORE_BASE_PATH_PLACEHOLDER
)))
templateUrl
=
templateUrl
.
replace
(
getConfigValue
(
CLOUD_STORE_BASE_PATH_PLACEHOLDER
),
getConfigValue
(
CLOUD_STORE_BASE_PATH
));
String
dailStorageBasePathPlaceHolder
=
getConfigValue
(
DIAL_STORAGE_BASE_PATH_PLACEHOLDER
);
templateUrl
=
resolvePlaceholder
(
templateUrl
,
dailStorageBasePathPlaceHolder
,
getConfigValue
(
CLOUD_STORAGE_DIAL_BUCKET_NAME
));
return
templateUrl
;
}
}
...
...
@@ -244,6 +243,14 @@ public class QRCodeDownloadManagementActor extends BaseActor {
return
""
;
}
private
String
resolvePlaceholder
(
String
templateUrl
,
String
placeHolder
,
String
containerName
)
{
if
(
templateUrl
.
contains
(
placeHolder
))
templateUrl
=
templateUrl
.
replace
(
placeHolder
,
CloudStorageUtil
.
getBaseUrl
()
+
"/"
+
containerName
);
return
templateUrl
;
}
/**
* Uploading the generated csv to aws
*
...
...
This diff is collapsed.
Click to expand it.
course-mw/sunbird-util/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/JsonKey.java
+
3
−
0
View file @
ce0a33d1
...
...
@@ -789,6 +789,9 @@ public final class JsonKey {
public
static
final
String
CLOUD_FOLDER_CONTENT
=
"sunbird_cloud_content_folder"
;
public
static
final
String
CLOUD_STORE_BASE_PATH
=
"cloud_storage_base_url"
;
public
static
final
String
CLOUD_STORAGE_CNAME_URL
=
"cloud_storage_cname_url"
;
public
static
final
String
CLOUD_STORAGE_DIAL_BUCKET_NAME
=
"cloud_storage_dial_bucketname"
;
public
static
final
String
DIAL_STORAGE_BASE_PATH_PLACEHOLDER
=
"cloud_storage_path_prefix_dial"
;
public
static
final
String
CLOUD_STORE_BASE_PATH_PLACEHOLDER
=
"cloud_store_base_path_placeholder"
;
public
static
final
String
TO_URL
=
"toUrl"
;
public
static
final
String
TTL
=
"ttl"
;
...
...
This diff is collapsed.
Click to expand it.
course-mw/sunbird-util/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/util/CloudStorageUtil.java
+
13
−
0
View file @
ce0a33d1
...
...
@@ -2,6 +2,8 @@ package org.sunbird.common.util;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.apache.commons.lang.StringUtils
;
import
org.sunbird.cloud.storage.BaseStorageService
;
import
org.sunbird.cloud.storage.factory.StorageConfig
;
import
org.sunbird.cloud.storage.factory.StorageServiceFactory
;
...
...
@@ -11,6 +13,10 @@ import org.sunbird.common.models.util.PropertiesCache;
import
scala.Option
;
import
scala.Some
;
import
static
org
.
sunbird
.
common
.
models
.
util
.
JsonKey
.
CLOUD_STORAGE_CNAME_URL
;
import
static
org
.
sunbird
.
common
.
models
.
util
.
JsonKey
.
CLOUD_STORE_BASE_PATH
;
import
static
org
.
sunbird
.
common
.
models
.
util
.
ProjectUtil
.
getConfigValue
;
public
class
CloudStorageUtil
{
private
static
final
int
STORAGE_SERVICE_API_RETRY_COUNT
=
3
;
...
...
@@ -76,4 +82,11 @@ public class CloudStorageUtil {
BaseStorageService
storageService
=
getStorageService
(
storageType
);
return
storageService
.
getUri
(
container
,
prefix
,
Option
.
apply
(
isDirectory
));
}
public
static
String
getBaseUrl
()
{
String
baseUrl
=
getConfigValue
(
CLOUD_STORAGE_CNAME_URL
);
if
(
StringUtils
.
isEmpty
(
baseUrl
))
baseUrl
=
getConfigValue
(
CLOUD_STORE_BASE_PATH
);
return
baseUrl
;
}
}
This diff is collapsed.
Click to expand it.
course-mw/sunbird-util/sunbird-platform-core/common-util/src/main/resources/externalresource.properties
+
4
−
2
View file @
ce0a33d1
...
...
@@ -80,7 +80,7 @@ sunbird_otp_allowed_attempt=2
#Telemetry producer related info
telemetry_pdata_id
=
local.sunbird.learning.service
telemetry_pdata_pid
=
learning-service
telemetry_pdata_ver
=
5.0.
0
telemetry_pdata_ver
=
5.0.
1
#elastic search top n result count for telemetry
searchTopN
=
5
telemetry_queue_threshold_value
=
200
...
...
@@ -207,4 +207,6 @@ sunbird_msg_91_auth=
sunbird_api_mgr_base_url
=
https://dev.sunbirded.org/api
enrollment_list_size
=
1000
cloud_storage_base_url
=
https://sunbirddev.blob.core.windows.net
cloud_store_base_path_placeholder
=
$CLOUD_STORE_BASE_PATH
\ No newline at end of file
cloud_store_base_path_placeholder
=
CLOUD_BASE_PATH
cloud_storage_dial_bucketname
=
dial
cloud_storage_path_prefix_dial
=
DIAL_STORAGE_BASE_PATH
\ No newline at end of file
This diff is collapsed.
Click to expand it.
service/app/filters/ResponseFilter.scala
+
9
−
1
View file @
ce0a33d1
...
...
@@ -2,7 +2,9 @@ package filters
import
akka.stream.Materializer
import
akka.util.ByteString
import
org.apache.commons.lang.StringUtils
import
org.sunbird.common.models.util.JsonKey
import
org.sunbird.common.models.util.JsonKey.
{
CLOUD_STORAGE_CNAME_URL
,
CLOUD_STORE_BASE_PATH
,
CONTENT_CLOUD_STORAGE_CONTAINER
}
import
play.api.http.HttpEntity.Strict
import
play.api.mvc.
{
Filter
,
RequestHeader
,
Result
}
import
org.sunbird.common.models.util.ProjectUtil.getConfigValue
...
...
@@ -18,7 +20,7 @@ class ResponseFilter @Inject()(implicit val mat: Materializer, ec: ExecutionCon
if
(
null
!=
result
.
body
&&
!
result
.
body
.
isKnownEmpty
){
val
contentType
=
result
.
body
.
contentType
val
updatedBody
=
result
.
body
.
consumeData
.
map
{
x
=>
val
y
=
x
.
utf8String
.
replaceAll
(
getConfigValue
(
JsonKey
.
CLOUD_STORE_BASE_PATH_PLACEHOLDER
),
getConfigValue
(
JsonKey
.
CLOUD_STOR
E_BASE_PATH
))
val
y
=
x
.
utf8String
.
replaceAll
(
getConfigValue
(
JsonKey
.
CLOUD_STORE_BASE_PATH_PLACEHOLDER
),
getBaseUrl
+
"/"
+
getConfigValue
(
CONTENT_
CLOUD_STOR
AGE_CONTAINER
))
logger
.
info
(
"updated body: "
+
y
)
y
}
...
...
@@ -29,4 +31,10 @@ class ResponseFilter @Inject()(implicit val mat: Materializer, ec: ExecutionCon
Future
(
result
)
}
}
def
getBaseUrl
:
String
=
{
var
baseUrl
=
getConfigValue
(
CLOUD_STORAGE_CNAME_URL
)
if
(
StringUtils
.
isEmpty
(
baseUrl
))
baseUrl
=
getConfigValue
(
CLOUD_STORE_BASE_PATH
)
baseUrl
}
}
\ No newline at end of file
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