本文整理了Java中cz.metacentrum.perun.core.api.Attribute
类的一些代码示例,展示了Attribute
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Attribute
类的具体详情如下:
包路径:cz.metacentrum.perun.core.api.Attribute
类名称:Attribute
[英]This class represents attribute (with value) of some object (VO, member). TODO
[中]此类表示某个对象(VO、成员)的属性(带值)。待办事项
代码示例来源:origin: CESNET/perun
if (a != null && a.getValue() != null && !((String)a.getValue()).isEmpty()) {
result = (String)a.getValue();
if (a2 != null && a2.getValue() != null && !((String)a2.getValue()).isEmpty()) {
result = (String)a2.getValue();
if (a2 != null && a2.getValue() != null && !((String)a2.getValue()).isEmpty()) {
result = (String)a2.getValue();
代码示例来源:origin: CESNET/perun
private static Attribute createAttribute(Map<String, String> beanAttr) throws InternalErrorException {
if(beanAttr==null) return null;
Attribute attribute = new Attribute();
attribute.setId(Integer.valueOf(beanAttr.get("id")));
attribute.setFriendlyName(BeansUtils.eraseEscaping(beanAttr.get("friendlyName")));
attribute.setNamespace(BeansUtils.eraseEscaping(beanAttr.get("namespace")));
attribute.setType(BeansUtils.eraseEscaping(beanAttr.get("type")));
attribute.setValue(BeansUtils.stringToAttributeValue(BeansUtils.eraseEscaping(beanAttr.get("value")), attribute.getType()));
attribute.setUnique(Boolean.valueOf(beanAttr.get("unique")));
return attribute;
}
代码示例来源:origin: CESNET/perun
if (a.getName().equals(AttributesManager.NS_USER_ATTR_DEF + ":preferredMail")) {
if (a.getValue() != null && !((String)a.getValue()).isEmpty()) {
String safeMail = ((String) a.getValue()).split("@")[0];
safeMail += "@"+((String) a.getValue()).split("@")[1];
a.setValue(safeMail);
代码示例来源:origin: CESNET/perun
public Attribute(Attribute attribute, boolean copyValue) {
super(attribute);
if(copyValue) {
this.value = attribute.getValue();
this.valueCreatedAt = attribute.getValueCreatedAt();
this.valueCreatedBy = attribute.getValueCreatedBy();
this.valueModifiedAt = attribute.getValueModifiedAt();
this.valueModifiedBy = attribute.getValueModifiedBy();
}
}
代码示例来源:origin: CESNET/perun
@Override
public String toString() {
return this.getClass().getSimpleName() + ":[" +
"id='" + getId() + '\'' +
", friendlyName='" + getFriendlyName() + '\'' +
", namespace='" + getNamespace() + '\'' +
", type='" + getType() + '\'' +
", unique='" + isUnique() + '\'' +
", value='" + getValue() + '\'' +
']';
}
}
代码示例来源:origin: CESNET/perun
/**
* Converts attribute value to string (serialize object to string).
* This is a wrapper for passing value and type only for specific use.
* @see #attributeValueToString(Attribute)
*
* @param attributeValue value of the attribute
* @param type type of resulting attribute
* @return string representation of the value
*
* @throws InternalErrorException
*/
@SuppressWarnings("unchecked")
public static String attributeValueToString(Object attributeValue, String type) throws InternalErrorException {
Attribute a = new Attribute();
a.setType(type);
a.setValue(attributeValue);
return attributeValueToString(a);
}
代码示例来源:origin: CESNET/perun
Attribute loginMu = perun.getAttributesManager().getAttribute(session, user, "urn:perun:user:attribute-def:def:login-namespace:mu");
if (eduroamIdentities.getValue() == null) {
if (loginMu.getValue() != null) {
identities.add(((String)loginMu.getValue())+"@eduroam.muni.cz");
eduroamIdentities.setValue(identities);
if (loginMu.getValue() != null) {
for (String value : (List<String>)eduroamIdentities.getValue()) {
if (Objects.equals(value, ((String)loginMu.getValue())+"@eduroam.muni.cz")) {
found = true;
break;
((List<String>) eduroamIdentities.getValue()).add(((String)loginMu.getValue())+"@eduroam.muni.cz");
代码示例来源:origin: CESNET/perun
boolean found = false;
for (Attribute a : loginAttrs) {
if (pair.getLeft().equals(a.getFriendlyNameParameter())) {
, pair.getRight(), pair.getLeft(), a.getValue());
found = true;
break;
代码示例来源:origin: CESNET/perun
private EmailSCIM getEmail(User perunUser) {
Attribute preferredEmailAttribute = new Attribute();
EmailSCIM email = new EmailSCIM();
try {
preferredEmailAttribute = perunBl.getAttributesManagerBl().getAttribute(session, perunUser, AttributesManager.NS_USER_ATTR_DEF + ":preferredMail");
if (preferredEmailAttribute.getValue() != null) {
email.setValue(preferredEmailAttribute.getValue().toString());
email.setPrimary(true);
email.setType("preferred email");
return email;
}
} catch (InternalErrorException | WrongAttributeAssignmentException ex) {
log.error("Internal exception occured while getting preferred email of user " + perunUser.getId(), ex);
} catch (AttributeNotExistsException ex) {
log.error("Attribute preferredMail doesn't exist for user " + perunUser.getId(), ex);
}
return null;
}
}
代码示例来源:origin: CESNET/perun
if (a != null && "login-namespace".equals(a.getBaseFriendlyName())) {
continue;
if (a.getType().equalsIgnoreCase("java.util.LinkedHashMap")) {
} else if (a.getType().equalsIgnoreCase("java.util.ArrayList") || a.getType().equalsIgnoreCase(BeansUtils.largeArrayListClassName)) {
ArrayList<String> value = ((ArrayList<String>)a.getValue());
a.setValue(value);
attributes.add(a);
continue;
} else {
a.setValue(newValue);
attributes.add(a);
代码示例来源:origin: CESNET/perun
/**
* Add new bonaFideStatus to the user attribute.
*/
@Override
public Application approveApplication(PerunSession session, Application app) throws PerunException {
User user = app.getUser();
Group group = app.getGroup();
AttributesManager am = session.getPerun().getAttributesManager();
Attribute attestation = am.getAttribute(session, group, A_G_D_groupAttestation);
String newValue = attestation.valueAsString();
Attribute bonaFideStatus = am.getAttribute(session, user, A_U_D_userBonaFideStatus);
List<String> value = new ArrayList<>();
if (bonaFideStatus.getValue() != null && bonaFideStatus.valueAsList() != null) {
value = bonaFideStatus.valueAsList();
}
value.add(newValue);
bonaFideStatus.setValue(value);
am.setAttribute(session, user, bonaFideStatus);
return app;
}
代码示例来源:origin: CESNET/perun
/**
* Check if the attribute value contains value. In case of list, it uses method contains. In case of array it searches in both keys and values.
*
* @param value value
* @return true if the attribute value contains value.
*/
@SuppressWarnings("unchecked")
public boolean valueContains(String value) {
if (this.getType().equals(String.class.getName()) || this.getType().equals(BeansUtils.largeStringClassName)) {
return value == null ? this.getValue() == null : value.equals(this.getValue());
} else if (this.getType().equals(ArrayList.class.getName()) || this.getType().equals(BeansUtils.largeArrayListClassName)) {
return this.getValue() == null ? value == null : ((ArrayList<String>) this.getValue()).contains(value);
} else if (this.getType().equals(LinkedHashMap.class.getName())) {
return this.getValue() == null ? value == null :
(((LinkedHashMap<String, String>) this.getValue()).containsKey(value) ||
((LinkedHashMap<String, String>) this.getValue()).containsValue(value));
} else return false;
}
代码示例来源:origin: CESNET/perun
if (MailManagerImpl.URN_USER_PREFERRED_MAIL.equals(a.getName())) {
if (a.getValue() != null && !((String)a.getValue()).isEmpty()) {
String safeMail = ((String) a.getValue()).split("@")[0];
safeMail += "@"+((String) a.getValue()).split("@")[1];
} else if ("urn:perun:user:attribute-def:def:organization".equals(a.getName())) {
if (a.getValue() != null) {
identity.setOrganization((String)a.getValue());
if (uesAttr.getValue() != null && !((String) uesAttr.getValue()).isEmpty()) {
ues.getExtSource().setName((String) uesAttr.getValue());
代码示例来源:origin: CESNET/perun
Matcher uidMatcher = userUidNamespacePattern.matcher(this.attribute.getName());
Matcher loginMatcher = userLoginNamespacePattern.matcher(this.attribute.getName());
if(this.attribute.getName().equals(cz.metacentrum.perun.core.api.AttributesManager.NS_USER_ATTR_DEF + ":" + perunAttrPreferredMail)) {
if(this.attribute.getValue() != null) {
updateUserAttribute(ldapAttrPreferredMail, (String) this.attribute.getValue(), LdapOperation.REPLACE_ATTRIBUTE, user);
updateUserAttribute(ldapAttrMail, (String) this.attribute.getValue(), LdapOperation.REPLACE_ATTRIBUTE, user);
} else {
if(ldapConnector.userAttributeExist(this.user, ldapAttrPreferredMail)) {
} else if(this.attribute.getName().equals(cz.metacentrum.perun.core.api.AttributesManager.NS_USER_ATTR_DEF + ":" + perunAttrOrganization)) {
if(this.attribute.getValue() != null) {
updateUserAttribute(ldapAttrOrganization, (String) attribute.getValue(), LdapOperation.REPLACE_ATTRIBUTE, this.user);
} else {
if(ldapConnector.userAttributeExist(this.user, ldapAttrOrganization)) {
} else if(this.attribute.getName().equals(cz.metacentrum.perun.core.api.AttributesManager.NS_USER_ATTR_DEF + ":" + perunAttrPhone)) {
if(this.attribute.getValue() != null) {
updateUserAttribute(ldapAttrTelephoneNumber, (String) attribute.getValue(), LdapOperation.REPLACE_ATTRIBUTE, this.user);
} else {
if(ldapConnector.userAttributeExist(this.user, ldapAttrTelephoneNumber)) {
} else if(this.attribute.getName().equals(cz.metacentrum.perun.core.api.AttributesManager.NS_USER_ATTR_VIRT + ":" + perunAttrUserCertDNs)) {
Map<String, String> certDNsMap = (this.attribute.getValue() != null) ? (Map) this.attribute.getValue() : null;
Set<String> certSubjectsWithPrefixes = ((Map) this.attribute.getValue()).keySet();
Set<String> certSubjectsWithoutPrefixes = new HashSet<>();
代码示例来源:origin: CESNET/perun
User user = perun.getUsersManagerBl().getUserById(session, id);
Attribute emailAttribute = perun.getAttributesManagerBl().getAttribute(session, user, "urn:perun:user:attribute-def:def:preferredMail");
if (emailAttribute != null && StringUtils.hasText(emailAttribute.toString())) {
emailDto.setReceiver((String) emailAttribute.getValue());
代码示例来源:origin: CESNET/perun
public void updatePriorityCoefficient(PerunSession sess, Integer userId, Double rank) throws CabinetException {
try {
// get definition
AttributeDefinition attrDef = perun.getAttributesManager().getAttributeDefinition(cabinetSession, ATTR_COEF_NAMESPACE+":"+ATTR_COEF_FRIENDLY_NAME);
// Set attribute value
Attribute attr = new Attribute(attrDef);
DecimalFormat twoDForm = new DecimalFormat("#.##");
attr.setValue(String.valueOf(twoDForm.format(rank)));
// get user
User user = perun.getUsersManager().getUserById(cabinetSession, userId);
// assign or update user's attribute
perun.getAttributesManager().setAttribute(cabinetSession, user, attr);
} catch (PerunException e) {
throw new CabinetException("Failed to update priority coefficient in Perun.",ErrorCodes.PERUN_EXCEPTION, e);
}
}
代码示例来源:origin: CESNET/perun
if (affiliations.getValue() != null) {
List<String> val = affiliations.valueAsList();
for (String affiliation: val) {
if (affiliation.startsWith("faculty@")) {
if (rems.getValue() != null) {
return;
代码示例来源:origin: CESNET/perun
/**
* Get list of Attributes from list of AttributeHolders
* Used in CacheManager to transform result of query (list of AttributeHolders) to list of Attributes.
*
* @param attrHolders list of AttributeHolders
* @return list of Attributes
*/
public static List<Attribute> getAttributesFromAttributeHolders(List<AttributeHolders> attrHolders) {
List<Attribute> attrs = new ArrayList<>();
for (AttributeHolders attrHolder: attrHolders) {
attrs.add(new Attribute(attrHolder, true));
}
return attrs;
}
代码示例来源:origin: CESNET/perun
public AttributeHolders(Attribute attribute, Holder primaryHolder, Holder secondaryHolder, SavedBy savedBy) throws InternalErrorException {
super(attribute, true);
if (primaryHolder != null && secondaryHolder != null) {
if (secondaryHolder.getType().equals(Holder.HolderType.GROUP) && (!primaryHolder.getType().equals(Holder.HolderType.MEMBER))
|| (secondaryHolder.getType().equals(Holder.HolderType.MEMBER))
|| (secondaryHolder.getType().equals(Holder.HolderType.USER))) {
this.primaryHolder = secondaryHolder;
this.secondaryHolder = primaryHolder;
}
else {
this.primaryHolder = primaryHolder;
this.secondaryHolder = secondaryHolder;
}
}
else {
this.primaryHolder = primaryHolder;
this.secondaryHolder = secondaryHolder;
}
this.nameForSearch = attribute.getNamespace() + ":" + attribute.getFriendlyName();
this.namespaceForSearch = attribute.getNamespace();
this.friendlyNameForSearch = attribute.getFriendlyName();
this.typeForSearch = attribute.getType();
this.idForSearch = attribute.getId();
this.valueForSearch = BeansUtils.attributeValueToString(attribute);
this.savedBy = savedBy;
}
代码示例来源:origin: CESNET/perun
/**
* Creates Attribute instance from an AttributeDefinition and a value.
*/
public Attribute(AttributeDefinition attributeDefinition, Object value) {
this(attributeDefinition);
this.setValue(value);
}
内容来源于网络,如有侵权,请联系作者删除!