Commit 04977f27 authored by  Bruno Daniel Di Bello Baladan's avatar Bruno Daniel Di Bello Baladan
Browse files

Funcionando con moodlecloud

parent 0ee7d707
File added
......@@ -5,5 +5,6 @@
//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';
//export const SERVER = window.location.protocol + '//' + window.location.host;//'http://localhost:9090';
export const SERVER = 'http://localhost:8080';
export const GHCI_URL = window.location.protocol == 'http:'? 'ws://'+window.location.host+'/endpoint': 'wss://'+window.location.host+'/endpoint';
#Deben definirse moodle_endpoint y moodle_group para conectar con el API de moodle.
#De lo contrario solo se realizara login local.
moodle_endpoint=https://tics.moodlecloud.com
moodle_group=Piloto
moodle_endpoint=https://matefun.moodlecloud.com
moodle_group=introduction to moodle
#El grupo se define como liceoId#grado#grupo#anio
#Si no se sefine default_group entonces no se asigna grupo para docente o alumno.
default_group=0#2#Año#2017
......@@ -46,7 +46,11 @@
<artifactId>jackson-annotations</artifactId>
<version>2.9.0</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.42</version>
</dependency>
</dependencies>
<build>
......
......@@ -21,7 +21,7 @@ public class MoodleCoursesInfoDTO {
private Boolean confirmed;
private String lang;
private String theme;
private Long timezone;
private String timezone;
private Long mailformat;
private String description;
private Long descriptionformat;
......@@ -118,10 +118,10 @@ public class MoodleCoursesInfoDTO {
public void setTheme(String theme) {
this.theme = theme;
}
public Long getTimezone() {
public String getTimezone() {
return timezone;
}
public void setTimezone(Long timezone) {
public void setTimezone(String timezone) {
this.timezone = timezone;
}
public Long getMailformat() {
......
......@@ -15,13 +15,17 @@ import java.util.Date;
import java.util.List;
import java.util.Properties;
import javax.annotation.Resource;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.ejb.TransactionManagement;
import javax.ejb.TransactionManagementType;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
import javax.servlet.ServletContext;
import javax.transaction.UserTransaction;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.GenericType;
......@@ -50,6 +54,7 @@ import edu.proygrado.modelo.Usuario;
* @author gonzalo
*/
@Stateless
@TransactionManagement(value=TransactionManagementType.BEAN)
public class LoginEJB {
@Inject
......@@ -63,6 +68,9 @@ public class LoginEJB {
@EJB
private InvitadoEJB invitadoEJB;
@Resource
private UserTransaction userTransaction;
public boolean validarSesion(String token){
Sesion sesion = em.find(Sesion.class,token);
......@@ -80,7 +88,14 @@ public class LoginEJB {
sesion.setToken(token);
sesion.setUsuario(usuario);
sesion.setTimestamp(new Date());
em.persist(sesion);
try {
userTransaction.begin();
em.persist(sesion);
userTransaction.commit();
}catch(Exception e) {
System.out.println("Error persistiendo sesion: "+e.getMessage());
}
}else{
sesion.setTimestamp(new Date());
}
......@@ -222,9 +237,15 @@ public class LoginEJB {
conf.setFontSizeEditor(12);
conf.setThemeEditor("dracula");
nuevoDesdeMoodle.setConfiguracion(conf);
em.persist(conf);
em.persist(root);
em.persist(nuevoDesdeMoodle);
try {
userTransaction.begin();
em.persist(conf);
em.persist(root);
em.persist(nuevoDesdeMoodle);
userTransaction.commit();
}catch(Exception e) {
System.out.println("Error guardando configuracion de usuario");
}
String tokenAuth = generateToken();
updateSession(tokenAuth, usuario);
invitadoEJB.setUsuario(tokenAuth, nuevoDesdeMoodle);
......
......@@ -25,7 +25,7 @@
<persistence-unit name="matefunDS" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/azureDSjta</jta-data-source>
<jta-data-source>java:/matefun</jta-data-source>
<class>edu.proygrado.modelo.Alumno</class>
<class>edu.proygrado.modelo.Archivo</class>
<class>edu.proygrado.modelo.Configuracion</class>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment