コード例 #1
0
 @Override
 public void process(TemplatingContext templatingContext) throws ProcessingException {
   RequestParameters parameters = RequestParameters.getRequestParameters(context);
   super.process(templatingContext);
   if (parameters.get("exportType").equals("full") || parameters.get("exportType").equals("xml")) {
     templatingContext.put("recordDetails", recordDetailsExport);
     templatingContext.put("dateConverter", new PatternDateConverter("yyyyMMdd"));
   }
   if (parameters.get("exportType").equals("xml")) {
     HttpContext httpContext = HttpContext.getHttpContext(context);
     httpContext.setContentType("application/xml");
   }
 }
コード例 #2
0
ファイル: AddAlias.java プロジェクト: objectledge/cyklotron
 public boolean checkAccessRights(Context context) throws ProcessingException {
   CoralSession coralSession = (CoralSession) context.getAttribute(CoralSession.class);
   RequestParameters parameters = RequestParameters.getRequestParameters(context);
   try {
     NavigationNodeResource node = getCmsData(context).getNode();
     NavigationNodeResource originalNode =
         NavigationNodeResourceImpl.getNavigationNodeResource(
             coralSession, parameters.getLong("original_node_id"));
     Permission addInboundAlias =
         coralSession.getSecurity().getUniquePermission("cms.structure.add_inbound_alias");
     return node.canAddChild(coralSession, coralSession.getUserSubject())
         && coralSession.getUserSubject().hasPermission(originalNode, addInboundAlias);
   } catch (EntityDoesNotExistException e) {
     throw new ProcessingException("missing or invalid parameters", e);
   }
 }
コード例 #3
0
 public boolean checkAccessRights(Context context) throws ProcessingException {
   Parameters parameters = RequestParameters.getRequestParameters(context);
   CoralSession coralSession = (CoralSession) context.getAttribute(CoralSession.class);
   try {
     long dirId = parameters.getLong("parent_id", -1);
     if (dirId == -1) {
       return true;
     } else {
       Resource resource = coralSession.getStore().getResource(dirId);
       Permission permission = coralSession.getSecurity().getUniquePermission("cms.files.write");
       return coralSession.getUserSubject().hasPermission(resource, permission);
     }
   } catch (Exception e) {
     logger.error("Subject has no rights to view this screen", e);
     return false;
   }
 }
コード例 #4
0
 public void prepareDefault(Context context) throws ProcessingException {
   Parameters parameters = RequestParameters.getRequestParameters(context);
   CoralSession coralSession = (CoralSession) context.getAttribute(CoralSession.class);
   HttpContext httpContext = HttpContext.getHttpContext(context);
   I18nContext i18nContext = I18nContext.getI18nContext(context);
   TemplatingContext templatingContext = TemplatingContext.getTemplatingContext(context);
   SiteResource site = getSite();
   try {
     templatingContext.put("styles", Arrays.asList(styleService.getStyles(coralSession, site)));
     long parent_node_id = parameters.getLong("parent_node_id", -1);
     if (parent_node_id == -1) {
       templatingContext.put("parent_node", getHomePage());
     } else {
       templatingContext.put(
           "parent_node",
           NavigationNodeResourceImpl.getNavigationNodeResource(coralSession, parent_node_id));
     }
   } catch (Exception e) {
     throw new ProcessingException("Screen Error " + e);
   }
 }
コード例 #5
0
 /** Checks if the current user has the specific permission on the current category. */
 public boolean checkPermission(Context context, CoralSession coralSession, String permissionName)
     throws ProcessingException {
   Parameters parameters = RequestParameters.getRequestParameters(context);
   return CategoryUtil.checkPermission(coralSession, parameters, permissionName);
 }
コード例 #6
0
 public String getState() {
   Parameters parameters = RequestParameters.getRequestParameters(context);
   return parameters.get("state", "Default");
 }
コード例 #7
0
  @Override
  protected MultiIndexTableTool createHitsTable(
      TemplatingContext templatingContext,
      RequestParameters parameters,
      Locale locale,
      Collection<String> indexNames,
      String page)
      throws QueryCreationException, TableException {
    if (!parameters.isDefined("selected")) {
      QueryCreator queryCreator = queryCreatorFactory.getQueryCreator(parameters, locale);
      templatingContext.put("queryCreator", queryCreator);
      TableState state = tableStateManager.getState(context, this.getClass().getCanonicalName());
      state.setPageSize(configurator.getPageSize());
      if (page == null) state.setCurrentPage(1);
      else state.setCurrentPage(new Integer(page));

      state.setOld();
      log.debug("Query: " + queryCreator.getQuery());

      List<TableFilter> filters = new ArrayList<TableFilter>();
      MultiIndexTableTool hitsTable =
          (MultiIndexTableTool)
              searchExecutor.search(
                  indexNames,
                  queryCreator.getQuery(),
                  queryCreator.getSortFields(),
                  state,
                  filters);

      templatingContext.put("page", page);
      List<Integer> selected = new LinkedList<Integer>();
      for (int i = 0; i < hitsTable.getPageRowCount(); i++) {
        selected.add(i);
        templatingContext.put("selected", selected);
      }
      return hitsTable;
    }
    QueryCreator queryCreator = queryCreatorFactory.getQueryCreator(parameters, locale);
    templatingContext.put("queryCreator", queryCreator);
    TableState state = tableStateManager.getState(context, this.getClass().getCanonicalName());

    SortedSet<String> selectedItems = new TreeSet<String>();
    SortedSet<String> index = new TreeSet<String>();
    for (String selected : parameters.getStrings("selected")) {
      String id = selected.replaceAll("\\.", "");
      selectedItems.add(id);
      index.add(indexIdentifier.identify(id));
    }
    state.setPageSize(0);
    List<String> indx = new LinkedList<String>();
    indx.addAll(index);
    Collections.sort(
        indx,
        new Comparator<String>() {
          @Override
          public int compare(String a, String b) {
            if ("treaties".equals(a)) return -1;
            if ("treaties".equals(b)) return 1;
            if ("documents".equals(a)) return -1;
            if ("documents".equals(b)) return 1;
            if ("literature".equals(a)) return -1;
            if ("literature".equals(b)) return 1;
            if ("courtdecisions".equals(a)) return -1;
            if ("courtdecisions".equals(b)) return 1;

            return 1;
          }
        });

    log.debug("Query: " + queryCreator.getQuery());

    List<TableFilter> filters = new ArrayList<TableFilter>();
    MultiIndexTableTool table =
        (MultiIndexTableTool)
            searchExecutor.search(
                indx, queryCreator.getQuery(), queryCreator.getSortFields(), state, filters);

    List<Integer> selected = new LinkedList<Integer>();
    for (int i = 0; i < table.getRows().size(); i++) {
      String id =
          (String) ((LuceneSearchHit) ((TableRow) table.getRows().get(i)).getObject()).get("id");
      if (selectedItems.contains(id)) {
        selected.add(i);
      }
    }
    templatingContext.put("selected", selected);
    return table;
  }