コード例 #1
0
ファイル: Exporter.java プロジェクト: jameswu/code-search
  protected void exportPage(WikiEngine engine, WikiPage p) throws IOException, ProviderException {
    String name = p.getName();
    String title = name;
    boolean isAttachment = p instanceof Attachment;

    title = generateTitle(name, title, isAttachment);

    exportPageHeader(p.getName(), p.getWiki(), p.getAuthor(), p.getLastModified(), isAttachment);

    Map<String, Object> attrMap = p.getAttributes();

    exportAttributes(attrMap);

    //
    //  ACLs
    //

    Acl acl = p.getAcl();

    exportAcl(acl);

    //
    //  Export page content
    //

    exportProperty("wiki:content", engine.getPureText(p), STRING);

    //
    //  Finally, list attachment.  According to JCR rules, these must be last.
    //
    /*
    Collection<Attachment> atts = m_engine.getAttachmentManager().listAttachments( p );

    for( Attachment a : atts )
    {
        exportPage( a );
    }
    */
    exportPageFooter();
  }
コード例 #2
0
  /**
   * Filters a collection according to the include and exclude parameters.
   *
   * @param c The collection to filter.
   * @return A filtered collection.
   */
  protected Collection filterCollection(Collection c) {
    ArrayList<Object> result = new ArrayList<Object>();

    PatternMatcher pm = new Perl5Matcher();

    for (Iterator i = c.iterator(); i.hasNext(); ) {
      String pageName = null;
      Object objectje = i.next();
      if (objectje instanceof WikiPage) {
        pageName = ((WikiPage) objectje).getName();
      } else {
        pageName = (String) objectje;
      }

      //
      //  If include parameter exists, then by default we include only those
      //  pages in it (excluding the ones in the exclude pattern list).
      //
      //  include='*' means the same as no include.
      //
      boolean includeThis = m_include == null;

      if (m_include != null) {
        for (int j = 0; j < m_include.length; j++) {
          if (pm.matches(pageName, m_include[j])) {
            includeThis = true;
            break;
          }
        }
      }

      if (m_exclude != null) {
        for (int j = 0; j < m_exclude.length; j++) {
          if (pm.matches(pageName, m_exclude[j])) {
            includeThis = false;
            break; // The inner loop, continue on the next item
          }
        }
      }

      if (includeThis) {
        if (objectje instanceof WikiPage) {
          result.add(objectje);
        } else {
          result.add(pageName);
        }
        //
        //  if we want to show the last modified date of the most recently change page, we keep a
        // "high watermark" here:
        WikiPage page = null;
        if (m_lastModified) {
          page = m_engine.getPage(pageName);
          if (page != null) {
            Date lastModPage = page.getLastModified();
            if (log.isDebugEnabled()) {
              log.debug("lastModified Date of page " + pageName + " : " + m_dateLastModified);
            }
            if (lastModPage.after(m_dateLastModified)) {
              m_dateLastModified = lastModPage;
            }
          }
        }
      }
    }

    return result;
  }