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
a74eac9d
Commit
a74eac9d
authored
5 years ago
by
Mahesh Kumar Gangula
Browse files
Options
Download
Patches
Plain Diff
Issue #000 feat: session apis mock.
parent
096fa86b
devcon-2020
No related merge requests found
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
learning-api/content-service/app/controllers/v3/SessionController.scala
+45
-0
...ontent-service/app/controllers/v3/SessionController.scala
learning-api/content-service/app/modules/ContentModule.scala
+2
-1
learning-api/content-service/app/modules/ContentModule.scala
learning-api/content-service/app/utils/ActorNames.scala
+1
-0
learning-api/content-service/app/utils/ActorNames.scala
learning-api/content-service/conf/routes
+4
-0
learning-api/content-service/conf/routes
learning-api/hierarchy-manager/src/main/scala/org/sunbird/managers/SessionManager.scala
+24
-0
.../src/main/scala/org/sunbird/managers/SessionManager.scala
learning-api/orchestrator/src/main/java/org/sunbird/actors/SessionActor.java
+35
-0
...trator/src/main/java/org/sunbird/actors/SessionActor.java
with
111 additions
and
1 deletion
+111
-1
learning-api/content-service/app/controllers/v3/SessionController.scala
0 → 100644
+
45
−
0
View file @
a74eac9d
package
controllers.v3
import
akka.actor.
{
ActorRef
,
ActorSystem
}
import
controllers.BaseController
import
javax.inject.
{
Inject
,
Named
}
import
play.api.mvc.ControllerComponents
import
utils.
{
ActorNames
,
ApiId
}
import
scala.concurrent.ExecutionContext
class
SessionController
@Inject
()(
@Named
(
ActorNames
.
SESSION_ACTOR
)
sessionActor
:
ActorRef
,
cc
:
ControllerComponents
,
actorSystem
:
ActorSystem
)(
implicit
exec
:
ExecutionContext
)
extends
BaseController
(
cc
)
{
val
objectType
=
"Content"
val
schemaName
:
String
=
"content"
val
version
=
"1.0"
def
add
()
=
Action
.
async
{
implicit
request
=>
val
headers
=
commonHeaders
()
val
body
=
requestBody
()
body
.
putAll
(
headers
)
val
contentRequest
=
getRequest
(
body
,
headers
,
"addSession"
)
setRequestContext
(
contentRequest
,
version
,
objectType
,
schemaName
)
getResult
(
ApiId
.
ADD_HIERARCHY
,
sessionActor
,
contentRequest
)
}
def
remove
()
=
Action
.
async
{
implicit
request
=>
val
headers
=
commonHeaders
()
val
body
=
requestBody
()
body
.
putAll
(
headers
)
val
contentRequest
=
getRequest
(
body
,
headers
,
"removeSession"
)
setRequestContext
(
contentRequest
,
version
,
objectType
,
schemaName
)
getResult
(
ApiId
.
REMOVE_HIERARCHY
,
sessionActor
,
contentRequest
)
}
def
update
(
identifier
:
String
)
=
Action
.
async
{
implicit
request
=>
val
headers
=
commonHeaders
()
val
body
=
requestBody
()
body
.
putAll
(
headers
)
val
contentRequest
=
getRequest
(
body
,
headers
,
"removeSession"
)
setRequestContext
(
contentRequest
,
version
,
objectType
,
schemaName
)
getResult
(
ApiId
.
REMOVE_HIERARCHY
,
sessionActor
,
contentRequest
)
}
}
This diff is collapsed.
Click to expand it.
learning-api/content-service/app/modules/ContentModule.scala
+
2
−
1
View file @
a74eac9d
...
...
@@ -2,7 +2,7 @@ package modules
import
com.google.inject.AbstractModule
import
org.sunbird.actors.
{
CollectionActor
,
ContentActor
,
HealthActor
,
LicenseActor
}
import
org.sunbird.actors.
{
CollectionActor
,
ContentActor
,
HealthActor
,
LicenseActor
,
SessionActor
}
import
play.libs.akka.AkkaGuiceSupport
import
utils.ActorNames
...
...
@@ -15,6 +15,7 @@ class ContentModule extends AbstractModule with AkkaGuiceSupport {
bindActor
(
classOf
[
ContentActor
],
ActorNames
.
CONTENT_ACTOR
)
bindActor
(
classOf
[
LicenseActor
],
ActorNames
.
LICENSE_ACTOR
)
bindActor
(
classOf
[
CollectionActor
],
ActorNames
.
COLLECTION_ACTOR
)
bindActor
(
classOf
[
SessionActor
],
ActorNames
.
SESSION_ACTOR
)
println
(
"Initialized application actors..."
)
// $COVERAGE-ON
}
...
...
This diff is collapsed.
Click to expand it.
learning-api/content-service/app/utils/ActorNames.scala
+
1
−
0
View file @
a74eac9d
...
...
@@ -6,5 +6,6 @@ object ActorNames {
final
val
CONTENT_ACTOR
=
"contentActor"
final
val
LICENSE_ACTOR
=
"licenseActor"
final
val
COLLECTION_ACTOR
=
"collectionActor"
final
val
SESSION_ACTOR
=
"SessionActor"
}
This diff is collapsed.
Click to expand it.
learning-api/content-service/conf/routes
+
4
−
0
View file @
a74eac9d
...
...
@@ -16,6 +16,10 @@ PATCH /license/v3/update/:identifier controllers.v3.LicenseController
DELETE /license/v3/retire/:identifier controllers.v3.LicenseController.retire(identifier: String)
POST /content/v3/session/add controllers.v3.SessionController.add
DELETE /content/v3/session/remove controllers.v3.SessionController.remove
PATCH /content/v3/session/update/:identifier controllers.v3.SessionController.update(identifier: String)
#Devcon-School
POST /teacher/v3/create controllers.v3.TeacherController.create
GET /teacher/v3/read/:identifier controllers.v3.TeacherController.read(identifier: String)
...
...
This diff is collapsed.
Click to expand it.
learning-api/hierarchy-manager/src/main/scala/org/sunbird/managers/SessionManager.scala
0 → 100644
+
24
−
0
View file @
a74eac9d
package
org.sunbird.managers
import
org.sunbird.common.dto.
{
Request
,
Response
,
ResponseHandler
}
import
scala.concurrent.
{
ExecutionContext
,
Future
}
object
SessionManager
{
val
schemaName
:
String
=
"collection"
val
schemaVersion
:
String
=
"1.0"
def
addSession
(
request
:
Request
)(
implicit
ec
:
ExecutionContext
)
:
Future
[
Response
]
=
{
Future
(
ResponseHandler
.
OK
())
}
def
removeSession
(
request
:
Request
)(
implicit
ec
:
ExecutionContext
)
:
Future
[
Response
]
=
{
Future
(
ResponseHandler
.
OK
())
}
def
updateSession
(
request
:
Request
)(
implicit
ec
:
ExecutionContext
)
:
Future
[
Response
]
=
{
Future
(
ResponseHandler
.
OK
())
}
}
This diff is collapsed.
Click to expand it.
learning-api/orchestrator/src/main/java/org/sunbird/actors/SessionActor.java
0 → 100644
+
35
−
0
View file @
a74eac9d
package
org.sunbird.actors
;
import
org.sunbird.actor.core.BaseActor
;
import
org.sunbird.common.dto.Request
;
import
org.sunbird.common.dto.Response
;
import
org.sunbird.managers.SessionManager
;
import
scala.concurrent.Future
;
public
class
SessionActor
extends
BaseActor
{
private
static
final
String
SCHEMA_NAME
=
"collection"
;
public
Future
<
Response
>
onReceive
(
Request
request
)
throws
Throwable
{
String
operation
=
request
.
getOperation
();
request
.
getContext
().
put
(
"schemaName"
,
SCHEMA_NAME
);
switch
(
operation
)
{
case
"addSession"
:
return
addSession
(
request
);
case
"updateSession"
:
return
updateSession
(
request
);
case
"removeSession"
:
return
removeSession
(
request
);
default
:
return
ERROR
(
operation
);
}
}
private
Future
<
Response
>
addSession
(
Request
request
)
{
return
SessionManager
.
addSession
(
request
,
getContext
().
getDispatcher
());
}
private
Future
<
Response
>
removeSession
(
Request
request
)
{
return
SessionManager
.
removeSession
(
request
,
getContext
().
getDispatcher
());
}
private
Future
<
Response
>
updateSession
(
Request
request
)
{
return
SessionManager
.
updateSession
(
request
,
getContext
().
getDispatcher
());
}
}
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