Source:
<code>public List<Category> getCategories (final Contentlet contentlet, final User user, final boolean respectFrontendRoles) throws DotDataException, DotSecurityException { <START> DotPreconditions.checkNotNull(contentlet, IllegalArgumentException.class, "Invalid Content Type"); <END> DotPreconditions.checkNotNull(contentlet.getContentType(), IllegalArgumentException.class, "Invalid Content Type"); final List<Category> categories = new ArrayList<>(); final List<Field> fields = new LegacyFieldTransformer( APILocator.getContentTypeAPI(APILocator.systemUser()). find(contentlet.getContentType().inode()).fields()).asOldFieldList(); for (final Field field : fields) { if (field.getFieldType().equals(FieldType.CATEGORY.toString())) { final String catValue = contentlet.getStringProperty(field.getVelocityVarName()); if (UtilMethods.isSet(catValue)) { for (final String categoryValue : catValue.split("\\s*,\\s*")) { Category category = APILocator.getCategoryAPI() .find(categoryValue, user, respectFrontendRoles); if (category != null && InodeUtils.isSet(category.getCategoryId())) { categories.add(category); } else { category = APILocator.getCategoryAPI() .findByKey(categoryValue, user, respectFrontendRoles); if (category != null && InodeUtils.isSet(category.getCategoryId())) { categories.add(category); } else { final HibernateUtil hu = new HibernateUtil(Category.class); hu.setQuery("from " + Category.class.getCanonicalName() + " WHERE category_velocity_var_name=?"); hu.setParam(categoryValue); category = (Category) hu.load(); if (category != null && InodeUtils.isSet(category.getCategoryId())) { categories.add(category); } } } } } } } return categories; }</code><technical_language>another message below, **Invalid Contentlet**?</technical_language>

Target:
public List<Category> getCategories (final Contentlet contentlet, final User user, final boolean respectFrontendRoles) throws DotDataException, DotSecurityException { DotPreconditions.checkNotNull(contentlet, IllegalArgumentException.class, "Invalid Contentlet"); DotPreconditions.checkNotNull(contentlet.getContentType(), IllegalArgumentException.class, "Invalid Content Type"); final List<Category> categories = new ArrayList<>(); final List<Field> fields = new LegacyFieldTransformer( APILocator.getContentTypeAPI(APILocator.systemUser()). find(contentlet.getContentType().inode()).fields()).asOldFieldList(); for (final Field field : fields) { if (field.getFieldType().equals(FieldType.CATEGORY.toString())) { final String catValue = contentlet.getStringProperty(field.getVelocityVarName()); if (UtilMethods.isSet(catValue)) { for (final String categoryValue : catValue.split("\\s*,\\s*")) { Category category = APILocator.getCategoryAPI() .find(categoryValue, user, respectFrontendRoles); if (category != null && InodeUtils.isSet(category.getCategoryId())) { categories.add(category); } else { category = APILocator.getCategoryAPI() .findByKey(categoryValue, user, respectFrontendRoles); if (category != null && InodeUtils.isSet(category.getCategoryId())) { categories.add(category); } else { final HibernateUtil hu = new HibernateUtil(Category.class); hu.setQuery("from " + Category.class.getCanonicalName() + " WHERE category_velocity_var_name=?"); hu.setParam(categoryValue); category = (Category) hu.load(); if (category != null && InodeUtils.isSet(category.getCategoryId())) { categories.add(category); } } } } } } } return categories; }