UserProperties userProperties = (UserProperties)userPropertiesListIterator.next();
if(userProperties != null && userProperties.getLanguage().getLanguageId().equals(languageId) && userProperties.getValue() != null && propertyName != null)
{
String propertyXML = userProperties.getValue();
DOMBuilder domBuilder = new DOMBuilder();
Document document = domBuilder.getDocument(propertyXML);
Node node = document.getRootElement().selectSingleNode("attributes/" + propertyName);
if(node != null)
{
value = node.getStringValue();
logger.info("Getting value: " + value);
if(value != null && escapeSpecialCharacters)
value = new VisualFormatter().escapeHTML(value);
break;
}
}
}
if(value.equals(""))
{
List roles = infoGluePrincipal.getRoles();
String largestValue = "-1";
String prioValue = null;
int latestPriority = 0;
Iterator rolesIterator = roles.iterator();
while(rolesIterator.hasNext())
{
InfoGlueRole role = (InfoGlueRole)rolesIterator.next();
Collection rolePropertiesList = RolePropertiesController.getController().getRolePropertiesList(role.getName(), languageId, db, true);
Iterator rolePropertiesListIterator = rolePropertiesList.iterator();
while(rolePropertiesListIterator.hasNext())
{
RoleProperties roleProperties = (RoleProperties)rolePropertiesListIterator.next();
if(roleProperties != null && roleProperties.getLanguage().getLanguageId().equals(languageId) && roleProperties.getValue() != null && propertyName != null)
{
String propertyXML = roleProperties.getValue();
DOMBuilder domBuilder = new DOMBuilder();
Document document = domBuilder.getDocument(propertyXML);
Node propertyPriorityNode = document.getRootElement().selectSingleNode("attributes/PropertyPriority");
int currentPriority = 0;
if(propertyPriorityNode != null)
{
try
{
String propertyPriorityValue = propertyPriorityNode.getStringValue();
logger.info("propertyPriorityValue:" + propertyPriorityValue);
if(propertyPriorityValue != null && !propertyPriorityValue.equals(""))
currentPriority = new Integer(propertyPriorityValue);
}
catch (Exception e)
{
e.printStackTrace();
}
}
Node node = document.getRootElement().selectSingleNode("attributes/" + propertyName);
if(node != null)
{
value = node.getStringValue();
logger.info("Getting value: " + value);
if(value != null && escapeSpecialCharacters)
value = new VisualFormatter().escapeHTML(value);
if(value != null && !value.equals("") && findLargestValue && new Integer(largestValue).intValue() < new Integer(value).intValue())
largestValue = value;
logger.info("" + findLargestValue + ":" + findPrioValue + ":" + currentPriority + "=" + latestPriority);
if(value != null && !value.equals("") && !findLargestValue && findPrioValue && currentPriority > latestPriority)
{
logger.info("Using other value..");
prioValue = value;
latestPriority = currentPriority;
}
break;
}
}
}
}
if(findLargestValue)
value = largestValue;
if(findPrioValue && prioValue != null)
{
value = prioValue;
logger.info("Using prio value");
}
if(value.equals("") && useLanguageFallback)
{
LanguageVO masterLanguageVO = LanguageDeliveryController.getLanguageDeliveryController().getMasterLanguageForSiteNode(db, siteNodeId);
if(!masterLanguageVO.getLanguageId().equals(languageId))
value = getPrincipalPropertyValue(infoGluePrincipal, propertyName, masterLanguageVO.getLanguageId(), siteNodeId, useLanguageFallback, escapeSpecialCharacters, findLargestValue);
}
}
if(value.equals(""))
{
List groups = infoGluePrincipal.getGroups();
String largestValue = "-1";
String prioValue = null;
int latestPriority = 0;
Iterator groupsIterator = groups.iterator();
while(groupsIterator.hasNext())
{
InfoGlueGroup group = (InfoGlueGroup)groupsIterator.next();
Collection groupPropertiesList = GroupPropertiesController.getController().getGroupPropertiesList(group.getName(), languageId, db, true);
Iterator groupPropertiesListIterator = groupPropertiesList.iterator();
while(groupPropertiesListIterator.hasNext())
{
GroupProperties groupProperties = (GroupProperties)groupPropertiesListIterator.next();
if(groupProperties != null && groupProperties.getLanguage().getLanguageId().equals(languageId) && groupProperties.getValue() != null && propertyName != null)
{
String propertyXML = groupProperties.getValue();
DOMBuilder domBuilder = new DOMBuilder();
Document document = domBuilder.getDocument(propertyXML);
Node propertyPriorityNode = document.getRootElement().selectSingleNode("attributes/PropertyPriority");
int currentPriority = 0;
if(propertyPriorityNode != null)
{