Adds the digester rules for OpenCms version 5 modules.<p>

@param digester the digester to add the rules to
197482
private static void addXmlDigesterRulesForVersion5Modules(Digester digester) {

        // mark method
        digester.addCallMethod("*/" + N_MODULE + "/author", "setOldModule");

        // base module information
        digester.addCallParam("*/" + N_MODULE + "/author", 10);
        digester.addCallParam("*/" + N_MODULE + "/email", 11);
        digester.addCallParam("*/" + N_MODULE + "/creationdate", 12);

        // dependencies
        digester.addCallParam("*/" + N_MODULE + "/dependencies/dependency/name", 0);
        digester.addCallParam("*/" + N_MODULE + "/dependencies/dependency/minversion", 1);

        // export points
        digester.addCallMethod("*/" + N_MODULE + "/exportpoint", "addExportPoint", 2);
        digester.addCallParam("*/" + N_MODULE + "/exportpoint/source", 0);
        digester.addCallParam("*/" + N_MODULE + "/exportpoint/destination", 1);

        // parameters
        digester.addCallMethod("*/" + N_MODULE + "/parameters/para", "addParameter", 2);
        digester.addCallParam("*/" + N_MODULE + "/parameters/para/name", 0);
        digester.addCallParam("*/" + N_MODULE + "/parameters/para/value", 1);
    }
593797
private long addDigest(long digest, Class<?> cl)
    throws Exception
  {
    if (_cl == null)
      return digest;

    digest = addDigest(digest, cl.getName());

    digest = addDigest(digest, cl.getModifiers());

    Class<?> superClass = cl.getSuperclass();
    if (superClass != null
        && superClass.getName().startsWith("java.")
        && ! superClass.getName().startsWith("javax.")) {
      digest = addDigest(digest, superClass);
    }

    Class<?> []interfaces = cl.getInterfaces();
    Arrays.sort(interfaces, ClassComparator.CMP);
    for (int i = 0; i < interfaces.length; i++)
      digest = addDigest(digest, interfaces[i].getName());

    if (_checkFields) {
      Field []fields = cl.getDeclaredFields();

      Arrays.sort(fields, FieldComparator.CMP);

      for (int i = 0; i < fields.length; i++) {
        int modifiers = fields[i].getModifiers();

        if (Modifier.isPrivate(modifiers) && ! _checkPrivate)
          continue;
        if (Modifier.isProtected(modifiers) && ! _checkProtected)
          continue;
          
        digest = addDigest(digest, fields[i].getName());
        digest = addDigest(digest, fields[i].getModifiers());
        digest = addDigest(digest, fields[i].getType().getName());
        // jpa/0021
        Annotation[] annotations = fields[i].getAnnotations();
        for (Annotation annotation : annotations) {
          digest = addDigest(digest, annotation.annotationType().getName());
        }
      }
    }

    Method []methods = cl.getDeclaredMethods();
    Arrays.sort(methods, MethodComparator.CMP);
      
    for (int i = 0; i < methods.length; i++) {
      Method method = methods[i];
      int modifiers = method.getModifiers();

      if (Modifier.isPrivate(modifiers) && ! _checkPrivate)
        continue;
      if (Modifier.isProtected(modifiers) && ! _checkProtected)
        continue;
      if (Modifier.isStatic(modifiers) && ! _checkStatic)
        continue;
          
      digest = addDigest(digest, method.getName());
      digest = addDigest(digest, method.getModifiers());
      digest = addDigest(digest, method.getName());

      Class<?> []param = method.getParameterTypes();
      for (int j = 0; j < param.length; j++)
        digest = addDigest(digest, param[j].getName());

      digest = addDigest(digest, method.getReturnType().getName());

      Class<?> []exn = method.getExceptionTypes();
      Arrays.sort(exn, ClassComparator.CMP);
      for (int j = 0; j < exn.length; j++)
        digest = addDigest(digest, exn[j].getName());
    }

    return digest;
  }
1321958
protected void addValidators() {

        m_target.removeAllValidators();
        m_target.addValidator(new TargetValidator());

        for (Component c : m_componentsToValidate) {
            if (c instanceof CmsPathSelectField) {
                ((CmsPathSelectField)c).removeAllValidators();
                ((CmsPathSelectField)c).addValidator(new ResourceValidator());
            }
        }
    }
19042
public synchronized void setCms(CmsObject cms) {

        if (m_perThreadCmsObject == null) {
            m_perThreadCmsObject = new ThreadLocal<CmsObject>();
        }
        m_perThreadCmsObject.set(cms);
    }
721355
public void addSite(CmsObject cms, CmsSite site) throws CmsException {

        // check permissions
        if (OpenCms.getRunLevel() > OpenCms.RUNLEVEL_1_CORE_OBJECT) {
            // simple unit tests will have runlevel 1 and no CmsObject
            OpenCms.getRoleManager().checkRole(cms, CmsRole.DATABASE_MANAGER);
        }

        // un-freeze
        m_frozen = false;

        // set aliases and parameters, they will be used in the addSite method
        // this is necessary because of a digester workaround
        m_siteParams = site.getParameters();
        m_aliases = site.getAliases();

        String secureUrl = null;
        if (site.hasSecureServer()) {
            secureUrl = site.getSecureUrl();
        }

        // add the site
        addSite(
            site.getUrl(),
            site.getSiteRoot(),
            site.getTitle(),
            Float.toString(site.getPosition()),
            site.getErrorPage(),
            Boolean.toString(site.isWebserver()),
            site.getSSLMode().getXMLValue(),
            secureUrl,
            Boolean.toString(site.isExclusiveUrl()),
            Boolean.toString(site.isExclusiveError()),
            Boolean.toString(site.usesPermanentRedirects()));

        // re-initialize, will freeze the state when finished
        initialize(cms);
        OpenCms.writeConfiguration(CmsSitesConfiguration.class);
    }
552683
protected void addResourcePropertyRules(Digester digester, String xpath) {

        String xp_props = xpath + N_PROPERTIES + "/" + N_PROPERTY;
        // first rule in case the type is implicit
        digester.addCallMethod(xp_props, "addProperty");
        // second rule in case the type is given
        digester.addCallMethod(xp_props, "addProperty", 1);
        digester.addCallParam(xp_props, 0, A_TYPE);

        digester.addCallMethod(xp_props + "/" + N_NAME, "setPropertyName", 0);
        digester.addCallMethod(xp_props + "/" + N_VALUE, "setPropertyValue", 0);

    }
121585
private static void addDigest(MessageDigest digest, Annotation []annList)
  {
    if (annList == null)
      return;

    for (Annotation ann : annList)
      addDigest(digest, ann);
  }
  
  /**
   * 
   */
  private static void addDigest(MessageDigest digest, Annotation ann)
  {
    addDigest(digest, ann.annotationType().getName());
  }
  
  /**
   * Adds the int to the digest.
   */
  private static void addDigest(MessageDigest digest, int v)
  {
    digest.update((byte) (v >> 24));
    digest.update((byte) (v >> 16));
    digest.update((byte) (v >> 8));
    digest.update((byte) v);
  }
  
  /**
   * Adds the string to the digest using a UTF8 encoding.
   */
  private static void addDigest(MessageDigest digest, String string)
  {
    if (string == null)
      return;
    
    int len = string.length();
    for (int i = 0; i < len; i++) {
      int ch = string.charAt(i);
      if (ch < 0x80)
        digest.update((byte) ch);
      else if (ch < 0x800) {
        digest.update((byte) (0xc0 + (ch >> 6)));
        digest.update((byte) (0x80 + (ch & 0x3f)));
      }
      else {
        digest.update((byte) (0xe0 + (ch >> 12)));
        digest.update((byte) (0x80 + ((ch >> 6) & 0x3f)));
        digest.update((byte) (0x80 + (ch & 0x3f)));
      }
    }
  }
  
  private String digestToBase64(byte []digest, int len)
  {
    StringBuilder cb = new StringBuilder();

    Base64Util.encode(cb, digest, 0, len);

    return cb.toString();
  }

  public boolean isEqual(Object o)
  {
    if (o == this)
      return true;
    
    if (! (o instanceof JClassDependency))
      return false;

    JClassDependency depend = (JClassDependency) o;

    return _className.equals(depend._className);
  }

  static class FieldComparator implements Comparator<Field> {
    public int compare(Field a, Field b)
    {
      if (a == b)
        return 0;
      else if (a == null)
        return -1;
      else if (b == null)
        return 1;
      else if (a.equals(b))
        return 0;

      int cmp = a.getName().compareTo(b.getName());
      if (cmp != 0)
        return cmp;
      
      cmp = a.getDeclaringClass().getName().compareTo(b.getDeclaringClass().getName());
      if (cmp != 0)
        return cmp;
      
      return a.getType().getName().compareTo(b.getType().getName());
    }
  }

  static class MethodComparator implements Comparator<Method> {
    public int compare(Method a, Method b)
    {
      if (a == b)
        return 0;
      else if (a == null)
        return -1;
      else if (b == null)
        return 1;
      else if (a.equals(b))
        return 0;

      int cmp = a.getName().compareTo(b.getName());
      if (cmp != 0)
        return cmp;

      Class []paramA = a.getParameterTypes();
      Class []paramB = b.getParameterTypes();

      if (paramA.length < paramB.length)
        return -1;
      else if (paramB.length < paramA.length)
        return 1;

      for (int i = 0; i < paramA.length; i++) {
        cmp = paramA[i].getName().compareTo(paramB[i].getName());
        if (cmp != 0)
          return cmp;
      }
      
      cmp = a.getDeclaringClass().getName().compareTo(b.getDeclaringClass().getName());
      if (cmp != 0)
        return cmp;
      
      return a.getReturnType().getName().compareTo(b.getReturnType().getName());
    }
  }
}
828436
protected void addToolManagerRules(Digester digester) {

        // add tool-manager
        String rulePath = "*/" + N_TOOLMANAGER;
        digester.addObjectCreate(rulePath, CmsToolManager.class);
        digester.addSetNext(rulePath, "setToolManager");
        // add tool-manager roots
        rulePath += "/" + N_ROOTS + "/" + N_ROOT;
        digester.addObjectCreate(rulePath, CmsToolRootHandler.class);
        digester.addSetNext(rulePath, "addToolRoot");
        digester.addBeanPropertySetter(rulePath + "/" + N_KEY);
        digester.addBeanPropertySetter(rulePath + "/" + N_URI);
        digester.addBeanPropertySetter(rulePath + "/" + N_NAME);
        digester.addBeanPropertySetter(rulePath + "/" + N_HELPTEXT, "helpText");
    }
994543
protected void addAccountsOrgunitRules(Digester digester, String xpath) {

        digester.addCallMethod(xpath + N_NAME, "setOrgUnitName", 0);
        digester.addCallMethod(xpath + N_DESCRIPTION, "setOrgUnitDescription", 0);
        digester.addCallMethod(xpath + N_FLAGS, "setOrgUnitFlags", 0);
        digester.addCallMethod(xpath + N_RESOURCES + "/" + N_RESOURCE, "addOrgUnitResource", 0);
        digester.addCallMethod(xpath + N_RESOURCES, "importOrgUnit");
    }
162610
public void setAdminCms(CmsObject cms) {

        if (m_adminCms != null) {
            LOG.error("Can not set admin CmsObject of configuration manager because it is already set.");
            return;
        }
        for (I_CmsXmlConfiguration config : m_configurations) {
            if (config instanceof I_CmsXmlConfigurationWithUpdateHandler) {
                ((I_CmsXmlConfigurationWithUpdateHandler)config).setCmsObject(cms);
            }
        }
        m_adminCms = cms;
    }
399740
public <T> void addMapper(Class<T> clazz, StringMapper<T> mapper) {
		addParser(clazz, mapper);
		mappers.put(clazz, mapper);
	}
40578
public void addLoader(I_CmsResourceLoader loader) throws CmsConfigurationException {

        // check if new loaders can still be added
        if (m_frozen) {
            throw new CmsConfigurationException(Messages.get().container(Messages.ERR_NO_CONFIG_AFTER_STARTUP_0));
        }

        // add the loader to the internal list of loaders
        int pos = loader.getLoaderId();
        if (pos >= m_loaders.length) {
            I_CmsResourceLoader[] buffer = new I_CmsResourceLoader[pos * 2];
            System.arraycopy(m_loaders, 0, buffer, 0, m_loaders.length);
            m_loaders = buffer;
        }
        m_loaders[pos] = loader;
        m_loaderList.add(loader);
        if (CmsLog.INIT.isInfoEnabled()) {
            CmsLog.INIT.info(
                Messages.get().getBundle().key(
                    Messages.INIT_ADD_LOADER_2,
                    loader.getClass().getName(),
                    new Integer(pos)));
        }
    }
442643
@Override
    public void addRuleInstances(Digester digester) {
        digester.addObjectCreate("profiles", Profiles.class);
        digester.addObjectCreate(PROFILES_PROFILE, Profile.class);
        digester.addObjectCreate(PROFILES_PROFILE_SETTING, Setting.class);

        digester.addSetNext(PROFILES_PROFILE, "addProfile");
        digester.addSetNext(PROFILES_PROFILE_SETTING, "addSetting");

        digester.addSetProperties(PROFILES_PROFILE, "kind", "kind");
        digester.addSetProperties(PROFILES_PROFILE_SETTING, "id", "id");
        digester.addSetProperties(PROFILES_PROFILE_SETTING, "value", "value");
    }
1186214
private void addVersionColumn() {

        AbstractCell<CmsHistoryResourceBean> cell = new CmsVersionCell();
        addColumn(CmsHistoryMessages.columnVersion(), 40, new IdentityColumn<CmsHistoryResourceBean>(cell));
    }
472166
@SuppressWarnings( "unchecked" )
    public synchronized void addConsumer( MessageConsumer<? extends Serializable> consumer ) {
        consumers.add((MessageConsumer<Serializable>)consumer);
    }
1213191
public void updateDigest(MessageDigest digest)
  {
    if (topLevel.markedForDeleteAt != Long.MIN_VALUE)
      digest.update(ByteBufferUtil.bytes(topLevel.markedForDeleteAt));

    if (ranges != null)
      ranges.updateDigest(digest);
  }
507641
public void addClassLoader(final ClassLoader classLoader) {
        if (this.addedClassLoaders == null) {
            this.addedClassLoaders = new ArrayList<>();
        }
        if (classLoader != null) {
            this.addedClassLoaders.add(classLoader);
        }
    }