Commit 59c20f76 authored by michael.simon's avatar michael.simon
Browse files

Add attribute-query interface with uidNumber

parent b6a6059d
......@@ -19,5 +19,8 @@ public interface UserUpdateService {
void updateUserAsync(String eppn, String localHostName, String executor);
Map<String, String> updateUser(Long uidNumber, String serviceShortName, String localHostName, String executor)
throws IOException, RestInterfaceException;
}
......@@ -62,6 +62,26 @@ public class UserUpdateServiceImpl implements UserUpdateService, Serializable {
@Inject
private ApplicationConfig appConfig;
@Override
public Map<String, String> updateUser(Long uidNumber,
String serviceShortName, String localHostName, String executor)
throws IOException, RestInterfaceException {
UserEntity user = findUser(uidNumber);
if (user == null)
throw new NoUserFoundException("no such user");
ServiceEntity service = findService(serviceShortName);
if (service == null)
throw new NoServiceFoundException("no such service");
RegistryEntity registry = findRegistry(user, service);
if (registry == null)
throw new NoRegistryFoundException("user not registered for service");
return update(user, service, registry, localHostName, executor);
}
@Override
public Map<String, String> updateUser(String eppn,
String serviceShortName, String localHostName, String executor)
......@@ -278,4 +298,14 @@ public class UserUpdateServiceImpl implements UserUpdateService, Serializable {
return user;
}
private UserEntity findUser(Long uidNumber) {
UserEntity user = userDao.findByUidNumber(uidNumber);
if (user != null) {
user = userDao.findByIdWithStore(user.getId());
}
return user;
}
}
......@@ -63,6 +63,15 @@ public class AttributeQueryController {
return userUpdateService.updateUser(eppn, serviceShortName, request.getLocalName(), "rest-/attrq/eppn/" + serviceShortName + "/" + eppn);
}
@GET
@Path("/uid-number/{service}/{uidNumber}")
@Produces(MediaType.APPLICATION_JSON)
public Map<String, String> attributeQueryUidNumber(@PathParam("uidNumber") Long uidNumber,
@PathParam("service") String serviceShortName, @Context HttpServletRequest request)
throws IOException, ServletException, RestInterfaceException {
return userUpdateService.updateUser(uidNumber, serviceShortName, request.getLocalName(), "rest-/attrq/uid-number/" + serviceShortName + "/" + uidNumber);
}
@GET
@Path("/regid/{regid}")
@Produces(MediaType.APPLICATION_JSON)
......
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