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 final char SLASH = '/';
public static final String ROOT_SLASH = "" + SLASH;
+ public static final String EMPTY = "";
/**
* Split a path (with '/' separator) in an array of length 2, the first part
}
if (parentIndex == -1) // no '/'
- return new String[] { "", path };
+ return new String[] { EMPTY, path };
return new String[] { parentIndex != 0 ? path.substring(0, parentIndex) : "" + SLASH,
path.substring(parentIndex + 1) };
public static List<String> toPathSegments(String path) {
List<String> res = new ArrayList<>();
- if ("".equals(path) || ROOT_SLASH.equals(path))
+ if (EMPTY.equals(path) || ROOT_SLASH.equals(path))
return res;
collectPathSegments(path, res);
return res;
private static void collectPathSegments(String path, List<String> segments) {
String[] parent = getParentPath(path);
- if ("".equals(parent[1])) // root
+ if (EMPTY.equals(parent[1])) // root
return;
segments.add(0, parent[1]);
- if ("".equals(parent[0])) // end
+ if (EMPTY.equals(parent[0])) // end
return;
collectPathSegments(parent[0], segments);
}
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;
}
}