// 2. store sets
ResourceSet resourceCollector = new DefaultResourceSet();
ResourceSetDTO[] resourceSetDTOs = new ResourceSetDTO[resourceSetCollector
.getResourceSets().size()];
for (int i = 0; i < resourceSetCollector.getResourceSets().size(); i++) {
ResourceSetDTO dto = new ResourceSetDTO();
ResourceSet resourceSet = resourceSetCollector.getResourceSets()
.get(i);
if (resourceSet.hasLabel()) {
dto.setLabel(resourceSet.getLabel());
}
dto.setId(i);
if (resourceSet instanceof UnmodifiableResourceSet) {
ResourceSet sourceSet = ((UnmodifiableResourceSet) resourceSet)
.getDelegate();
dto.setDelegateSetId(resourceSetCollector
.storeResourceSet(sourceSet));
} else {
List<String> resourceIds = new ArrayList<String>();
for (Resource resource : resourceSet) {
resourceCollector.add(resource);
resourceIds.add(resource.getUri());
}
dto.setResourceIds(resourceIds);
}
resourceSetDTOs[i] = dto;
}
workspaceDTO.setResourceSets(resourceSetDTOs);