use of fi.otavanopisto.muikku.schooldata.SchoolDataBridgeInternalException in project muikku by otavanopisto.
the class PyramusUserSchoolDataBridge method setUserProperty.
@Override
public UserProperty setUserProperty(String userIdentifier, String key, String value) {
Long studentId = identifierMapper.getPyramusStudentId(userIdentifier);
if (studentId != null) {
Student student = pyramusClient.get("/students/students/" + studentId, Student.class);
Map<String, String> variables = student.getVariables();
variables.put(key, value);
student.setVariables(variables);
pyramusClient.put(String.format("/students/students/%d", studentId), student);
return new PyramusUserProperty(userIdentifier, key, value);
}
logger.warning(String.format("PyramusUserSchoolDataBridge.setUserProperty malformed user identifier %s\n%s", userIdentifier, ExceptionUtils.getStackTrace(new Throwable())));
throw new SchoolDataBridgeInternalException(String.format("Malformed user identifier %s", userIdentifier));
}
use of fi.otavanopisto.muikku.schooldata.SchoolDataBridgeInternalException in project muikku by otavanopisto.
the class PyramusUserSchoolDataBridge method findRole.
@Override
public Role findRole(String identifier) {
UserRole pyramusUserRole = identifierMapper.getPyramusUserRole(identifier);
if (pyramusUserRole != null) {
return entityFactory.createEntity(pyramusUserRole);
}
String id = identifierMapper.getPyramusCourseRoleId(identifier);
if (StringUtils.isBlank(id)) {
throw new SchoolDataBridgeInternalException("Malformed role identifier");
}
if ("STUDENT".equals(id)) {
return entityFactory.createCourseStudentRoleEntity();
}
return entityFactory.createEntity(pyramusClient.get("/courses/staffMemberRoles/" + id, CourseStaffMemberRole.class));
}
use of fi.otavanopisto.muikku.schooldata.SchoolDataBridgeInternalException in project muikku by otavanopisto.
the class PyramusWorkspaceSchoolDataBridge method listWorkspacesByCourseIdentifier.
@Override
public List<Workspace> listWorkspacesByCourseIdentifier(String courseIdentifierIdentifier) {
if (courseIdentifierIdentifier.indexOf("/") == -1)
throw new SchoolDataBridgeInternalException("Invalid CourseIdentifierId");
String subjectId = courseIdentifierIdentifier.substring(0, courseIdentifierIdentifier.indexOf("/"));
String courseNumber = courseIdentifierIdentifier.substring(courseIdentifierIdentifier.indexOf("/") + 1);
Course[] courses = pyramusClient.get("/common/subjects/" + subjectId + "/courses", fi.otavanopisto.pyramus.rest.model.Course[].class);
List<Workspace> result = new ArrayList<Workspace>();
for (Course course : courses) {
String courseNumber2 = course.getCourseNumber() != null ? course.getCourseNumber().toString() : "null";
if (courseNumber.equals(courseNumber2))
result.add(createWorkspaceEntity(course));
}
return result;
}
use of fi.otavanopisto.muikku.schooldata.SchoolDataBridgeInternalException in project muikku by otavanopisto.
the class LocalUserSchoolDataBridge method findUserEnvironmentRole.
/**
* {@inheritDoc}
*/
public Role findUserEnvironmentRole(String userIdentifier) {
LocalUser user = localUserSchoolDataController.findUser(userIdentifier);
if (user == null) {
throw new SchoolDataBridgeInternalException("User not found");
}
Long roleId = user.getRoleId();
if (roleId != null) {
RoleEntity roleEntity = localUserSchoolDataController.findCoreRoleEntityById(roleId);
if (roleEntity == null) {
throw new SchoolDataBridgeInternalException("User role could not be found");
}
return toLocalRoleEntity(roleEntity);
}
return null;
}
use of fi.otavanopisto.muikku.schooldata.SchoolDataBridgeInternalException in project muikku by otavanopisto.
the class LocalUserSchoolDataBridge method removeUserEmail.
/**
* {@inheritDoc}
*/
@Override
public void removeUserEmail(String identifier) {
LocalUserEmail localUserEmail = localUserSchoolDataController.findUserEmail(identifier);
if (localUserEmail == null) {
throw new SchoolDataBridgeInternalException("UserEmail can not be removed because it does not exist");
}
localUserSchoolDataController.removeUserEmail(localUserEmail);
}
Aggregations