protected CmsXmlContentErrorHandler validateCategories(
        CmsObject cms,
        I_CmsXmlContentValue value,
        CmsXmlContentErrorHandler errorHandler) {

        if (!value.isSimpleType()) {
            // do not validate complex types
            return errorHandler;
        }
        I_CmsWidget widget = null;

        widget = CmsWidgetUtil.collectWidgetInfo(value).getWidget();
        if (!(widget instanceof CmsCategoryWidget)) {
            // do not validate widget that are not category widgets
            return errorHandler;
        }
        String stringValue = value.getStringValue(cms);
        if (stringValue.isEmpty()) {
            return errorHandler;
        }
        try {
            String[] values = stringValue.split(",");
            for (int i = 0; i < values.length; i++) {
                String val = values[i];
                String catPath = CmsCategoryService.getInstance().getCategory(cms, val).getPath();
                String refPath = getReferencePath(cms, value);
                CmsCategoryService.getInstance().readCategory(cms, catPath, refPath);
                if (((CmsCategoryWidget)widget).isOnlyLeafs()) {
                    if (!CmsCategoryService.getInstance().readCategories(cms, catPath, false, refPath).isEmpty()) {
                        errorHandler.addError(
                            value,
                            Messages.get().getBundle(value.getLocale()).key(
                                Messages.GUI_CATEGORY_CHECK_NOLEAF_ERROR_0));
                    }
                }
            }
        } catch (CmsDataAccessException e) {
            // expected error in case of empty/invalid value
            // see CmsCategory#getCategoryPath(String, String)
            if (LOG.isDebugEnabled()) {
                LOG.debug(e.getLocalizedMessage(), e);
            }
            errorHandler.addError(
                value,
                Messages.get().getBundle(value.getLocale()).key(Messages.GUI_CATEGORY_CHECK_EMPTY_ERROR_0));
        } catch (CmsException e) {
            // unexpected error
            if (LOG.isErrorEnabled()) {
                LOG.error(e.getLocalizedMessage(), e);
            }
            errorHandler.addError(value, e.getLocalizedMessage());
        }
        return errorHandler;
    }
protected CmsXmlContentErrorHandler validateCategories ( CmsObject cms , I_CmsXmlContentValue value , CmsXmlContentErrorHandler errorHandler ) { if ( ! value . isSimpleType ( ) ) { return errorHandler ; } I_CmsWidget widget = null ; widget = CmsWidgetUtil . collectWidgetInfo ( value ) . getWidget ( ) ; if ( ! ( widget instanceof CmsCategoryWidget ) ) { return errorHandler ; } String stringValue = value . getStringValue ( cms ) ; if ( stringValue . isEmpty ( ) ) { return errorHandler ; } try { String [ ] values = stringValue . split ( "," ) ; for ( int i = 0 ; i < values . length ; i ++ ) { String val = values [ i ] ; String catPath = CmsCategoryService . getInstance ( ) . getCategory ( cms , val ) . getPath ( ) ; String refPath = getReferencePath ( cms , value ) ; CmsCategoryService . getInstance ( ) . readCategory ( cms , catPath , refPath ) ; if ( ( ( CmsCategoryWidget ) widget ) . isOnlyLeafs ( ) ) { if ( ! CmsCategoryService . getInstance ( ) . readCategories ( cms , catPath , false , refPath ) . isEmpty ( ) ) { errorHandler . addError ( value , Messages . get ( ) . getBundle ( value . getLocale ( ) ) . key ( Messages . GUI_CATEGORY_CHECK_NOLEAF_ERROR_0 ) ) ; } } } } catch ( CmsDataAccessException e ) { if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( e . getLocalizedMessage ( ) , e ) ; } errorHandler . addError ( value , Messages . get ( ) . getBundle ( value . getLocale ( ) ) . key ( Messages . GUI_CATEGORY_CHECK_EMPTY_ERROR_0 ) ) ; } catch ( CmsException e ) { if ( LOG . isErrorEnabled ( ) ) { LOG . error ( e . getLocalizedMessage ( ) , e ) ; } errorHandler . addError ( value , e . getLocalizedMessage ( ) ) ; } return errorHandler ; }
The errorHandler parameter is optional, if <code>null</code> is given a new error handler
instance must be created.<p>

@param cms the current OpenCms user context
@param value the value to resolve the validation rules for
@param errorHandler (optional) an error handler instance that contains previous error or warnings

@return an error handler that contains all errors and warnings currently found