/** * Returns a path to the parent of the current object * * @return */ public ArchiveObjectPath getParent() { if (path.length > 0) { return new ArchiveObjectPath(rootId, (String[]) ArrayUtils .subarray(path, 0, path.length - 1)); } else return null; }
protected String contentPathToArchiveUri(String addr) throws Exception { String[] chunks = StringUtils.split(addr, "\\/"); List<String> chunkList = new LinkedList<String>(); boolean wasFirst = false; for (String chunk : chunks) { if (wasFirst && !chunk.startsWith("dsc_")) { chunkList.add(chunk); } wasFirst = true; } String firstChunk = chunkList.get(0); chunkList.remove(0); String[] internalChunks = chunkList .toArray(new String[chunkList.size()]); ArchiveObjectPath path = new ArchiveObjectPath(new YaddaObjectID( firstChunk), internalChunks); return path.encode(); }
ContentFileBuilder location(String articleId, String fileName) { if(StringUtils.isNotEmpty(fileName)){ fileName = fileName.replaceAll("\\s+",CS.UNDERSCORE); } final String originalFilename = fileName; ArchiveObjectPath path = new ArchiveObjectPath(new YaddaObjectID(articleId), new String[]{FileTypes.FT_FULL_TEXT, originalFilename}); this.location = path.encode(); return this; }
/** * Creates a path object from an URI * * @param uri * @return * @throws URISyntaxException * @throws ServiceException */ public static ArchiveObjectPath decode(String uri) throws URISyntaxException, ServiceException { URI decodedUri = new URI(uri).normalize(); if (!URI_SCHEME.equals(decodedUri.getScheme())) throw new ServiceException("Malformed object id " + uri); String[] pathParts = StringUtils.split(decodedUri.getPath(), "/"); String rootId = decodedUri.getAuthority(); YaddaObjectID id = null; if (StringUtils.contains(rootId, ";")) { String[] idParts = StringUtils.split(rootId, ";"); if (idParts.length != 3) throw new ServiceException("Malformed object id " + uri); id = new YaddaObjectID(idParts[0], idParts[2], idParts[1]); } else { id = new YaddaObjectID(rootId); } ArchiveObjectPath path = new ArchiveObjectPath(id, pathParts); return path; }
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 String contentPathToArchiveUri(String addr) throws Exception { if (isAlreadyArchiveUri(addr)) { return addr; } String[] chunks = StringUtils.split(addr, "\\/"); boolean isNewPath = chunks[0].equalsIgnoreCase(BasicPackConstants.NEW_CONTENT_DIRECTORY); if (isNewPath) { List<String> chunkList = new LinkedList<String>(); boolean wasFirst = false; for (String chunk : chunks) { if (wasFirst && !chunk.startsWith("dsc_")) { chunkList.add(chunk); } wasFirst = true; } String firstChunk = chunkList.get(0); chunkList.remove(0); String[] internalChunks = chunkList.toArray(new String[chunkList.size()]); ArchiveObjectPath path = new ArchiveObjectPath(new YaddaObjectID(firstChunk), internalChunks); encodeIfNotEncoded(path); return path.encode(); } else { if (chunks.length > 2) { chunks = new String[]{chunks[0], chunks[chunks.length - 1]}; } ArchiveObjectPath path = new ArchiveObjectPath(new YaddaObjectID(importId), chunks); encodeIfNotEncoded(path); return path.encode(); } }
ArchiveObjectPath path = new ArchiveObjectPath(ERROR_DUMP_OBJECT_PATH, "dump_" + date);