+ @Override
+ protected void removeAttr(String key) {
+ UserDefinedFileAttributeView udfav = Files.getFileAttributeView(path, UserDefinedFileAttributeView.class);
+ try {
+ udfav.delete(key);
+ } catch (IOException e) {
+ throw new ContentResourceException("Cannot delete attribute " + key + " for " + path, e);
+ }
+ }
+
+ @Override
+ public Object put(String key, Object value) {
+ Object previous = get(key);
+ UserDefinedFileAttributeView udfav = Files.getFileAttributeView(path, UserDefinedFileAttributeView.class);
+ ByteBuffer bb = ByteBuffer.wrap(value.toString().getBytes(StandardCharsets.UTF_8));
+ try {
+ int size = udfav.write(key, bb);
+ } catch (IOException e) {
+ throw new ContentResourceException("Cannot delete attribute " + key + " for " + path, e);
+ }
+ return previous;
+ }
+
+ protected String toFsAttributeKey(String key) {
+ if (POSIX_KEYS.contains(key))
+ return key;
+ else
+ return USER_ + key;
+ }
+
+ /*
+ * CONTENT OPERATIONS
+ */
+ @Override
+ public Iterator<Content> iterator() {
+ if (Files.isDirectory(path)) {
+ try {
+ return Files.list(path).map((p) -> (Content) new FsContent(contentProvider, p)).iterator();
+ } catch (IOException e) {
+ throw new ContentResourceException("Cannot list " + path, e);
+ }
+ } else {
+ return Collections.emptyIterator();
+ }
+ }
+
+ @Override
+ public Content add(String name, ContentName... classes) {
+ try {
+ Path newPath = path.resolve(name);
+ if (ContentName.contains(classes, CrName.COLLECTION))
+ Files.createDirectory(newPath);
+ else
+ Files.createFile(newPath);
+
+// for(ContentClass clss:classes) {
+// Files.setAttribute(newPath, name, newPath, null)
+// }
+ return new FsContent(contentProvider, newPath);
+ } catch (IOException e) {
+ throw new ContentResourceException("Cannot create new content", e);
+ }
+ }
+
+ @Override
+ public void remove() {
+ FsUtils.delete(path);
+ }
+
+ @Override
+ public Content getParent() {
+ if (isRoot)
+ return null;// TODO deal with mounts
+ return new FsContent(contentProvider, path.getParent());
+ }
+