*/
public static PropertiesBean populate(UserRegistry registry, String path, String viewProps)
throws RegistryException {
Resource resource = registry.get(path);
ResourcePath resourcePath = new ResourcePath(path);
PropertiesBean propertiesBean = new PropertiesBean();
boolean isPutAllowed = false;
Properties properties = resource.getProperties();
Set keySet = properties.keySet();
Property [] propArray;
if(keySet.size() != 0) {
Object [] keys = keySet.toArray();
List values;
propArray = new Property [keys.length];
for (int i=0; i<keys.length; i++) {
Property prop = new Property();
prop.setKey((String) keys[i]);
values = (List) properties.get((String)keys[i]);
prop.setValue((String) values.get(0));
propArray[i] = prop;
if (keys[i].equals("registry.link") &&
values.get(0).equals("true")) {
isPutAllowed = true;
}
}
} else {
propArray = new Property [0];
}
propertiesBean.setProperties(propArray);
Boolean viewSysProps = false;
if(viewProps.equalsIgnoreCase("yes")) {
viewSysProps = true;
}
Iterator iTmpProps = resource.getProperties().keySet().iterator();
List<String> sysProperties = new ArrayList<String>();
List <String> validationProperties = new ArrayList <String> ();
List <String> lifecycleProperties = new ArrayList <String> ();
while (iTmpProps.hasNext()) {
String name = (String) iTmpProps.next();
if ((viewSysProps != null && viewSysProps) || !name.startsWith("registry.")) {
sysProperties.add(name);
}
if (name.startsWith("registry.wsdl") || name.startsWith("registry.wsi")) {
validationProperties.add(name);
} else if (name.startsWith("registry.lifecycle.") ||
name.equals(Aspect.AVAILABLE_ASPECTS)) {
lifecycleProperties.add(name);
}
}
Collections.sort(sysProperties);
String [] sysProps = new String [sysProperties.size()];
for(int i=0; i<sysProperties.size(); i++) {
sysProps[i] = sysProperties.get(i);
}
propertiesBean.setSysProperties(sysProps);
String [] validationProps = new String [validationProperties.size()];
for(int i=0; i<validationProperties.size(); i++) {
validationProps[i] = validationProperties.get(i);
}
propertiesBean.setValidationProperties(validationProps);
String [] lifecycleProps = new String [lifecycleProperties.size()];
for(int i=0; i<lifecycleProperties.size(); i++) {
lifecycleProps[i] = lifecycleProperties.get(i);
}
propertiesBean.setLifecycleProperties(lifecycleProps);
propertiesBean.setVersionView(!resourcePath.isCurrentVersion());
propertiesBean.setPathWithVersion(resourcePath.getPathWithVersion());
if (!isPutAllowed) {
isPutAllowed = UserUtil.isPutAllowed(registry.getUserName(), path, registry);
}
propertiesBean.setPutAllowed(isPutAllowed);
propertiesBean.setLoggedIn(!RegistryConstants.ANONYMOUS_USER.equals(registry.getUserName()));
return propertiesBean;
}