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; }
public void doTest() throws Exception { CountingIterator<ArchiveObject2Meta> it = archiveFacade.listObjects(null, null, null, false); InputStream is = archiveFacade.fetchPartContent(uri, FTXT_PART_TYPE);
@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); } }
archiveFacade.getArchiveId() + " and path: " + sourceYarPath); ArchiveObject2Meta parentMeta = archiveFacade.queryUniqueObject( sourceYarPath, true); if (parentMeta==null) { logger.error("no parent meta entry for" + " archive path:" + sourceYarPath + " ,archive id: " + archiveFacade.getArchiveId()); return new DataAdapter[0]; ArchiveObjectFacade archObjFacade = archiveFacade.getObject( parentMeta.getId(), new String[] {partName}, true);
public ArchiveObject2Meta next() { String loc = iter.next(); try { currentLoc= loc; ArchiveObject2Meta object = archiveFacade2.queryUniqueObject(loc, true); if (object == null) { logger.error("Unexpected problem: no conent found under address: " + loc); throw new MissingContentRuntimeException(loc); } return object; } catch (Exception ex) { logger.error("Unexpected problem: exception reading content under address: " + loc, ex); throw new MissingContentRuntimeException(loc); } }
@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; }
/** * Finds collection id in archive object. * @param archiveObjId * @return collection id * @throws IndeterminateException */ protected String findCollectionTagInArchive(String archiveObjId) throws IndeterminateException { try { ArchiveObjectFacade archObjFacade = archiveFacade.getObject( new YaddaObjectID(archiveObjId), new String[0], false); for (String currentTag : archObjFacade.getTags()) { if (currentTag.startsWith(ACLConstants.COLLECTION_TAG_PREFIX)) { return currentTag; } } return null; } catch (ServiceException e) { throw new IndeterminateException("exception occured when " + "finding archive object for id: " + archiveObjId, e); } }
for (YaddaObjectID childSubId : currentObjFacade.getChildren().get(currentChildKey)) { try { ArchiveObjectFacade childObjFacade = archiveFacade.getObject( childSubId, new String[] {partName}, true); harvestPolicies(childObjFacade, policies, " parent relation name:" + currentObjFacade.getParentRelationName() + " ,part name: " + partName + " ,archive id: " + archiveFacade.getArchiveId());
public ChunkErrorDump fetchDump(String dumpId) throws Exception { InputStream is = archiveFacade.fetchPartContent(dumpId, PART_TYPE_DUMP); if (is == null) return null; ObjectInputStream ois = new ObjectInputStream(is); ChunkErrorDump result = (ChunkErrorDump)ois.readObject(); ois.close(); return result; }
@Override protected void processContentFile(String addr, InputStream is, Set<String> tags, boolean closeStream) throws Exception { String ext = contentPathToExtension(addr); String mime = MimeTypeHelper.getTypeForExtension(ext); if (mime == null) { mime = MimeTypeHelper.MIME_UNKNOWN; } String uri = contentPathToArchiveUri(addr); // Object already exists and we don't want to overwrite it if ((overwriteMode == OverwriteMode.NEVER) && (archiveFacade2.queryObjects(uri, false).hasNext())) { return; } archiveTransaction.storeData(uri, mime, is, tags.toArray(new String[tags.size()]), closeStream); archiveObjectsInTransaction++; flushIfNecessary(); }
logger.info("Exporting whole archive."); objects = archiveFacade2.listObjects(null, null, new String[0][0], false, true);
public void removeDump(String dumpId) throws Exception { ArchiveObject2Meta dumpMeta = archiveFacade.queryUniqueObject(dumpId, false); if (dumpMeta == null) return; storageFacade.deleteObject(dumpMeta.getId()); }
@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); } }
final InputStream is = archiveFacade.fetchPartContent(ftxtUri, FTXT_PART_TYPE);
archiveFacade.queryObjects(uri, true); if (metasIt!=null) { while (metasIt.hasNext()) {
ArchiveObject2Meta meta = ossf.queryUniqueObject(yar, true); ArchiveObjectFacade o = ossf.getObject(meta.getId(), new String[] {ArchiveParamConstants.PART_TYPE_MAIN}, false); ArchiveContentPartFacade p = o.getPart(ArchiveParamConstants.PART_TYPE_MAIN); is = p.getData();
InputType.IDENTIFIER, filteringContext)); archiveFacade.queryUniqueObject(loc, true); } catch (ServiceException e) { log.error("No access rights for element in location=" + loc);
@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); } }
@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); } }
InputStream is = archiveFacade.fetchPartContent(ftxtUri, FTXT_PART_TYPE);