Search in sources :

Example 1 with DAOFactory

use of fi.otavanopisto.pyramus.dao.DAOFactory in project pyramus by otavanopisto.

the class ClientApplicationAuthorizationCodeAPI method create.

public Long create(String authorizationCode, String redirectUrl, Long userId, Long clientApplicationId) throws InvalidScriptException {
    DAOFactory daoFactory = DAOFactory.getInstance();
    User user = daoFactory.getStaffMemberDAO().findById(userId);
    if (user == null) {
        user = daoFactory.getStudentDAO().findById(userId);
    }
    if (user == null) {
        throw new InvalidScriptException("User not found");
    }
    ClientApplication clientApplication = daoFactory.getClientApplicationDAO().findById(clientApplicationId);
    if (clientApplication == null) {
        throw new InvalidScriptException("Client application not found");
    }
    ClientApplicationAuthorizationCode code = DAOFactory.getInstance().getClientApplicationAuthorizationCodeDAO().create(user, clientApplication, authorizationCode, redirectUrl);
    return code.getId();
}
Also used : ClientApplication(fi.otavanopisto.pyramus.domainmodel.clientapplications.ClientApplication) User(fi.otavanopisto.pyramus.domainmodel.users.User) InvalidScriptException(fi.otavanopisto.pyramus.util.dataimport.scripting.InvalidScriptException) DAOFactory(fi.otavanopisto.pyramus.dao.DAOFactory) ClientApplicationAuthorizationCode(fi.otavanopisto.pyramus.domainmodel.clientapplications.ClientApplicationAuthorizationCode)

Example 2 with DAOFactory

use of fi.otavanopisto.pyramus.dao.DAOFactory in project pyramus by otavanopisto.

the class UserIdentificationAPI method create.

public Long create(Long personId, String authSource, String externalId) throws InvalidScriptException {
    DAOFactory daoFactory = DAOFactory.getInstance();
    Person person = daoFactory.getPersonDAO().findById(personId);
    if (person == null) {
        throw new InvalidScriptException("Person not found");
    }
    UserIdentification userIdentification = daoFactory.getUserIdentificationDAO().create(person, authSource, externalId);
    if (userIdentification == null) {
        return null;
    } else {
        return userIdentification.getId();
    }
}
Also used : InvalidScriptException(fi.otavanopisto.pyramus.util.dataimport.scripting.InvalidScriptException) DAOFactory(fi.otavanopisto.pyramus.dao.DAOFactory) Person(fi.otavanopisto.pyramus.domainmodel.base.Person) UserIdentification(fi.otavanopisto.pyramus.domainmodel.users.UserIdentification)

Aggregations

DAOFactory (fi.otavanopisto.pyramus.dao.DAOFactory)2 InvalidScriptException (fi.otavanopisto.pyramus.util.dataimport.scripting.InvalidScriptException)2 Person (fi.otavanopisto.pyramus.domainmodel.base.Person)1 ClientApplication (fi.otavanopisto.pyramus.domainmodel.clientapplications.ClientApplication)1 ClientApplicationAuthorizationCode (fi.otavanopisto.pyramus.domainmodel.clientapplications.ClientApplicationAuthorizationCode)1 User (fi.otavanopisto.pyramus.domainmodel.users.User)1 UserIdentification (fi.otavanopisto.pyramus.domainmodel.users.UserIdentification)1