All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.greenpepper.confluence.actions.execution.LabelExecutionAction Maven / Gradle / Ivy

There is a newer version: 4.2.4
Show newest version
package com.greenpepper.confluence.actions.execution;

import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

import com.atlassian.confluence.labels.Label;
import com.atlassian.confluence.pages.Page;

/**
 * 

LabelExecutionAction class.

* * @author oaouattara * @version $Id: $Id */ @SuppressWarnings("serial") public class LabelExecutionAction extends AbstractListExecutionAction { private String labels; private boolean searchQuery; /** *

buildExecutableList.

*/ public void buildExecutableList() { for(String labelExp : labels.split(",")) { List pages = getExpLabeledPages(labelExp); for(Page page : pages) { if (page.getSpaceKey().equals(spaceKey) && !executableList.contains(page) && gpUtil.isExecutable(page)) { executableList.add(page); } } } } /** *

Getter for the field labels.

* * @return a {@link java.lang.String} object. */ public String getLabels() { return labels; } /** *

Setter for the field labels.

* * @param labels a {@link java.lang.String} object. */ public void setLabels(String labels) { this.labels = labels.replaceAll("&", "&"); } /** *

Getter for the field searchQuery.

* * @return a boolean. */ public boolean getSearchQuery() { return searchQuery; } /** *

Setter for the field searchQuery.

* * @param searchQuery a boolean. */ public void setSearchQuery(boolean searchQuery) { this.searchQuery = searchQuery; } private List getExpLabeledPages(String labelExp) { StringTokenizer stk = new StringTokenizer(labelExp, "&"); int tokens = stk.countTokens(); if(tokens <= 1) { return getLabeledPages(labelExp.trim()); } List pages = getLabeledPages(stk.nextToken().trim()); for(int i = 1; i < tokens; i++) { pages.retainAll(getLabeledPages(stk.nextToken().trim())); } return pages; } @SuppressWarnings("unchecked") private List getLabeledPages(String label) { Label labelObject = gpUtil.getLabelManager().getLabel(label.trim()); if(labelObject != null) { return gpUtil.getLabelManager().getContent(labelObject); } return new ArrayList(); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy