private boolean contentTypeAllowed(WGDocument doc) throws WGAPIException {
// With specified content type
if (getContenttype() != null) {
WGContentType contentType = getTMLContext().db().getContentType(getContenttype());
if (contentType != null) {
return contentType.mayCreateContent() && contentType.mayCreateChildEntry(doc);
}
else {
addWarning("Contenttype '" + getContenttype() + "' could not be found in database '" + getTMLContext().db().getDbReference() + "'.");
return false;
}
}
// no content type specified. Look if any content type is usable at this position
else {
Iterator contentTypes = getTMLContext().db().getContentTypes().iterator();
boolean ctFound = false;
while (contentTypes.hasNext()) {
WGContentType ct = (WGContentType) contentTypes.next();
if (ct.mayCreateContent() && ct.mayCreateChildEntry(doc)) {
ctFound = true;
break;
}
}
return ctFound;