/**
   * Reads the resources available for processing based on the path parameters.
   *
   * <p>
   *
   * @return the resources available for processing based on the path parameters.
   */
  @SuppressWarnings("unchecked")
  private List<CmsResource> getResources() {

    List<CmsResource> result = new LinkedList<CmsResource>();
    CmsObject cms = this.getCms();
    CmsResourceFilter filter = CmsResourceFilter.ALL;
    try {
      for (String path : this.m_paths) {
        List<CmsResource> resources = cms.readResources(path, filter, true);
        // filter out any resource that is no XML content:
        for (CmsResource resource : resources) {
          if (resource.isFile()) {
            if (CmsResourceTypeXmlContent.isXmlContent(resource)) {
              result.add(resource);
            } else if (CmsResourceTypeXmlPage.isXmlPage(resource)) {
              result.add(resource);
            }
          }
        }
      }
    } catch (CmsException e) {
      LOG.error(Messages.get().getBundle().key(Messages.LOG_ERR_LANGUAGECOPY_READRESOURCES_0), e);
      result = Collections.emptyList();
    }

    return result;
  }
  /**
   * Calculates the date to use for comparison of this resource based on the given date identifiers.
   *
   * <p>
   *
   * @param cms the current OpenCms user context
   * @param resource the resource to create the key for
   * @param dateIdentifiers the date identifiers to use for selecting the date
   * @param defaultValue the default value to use in case no value can be calculated
   * @return the calculated date
   * @see CmsDateResourceComparator for a description about how the date identifieres are used
   */
  public static long calculateDate(
      CmsObject cms, CmsResource resource, List<String> dateIdentifiers, long defaultValue) {

    long result = 0;
    List<CmsProperty> properties = null;
    for (int i = 0, size = dateIdentifiers.size(); i < size; i++) {
      // check all configured comparisons
      String date = dateIdentifiers.get(i);
      int pos = DATE_ATTRIBUTES_LIST.indexOf(date);
      switch (pos) {
        case 0: // "dateCreated"
          result = resource.getDateCreated();
          break;
        case 1: // "dateLastModified"
          result = resource.getDateLastModified();
          break;
        case 2: // "dateContent"
          if (resource.isFile()) {
            // date content makes no sense for folders
            result = resource.getDateContent();
          }
          break;
        case 3: // "dateReleased"
          long dr = resource.getDateReleased();
          if (dr != CmsResource.DATE_RELEASED_DEFAULT) {
            // default release date must be ignored
            result = dr;
          }
          break;
        case 4: // "dateExpired"
          long de = resource.getDateExpired();
          if (de != CmsResource.DATE_EXPIRED_DEFAULT) {
            // default expiration date must be ignored
            result = de;
          }
          break;
        default:
          // of this is not an attribute, assume this is a property
          if (properties == null) {
            // we may not have to read the properties since the user may only use attributes,
            // so use lazy initializing here
            try {
              properties = cms.readPropertyObjects(resource, false);
            } catch (CmsException e) {
              // use empty list in case of an error, to avoid further re-read tries
              properties = Collections.emptyList();
            }
          }
          String propValue = CmsProperty.get(date, properties).getValue();
          if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(propValue)) {
            try {
              result = Long.parseLong(propValue.trim());
            } catch (NumberFormatException e) {
              // maybe we have better luck with the next property
            }
          }
          break;
      }
      if (result != 0) {
        // if a date value has been found, terminate the loop
        break;
      }
    }
    if (result == 0) {
      // if nothing else was found, use default
      result = defaultValue;
    }
    return result;
  }