Example #1
0
  private void handleRecentItems(
      Document verticalDoc,
      Map<Integer, String> contentTypeKeyHandlerMapping,
      final ExtendedMap formItems,
      UserEntity user) {

    String maximize = formItems.getString("maximize", null);
    int index = formItems.getInt("index", 0);
    int count = formItems.getInt("count", maximize != null ? 20 : 10);

    ContentLogEntrySpecification logSpecification = new ContentLogEntrySpecification();
    logSpecification.setUser(user);
    logSpecification.setTypes(
        new LogType[] {LogType.ENTITY_OPENED, LogType.ENTITY_CREATED, LogType.ENTITY_UPDATED});
    logSpecification.setTableTypes(new Table[] {Table.CONTENT});
    logSpecification.setAllowDuplicateEntries(false);
    logSpecification.setAllowDeletedContent(false);

    Calendar now = GregorianCalendar.getInstance();
    final int monthsInPast = 3;
    now.add(Calendar.MONTH, -monthsInPast);
    logSpecification.setDateFilter(now.getTime());

    LogEntryResultSet logResult =
        logService.getLogEntries(logSpecification, "timestamp DESC", count, index);

    if (logResult.getLength() > 0) {

      // build contentTypeKey and handler mapping
      List<ContentKey> contentKeys = new ArrayList<ContentKey>();
      for (LogEntryEntity entity : logResult.getLogEntries()) {
        contentKeys.add(new ContentKey(entity.getKeyValue()));
      }

      ContentByContentQuery contentByContentQuery = new ContentByContentQuery();
      contentByContentQuery.setContentKeyFilter(contentKeys);
      contentByContentQuery.setUser(user);
      contentByContentQuery.setIndex(0);
      contentByContentQuery.setCount(logResult.getLength());
      ContentResultSet contentResultSet = contentService.queryContent(contentByContentQuery);
      for (ContentEntity entity : contentResultSet.getContents()) {
        contentTypeKeyHandlerMapping.put(
            entity.getContentType().getKey(),
            entity.getContentType().getContentHandlerName().getHandlerClassShortName());
      }
    }

    ContentLogXMLCreator logXMLCreator = new ContentLogXMLCreator();
    logXMLCreator.setIncludeContentData(true);
    logXMLCreator.setContentDao(contentDao);
    XMLDocument xmlDocument = logXMLCreator.createLogsDocument(logResult);

    Document lastModifiedDoc = xmlDocument.getAsDOMDocument();

    lastModifiedDoc.getDocumentElement().setAttribute("type", "lastmodified");
    XMLTool.mergeDocuments(verticalDoc, lastModifiedDoc, true);
  }
Example #2
0
  private void handleActivation(
      Document verticalDoc,
      Map<Integer, String> contentTypeKeyHandlerMapping,
      final ExtendedMap formItems,
      UserEntity user) {

    String maximize = formItems.getString("maximize", null);
    int index = formItems.getInt("index", 0);
    int count = formItems.getInt("count", maximize != null ? 20 : 3);

    ContentBySectionQuery contentBySectionQuery = new ContentBySectionQuery();
    contentBySectionQuery.setSectionFilterStatus(SectionFilterStatus.UNAPPROVED_ONLY);
    contentBySectionQuery.setSearchInAllSections();
    contentBySectionQuery.setCount(count);
    contentBySectionQuery.setUser(user);
    contentBySectionQuery.setOrderBy("timestamp DESC");
    contentBySectionQuery.setIndex(index);
    contentBySectionQuery.setFilterIncludeOfflineContent();
    contentBySectionQuery.setLevels(Integer.MAX_VALUE);

    List<CategoryAccessType> categoryAccessTypeFilter = new ArrayList<CategoryAccessType>();
    categoryAccessTypeFilter.add(CategoryAccessType.ADMINISTRATE);
    categoryAccessTypeFilter.add(CategoryAccessType.APPROVE);
    contentBySectionQuery.setCategoryAccessTypeFilter(
        categoryAccessTypeFilter, CategoryAccessTypeFilterPolicy.OR);

    ContentResultSet contentResultSet = null;
    try {
      contentResultSet = contentService.queryContent(contentBySectionQuery);
    } catch (Exception e) {
      throw new VerticalAdminException("Failed to get unapproved content", e);
    }

    // build contentTypeKey and handlerName mapping
    for (ContentEntity entity : contentResultSet.getContents()) {
      contentTypeKeyHandlerMapping.put(
          entity.getContentType().getKey(),
          entity.getContentType().getContentHandlerName().getHandlerClassShortName());
    }

    SectionXmlCreator sectionXmlCreator =
        new SectionXmlCreator(
            siteDao, new CategoryAccessResolver(groupDao), new ContentAccessResolver(groupDao));
    XMLDocument sectionDocument =
        sectionXmlCreator.createSectionsDocument(user, contentResultSet, count);

    Document waitingForActivationDoc = sectionDocument.getAsDOMDocument();
    // waitingForActivationDoc.getDocumentElement().setAttribute("type", "activation");

    XMLTool.mergeDocuments(verticalDoc, waitingForActivationDoc, true);
  }
Example #3
0
  private void handleAssignedToMe(
      Document verticalDoc,
      Map<Integer, String> contentTypeKeyHandlerMapping,
      final ExtendedMap formItems,
      UserEntity user) {
    String maximize = formItems.getString("maximize", null);
    int index = formItems.getInt("index", 0);
    int count = formItems.getInt("count", maximize != null ? 20 : ASSIGNED_TO_COUNT);

    ContentSpecification contentSpecification = new ContentSpecification();
    // contentSpecification.setUser( user );
    contentSpecification.setAssignee(user);
    contentSpecification.setAssignedDraftsOnly(false);

    ContentResultSet contentResultSet =
        contentService.getContent(
            contentSpecification, "c.assignmentDueDate ASC, c.timestamp DESC", count, index);

    for (ContentEntity content : contentResultSet.getContents()) {
      contentTypeKeyHandlerMapping.put(
          content.getContentType().getKey(),
          content.getContentType().getContentHandlerName().getHandlerClassShortName());
    }

    ContentXMLCreator contentXMLCreator = new ContentXMLCreator();
    contentXMLCreator.setResultIndexing(index, count);
    contentXMLCreator.setIncludeOwnerAndModifierData(true);
    contentXMLCreator.setIncludeContentData(true);
    contentXMLCreator.setIncludeCategoryData(true);
    contentXMLCreator.setIncludeAccessRightsInfo(false);
    contentXMLCreator.setIncludeRelatedContentsInfo(false);
    contentXMLCreator.setIncludeRepositoryPathInfo(true);
    contentXMLCreator.setIncludeVersionsInfoForAdmin(true);
    contentXMLCreator.setIncludeAssignment(true);
    contentXMLCreator.setIncludeDraftInfo(true);
    contentXMLCreator.setIncludeSectionActivationInfo(true);
    XMLDocument xmlDocument =
        contentXMLCreator.createContentVersionsDocument(
            user, contentResultSet, new RelatedContentResultSetImpl());

    Document doc = xmlDocument.getAsDOMDocument();
    doc.getDocumentElement().setAttribute("type", "assignedto");

    XMLTool.mergeDocuments(verticalDoc, doc, true);
  }