use of com.serotonin.m2m2.vo.FileStore in project ma-core-public by MangoAutomation.
the class FileStoreServiceTest method updateVO.
@Override
FileStore updateVO(FileStore existing) {
FileStore edit = new FileStore();
edit.setId(existing.getId());
edit.setXid("new store name");
edit.setName(edit.getXid());
return edit;
}
use of com.serotonin.m2m2.vo.FileStore in project ma-core-public by MangoAutomation.
the class DiskInfoDefinition method getValue.
@Override
public List<DiskInfo> getValue() {
FileSystem fs = FileSystems.getDefault();
List<DiskInfo> disks = new ArrayList<DiskInfo>();
for (Path root : fs.getRootDirectories()) {
try {
FileStore store = Files.getFileStore(root);
DiskInfo disk = new DiskInfo();
disk.setName(root.getRoot().toString());
disk.setTotalSpace(store.getTotalSpace());
disk.setUsableSpace(store.getUsableSpace());
disks.add(disk);
} catch (IOException e) {
}
}
return disks;
}
use of com.serotonin.m2m2.vo.FileStore in project ma-core-public by MangoAutomation.
the class FileStoreService method forRead.
/**
* Retrieves the path to a file in the file store, checking that the user has read permission for the file store.
* Does not check if the file exists, only that the filestore exists.
*
* @param xid xid of the user file store, or the storeName of the {@link FileStoreDefinition}
* @throws PermissionException user does not have permission to read from the file store
* @throws NotFoundException file store does not exist
*/
public FileStorePath forRead(String xid, String path) throws PermissionException, NotFoundException {
FileStore fileStore = getWithoutPermissionCheck(xid);
ensureReadPermission(Common.getUser(), fileStore);
return getPathWithinFileStore(fileStore, path);
}
use of com.serotonin.m2m2.vo.FileStore in project ma-core-public by MangoAutomation.
the class FileStoreService method forWrite.
/**
* Retrieves the path to a file in the file store, checking that the user has write permission for the file store.
* Does not check if the file exists, only that the filestore exists.
*
* @param xid xid of the user file store, or the storeName of the {@link FileStoreDefinition}
* @throws PermissionException user does not have permission to write to the file store
* @throws NotFoundException file store does not exist
*/
public FileStorePath forWrite(String xid, String path) throws PermissionException, NotFoundException {
FileStore fileStore = getWithoutPermissionCheck(xid);
ensureEditPermission(Common.getUser(), fileStore);
return getPathWithinFileStore(fileStore, path);
}
use of com.serotonin.m2m2.vo.FileStore in project ma-core-public by MangoAutomation.
the class FileStoreService method insert.
@Override
public FileStore insert(FileStore vo) throws PermissionException, ValidationException {
FileStore newFilestore = super.insert(vo);
Path newPath = getFileStoreRoot(newFilestore);
try {
Files.createDirectories(newPath);
} catch (IOException e) {
throw new FileStoreException(new TranslatableMessage("filestore.failedToCreateRoot", newFilestore.getXid()), e);
}
return newFilestore;
}
Aggregations