private void quickRestoreCategory(RESTBackupCategory rbc) throws BadRequestServiceEx, NotFoundServiceEx, DuplicatedResourceNameServiceEx { LOGGER.info("Restoring category: " + rbc.getName()); Category cat = rbc2cat(rbc); long catId = categoryService.insert(cat); // TODO: cat auth for (RESTBackupResource rbr : rbc.getResources()) { if (LOGGER.isInfoEnabled()) { int attnum = (rbr != null && rbr.getResource() != null && rbr.getResource() .getAttribute() != null) ? rbr.getResource().getAttribute().size() : -1; LOGGER.info("Restoring resource: " + cat.getName() + ":" + rbr.getResource().getName() + " (" + attnum + " attrs)"); } Resource res = rbr2res(rbr, catId); resourceService.insert(res); // TODO: res auth } }
if (resource.getAttribute() == null) { if (LOGGER.isDebugEnabled()) LOGGER.debug("Attribute list is null: no change in the attrib list"); } else { if (LOGGER.isDebugEnabled()) LOGGER.debug("Attribute list is " + resource.getAttribute().size()); List<Attribute> attributes = Convert.convertAttributeList(resource .getAttribute()); resourceService.updateAttributes(id, attributes);
public static Resource convertResource(RESTResource resource) { Category category = new Category(); if (resource.getCategory().getName() != null) category.setName(resource.getCategory().getName()); if (resource.getCategory().getId() != null) category.setId(resource.getCategory().getId()); Resource r = new Resource(); r.setDescription(resource.getDescription()); r.setMetadata(resource.getMetadata()); r.setName(resource.getName()); r.setCategory(category); // Parsing Attributes list if (CollectionUtils.isNotEmpty(resource.getAttribute())) { List<Attribute> attributes = Convert.convertAttributeList(resource.getAttribute()); r.setAttribute(attributes); } RESTStoredData dataDto = resource.getStore(); if (dataDto != null) { StoredData data = new StoredData(); data.setData(dataDto.getData()); r.setData(data); } return r; }