use of com.infiniteautomation.mango.util.exception.NotFoundException in project ma-core-public by MangoAutomation.
the class DataPointService method getReadPermission.
/**
* Get the read permission for this data point
*/
public MangoPermission getReadPermission(int dataPointId) throws NotFoundException, PermissionException {
PermissionHolder user = Common.getUser();
Integer permissionId = dao.getReadPermissionId(dataPointId);
if (permissionId == null) {
throw new NotFoundException();
}
MangoPermission read = permissionService.get(permissionId);
permissionService.ensurePermission(user, read);
return read;
}
use of com.infiniteautomation.mango.util.exception.NotFoundException in project ma-core-public by MangoAutomation.
the class DataPointService method getSummary.
/**
* Get a summary for a data point.
* A summary is a subset of a data point configuration.
*/
public DataPointSummary getSummary(String xid) {
DataPointSummary vo = dao.getSummary(xid);
if (vo == null) {
throw new NotFoundException();
}
permissionService.ensurePermission(Common.getUser(), vo.getReadPermission());
return vo;
}
use of com.infiniteautomation.mango.util.exception.NotFoundException in project ma-core-public by MangoAutomation.
the class FileStoreService method deleteFileOrFolder.
public FileStorePath deleteFileOrFolder(String xid, String toDelete, boolean recursive) {
FileStore fileStore = getWithoutPermissionCheck(xid);
ensureEditPermission(Common.getUser(), fileStore);
FileStorePath toDeletePath = getPathWithinFileStore(fileStore, toDelete);
if (toDeletePath.absolutePath.equals(toDeletePath.getFileStoreRoot())) {
throw new FileStoreException(new TranslatableMessage("filestore.deleteRootNotPermitted"));
}
if (!Files.exists(toDeletePath.absolutePath)) {
throw new NotFoundException();
}
try {
if (Files.isDirectory(toDeletePath.absolutePath) && recursive) {
FileUtils.deleteDirectory(toDeletePath.absolutePath.toFile());
} else {
Files.delete(toDeletePath.absolutePath);
}
return toDeletePath;
} catch (NoSuchFileException e) {
throw new NotFoundException();
} catch (Exception e) {
throw new FileStoreException(new TranslatableMessage("filestore.errorDeletingFile"));
}
}
use of com.infiniteautomation.mango.util.exception.NotFoundException in project ma-core-public by MangoAutomation.
the class FileStoreService method copyFileOrFolder.
public FileStorePath copyFileOrFolder(String xid, String src, String dst) {
FileStore fileStore = getWithoutPermissionCheck(xid);
ensureEditPermission(Common.getUser(), fileStore);
FileStorePath srcPath = getPathWithinFileStore(fileStore, src);
if (!Files.exists(srcPath.absolutePath)) {
throw new NotFoundException();
}
FileStorePath dstPath = srcPath.getParent().resolve(Paths.get(dst));
if (Files.isDirectory(dstPath.absolutePath)) {
Path pathWithFileName = dstPath.absolutePath.resolve(srcPath.absolutePath.getFileName());
dstPath = new FileStorePath(fileStore, pathWithFileName);
}
if (Files.exists(dstPath.absolutePath)) {
throw new FileStoreException(new TranslatableMessage("filestore.fileExists", dstPath.standardizedPath()));
}
try {
if (Files.isDirectory(srcPath.absolutePath)) {
FileUtils.copyDirectory(srcPath.absolutePath.toFile(), dstPath.absolutePath.toFile());
} else {
Files.copy(srcPath.absolutePath, dstPath.absolutePath);
}
return dstPath;
} catch (FileAlreadyExistsException e) {
throw new FileStoreException(new TranslatableMessage("filestore.fileExists", dstPath.standardizedPath()));
} catch (Exception e) {
throw new FileStoreException(new TranslatableMessage("filestore.errorCopyingFile"));
}
}
use of com.infiniteautomation.mango.util.exception.NotFoundException in project ma-core-public by MangoAutomation.
the class DataSourceService method getDefinition.
/**
* Get a definition for a data source
*/
public DataSourceDefinition<DataSourceVO> getDefinition(String dataSourceType, PermissionHolder user) throws NotFoundException, PermissionException {
permissionService.ensurePermission(user, createPermission.getPermission());
DataSourceDefinition<DataSourceVO> def = ModuleRegistry.getDataSourceDefinition(dataSourceType);
if (def == null)
throw new NotFoundException();
return def;
}
Aggregations