use of org.olat.core.id.Identity in project OpenOLAT by OpenOLAT.
the class Tracing method assembleMsg.
private static String assembleMsg(String category, char prefix, long refNum, Class<?> callingClass, String userObj, String logMsg) {
HttpServletRequest ureq = null;
if (tld != null) {
// thread local data is not initialized so far if Tracing is called from
// e.g. a worker thread like in Search or UpdateEfficiency worker
// TODO:pb:check if this was also a problem with IM threads.
ureq = tld.getHttpServletRequest();
}
UserSession usess = null;
Identity identity = null;
String remoteIp = null;
String userAgent = null;
String referer = null;
if (ureq != null) {
usess = CoreSpringFactory.getImpl(UserSessionManager.class).getUserSessionIfAlreadySet(ureq);
if (usess != null) {
identity = usess.getIdentity();
remoteIp = ureq.getRemoteAddr();
userAgent = ureq.getHeader("User-Agent");
referer = ureq.getHeader("Referer");
}
}
StringBuilder sb = new StringBuilder(256);
if (Settings.isDebuging()) {
// Short version for console output during debugging
if (userObj != null) {
sb.append(userObj).append(" ");
}
} else {
sb.append(PREFIX);
sb.append(category);
sb.append(SEPARATOR);
try {
// Node-Id + Error number e.g. N1-E17
sb.append("N");
sb.append(WebappHelper.getNodeId());
sb.append("-");
} catch (Throwable th) {
// ok
sb.append(N_A);
}
sb.append(prefix);
sb.append(refNum);
sb.append(SEPARATOR);
sb.append(callingClass == null ? N_A : callingClass.getPackage().getName());
sb.append(SEPARATOR);
sb.append(identity == null ? N_A : identity.getName());
sb.append(SEPARATOR);
sb.append(remoteIp == null ? N_A : remoteIp);
sb.append(SEPARATOR);
sb.append(referer == null ? N_A : referer);
sb.append(SEPARATOR);
sb.append(userAgent == null ? N_A : userAgent);
sb.append(SEPARATOR);
sb.append(userObj == null ? N_A : userObj);
sb.append(SEPARATOR);
}
sb.append(logMsg == null ? N_A : logMsg.replaceAll("[\\r\\f]", "").replaceAll("[/^]M", "").replaceAll("[\\r\\n]", ""));
return sb.toString();
}
use of org.olat.core.id.Identity in project OpenOLAT by OpenOLAT.
the class ContactList method getEmailsAsStrings.
/**
* the returned ArrayList contains String Objects representing the e-mail
* addresses added. The address of user which login is denied are excluded.
*
* @return
*/
public List<String> getEmailsAsStrings() {
List<String> ret = new ArrayList<>(stringEmails.values());
/*
* if priority is on institutional email get all the institutional emails
* first, if they are present, remove the identity from the hashtable. If
* they were not present, the user email is used in the next loop.
*/
List<Identity> copy = new ArrayList<>(identiEmails.values());
if (emailPrioInstitutional) {
for (Iterator<Identity> it = copy.iterator(); it.hasNext(); ) {
Identity tmp = it.next();
if (tmp.getStatus() == Identity.STATUS_LOGIN_DENIED) {
continue;
}
String addEmail = tmp.getUser().getProperty(UserConstants.INSTITUTIONALEMAIL, null);
if (addEmail != null) {
ret.add(addEmail);
it.remove();
}
}
}
/*
* loops over the (remaining) identities, fetches the user email.
*/
for (Identity tmp : copy) {
if (tmp.getStatus() == Identity.STATUS_LOGIN_DENIED) {
continue;
}
String email = tmp.getUser().getProperty(UserConstants.EMAIL, null);
if (StringHelper.containsNonWhitespace(email)) {
ret.add(email);
}
}
return ret;
}
use of org.olat.core.id.Identity in project OpenOLAT by OpenOLAT.
the class EMailCalloutCtrl method formOK.
@Override
protected void formOK(UserRequest ureq) {
if (emailEl != null) {
String mail = emailEl.getValue();
if (MailHelper.isValidEmailAddress(mail)) {
Identity identity = userManager.findUniqueIdentityByEmail(mail);
if (identity == null) {
identity = new EMailIdentity(mail, getLocale());
}
fireEvent(ureq, new SingleIdentityChosenEvent(identity));
}
}
}
use of org.olat.core.id.Identity in project OpenOLAT by OpenOLAT.
the class DBPersistentLockManager method aquirePersistentLock.
/**
* @see org.olat.core.util.locks.PersistentLockManager#aquirePersistentLock(org.olat.core.id.OLATResourceable,
* org.olat.core.id.Identity, java.lang.String)
*/
@Override
public LockResult aquirePersistentLock(OLATResourceable ores, Identity ident, String locksubkey) {
// synchronisation is solved in the LockManager
LockResult lres;
PropertyManager pm = PropertyManager.getInstance();
String derivedLockString = OresHelper.createStringRepresenting(ores, locksubkey);
long aqTime;
Identity lockOwner;
boolean success;
Property p;
p = pm.findProperty(null, null, null, CATEGORY_PERSISTENTLOCK, derivedLockString);
if (p == null) {
// no persistent lock acquired yet
// save a property: cat = o_lock, key = derivedLockString, Longvalue = key
// of identity acquiring the lock
Property newp = pm.createPropertyInstance(null, null, null, CATEGORY_PERSISTENTLOCK, derivedLockString, null, ident.getKey(), null, null);
pm.saveProperty(newp);
aqTime = System.currentTimeMillis();
lockOwner = ident;
success = true;
} else {
// already acquired, but check on reaquiring
aqTime = p.getLastModified().getTime();
Long lockOwnerKey = p.getLongValue();
if (ident.getKey().equals(lockOwnerKey)) {
// reaquire ok
success = true;
} else {
// already locked by an other person
success = false;
}
// FIXME:fj:c find a better way to retrieve information about the
// lock-holder
lockOwner = BaseSecurityManager.getInstance().loadIdentityByKey(lockOwnerKey);
}
LockEntry le = new LockEntry(derivedLockString, aqTime, lockOwner);
lres = new LockResultImpl(success, le);
return lres;
}
use of org.olat.core.id.Identity in project OpenOLAT by OpenOLAT.
the class MailController method getFrom.
private String getFrom() {
StringBuilder sb = new StringBuilder();
DBMailRecipient from = mail.getFrom();
sb.append("<ul class='list-inline'><li>");
if (from != null) {
sb.append(getFullName(from));
if (showMailAdresses()) {
Identity fromIdentity = from.getRecipient();
if (fromIdentity != null) {
sb.append(" <");
sb.append(UserManager.getInstance().getUserDisplayEmail(fromIdentity, getLocale()));
sb.append("> ");
}
}
}
sb.append("</li></ul>");
return sb.toString();
}
Aggregations