import org.argeo.api.acr.Content;
import org.argeo.api.acr.ContentName;
import org.argeo.api.acr.CrName;
+import org.argeo.api.acr.DName;
import org.argeo.api.acr.NamespaceUtils;
import org.argeo.api.acr.spi.ProvidedContent;
import org.argeo.api.acr.spi.ProvidedSession;
file.write(InputStream.class).complete(in);
}
} else if (node.isNodeType(NodeType.NT_FOLDER)) {
- Content subCol = collection.add(name, CrName.collection.qName());
+ Content subCol = collection.add(name, DName.collection.qName());
copyFiles(node, subCol, additionalCollectionTypes);
} else {
List<QName> contentClasses = typesAsContentClasses(node, jcrNamespaceContext);
for (String collectionType : additionalCollectionTypes) {
if (node.isNodeType(collectionType)) {
- contentClasses.add(CrName.collection.qName());
+ contentClasses.add(DName.collection.qName());
Content subCol = collection.add(name,
contentClasses.toArray(new QName[contentClasses.size()]));
setAttributes(node, subCol, jcrNamespaceContext);
/*
* TYPES
*/
- collection, // a collection type
+// collection, // a collection type
/*
* ATTRIBUTES
*/
uuid, // the UUID of a content
mount, // a mount point
- cc, // content class
+// cc, // content class
/*
* ATTRIBUTES FROM FILE SEMANTICS
*/
- creationTime, //
- lastModifiedTime, //
- size, //
+// creationTime, //
+// lastModifiedTime, //
+// size, //
fileKey, //
- owner, //
- group, //
+// owner, //
+// group, //
permissions, //
/*
--- /dev/null
+package org.argeo.api.acr;
+
+/**
+ * Name for core concepts with the same semantics as defined in the WebDav
+ * standard and extensions.
+ *
+ * @see http://www.webdav.org/specs/rfc4918.html
+ * @see http://www.webdav.org/specs/rfc3744.html
+ */
+public enum DName implements QNamed
+
+{
+ // RFC4918 (WebDav) properties used as CR attr
+ creationdate, //
+ displayname, //
+ getcontentlanguage, //
+ getcontentlength, //
+ getcontenttype, //
+ getetag, //
+ getlastmodified, //
+ resourcetype, //
+
+ // RFC4918 (WebDav) value used as CR class
+ collection, //
+
+ // RFC3744 (ACL) properties uase as CR attr
+ owner, //
+ group, //
+ //
+ ;
+
+ public final static String WEBDAV_NAMESPACE_URI = "DAV:";
+ public final static String WEBDAV_DEFAULT_PREFIX = "D";
+
+ @Override
+ public String getNamespace() {
+ return WEBDAV_NAMESPACE_URI;
+ }
+
+ @Override
+ public String getDefaultPrefix() {
+ return WEBDAV_DEFAULT_PREFIX;
+ }
+
+}
import org.argeo.api.acr.Content;
import org.argeo.api.acr.ContentSession;
import org.argeo.api.acr.CrName;
+import org.argeo.api.acr.DName;
import org.argeo.api.acr.spi.ContentProvider;
import org.argeo.api.acr.spi.ProvidedContent;
import org.argeo.api.acr.spi.ProvidedRepository;
else {
Content runDir = get(CmsContentRepository.RUN_BASE);
// TODO deal with no run dir available?
- sessionRunDir = runDir.add(uuid.toString(), CrName.collection.qName());
+ sessionRunDir = runDir.add(uuid.toString(),DName.collection.qName());
}
}
return sessionRunDir;
import org.argeo.api.acr.ContentRepository;
import org.argeo.api.acr.ContentSession;
import org.argeo.api.acr.CrName;
+import org.argeo.api.acr.DName;
import org.argeo.api.cms.CmsAuth;
import org.argeo.cms.CmsUserManager;
import org.argeo.osgi.useradmin.UserDirectory;
public static Content createCollections(ContentSession session, String path) {
if (session.exists(path)) {
Content content = session.get(path);
- if (!content.isContentClass(CrName.collection.qName())) {
+ if (!content.isContentClass(DName.collection.qName())) {
throw new IllegalStateException("Content " + path + " already exists, but is not a collection");
} else {
return content;
} else {
String[] parentPath = getParentPath(path);
Content parent = createCollections(session, parentPath[0]);
- Content content = parent.add(parentPath[1], CrName.collection.qName());
+ Content content = parent.add(parentPath[1], DName.collection.qName());
return content;
}
}
import org.argeo.api.acr.Content;
import org.argeo.api.acr.ContentName;
import org.argeo.api.acr.CrName;
+import org.argeo.api.acr.DName;
import org.argeo.api.acr.spi.ProvidedSession;
import org.argeo.osgi.useradmin.UserDirectory;
import org.argeo.util.directory.Directory;
@Override
public List<QName> getContentClasses() {
List<QName> contentClasses = super.getContentClasses();
- contentClasses.add(CrName.collection.qName());
+ contentClasses.add(DName.collection.qName());
return contentClasses;
}
import org.argeo.api.acr.ContentResourceException;
import org.argeo.api.acr.CrAttributeType;
import org.argeo.api.acr.CrName;
+import org.argeo.api.acr.DName;
import org.argeo.api.acr.NamespaceUtils;
import org.argeo.api.acr.spi.ContentProvider;
import org.argeo.api.acr.spi.ProvidedContent;
private static final Map<QName, String> POSIX_KEYS;
static {
BASIC_KEYS = new HashMap<>();
- BASIC_KEYS.put(CrName.creationTime.qName(), "basic:creationTime");
- BASIC_KEYS.put(CrName.lastModifiedTime.qName(), "basic:lastModifiedTime");
- BASIC_KEYS.put(CrName.size.qName(), "basic:size");
+ BASIC_KEYS.put(DName.creationdate.qName(), "basic:creationTime");
+ BASIC_KEYS.put(DName.getlastmodified.qName(), "basic:lastModifiedTime");
+ BASIC_KEYS.put(DName.getcontentlength.qName(), "basic:size");
+
BASIC_KEYS.put(CrName.fileKey.qName(), "basic:fileKey");
POSIX_KEYS = new HashMap<>(BASIC_KEYS);
- POSIX_KEYS.put(CrName.owner.qName(), "owner:owner");
- POSIX_KEYS.put(CrName.group.qName(), "posix:group");
+ POSIX_KEYS.put(DName.owner.qName(), "owner:owner");
+ POSIX_KEYS.put(DName.group.qName(), "posix:group");
POSIX_KEYS.put(CrName.permissions.qName(), "posix:permissions");
}
FsContent fsContent;
try {
Path newPath = path.resolve(NamespaceUtils.toPrefixedName(provider, name));
- if (ContentName.contains(classes, CrName.collection.qName()))
+ if (ContentName.contains(classes, DName.collection.qName()))
Files.createDirectory(newPath);
else
Files.createFile(newPath);
@Override
public List<QName> getContentClasses() {
List<QName> res = new ArrayList<>();
- List<String> value = getMultiple(CrName.cc.qName(), String.class);
+ List<String> value = getMultiple(DName.resourcetype.qName(), String.class);
for (String s : value) {
QName name = NamespaceUtils.parsePrefixedName(provider, s);
res.add(name);
}
if (Files.isDirectory(path))
- res.add(CrName.collection.qName());
+ res.add(DName.collection.qName());
return res;
}
public void addContentClasses(QName... contentClass) {
List<String> toWrite = new ArrayList<>();
for (QName cc : getContentClasses()) {
- if (cc.equals(CrName.collection.qName()))
+ if (cc.equals(DName.collection.qName()))
continue; // skip
toWrite.add(NamespaceUtils.toPrefixedName(provider, cc));
}
for (QName cc : contentClass) {
toWrite.add(NamespaceUtils.toPrefixedName(provider, cc));
}
- put(CrName.cc.qName(), toWrite);
+ put(DName.resourcetype.qName(), toWrite);
}
/*
*/
@SuppressWarnings("unchecked")
public <A> CompletableFuture<A> write(Class<A> clss) {
- if (isContentClass(CrName.collection.qName())) {
+ if (isContentClass(DName.collection.qName())) {
throw new IllegalStateException("Cannot directly write to a collection");
}
if (InputStream.class.isAssignableFrom(clss)) {
response, //
multistatus, //
href, //
+ /** MUST be the same as DName.collection */
collection, //
prop, //
resourcetype, //
import org.argeo.api.acr.Content;
import org.argeo.api.acr.ContentSession;
-import org.argeo.api.acr.CrName;
+import org.argeo.api.acr.DName;
import org.argeo.api.acr.spi.ProvidedRepository;
import org.argeo.api.cms.CmsConstants;
import org.argeo.cms.acr.ContentUtils;
DavResponse davResponse = new DavResponse();
String href = CmsConstants.PATH_API_ACR + content.getPath();
davResponse.setHref(href);
- if (content.hasContentClass(CrName.collection))
+ if (content.hasContentClass(DName.collection))
davResponse.setCollection(true);
if (davPropfind.isAllprop()) {
for (Map.Entry<QName, Object> entry : content.entrySet()) {
consumer.accept(davResponse);
// recurse only on collections
- if (content.hasContentClass(CrName.collection)) {
+ if (content.hasContentClass(DName.collection)) {
if (davPropfind.getDepth() == DavDepth.DEPTH_INFINITY
|| (davPropfind.getDepth() == DavDepth.DEPTH_1 && currentDepth == 0)) {
for (Content child : content) {
protected void processMapEntry(DavResponse davResponse, QName key, Object value) {
// ignore content classes
- if (CrName.cc.qName().equals(key))
+ if (DName.resourcetype.qName().equals(key))
return;
String str;
if (value instanceof Collection) {
ContentSession session = RemoteAuthUtils.doAs(() -> contentRepository.get(),
new RemoteAuthHttpExchange(exchange));
Content content = session.get(ContentUtils.ROOT_SLASH + relativePath);
- Optional<Long> size = content.get(CrName.size, Long.class);
+ Optional<Long> size = content.get(DName.getcontentlength, Long.class);
try (InputStream in = content.open(InputStream.class)) {
exchange.sendResponseHeaders(HttpResponseStatus.OK.getCode(), size.orElse(0l));
StreamUtils.copy(in, exchange.getResponseBody());