if (childPath == null || childPath.length() == 0) {
continue;
}
Resource child = registry.get(childPath);
ResourceData resourceData = new ResourceData();
resourceData.setResourcePath(childPath); // + RegistryConstants.VIEW_ACTION);
String[] parts = childPath.split(RegistryConstants.PATH_SEPARATOR);
if (parts.length > 0) {
resourceData.setName(parts[parts.length - 1]);
}
resourceData.setResourceType(child instanceof Collection ?
CommonConstants.COLLECTION : CommonConstants.RESOURCE);
resourceData.setAuthorUserName(child.getAuthorUserName());
resourceData.setDescription(child.getDescription());
resourceData.setAverageRating(registry.getAverageRating(child.getPath()));
Calendar createDateTime = Calendar.getInstance();
createDateTime.setTime(child.getCreatedTime());
resourceData.setCreatedOn(createDateTime);
List mountPoints = child.getPropertyValues("registry.mountpoint");
List targetPoints = child.getPropertyValues("registry.targetpoint");
// List paths = child.getPropertyValues("registry.path");
List actualPaths = child.getPropertyValues("registry.actualpath");
String user = child.getProperty("registry.user");
if (child.getProperty("registry.mount") != null) {
resourceData.setMounted(true);
}
if (child.getProperty("registry.link") != null) {
resourceData.setLink(true);
if(mountPoints != null && targetPoints != null) {
// String mountPoint = (String)mountPoints.get(0);
// String targetPoint = (String)targetPoints.get(0);
// String tempPath;
// if (targetPoint.equals(RegistryConstants.PATH_SEPARATOR) && !childPath.equals(mountPoint)) {
// tempPath = ((String)paths.get(0)).substring(mountPoint.length());
// } else {
// tempPath = targetPoint + ((String)paths.get(0)).substring(mountPoint.length());
// }
String tempPath = (String)actualPaths.get(0);
resourceData.setPutAllowed(
UserUtil.isPutAllowed(registry.getUserName(), tempPath, registry));
resourceData.setDeleteAllowed(UserUtil.isDeleteAllowed(registry.getUserName(),
tempPath, registry));
resourceData.setGetAllowed(UserUtil.isGetAllowed(registry.getUserName(), tempPath, registry));
resourceData.setRealPath(tempPath);
} else if (user != null) {
if (registry.getUserName().equals(user)) {
resourceData.setPutAllowed(true);
resourceData.setDeleteAllowed(true);
resourceData.setGetAllowed(true);
} else {
resourceData.setPutAllowed(
UserUtil.isPutAllowed(registry.getUserName(), childPath, registry));
resourceData.setDeleteAllowed(
UserUtil.isDeleteAllowed(registry.getUserName(), childPath, registry));
resourceData.setGetAllowed(
UserUtil.isGetAllowed(registry.getUserName(), childPath, registry));
}
// Mounted resources should be accessed via the link, and we need not set
// the real path.
}
} else {
resourceData.setPutAllowed(
UserUtil.isPutAllowed(registry.getUserName(), childPath, registry));
resourceData.setDeleteAllowed(
UserUtil.isDeleteAllowed(registry.getUserName(), childPath, registry));
resourceData.setGetAllowed(
UserUtil.isGetAllowed(registry.getUserName(), childPath, registry));
}
calculateAverageStars(resourceData);
if(child.getProperty("registry.externalLink") != null) {
resourceData.setExternalLink(true);
}
if(child.getProperty("registry.absent") != null){
resourceData.setAbsent(child.getProperty("registry.absent"));
}
resourceDataList.add(resourceData);
} catch (AuthorizationFailedException ignore) {
// if we get an auth failed exception while accessing a child, we simply skip it.