use of org.olat.basesecurity.IdentityShort in project OpenOLAT by OpenOLAT.
the class UserManagerImpl method getUsername.
@Override
public String getUsername(Long identityKey) {
if (identityKey == null || identityKey.longValue() <= 0) {
return null;
}
String username = userToNameCache.get(identityKey);
if (username == null) {
IdentityShort identity = securityManager.loadIdentityShortByKey(identityKey);
// fill the cache
getUserDisplayName(identity);
username = identity.getName();
}
return username;
}
use of org.olat.basesecurity.IdentityShort in project OpenOLAT by OpenOLAT.
the class UserManagerImpl method warmUp.
@Override
public int warmUp() {
EntityManager em = dbInstance.getCurrentEntityManager();
int batchSize = 5000;
TypedQuery<IdentityShort> query = em.createNamedQuery("selectAllIdentitiesShortUnordered", IdentityShort.class).setMaxResults(batchSize);
int count = 0;
List<IdentityShort> identities;
do {
identities = query.setFirstResult(count).getResultList();
em.clear();
for (IdentityShort identity : identities) {
if (identity.getStatus() < Identity.STATUS_DELETED) {
getUserDisplayName(identity);
}
}
count += identities.size();
} while (identities.size() >= batchSize);
return count;
}
use of org.olat.basesecurity.IdentityShort in project OpenOLAT by OpenOLAT.
the class UserWebService method getPortraitHead.
/**
* Retrieves the portrait of an user
* @response.representation.200.mediaType application/octet-stream
* @response.representation.200.doc The portrait as image
* @response.representation.404.doc The identity or the portrait not found
* @param identityKey The identity key of the user being searched
* @return The image
*/
@HEAD
@Path("{identityKey}/portrait")
@Produces({ "image/jpeg", "image/jpg", MediaType.APPLICATION_OCTET_STREAM })
public Response getPortraitHead(@PathParam("identityKey") Long identityKey) {
try {
IdentityShort identity = BaseSecurityManager.getInstance().loadIdentityShortByKey(identityKey);
if (identity == null) {
return Response.serverError().status(Status.NOT_FOUND).build();
}
File portrait = DisplayPortraitManager.getInstance().getBigPortrait(identity.getName());
if (portrait == null || !portrait.exists()) {
return Response.serverError().status(Status.NOT_FOUND).build();
}
Date lastModified = new Date(portrait.lastModified());
return Response.ok().lastModified(lastModified).build();
} catch (Throwable e) {
throw new WebApplicationException(e);
}
}
use of org.olat.basesecurity.IdentityShort in project openolat by klemens.
the class UserSearchListProvider method getResult.
@Override
public void getResult(String searchValue, ListReceiver receiver) {
Map<String, String> userProperties = new HashMap<>();
// We can only search in mandatory User-Properties due to problems
// with hibernate query with join and not existing rows
userProperties.put(UserConstants.FIRSTNAME, searchValue);
userProperties.put(UserConstants.LASTNAME, searchValue);
userProperties.put(UserConstants.EMAIL, searchValue);
// Search in all fileds -> non intersection search
int maxEntries = MAX_ENTRIES;
List<IdentityShort> res = securityManager.searchIdentityShort(searchValue, maxEntries);
boolean hasMore = false;
for (Iterator<IdentityShort> it_res = res.iterator(); (hasMore = it_res.hasNext()) && maxEntries > 0; ) {
maxEntries--;
IdentityShort ident = it_res.next();
String key = ident.getKey().toString();
String displayKey = ident.getName();
String displayText = userManager.getUserDisplayName(ident);
receiver.addEntry(key, displayKey, displayText, null);
}
if (hasMore) {
receiver.addEntry(".....", ".....");
}
}
use of org.olat.basesecurity.IdentityShort in project OpenOLAT by OpenOLAT.
the class RevisionListController method loadModel.
private void loadModel(VFSLeaf versionedLeaf) {
Versions versions = versionedFile.getVersions();
List<VFSRevision> revisions = new ArrayList<VFSRevision>(versions.getRevisions());
revisions.add(new CurrentRevision(versionedLeaf, versions));
Collection<String> names = new HashSet<String>();
for (VFSRevision revision : revisions) {
if (revision.getAuthor() != null) {
names.add(revision.getAuthor());
}
}
Map<String, IdentityShort> mappedIdentities = new HashMap<String, IdentityShort>();
for (IdentityShort identity : BaseSecurityManager.getInstance().findShortIdentitiesByName(names)) {
mappedIdentities.put(identity.getName(), identity);
}
revisionListTableCtr.setTableDataModel(new RevisionListDataModel(revisions, mappedIdentities, getLocale()));
}
Aggregations