@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); } }
for (ArchiveContentPartFacade part : root.getParts()) { String discriminatedPath = BasicPackConstants.NEW_CONTENT_DIRECTORY + pathDispather.dispatch( rootPath) + BasicPackConstants.DIRECTORY_SEPARATOR
@Override public UserProfile getUserProfile(String userId) { try { ArchiveObjectFacade archiveObject = archive.getObjectWithAllParts(new YaddaObjectID(userId), false); if (archiveObject.getStatus().isDeleted()) { return null; } UserProfile userProfile = new UserProfile(); userProfile.setUserId(archiveObject.getId().getId()); Collection<ArchiveContentPartFacade> archiveParts = archiveObject.getParts(); Set<String> parts = new HashSet<String>(); for (ArchiveContentPartFacade archivePart : archiveParts) { parts.add(archivePart.getType()); } userProfile.setAvailableParts(parts); return userProfile; } catch (NotFoundException e) { // OK profile not found so part is null return null; } catch (ServiceException e) { String message = "Fetching user profile for user " + userId + " not successfull."; logger.error(message, e); throw new RuntimeException(message, e); } }
@Override public Set<DocumentAttachment> call() throws Exception { ArchiveObjectPath archivePath = ArchiveObjectPath.decode(path); ArchiveObject2Meta aObject = archiveFacadeProvider.getArchiveFacade().queryUniqueObject(archivePath, true); if (aObject == null) { throw new InvalidAttachmentException(path, "Attachment not available "); } ArchiveObjectFacade objectFacade = archiveFacadeProvider.getArchiveFacade().getObjectWithAllParts(aObject.getId(), true); Set<DocumentAttachment> attachments = new HashSet<DocumentAttachment>(); Collection<ArchiveContentPartFacade> parts = objectFacade.getParts(); try { for (ArchiveContentPartFacade partFacade : parts) { byte[] bytes = IOUtils.toByteArray(partFacade.getData()); DocumentAttachment documentAttachment = new DocumentAttachment(parent, partFacade.getId(), partFacade.getId(), partFacade.getSize(), partFacade.getMime(), bytes, false); documentAttachment.getProperties().put(ImporterConstants.PROPERTY_REMOTE_SOURCE_URL, path); attachments.add(documentAttachment); } } finally { closeFacades(parts); } return attachments; }