ArchiveContentPartFacade currentPart = currentObjFacade.getPart(partName); if (currentPart!=null) { if (regexpPattern==null || Pattern.matches(regexpPattern, currentObjFacade.getParentRelationName())) { logger.info("parsing document: " + currentPart.getId() + ", parent relation name: " + currentObjFacade.getParentRelationName()); InputStream inputStream = currentPart.getData(); try { if (policyFileNamesByID.get(policyId) != null) { throw new DataAdapterException("The policy loaded from '" + currentObjFacade.getParentRelationName() + "' with ID<" + policyId + "> already exists."); policyFileNamesByID.put(policyId, currentObjFacade.getParentRelationName()); DataAdapter da = createPolicyDataAdapterFromXMLElement(root); DataAdapter daGenFromEngineElem = (DataAdapter)cons.newInstance(engineElem); logger.debug("Dump policy loaded from '" + currentObjFacade.getParentRelationName() + "': " + getNodeXMLText((Element)daGenFromEngineElem.getDataStoreObject())); if (e instanceof XMLGeneralException || e instanceof PolicySyntaxException) { logger.warn("Could not load file '" + currentObjFacade.getParentRelationName() + "' since it is not a valid policy file.", e); currentObjFacade.getParentRelationName(), e);
/** * 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); }
for (Map.Entry<String, List<YaddaObjectID>> entry : root.getChildren().entrySet()) { for (YaddaObjectID child : entry.getValue()) { processArchiveChild(child, rootPath String path = root.getPath(); logger.debug("getPath= "+path); for (ArchiveContentPartFacade part : root.getParts()) { String discriminatedPath = BasicPackConstants.NEW_CONTENT_DIRECTORY + pathDispather.dispatch( rootPath) + BasicPackConstants.DIRECTORY_SEPARATOR
@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); } }
public List<String> listErrorDumps() throws Exception { ArchiveObject2Meta dumpDirectoryMeta = archiveFacade.queryUniqueObject(ERROR_DUMP_OBJECT_PATH, true); if (dumpDirectoryMeta == null) return Collections.emptyList(); ArchiveObjectFacade dumpDirectory = archiveFacade.getObject(dumpDirectoryMeta.getId(), null, true); List<String> dumpList = new LinkedList<String>(); for (Map.Entry<String, List<YaddaObjectID>> children : dumpDirectory.getChildren().entrySet()) { for (YaddaObjectID child : children.getValue()) { ArchiveObjectFacade childObject = archiveFacade.getObject(child, null, false); if (!childObject.getStatus().isDeleted()) { ArchiveObjectPath dumpPath = new ArchiveObjectPath(ERROR_DUMP_OBJECT_PATH, children.getKey()); dumpList.add(dumpPath.encode()); } } } return dumpList; }
@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); } }
ArchiveObjectFacade object = new ArchiveObjectFacade( new ArchiveObject2Meta(SYSTEM_OBJECT_PATH.getRootId(), SYSTEM_OBJECT_TYPE, "nothing", null)); ArchiveObjectFacade object = new ArchiveObjectFacade( new ArchiveObject2Meta(new YaddaObjectID(new UUIDGenerator().generate(null)), ERROR_DUMPS_TYPE, "nothing", null)); ArchiveObjectFacade object = new ArchiveObjectFacade( new ArchiveObject2Meta(new YaddaObjectID(id), ERROR_DUMP_TYPE, "nothing", null)); object.addPart(PART_TYPE_DUMP, MIME_JAVA_SERIALIZED_OBJECT , dumpIs);
ArchiveContentPartFacade p = o.getPart(ArchiveParamConstants.PART_TYPE_MAIN); is = p.getData(); String relPath = yar.substring(ARCHIVE_PREFIX.length());
". Already existing tags: " + logArrayContent(meta.getTags())); ArchiveObjectFacade archObjFacade = new ArchiveObjectFacade(meta); archObjFacade.setTags(tagOp.getTagsToAdd()); result.add(storageFacade.buildSaveOperation( uri, archObjFacade, null, tagOp.getTagsToRemove()));
@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 ProfilePart getProfilePart(String userId, String partType) { try { ArchiveObjectFacade archiveObject = archive.getObjectWithAllParts(new YaddaObjectID(userId), false); ArchiveContentPartFacade archivePart = archiveObject.getPart(partType); if (archivePart != null) { ProfilePart profilePart = new ProfilePart(); profilePart.setType(archivePart.getType()); try { profilePart.setContent(IOUtils.toByteArray(archivePart.getData())); } catch (IOException e) { String message = "Setting part with part type " + partType + " to user profile for user " + userId + " not successfull."; logger.error(message, e); throw new RuntimeException(message, e); } return profilePart; } else { return null; } } 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; }
if (alreadyExistingNode==null) { log.debug("registering node: " + currentPath); ArchiveObjectFacade meta = new ArchiveObjectFacade(); if (i==0) { meta.setId(rootPath.getRootId()); } else { meta.setId(new YaddaObjectID(new UUIDGenerator().generate(null))); meta.setType(ArchiveParamConstants.OBJECT_TYPE_DIRECTORY); meta.setTags(auxiliaryTags); meta.setParentId(lastParent); Save2Operation saveOp = storageFacade.buildSaveOperation( currentPath, meta, null, null); if (alreadyExistingNode==null) { log.debug("registering node: " + currentYarFilePath); ArchiveObjectFacade meta = new ArchiveObjectFacade(); meta.setId(new YaddaObjectID(new UUIDGenerator().generate(null))); meta.setType(ArchiveParamConstants.OBJECT_TYPE_DIRECTORY); meta.setTags(auxiliaryTags); meta.setParentId(localLastParent); Save2Operation saveOp = storageFacade.buildSaveOperation( currentYarFilePath, meta, null, null);