public class IntroNewContentActionAspect {
@After("execution(* com.agiletec.plugins.jacms.apsadmin.content.IntroNewContentAction.createNewVoid())")
public void checkCreateNewContent(JoinPoint joinPoint) {
try {
IntroNewContentAction action = (IntroNewContentAction) joinPoint.getTarget();
List<SmallContentType> allowedContentTypes = this.getAllowedContentTypes();
boolean check = false;
for (int i = 0; i < allowedContentTypes.size(); i++) {
SmallContentType contentType = allowedContentTypes.get(i);
if (contentType.getCode().equals(action.getContentTypeCode())) {
check = true;
break;
}
}
if (!check) {
SmallContentType contentType = (SmallContentType) this.getContentManager().getSmallContentTypesMap().get(action.getContentTypeCode());
String typeDescr = contentType != null ? contentType.getCode() : action.getContentTypeCode();
action.addFieldError("contentTypeCode", action.getText("error.content.contentType.userNotAllowed", typeDescr));
}
} catch (Throwable t) {
ApsSystemUtils.logThrowable(t, this, "getAllowedContentTypes", "Error checking content type authorization");
throw new RuntimeException("Error extracting allowed content types", t);
}