1: Permanently Removed deprecated "getUserByUsername" methods.
2: Lookups and Json response handlers now use Autowiring instead of xml-boilerplate 3: Some minor refactoring in the response handlers, lots more to come
This commit is contained in:
parent
bed74f671a
commit
ec9691ecd3
src/main
java/se/su/dsv/scipro
data/dao
json
DefaultUserLookupBase.javaILookup.javaImportUpdateStatsResponseHandler.javaImportWorkerLookup.javaImportWorkerResponseHandler.javaJsonResponseHandler.javaJsonUserFullResponseHandler.javaJsonUserResponseHandler.java
workerthreads
resources
@ -3,14 +3,6 @@ package se.su.dsv.scipro.data.dao.interfaces;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceException;
|
||||
import javax.persistence.TypedQuery;
|
||||
|
||||
import org.hibernate.ejb.QueryHints;
|
||||
import org.springframework.orm.jpa.JpaCallback;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import se.su.dsv.scipro.data.dataobjects.DomainObject;
|
||||
/**
|
||||
* @author Richard Wilkinson - richard.wilkinson@jweekend.com
|
||||
|
@ -9,8 +9,6 @@ public interface UserDao extends LazyDeleteDao<User> {
|
||||
|
||||
User getUserByIdentifier(Long identifier);
|
||||
|
||||
User getUserByUsername(String userName);
|
||||
|
||||
User getUserByUsername(String userName, String realm);
|
||||
|
||||
User getUserByEmail(String emailAddress);
|
||||
|
@ -62,12 +62,6 @@ public class UserDaoJPAImp extends LazyDeleteAbstractDaoJPAImp<User> implements
|
||||
});
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Deprecated
|
||||
public User getUserByUsername(final String username) {
|
||||
return this.getUserByUsername(username, "DSV.SU.SE");
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public User getUserByUsername(final String username, final String realm) {
|
||||
return getJpaTemplate().execute(new JpaCallback<User>() {
|
||||
|
@ -10,6 +10,7 @@ import se.su.dsv.scipro.data.dao.interfaces.UserDao;
|
||||
|
||||
/**
|
||||
* Package-private Abstract base for the public UserLookups.
|
||||
* This is not an ideal pattern under most circumstances, but class is package private and thus not part of exported API.
|
||||
*/
|
||||
abstract class DefaultUserLookupBase{
|
||||
@Autowired
|
||||
|
@ -3,7 +3,7 @@ package se.su.dsv.scipro.json;
|
||||
/**
|
||||
* Generic interface for Remote lookups.
|
||||
* The recommended way of using this interface is to create specializations
|
||||
* (see IUserLookupFromIdentifier) that defines the actual parameterized types used, and implement those interfaces in concrete classes.
|
||||
* (see IUserLookupFromIdentifier for an example) that defines the actual parameterized types used, and implement those interfaces in concrete classes.
|
||||
* @param <T> The return type specifier, implementations are urged to return a null value when a lookup fails.
|
||||
* @param <E> The lookup parameter, use compound types to support querying on multiple parameters.
|
||||
*/
|
||||
|
@ -3,6 +3,7 @@ package se.su.dsv.scipro.json;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import org.apache.log4j.Level;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import se.su.dsv.scipro.jsonobjects.JsonUpdateStatsContainer;
|
||||
import se.su.dsv.scipro.workerthreads.UserAndProjectImportWorker;
|
||||
@ -13,19 +14,9 @@ import com.google.gson.reflect.TypeToken;
|
||||
/**
|
||||
* Handler for json responses regarding users (creating and updating)
|
||||
*
|
||||
* @author Dan Kjellman <dan-kjel@dsv.su.se>
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
public class ImportUpdateStatsResponseHandler extends JsonResponseHandler {
|
||||
|
||||
private boolean logResult = false;
|
||||
|
||||
|
||||
|
||||
public ImportUpdateStatsResponseHandler(){
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles a json string
|
||||
*
|
||||
@ -49,26 +40,5 @@ public class ImportUpdateStatsResponseHandler extends JsonResponseHandler {
|
||||
UserAndProjectImportWorker.updatedUsers = statsContainer.updatedUsers.intValue();
|
||||
UserAndProjectImportWorker.updatedTheses = statsContainer.updatedTheses.intValue();
|
||||
}
|
||||
/*
|
||||
if(logResult){
|
||||
logger.log(Level.INFO, "\nResult from userimport/update:\nChecked: " + completeContainer.theses.size() + " users\n" +
|
||||
"Changed users: " + changedUsers + "\n" +
|
||||
"Created users: " + createdUsers + "\n" +
|
||||
"Number of errors when creating users: " + userCreationErrors + "\n" +
|
||||
"Num First name changes: " + getNumFirstNameChanges() + "\n" +
|
||||
"Num last name changes: " + getNumLastNameChanges() + "\n" +
|
||||
"Num Email changes: " + getNumEmailChanges() + "\n" +
|
||||
"Num Usernames added: " + getNumUsernamesAdded() + "\n" +
|
||||
"Num Supervisors created: " + getNumFirstNameChanges() + "\n");
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public void setLogResult(boolean logResult) {
|
||||
this.logResult = logResult;
|
||||
}
|
||||
|
||||
public boolean isLogResult() {
|
||||
return logResult;
|
||||
}
|
||||
}
|
||||
|
@ -6,11 +6,10 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import se.su.dsv.scipro.ApplicationSettings;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This class does a lookup on a username against the remote remoteLookupUrl specified in
|
||||
* the applicationContext, under ApplicationSettings.
|
||||
@ -18,16 +17,14 @@ import se.su.dsv.scipro.ApplicationSettings;
|
||||
*
|
||||
* @author Dan Kjellman <dan-kjel@dsv.su.se>
|
||||
*/
|
||||
@Component
|
||||
public class ImportWorkerLookup {
|
||||
|
||||
public static final String USERS = "users";
|
||||
public static final String THESES = "theses";
|
||||
/*
|
||||
* References populated by spring (from applicationContext)
|
||||
*/
|
||||
private ImportWorkerResponseHandler thesesResponseHandler;
|
||||
private ImportUpdateStatsResponseHandler statsResonseHandler;
|
||||
|
||||
@Autowired
|
||||
private ImportWorkerResponseHandler importWorkerResponseHandler;
|
||||
@Autowired
|
||||
private ImportUpdateStatsResponseHandler importUpdateStatsResponseHandler;
|
||||
@Autowired
|
||||
private ApplicationSettings applicationSettings;
|
||||
|
||||
@ -55,7 +52,7 @@ public class ImportWorkerLookup {
|
||||
}else{
|
||||
//logger.log(Level.INFO,"Starting lookup for completeGet=true & type="+type+" & updatedAfter=" + updatedAfter);
|
||||
}
|
||||
RequestSender request = new RequestSender(thesesResponseHandler, applicationSettings.getRemoteLookupUrl(), params, RequestSender.REQUEST_TYPE_POST);
|
||||
RequestSender request = new RequestSender(importWorkerResponseHandler, applicationSettings.getRemoteLookupUrl(), params, RequestSender.REQUEST_TYPE_POST);
|
||||
try{
|
||||
request.processRequest();
|
||||
} catch (IOException e) {
|
||||
@ -69,7 +66,7 @@ public class ImportWorkerLookup {
|
||||
params.put("updateStats", "true");
|
||||
params.put("updatedAfter",""+updatedAfter.getTime());
|
||||
|
||||
RequestSender request = new RequestSender(statsResonseHandler, applicationSettings.getRemoteLookupUrl(), params, RequestSender.REQUEST_TYPE_POST);
|
||||
RequestSender request = new RequestSender(importUpdateStatsResponseHandler, applicationSettings.getRemoteLookupUrl(), params, RequestSender.REQUEST_TYPE_POST);
|
||||
try{
|
||||
request.processRequest();
|
||||
} catch (IOException e) {
|
||||
@ -77,22 +74,4 @@ public class ImportWorkerLookup {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Getters and setters (for spring)
|
||||
*/
|
||||
public ImportWorkerResponseHandler getUserResponseHandler() {
|
||||
return thesesResponseHandler;
|
||||
}
|
||||
public void setUserResponseHandler(ImportWorkerResponseHandler thesesResponseHandler) {
|
||||
this.thesesResponseHandler = thesesResponseHandler;
|
||||
}
|
||||
|
||||
public ImportUpdateStatsResponseHandler getStatsResonseHandler() {
|
||||
return statsResonseHandler;
|
||||
}
|
||||
public void setStatsResonseHandler(
|
||||
ImportUpdateStatsResponseHandler statsResonseHandler) {
|
||||
this.statsResonseHandler = statsResonseHandler;
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package se.su.dsv.scipro.json;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import org.apache.log4j.Level;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import se.su.dsv.scipro.data.dataobjects.Project;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
@ -21,16 +22,8 @@ import com.google.gson.reflect.TypeToken;
|
||||
* @author Dan Kjellman <dan-kjel@dsv.su.se>
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
public class ImportWorkerResponseHandler extends JsonResponseHandler {
|
||||
|
||||
private boolean logResult = false;
|
||||
|
||||
|
||||
|
||||
public ImportWorkerResponseHandler(){
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles a json string
|
||||
*
|
||||
@ -129,7 +122,7 @@ public class ImportWorkerResponseHandler extends JsonResponseHandler {
|
||||
}
|
||||
}
|
||||
|
||||
if(logResult){
|
||||
if(isLogResult()){
|
||||
logger.log(Level.INFO, "\nResult from userimport/update:\nChecked: " + completeContainer.users.size() + " users\n" +
|
||||
"Changed users: " + changedUsers + "\n" +
|
||||
"Created users: " + createdUsers + "\n" +
|
||||
@ -147,12 +140,4 @@ public class ImportWorkerResponseHandler extends JsonResponseHandler {
|
||||
"Number of errors when creating theses: " + thesesCreationsErrors + "\n" );
|
||||
}
|
||||
}
|
||||
|
||||
public void setLogResult(boolean logResult) {
|
||||
this.logResult = logResult;
|
||||
}
|
||||
|
||||
public boolean isLogResult() {
|
||||
return logResult;
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import java.util.TreeSet;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
|
||||
import se.su.dsv.scipro.ApplicationSettings;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.ProjectClassDao;
|
||||
@ -30,9 +30,11 @@ import se.su.dsv.scipro.jsonobjects.JsonThesisParticipant;
|
||||
import se.su.dsv.scipro.jsonobjects.JsonUser;
|
||||
import se.su.dsv.scipro.jsonobjects.JsonUserRole;
|
||||
import se.su.dsv.scipro.jsonobjects.JsonUsername;
|
||||
|
||||
@Component
|
||||
public abstract class JsonResponseHandler implements IResponseHandler {
|
||||
/**
|
||||
* Package-private sase class for JsonResponseHandlers.
|
||||
* Contains a number of utility methods to lessen boilerplate code inside implementations.
|
||||
*/
|
||||
abstract class JsonResponseHandler implements IResponseHandler {
|
||||
@Autowired
|
||||
protected UserDao userDao;
|
||||
@Autowired
|
||||
@ -50,7 +52,7 @@ public abstract class JsonResponseHandler implements IResponseHandler {
|
||||
@Autowired
|
||||
protected ApplicationSettings applicationSettings;
|
||||
|
||||
protected Logger logger = Logger.getLogger(this.getClass());
|
||||
protected Logger logger = Logger.getLogger(JsonResponseHandler.class);
|
||||
|
||||
private int numUsersCreated = 0;
|
||||
private int numEmailChanges = 0;
|
||||
@ -60,72 +62,65 @@ public abstract class JsonResponseHandler implements IResponseHandler {
|
||||
private int numSupervisorsCreated = 0;
|
||||
private int numThesesCreated = 0;
|
||||
private int numThesesChanged = 0;
|
||||
|
||||
private boolean logResult = false;
|
||||
|
||||
/**
|
||||
* Creates a thesis user from a json user
|
||||
*
|
||||
* @param jsonUser the json user to use for creation
|
||||
* @return User the create thesisuser
|
||||
* Creates and persists a User from a JsonUser
|
||||
* @param jsonUser the JsonUser to use for creation
|
||||
* @return The created User or null if it cannot be persisted.
|
||||
*/
|
||||
protected User createThesisUser(JsonUser jsonUser, boolean doFullCheck){
|
||||
User thesisUser = null;
|
||||
|
||||
try {
|
||||
thesisUser = new User();
|
||||
thesisUser.setFirstName(jsonUser.firstName);
|
||||
thesisUser.setLastName(jsonUser.lastName);
|
||||
thesisUser.setIdentifier(jsonUser.id);
|
||||
thesisUser.setEmailAddress(jsonUser.email);
|
||||
|
||||
//System.out.println("Trying to save " + thesisUser.getIdentifier());
|
||||
thesisUser = userDao.save(thesisUser);
|
||||
|
||||
User user = new User();
|
||||
user.setFirstName(jsonUser.firstName);
|
||||
user.setLastName(jsonUser.lastName);
|
||||
user.setIdentifier(jsonUser.id);
|
||||
user.setEmailAddress(jsonUser.email);
|
||||
try{
|
||||
user = userDao.save(user);
|
||||
}catch(final DataAccessException dae){
|
||||
logger.error("Cannot save User with jsonuserid: " + jsonUser.id);
|
||||
return null;
|
||||
}
|
||||
/*
|
||||
* Check against daisy if the user is a supervisor - if so, create a supervisor role
|
||||
* Check against remote system data if the user is a supervisor - if so, create a supervisor role
|
||||
*/
|
||||
for(JsonUserRole jur : jsonUser.roles){
|
||||
if(jur.role.equals("AUTHOR")){
|
||||
roleDao.makeStudent(thesisUser);
|
||||
roleDao.makeStudent(user);
|
||||
}
|
||||
if(jur.role.equals("SUPERVISOR")){
|
||||
roleDao.makeEmployee(thesisUser);
|
||||
roleDao.makeEmployee(user);
|
||||
}
|
||||
if(jur.role.equals("ADMIN")){
|
||||
// roleDao.makeAdmin(thesisUser);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Create and set the user's usernames
|
||||
*/
|
||||
for(JsonUsername jsonUsername : jsonUser.usernames){
|
||||
Username thesisUserName = new Username();
|
||||
thesisUserName.setUserName(jsonUsername.username.toLowerCase().trim());
|
||||
thesisUserName.setRealm(jsonUsername.realm.toUpperCase().trim());
|
||||
thesisUserName.setUser(thesisUser);
|
||||
thesisUserName = userNameDao.save(thesisUserName);
|
||||
Username userName = new Username();
|
||||
userName.setUserName(jsonUsername.username.toLowerCase().trim());
|
||||
userName.setRealm(jsonUsername.realm.toUpperCase().trim());
|
||||
userName.setUser(user);
|
||||
userName = userNameDao.save(userName);
|
||||
if(userName == null)
|
||||
logger.error("Cannot save Username '"+jsonUsername.username+"' for User '"+user.getIdentifier()+"'");
|
||||
}
|
||||
|
||||
/*
|
||||
* Create any projects of which the user is a member of
|
||||
*/
|
||||
if(doFullCheck){
|
||||
for(JsonThesis jThesis : jsonUser.theses){
|
||||
checkAndCreateProject(jThesis);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
numUsersCreated++;
|
||||
return user;
|
||||
}
|
||||
catch (Exception e){
|
||||
logger.error("Cannot save jsonuser with jsonuserid: " + jsonUser.id + " - Rolling back...\n" + e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return thesisUser;
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected Project checkAndCreateProject(JsonThesis jThesis) {
|
||||
|
||||
Project project = null;
|
||||
|
||||
//System.out.println("Creating project:" + jThesis.thesisID);
|
||||
project = projectDao.getProjectByIdentifier(jThesis.thesisID);
|
||||
if(project == null){
|
||||
@ -147,24 +142,17 @@ public abstract class JsonResponseHandler implements IResponseHandler {
|
||||
|
||||
}
|
||||
project = projectDao.save(project);
|
||||
|
||||
|
||||
//Synch participants
|
||||
for(JsonThesisParticipant jtp : jThesis.participants){
|
||||
User u = userDao.getUserByIdentifier(jtp.id);
|
||||
|
||||
//Attempt remote lookup if no user is found
|
||||
if(u == null){
|
||||
final Long id = Long.valueOf(jtp.id);
|
||||
try {
|
||||
u = userLookupFromIdentifier.lookup(id);
|
||||
} catch (Exception e) {
|
||||
logger.error("Cannot save jsonuser with jsonuserid: " + jtp.id + " - Rolling back...\n" + e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
if( (u = userLookupFromIdentifier.lookup(id)) == null){
|
||||
throw new RuntimeException("Cannot save jsonuser with jsonuserid: " + jtp.id);
|
||||
}
|
||||
u = userDao.getUserByIdentifier(jtp.id);
|
||||
}
|
||||
|
||||
|
||||
if(u != null){
|
||||
//Move on
|
||||
if(jtp.role.equals("SUPERVISOR")){
|
||||
Employee e = roleDao.makeEmployee(u);
|
||||
project.setHeadSupervisor(e);
|
||||
@ -192,29 +180,15 @@ public abstract class JsonResponseHandler implements IResponseHandler {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
project = projectDao.save(project);
|
||||
/*
|
||||
try{
|
||||
txManager.commit(status);
|
||||
}catch(TransactionException e){
|
||||
logger.log(Level.ERROR, "Cannot commit transaction with projectid:"+project.getId() + " - Rolling back...\n" + e.getMessage());
|
||||
txManager.rollback(status);
|
||||
throw e;
|
||||
}
|
||||
*/
|
||||
}
|
||||
project = null;
|
||||
project = projectDao.getProjectByIdentifier(jThesis.thesisID);
|
||||
return project;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Look for changes in a jsonuser against a thesisuser. BEWARE: you need to be sure that
|
||||
* a corresponding thesisuser exists, or an exception will be thrown
|
||||
*
|
||||
* @param daisyUser
|
||||
* Look for changes in a jsonuser against a User.
|
||||
* @note you need to be sure that a corresponding User exists, or a (potentially wrapped) Runtime exception will be thrown
|
||||
* @param jsonUser
|
||||
* @return
|
||||
*/
|
||||
protected boolean lookForChangesInUserAndSave(JsonUser jsonUser){
|
||||
@ -481,8 +455,6 @@ public abstract class JsonResponseHandler implements IResponseHandler {
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Force subclasses to handle the response
|
||||
*/
|
||||
@ -518,14 +490,21 @@ public abstract class JsonResponseHandler implements IResponseHandler {
|
||||
public int getNumThesesCreated() {
|
||||
return numThesesCreated;
|
||||
}
|
||||
public void setNumThesesCreated(int numThesesCreated) {
|
||||
this.numThesesCreated = numThesesCreated;
|
||||
}
|
||||
|
||||
public int getNumThesesChanged() {
|
||||
return numThesesChanged;
|
||||
}
|
||||
public void setNumThesesChanged(int numThesesChanged) {
|
||||
this.numThesesChanged = numThesesChanged;
|
||||
/**
|
||||
* Sets parameter to increase logging output.
|
||||
* @param logResult
|
||||
*/
|
||||
public void setLogResult(boolean logResult) {
|
||||
this.logResult = logResult;
|
||||
}
|
||||
/**
|
||||
* Getter for increased logging output.
|
||||
*/
|
||||
public boolean isLogResult() {
|
||||
return logResult;
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package se.su.dsv.scipro.json;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import org.apache.log4j.Level;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.data.dataobjects.Username;
|
||||
@ -19,15 +20,8 @@ import com.google.gson.reflect.TypeToken;
|
||||
* @author Dan Kjellman <dan-kjel@dsv.su.se>
|
||||
*
|
||||
*/
|
||||
//@Component
|
||||
@Component
|
||||
public class JsonUserFullResponseHandler extends JsonResponseHandler {
|
||||
|
||||
private boolean logResult = false;
|
||||
|
||||
public JsonUserFullResponseHandler(){
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles a json string
|
||||
*
|
||||
@ -124,8 +118,7 @@ public class JsonUserFullResponseHandler extends JsonResponseHandler {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(logResult){
|
||||
if(isLogResult()){
|
||||
logger.log(Level.INFO, "\nResult from userimport/update:\nChecked: " + userContainer.users.size() + " users\n" +
|
||||
"Changed users: " + changedUsers + "\n" +
|
||||
"Created users: " + createdUsers + "\n" +
|
||||
@ -137,12 +130,4 @@ public class JsonUserFullResponseHandler extends JsonResponseHandler {
|
||||
"Num Supervisors created: " + getNumFirstNameChanges() + "\n");
|
||||
}
|
||||
}
|
||||
|
||||
public void setLogResult(boolean logResult) {
|
||||
this.logResult = logResult;
|
||||
}
|
||||
|
||||
public boolean isLogResult() {
|
||||
return logResult;
|
||||
}
|
||||
}
|
||||
|
@ -19,9 +19,6 @@ import com.google.gson.reflect.TypeToken;
|
||||
*/
|
||||
@Component
|
||||
public class JsonUserResponseHandler extends JsonResponseHandler {
|
||||
|
||||
private boolean logResult = false;
|
||||
|
||||
/**
|
||||
* Handles a json string
|
||||
*
|
||||
@ -66,7 +63,7 @@ public class JsonUserResponseHandler extends JsonResponseHandler {
|
||||
}
|
||||
}
|
||||
|
||||
if(logResult){
|
||||
if(isLogResult()){
|
||||
logger.info("Result from userimport/update:\nChecked: " + userContainer.users.size() + " users\n" +
|
||||
"Changed users: " + changedUsers + "\n" +
|
||||
"Created users: " + createdUsers + "\n" +
|
||||
@ -78,12 +75,4 @@ public class JsonUserResponseHandler extends JsonResponseHandler {
|
||||
"Num Supervisors created: " + getNumFirstNameChanges() + "\n");
|
||||
}
|
||||
}
|
||||
|
||||
public void setLogResult(boolean logResult) {
|
||||
this.logResult = logResult;
|
||||
}
|
||||
|
||||
public boolean isLogResult() {
|
||||
return logResult;
|
||||
}
|
||||
}
|
||||
|
@ -11,10 +11,8 @@ import org.springframework.stereotype.Component;
|
||||
import se.su.dsv.scipro.json.ImportWorkerLookup;
|
||||
@Component
|
||||
public class UserAndProjectImportWorker extends AbstractWorker{
|
||||
|
||||
@Autowired
|
||||
private ImportWorkerLookup importLookup;
|
||||
|
||||
private ImportWorkerLookup importWorkerLookup;
|
||||
public static int updatedUsers;
|
||||
public static int updatedTheses;
|
||||
//The amount of theses or uses asked for
|
||||
@ -34,7 +32,7 @@ public class UserAndProjectImportWorker extends AbstractWorker{
|
||||
//Sets static params updatedUsers/updatedTheses
|
||||
try{
|
||||
beginTransaction();
|
||||
importLookup.lookupUpdateStats(this.getLastRun());
|
||||
importWorkerLookup.lookupUpdateStats(this.getLastRun());
|
||||
commitTransaction();
|
||||
} catch(Exception e){
|
||||
rollbackTransaction();
|
||||
@ -60,7 +58,7 @@ public class UserAndProjectImportWorker extends AbstractWorker{
|
||||
try{
|
||||
beginTransaction();
|
||||
if(endIndex > 0){
|
||||
importLookup.lookup(startIndex, endIndex,(this.getLastRun()),ImportWorkerLookup.USERS);
|
||||
importWorkerLookup.lookup(startIndex, endIndex,(this.getLastRun()),ImportWorkerLookup.USERS);
|
||||
}
|
||||
commitTransaction();
|
||||
|
||||
@ -90,7 +88,7 @@ public class UserAndProjectImportWorker extends AbstractWorker{
|
||||
try{
|
||||
beginTransaction();
|
||||
if(endIndex > 0)
|
||||
importLookup.lookup(startIndex, endIndex,(this.getLastRun()),
|
||||
importWorkerLookup.lookup(startIndex, endIndex,(this.getLastRun()),
|
||||
ImportWorkerLookup.THESES);
|
||||
commitTransaction();
|
||||
|
||||
|
@ -22,11 +22,10 @@
|
||||
annotations
|
||||
-->
|
||||
<tx:annotation-driven transaction-manager="transactionManager" />
|
||||
|
||||
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
|
||||
<property name="entityManagerFactory" ref="entityManagerFactory" />
|
||||
</bean>
|
||||
|
||||
<!-- Load data initializer for default table-data -->
|
||||
<bean class="se.su.dsv.scipro.DataInitialiser" init-method="dataInit" />
|
||||
<!-- Defines global settings for the application -->
|
||||
<bean id="applicationSettings" class="se.su.dsv.scipro.ApplicationSettings">
|
||||
@ -39,16 +38,4 @@
|
||||
<!-- External auth support (via J2EE standard mechanism REMOTE_USER), if true: other authentication mechanics will be bypassed.-->
|
||||
<property name="acceptExternalAuthentication" value="true"/>
|
||||
</bean>
|
||||
<!-- Defines the class used for lookup in username against a remote server -->
|
||||
<bean id="importWorkerLookup" class="se.su.dsv.scipro.json.ImportWorkerLookup">
|
||||
<property name="userResponseHandler" ref="importWorkerResponseHandler" />
|
||||
<property name="statsResonseHandler" ref="importStatsResponseHandler" />
|
||||
</bean>
|
||||
<!-- The abstract handler for json responses -->
|
||||
<bean id="jsonResponseHandler" abstract="true" class="se.su.dsv.scipro.json.JsonResponseHandler" />
|
||||
<!-- Handler for json responses regarding users -->
|
||||
<bean id="jsonUserResponseHandler" parent="jsonResponseHandler" class="se.su.dsv.scipro.json.JsonUserResponseHandler" />
|
||||
<bean id="jsonUserFullResponseHandler" parent="jsonResponseHandler" class="se.su.dsv.scipro.json.JsonUserFullResponseHandler" />
|
||||
<bean id="importWorkerResponseHandler" parent="jsonResponseHandler" class="se.su.dsv.scipro.json.ImportWorkerResponseHandler" />
|
||||
<bean id="importStatsResponseHandler" parent="jsonResponseHandler" class="se.su.dsv.scipro.json.ImportUpdateStatsResponseHandler" />
|
||||
</beans>
|
||||
|
Loading…
x
Reference in New Issue
Block a user