private static void copyCategoryDescriptors(DeviceTransferAccessor srcAccessor,
DeviceTransferAccessor dstAccessor)
throws RepositoryException {
// Now loop over all the source category names, copying the related
// category descriptors from the source to the destination.
RepositoryEnumeration names = srcAccessor.enumerateCategoryNames();
try {
while (names.hasNext()) {
String categoryName = (String) names.next();
if (logger.isDebugEnabled()) {
logger.debug("Copying category descriptor " +
"for '" + categoryName + "'");
}
// Read the descriptors from the source for this policy.
List categoryDescriptors;
try {
categoryDescriptors =
srcAccessor.retrieveCategoryDescriptors(
categoryName);
} catch (RepositoryException e) {
throw new RepositoryException(
exceptionLocalizer.format(
"cannot-read-category-descriptor", categoryName),
e);
}
for (Iterator iter = categoryDescriptors.iterator();
iter.hasNext();) {
final CategoryDescriptor categoryDescriptor =
(CategoryDescriptor) iter.next();
// Write the descriptors to the destination for this
// category.
try {
dstAccessor.addCategoryDescriptor(
categoryName, categoryDescriptor);
} catch (RepositoryException e) {
throw new RepositoryException(
exceptionLocalizer.format(
"cannot-write-policy-descriptor",
new Object[]{categoryName, categoryDescriptor}), e);
}
}
}
} finally {
names.close();
}
}