Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
matefun
Frontend
Commits
13280cfb
Commit
13280cfb
authored
Nov 04, 2017
by
Martín
Browse files
Archivo de configuración para ENDPOINT de Moodle y nombre del grupo asociado.
parent
46f097c5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Frontend Angular 4/src/app/shared/config.ts
View file @
13280cfb
//
export const SERVER = 'https://matefun.mybluemix.net';
//
export const GHCI_URL = 'wss://matefun.mybluemix.net/endpoint';
export
const
SERVER
=
'
https://matefun.mybluemix.net
'
;
export
const
GHCI_URL
=
'
wss://matefun.mybluemix.net/endpoint
'
;
export
const
SERVER
=
'
http://localhost:9090
'
;
export
const
GHCI_URL
=
'
ws://localhost:9090/endpoint
'
;
//
export const SERVER = 'http://localhost:9090';
//
export const GHCI_URL = 'ws://localhost:9090/endpoint';
//Configuracion dinamica pensando en servidor con ip dinamica
//export const SERVER = window.location.protocol + '//' + window.location.host;//'http://localhost:9090';
...
...
Servidor JEE/WebContent/WEB-INF/config.json
0 → 100644
View file @
13280cfb
{
"endpoint"
:
"https://tics.moodlecloud.com"
,
"group"
:
"Piloto"
}
\ No newline at end of file
Servidor JEE/WebContent/WEB-INF/lib/json-simple-1.1.1.jar
0 → 100644
View file @
13280cfb
File added
Servidor JEE/src/main/java/edu/proygrado/ejb/LoginEJB.java
View file @
13280cfb
...
...
@@ -48,7 +48,25 @@ import edu.proygrado.modelo.Usuario;
*/
@Stateless
public
class
LoginEJB
{
public
static
String
moodleApiEndpoint
=
null
;
public
static
String
moodleGroup
=
null
;
public
LoginEJB
()
{
super
();
//leo archivo de configuración.
JSONParser
parser
=
new
JSONParser
();
try
{
String
currentPath
=
System
.
getProperty
(
"user.dir"
);
String
configFilePath
=
currentPath
.
substring
(
0
,
currentPath
.
length
()-
4
);
configFilePath
=
configFilePath
+
"/standalone/deployments/matefun.war/WEB-INF/config.json"
;
Object
obj
=
parser
.
parse
(
new
FileReader
(
configFilePath
));
JSONObject
jsonObject
=
(
JSONObject
)
obj
;
LoginEJB
.
moodleApiEndpoint
=
(
String
)
jsonObject
.
get
(
"endpoint"
);
LoginEJB
.
moodleGroup
=
(
String
)
jsonObject
.
get
(
"group"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
System
.
out
.
print
(
"No se ha podido cargar el archivo: /standalone/deployments/matefun.war/WEB-INF/config.json"
);
}
}
@PersistenceContext
(
unitName
=
"matefunDS"
)
private
EntityManager
em
;
...
...
@@ -98,7 +116,8 @@ public class LoginEJB {
Long
courseId
=
null
;
for
(
MoodleCourseDTO
course
:
coursesInfo
.
getEnrolledcourses
())
{
System
.
out
.
println
(
course
.
getShortname
());
if
(
course
.
getShortname
().
toLowerCase
().
equals
(
"piloto"
))
{
String
groupName
=
LoginEJB
.
moodleGroup
.
toLowerCase
();
if
(
course
.
getShortname
().
toLowerCase
().
equals
(
groupName
))
{
courseId
=
course
.
getId
();
System
.
out
.
println
(
courseId
);
}
...
...
@@ -106,7 +125,7 @@ public class LoginEJB {
if
(
courseId
!=
null
)
{
coursesInfo
=
getCursesInfo
(
token
,
userInfo
.
getUserid
(),
courseId
);
}
else
{
throw
new
MatefunForbiddenException
(
"Usuario no asignado al curso \"
Piloto
\" en Moodle"
);
throw
new
MatefunForbiddenException
(
"Usuario no asignado al curso \"
"
+
LoginEJB
.
moodleGroup
+
"
\" en Moodle"
);
}
String
rol
=
null
;
...
...
@@ -121,7 +140,7 @@ public class LoginEJB {
}
if
(
rol
==
null
)
{
throw
new
MatefunForbiddenException
(
"Rol incorrecto en curso \"
Piloto
\""
);
throw
new
MatefunForbiddenException
(
"Rol incorrecto en curso \"
"
+
LoginEJB
.
moodleGroup
+
"
\""
);
}
Usuario
nuevoDesdeMoodle
;
...
...
@@ -180,7 +199,7 @@ public class LoginEJB {
javax
.
ws
.
rs
.
client
.
Client
c
=
cb
.
build
();
String
url
=
"https://tics.moodlecloud.com
/login/token.php"
;
String
url
=
LoginEJB
.
moodleApiEndpoint
+
"
/login/token.php"
;
MoodleTokensDTO
tokens
=
null
;
try
{
// https://tics.moodlecloud.com/login/token.php
...
...
@@ -206,8 +225,7 @@ public class LoginEJB {
javax
.
ws
.
rs
.
client
.
ClientBuilder
cb
=
ClientBuilder
.
newBuilder
();
javax
.
ws
.
rs
.
client
.
Client
c
=
cb
.
build
();
String
url
=
"https://tics.moodlecloud.com/webservice/rest/server.php"
;
String
url
=
LoginEJB
.
moodleApiEndpoint
+
"/webservice/rest/server.php"
;
MoodleUserInfoDTO
userInfo
=
null
;
try
{
...
...
@@ -234,7 +252,7 @@ public class LoginEJB {
private
MoodleCoursesInfoDTO
getCursesInfo
(
String
token
,
Long
userId
,
Long
courseId
)
throws
MatefunException
{
javax
.
ws
.
rs
.
client
.
ClientBuilder
cb
=
ClientBuilder
.
newBuilder
();
javax
.
ws
.
rs
.
client
.
Client
c
=
cb
.
build
();
String
url
=
"https://tics.moodlecloud.com
/webservice/rest/server.php"
;
String
url
=
LoginEJB
.
moodleApiEndpoint
+
"
/webservice/rest/server.php"
;
List
<
MoodleCoursesInfoDTO
>
coursesInfo
=
null
;
try
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment