@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); } }
object.addPart(PART_TYPE_DUMP, MIME_JAVA_SERIALIZED_OBJECT , dumpIs);
/** * Registers single file content into given storage location using parent and tags. * Returns {@link YaddaObjectID} of registered document. * @param file * @param yarPath * @param parentId * @param tags * @return {@link YaddaObjectID} of registered document * @throws ServiceException * @throws FileNotFoundException */ protected YaddaObjectID registerFile(File file, String yarPath, YaddaObjectID parentId, String[] tags) throws ServiceException, FileNotFoundException { ArchiveObjectFacade currentPolicyMeta = new ArchiveObjectFacade(); currentPolicyMeta.setId(new YaddaObjectID(new UUIDGenerator().generate(null))); currentPolicyMeta.setType(ArchiveParamConstants.OBJECT_TYPE_FILE); currentPolicyMeta.setParentId(parentId); currentPolicyMeta.setTags(tags); currentPolicyMeta.addPart(predefinedPartType, predefinedMimeType, new FileInputStream(file)); StorageOperation currentOp = storageFacade.buildSaveOperation( yarPath, currentPolicyMeta, null, null); return storageFacade.executeOperation(currentOp); }