use of diskCacheV111.util.InvalidMessageCacheException in project dcache by dCache.
the class ChimeraNameSpaceProvider method checkIsTemporaryDirectory.
protected void checkIsTemporaryDirectory(FsPath temporaryPath, FsPath temporaryDir) throws NotFileCacheException, InvalidMessageCacheException {
checkState(_uploadDirectory != null, "Upload directory is not configured.");
FsPath temporaryDirContainer = getParentOfFile(temporaryDir);
if (_uploadDirectory.startsWith("/")) {
if (!temporaryDirContainer.hasPrefix(FsPath.create(_uploadDirectory))) {
throw new InvalidMessageCacheException(temporaryPath + " is not part of the " + _uploadDirectory + " tree.");
}
} else {
if (!temporaryDirContainer.contains(_uploadDirectory)) {
throw new InvalidMessageCacheException(temporaryPath + " is not part of the " + _uploadDirectory + " tree.");
}
}
if (temporaryDir.isRoot()) {
throw new InvalidMessageCacheException("A temporary upload path cannot be in the root directory.");
}
}
use of diskCacheV111.util.InvalidMessageCacheException in project dcache by dCache.
the class PnfsManagerV3 method populatePnfsId.
private PnfsId populatePnfsId(PnfsMessage message) throws CacheException {
PnfsId pnfsId = message.getPnfsId();
if (pnfsId == null) {
String path = message.getPnfsPath();
if (path == null) {
throw new InvalidMessageCacheException("no pnfsid or path defined");
}
pnfsId = _nameSpaceProvider.pathToPnfsid(message.getSubject(), path, message.isFollowSymlink());
message.setPnfsId(pnfsId);
}
return pnfsId;
}
use of diskCacheV111.util.InvalidMessageCacheException in project dcache by dCache.
the class ProbeResponseEngine method queryUrl.
@Override
public void queryUrl(HttpRequest request) throws HttpException {
try {
String[] urlItems = request.getRequestTokens();
if (urlItems.length < 2) {
throw new HttpException(404, "No such property");
}
/* urlItems[0] is the mount point.
*/
BeanQueryMessage queryMessage = (urlItems.length == 3) ? new BeanQuerySinglePropertyMessage(urlItems[2]) : new BeanQueryAllPropertiesMessage();
BeanQueryMessage queryReply = stub.sendAndWait(new CellPath(urlItems[1]), queryMessage);
request.setContentType("application/json; charset=utf-8");
Writer writer = new OutputStreamWriter(request.getOutputStream(), UTF_8);
writer.append(new GsonBuilder().serializeSpecialFloatingPointValues().setPrettyPrinting().disableHtmlEscaping().create().toJson(queryReply.getResult()));
writer.flush();
} catch (NoRouteToCellException e) {
throw new HttpException(503, "The cell was unreachable, suspect trouble.");
} catch (TimeoutCacheException e) {
throw new HttpException(503, "The cell took too long to reply, suspect trouble.");
} catch (InvalidMessageCacheException e) {
throw new HttpException(404, "No such property");
} catch (CacheException | IOException e) {
throw new HttpException(500, e.getMessage());
} catch (InterruptedException e) {
throw new HttpException(503, "Received interrupt whilst processing data. Please try again later.");
}
}
use of diskCacheV111.util.InvalidMessageCacheException in project dcache by dCache.
the class PnfsManagerV3 method deleteEntry.
public void deleteEntry(PnfsDeleteEntryMessage pnfsMessage) {
String path = pnfsMessage.getPnfsPath();
PnfsId pnfsId = pnfsMessage.getPnfsId();
Subject subject = pnfsMessage.getSubject();
Set<FileType> allowed = pnfsMessage.getAllowedFileTypes();
Set<FileAttribute> requested = pnfsMessage.getRequestedAttributes();
try {
if (path == null && pnfsId == null) {
throw new InvalidMessageCacheException("pnfsid or path have to be defined for PnfsDeleteEntryMessage");
}
checkMask(pnfsMessage);
checkRestriction(pnfsMessage, DELETE);
FileAttributes attributes;
if (path != null) {
LOGGER.info("delete PNFS entry for {}", path);
if (pnfsId != null) {
attributes = _nameSpaceProvider.deleteEntry(subject, allowed, pnfsId, path, requested);
} else {
requested.add(PNFSID);
attributes = _nameSpaceProvider.deleteEntry(subject, allowed, path, requested);
pnfsMessage.setPnfsId(attributes.getPnfsId());
}
} else {
LOGGER.info("delete PNFS entry for {}", pnfsId);
attributes = _nameSpaceProvider.deleteEntry(subject, allowed, pnfsId, requested);
}
pnfsMessage.setFileAttributes(attributes);
pnfsMessage.setSucceeded();
} catch (FileNotFoundCacheException e) {
pnfsMessage.setFailed(CacheException.FILE_NOT_FOUND, e.getMessage());
} catch (CacheException e) {
LOGGER.warn("Failed to delete entry: {}", e.getMessage());
pnfsMessage.setFailed(e.getRc(), e.getMessage());
} catch (RuntimeException e) {
LOGGER.error("Failed to delete entry", e);
pnfsMessage.setFailed(CacheException.UNEXPECTED_SYSTEM_EXCEPTION, e);
}
}
use of diskCacheV111.util.InvalidMessageCacheException in project dcache by dCache.
the class PnfsManagerV3 method rename.
public void rename(PnfsRenameMessage msg) {
try {
checkMask(msg);
PnfsId pnfsId = msg.getPnfsId();
String sourcePath = msg.getPnfsPath();
String destinationPath = msg.newName();
// This case is for compatibility with versions before 2.14
if (sourcePath == null) {
if (pnfsId == null) {
throw new InvalidMessageCacheException("Either path or pnfs id is required.");
}
sourcePath = _nameSpaceProvider.pnfsidToPath(msg.getSubject(), pnfsId);
}
LOGGER.info("Rename {} to new name: {}", sourcePath, destinationPath);
checkRestriction(msg, MANAGE, FsPath.create(sourcePath).parent());
checkRestriction(msg, MANAGE, FsPath.create(destinationPath).parent());
boolean overwrite = msg.getOverwrite() && !msg.getRestriction().isRestricted(DELETE, FsPath.create(destinationPath));
_nameSpaceProvider.rename(msg.getSubject(), pnfsId, sourcePath, destinationPath, overwrite);
} catch (CacheException e) {
msg.setFailed(e.getRc(), e.getMessage());
} catch (RuntimeException e) {
LOGGER.error(e.toString(), e);
msg.setFailed(CacheException.UNEXPECTED_SYSTEM_EXCEPTION, "Pnfs rename failed");
}
}
Aggregations