@Override public boolean removeProfilePart(String userId, String partType) { boolean partExists = false; try { ArchiveObjectFacade archiveObject; archiveObject = archive.getObjectWithAllParts(new YaddaObjectID(userId), false); Collection<ArchiveContentPartFacade> archiveParts = archiveObject.getParts(); for (ArchiveContentPartFacade archivePart : archiveParts) { if (archivePart.getType().equals(partType)) { partExists = true; archiveParts.remove(archivePart); break; } } if (partExists) { storage.saveObject(generateStorePath(userId), archiveObject, new String[] { partType }, null); } return partExists; } catch (NotFoundException e) { return partExists; } catch (ServiceException e) { String message = "Fetching user profile for user " + userId + " not successfull."; logger.error(message, e); throw new RuntimeException(message, e); } }
@Override public void addProfilePart(String userId, ProfilePart part) throws UserProfileNotFoundException { try { ArchiveObjectFacade archiveObject; archiveObject = archive.getObject(new YaddaObjectID(userId), null, false); archiveObject.addPart(part.getType(), USER_PROFILE_PART_GENERIC_MIMETYPE, new ByteArrayInputStream(part.getContent())); storage.saveObject(generateStorePath(userId), archiveObject, null, null); } catch (NotFoundException e) { logger.error("User profile for user " + userId + " does not exist.", e); throw new UserProfileNotFoundException(userId); } catch (ServiceException e) { String message = "Fetching user profile for user " + userId + " not successfull."; logger.error(message, e); throw new RuntimeException(message, e); } }
@Override public boolean addUserProfile(String userId) { try { archive.getObject(new YaddaObjectID(userId), null, false); return false; } catch (NotFoundException e) { ArchiveObjectFacade archiveObject; archiveObject = new ArchiveObjectFacade(); archiveObject.setId(new YaddaObjectID(userId)); archiveObject.setType(USER_PROFILE_TYPE); try { storage.saveObject(generateStorePath(userId), archiveObject, null, null); } catch (ServiceException e1) { String message = "Adding user profile for user " + userId + " not successfull."; logger.error(message, e1); throw new RuntimeException(message, e1); } return true; } catch (ServiceException e) { String message = "Fetching user profile for user " + userId + " not successfull."; logger.error(message, e); throw new RuntimeException(message, e); } }
new ArchiveObject2Meta(SYSTEM_OBJECT_PATH.getRootId(), SYSTEM_OBJECT_TYPE, "nothing", null)); storageFacade.saveObject(SYSTEM_OBJECT_PATH.encode(), object, null, null); new ArchiveObject2Meta(new YaddaObjectID(new UUIDGenerator().generate(null)), ERROR_DUMPS_TYPE, "nothing", null)); storageFacade.saveObject(ERROR_DUMP_OBJECT_PATH.encode(), object, null, null); storageFacade.saveObject(path.encode(), object, null, null);