热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

org.xwiki.users.User类的使用及代码示例

本文整理了Java中org.xwiki.users.User类的一些代码示例,展示了User类的具体用法。这些代码示例主要来源于G

本文整理了Java中org.xwiki.users.User类的一些代码示例,展示了User类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。User类的具体详情如下:
包路径:org.xwiki.users.User
类名称:User

User介绍

[英]XWiki User Interface.
[中]XWiki用户界面。

代码示例

代码示例来源:origin: phenotips/phenotips

private boolean isGuestOwner(String owner, User user)
{
return StringUtils.isEmpty(owner) && (user == null || user.getProfileDocument() == null);
}
}

代码示例来源:origin: phenotips/phenotips

private void populateUserInfo(ContactInfo.Builder contactInfo, User user)
{
String email = (String) user.getAttribute(ATTRIBUTE_EMAIL_USER);
String institution = (String) user.getAttribute(ATTRIBUTE_INSTITUTION);
contactInfo.withUserId(user.getId());
contactInfo.withName(user.getName());
contactInfo.withEmail(email);
contactInfo.withInstitution(institution);
}

代码示例来源:origin: phenotips/phenotips

@Override
public DocumentLock getLock(DocumentReference doc)
{
XWikiContext cOntext= this.provider.get();
XWikiDocument xdoc;
try {
xdoc = context.getWiki().getDocument(doc, context);
if (xdoc == null) {
return null;
}
XWikiLock xlock = xdoc.getLock(context);
User user = this.userManager.getUser(xlock.getUserName());
if (xlock != null && !user.getId().equals(this.userManager.getCurrentUser().getId())) {
Set actiOns= Collections.singleton("edit");
return new DocumentLock(user, xlock.getDate(),
this.tm.translate("locks.documentInUse", user.getName()), actions, true);
}
} catch (XWikiException e) {
this.logger.error("Failed to access the document lock: {}", e.getMessage(), e);
}
return null;
}
}

代码示例来源:origin: phenotips/phenotips

private void runUsersQuery(JSONArray resultArray, String queryString, String formattedInput, int maxResults)
throws Exception
{
List queryResult = runQuery(queryString, formattedInput, maxResults);
for (String userName : queryResult)
{
User user = this.userManager.getUser(userName);
List attachmentRefs =
this.bridge.getAttachmentReferences((DocumentReference) user.getProfileDocument());
String avatarURL = "";
if (attachmentRefs.size() > 0) {
avatarURL = this.bridge.getAttachmentURL(attachmentRefs.get(0), true);
} else {
XWikiContext xcOntext= this.xcontextProvider.get();
XWiki xwiki = xcontext.getWiki();
avatarURL = xwiki.getSkinFile("icons/xwiki/noavatar.png", xcontext);
}
String name = user.getName();
if (StringUtils.isBlank(name)) {
name = user.getUsername();
}
JSONObject o = createObject(user.getUsername(), name, avatarURL, name, userName);
resultArray.put(o);
if (resultArray.length() == maxResults) {
break;
}
}
}

代码示例来源:origin: org.phenotips/family-studies-api

private synchronized XWikiDocument createFamilyDocument(User creator)
throws IllegalArgumentException, QueryException, XWikiException
{
XWikiContext cOntext= this.provider.get();
XWiki wiki = context.getWiki();
long nextId = getLastUsedId();
DocumentReference newFamilyRef;
do {
newFamilyRef = this.entityReferenceResolver.resolve(new EntityReference(
String.format("%s%07d", PREFIX, ++nextId), EntityType.DOCUMENT, Family.DATA_SPACE));
} while (wiki.exists(newFamilyRef, context));
XWikiDocument newFamilyDoc = wiki.getDocument(newFamilyRef, context);
// Copying all objects from template to family
newFamilyDoc.readFromTemplate(
this.entityReferenceResolver.resolve(FAMILY_TEMPLATE), context);
// Adding additional values to family
BaseObject ownerObject = newFamilyDoc.newXObject(Owner.CLASS_REFERENCE, context);
ownerObject.set("owner", creator == null ? "" : creator.getId(), context);
BaseObject familyObject = newFamilyDoc.getXObject(Family.CLASS_REFERENCE);
familyObject.set("identifier", nextId, context);
if (creator != null) {
DocumentReference creatorRef = creator.getProfileDocument();
newFamilyDoc.setCreatorReference(creatorRef);
newFamilyDoc.setAuthorReference(creatorRef);
newFamilyDoc.setContentAuthorReference(creatorRef);
}
this.updateFamilyPermissions(new PhenotipsFamily(newFamilyDoc), context, false);
wiki.saveDocument(newFamilyDoc, context);
return newFamilyDoc;
}

代码示例来源:origin: org.phenotips/patient-contacts

@Override
public List getContacts(Patient patient)
{
DocumentReference reporter = patient.getReporter();
if (reporter == null) {
return Collections.emptyList();
}
List list = new ArrayList<>();
ContactInfo.Builder cOntactInfo= new ContactInfo.Builder();
contactInfo.withUserId(this.serializer.serialize(reporter));
User user = this.userManager.getUser(reporter.toString());
if (user != null) {
String email = (String) user.getAttribute("email");
String institution = (String) user.getAttribute("company");
contactInfo.withName(user.getName());
contactInfo.withEmail(email);
contactInfo.withInstitution(institution);
// FIXME URL is missing
}
// Otherwise, if null user -> user is no longer valid, all we know is the username, already added before the if
list.add(contactInfo.build());
return list;
}
}

代码示例来源:origin: phenotips/phenotips

/**
* {@inheritDoc}
*
* @see Comparable#compareTo(Object)
*/
@Override
public int compareTo(User user)
{
return getName().compareTo(user.getName());
}
}

代码示例来源:origin: phenotips/phenotips

@Override
public Serializable disassemble(Object value) throws HibernateException
{
return ((User) value).getId();
}

代码示例来源:origin: org.phenotips/patient-data-default-impl

@Override
public DocumentLock getLock(DocumentReference doc)
{
XWikiContext cOntext= this.provider.get();
XWikiDocument xdoc;
try {
xdoc = context.getWiki().getDocument(doc, context);
if (xdoc == null) {
return null;
}
String documentId = xdoc.getDocumentReference().getName();
Patient patient = this.patientRepository.getPatientById(documentId);
if (patient == null) {
return null;
}
XWikiLock xlock = xdoc.getLock(context);
User user = this.userManager.getUser(xlock.getUserName());
if (xlock != null && !user.getId().equals(this.userManager.getCurrentUser().getId())) {
Set actiOns= Collections.singleton("edit");
return new DocumentLock(user, xlock.getDate(), this.tm.translate("patient.locks.patientInUse",
user.getName()), actions, false);
}
} catch (XWikiException e) {
this.logger.error("Failed to access the document lock: {}", e.getMessage(), e);
}
return null;
}
}

代码示例来源:origin: phenotips/phenotips

@Override
public List getContacts(Patient patient)
{
DocumentReference reporter = patient.getReporter();
if (reporter == null) {
return Collections.emptyList();
}
List list = new ArrayList<>();
ContactInfo.Builder cOntactInfo= new ContactInfo.Builder();
contactInfo.withUserId(this.serializer.serialize(reporter));
User user = this.userManager.getUser(reporter.toString());
if (user != null) {
String email = (String) user.getAttribute("email");
String institution = (String) user.getAttribute("company");
contactInfo.withName(user.getName());
contactInfo.withEmail(email);
contactInfo.withInstitution(institution);
// FIXME URL is missing
}
// Otherwise, if null user -> user is no longer valid, all we know is the username, already added before the if
list.add(contactInfo.build());
return list;
}
}

代码示例来源:origin: org.phenotips/family-studies-api

User user = this.userManager.getUser(xlock.getUserName());
return new DocumentLock(user, xlock.getDate(),
this.tm.translate("family.locks.patientFamilyInUse", user.getName()), actions, false);

代码示例来源:origin: phenotips/phenotips

@Override
public String toString()
{
return (this.user == null ? null : this.user.getId()) + " (" + this.ip + "): "
+ this.action + " on " + this.entity + " at "
+ (this.time == null ? null : this.time.getTime());
}

代码示例来源:origin: phenotips/phenotips

@Override
public Boolean hasAccess(User user, Right access, EntityReference entity)
{
return this.authorizationManager.hasAccess(access, user == null ? null : user.getProfileDocument(), entity);
}
}

代码示例来源:origin: org.phenotips/family-studies-api

@Override
public DocumentLock getLock(DocumentReference doc)
{
XWikiContext cOntext= this.provider.get();
XWikiDocument xdoc;
try {
xdoc = context.getWiki().getDocument(doc, context);
if (xdoc == null) {
return null;
}
String documentId = xdoc.getDocumentReference().getName();
Family family = this.familyRepository.getFamilyById(documentId);
if (family == null) {
return null;
}
XWikiLock xlock = xdoc.getLock(context);
User user = this.userManager.getUser(xlock.getUserName());
if (xlock != null && !user.getId().equals(this.userManager.getCurrentUser().getId())) {
Set actiOns= Collections.singleton("edit");
return new DocumentLock(user, xlock.getDate(), this.tm.translate("family.locks.familyInUse",
user.getName()), actions, false);
}
} catch (XWikiException e) {
this.logger.error("Failed to access the document lock: {}", e.getMessage(), e);
}
return null;
}
}

代码示例来源:origin: org.phenotips/patient-access-rules-api

private void populateUserInfo(ContactInfo.Builder contactInfo, User user)
{
String email = (String) user.getAttribute(ATTRIBUTE_EMAIL_USER);
String institution = (String) user.getAttribute(ATTRIBUTE_INSTITUTION);
contactInfo.withUserId(user.getId());
contactInfo.withName(user.getName());
contactInfo.withEmail(email);
contactInfo.withInstitution(institution);
}

代码示例来源:origin: phenotips/phenotips

User user = this.userManager.getUser(xlock.getUserName());
return new DocumentLock(user, xlock.getDate(),
this.tm.translate("family.locks.patientFamilyInUse", user.getName()), actions, false);

代码示例来源:origin: phenotips/phenotips

@Override
public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException
{
if (User.class.isInstance(value)) {
st.setString(index, ((User) value).getId());
} else {
st.setNull(index, Types.VARCHAR);
}
}

代码示例来源:origin: org.phenotips/phenotips-authorization

@Override
public Boolean hasAccess(User user, Right access, EntityReference entity)
{
return this.authorizationManager.hasAccess(access, user == null ? null : user.getProfileDocument(), entity);
}
}

代码示例来源:origin: phenotips/phenotips

@Override
public DocumentLock getLock(DocumentReference doc)
{
XWikiContext cOntext= this.provider.get();
XWikiDocument xdoc;
try {
xdoc = context.getWiki().getDocument(doc, context);
if (xdoc == null) {
return null;
}
String documentId = xdoc.getDocumentReference().getName();
Patient patient = this.patientRepository.getPatientById(documentId);
if (patient == null) {
return null;
}
XWikiLock xlock = xdoc.getLock(context);
User user = this.userManager.getUser(xlock.getUserName());
if (xlock != null && !user.getId().equals(this.userManager.getCurrentUser().getId())) {
Set actiOns= Collections.singleton("edit");
return new DocumentLock(user, xlock.getDate(), this.tm.translate("patient.locks.patientInUse",
user.getName()), actions, false);
}
} catch (XWikiException e) {
this.logger.error("Failed to access the document lock: {}", e.getMessage(), e);
}
return null;
}
}

代码示例来源:origin: phenotips/phenotips

/**
* Returns the JSON representation of the audit event.
*
* @return a JSON object.
*/
public JSONObject toJSON()
{
JSONObject event = new JSONObject();
event.put("user", this.user == null ? null : this.user.getId());
event.put("ip", this.ip);
event.put("action", this.action);
event.put("extra", this.extra);
event.put("entity", this.entity == null ? null : this.entity.toString());
event.put("time", this.time == null ? null : this.time.toInstant().toString());
return event;
}
}

推荐阅读
author-avatar
开心123
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有