Fixed URL generation for object lists and Content Item Summary. The WebContextPath was not used there therefore the URLs were incorrect if CCM is installed not in the root context.
git-svn-id: https://svn.libreccm.org/ccm/trunk@2878 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
b7ca4a6670
commit
7e646e8be6
|
|
@ -52,11 +52,13 @@ import com.arsdigita.toolbox.ui.FormatStandards;
|
||||||
import com.arsdigita.util.Assert;
|
import com.arsdigita.util.Assert;
|
||||||
import com.arsdigita.util.GraphSet;
|
import com.arsdigita.util.GraphSet;
|
||||||
import com.arsdigita.util.Graphs;
|
import com.arsdigita.util.Graphs;
|
||||||
|
import com.arsdigita.util.UncheckedWrapperException;
|
||||||
import com.arsdigita.versioning.Transaction;
|
import com.arsdigita.versioning.Transaction;
|
||||||
import com.arsdigita.versioning.TransactionCollection;
|
import com.arsdigita.versioning.TransactionCollection;
|
||||||
import com.arsdigita.versioning.Versions;
|
import com.arsdigita.versioning.Versions;
|
||||||
import com.arsdigita.web.RedirectSignal;
|
import com.arsdigita.web.RedirectSignal;
|
||||||
import com.arsdigita.web.Web;
|
import com.arsdigita.web.Web;
|
||||||
|
import com.arsdigita.web.WebContext;
|
||||||
import com.arsdigita.workflow.simple.Engine;
|
import com.arsdigita.workflow.simple.Engine;
|
||||||
import com.arsdigita.workflow.simple.Task;
|
import com.arsdigita.workflow.simple.Task;
|
||||||
import com.arsdigita.workflow.simple.TaskCollection;
|
import com.arsdigita.workflow.simple.TaskCollection;
|
||||||
|
|
@ -64,15 +66,18 @@ import com.arsdigita.workflow.simple.TaskComment;
|
||||||
import com.arsdigita.workflow.simple.Workflow;
|
import com.arsdigita.workflow.simple.Workflow;
|
||||||
import com.arsdigita.workflow.simple.WorkflowTemplate;
|
import com.arsdigita.workflow.simple.WorkflowTemplate;
|
||||||
import com.arsdigita.xml.Element;
|
import com.arsdigita.xml.Element;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>This panel displays basic details about a content item such as
|
* <p>
|
||||||
* attributes and associations.</p>
|
* This panel displays basic details about a content item such as attributes and associations.</p>
|
||||||
*
|
*
|
||||||
* <p>Container: {@link com.arsdigita.cms.ui.ContentItemPage}
|
* <p>
|
||||||
|
* Container: {@link com.arsdigita.cms.ui.ContentItemPage}
|
||||||
*
|
*
|
||||||
* <p>This panel uses an {@link com.arsdigita.cms.dispatcher.XMLGenerator}
|
* <p>
|
||||||
* to convert content items into XML.</p>
|
* This panel uses an {@link com.arsdigita.cms.dispatcher.XMLGenerator} to convert content items
|
||||||
|
* into XML.</p>
|
||||||
*
|
*
|
||||||
* @author Michael Pih (pihman@arsdigita.com)
|
* @author Michael Pih (pihman@arsdigita.com)
|
||||||
* @version $Id: Summary.java 1940 2009-05-29 07:15:05Z terry $
|
* @version $Id: Summary.java 1940 2009-05-29 07:15:05Z terry $
|
||||||
|
|
@ -84,7 +89,6 @@ public class Summary extends CMSContainer {
|
||||||
|
|
||||||
private final ItemSelectionModel m_item;
|
private final ItemSelectionModel m_item;
|
||||||
|
|
||||||
|
|
||||||
public Summary(ItemSelectionModel m) {
|
public Summary(ItemSelectionModel m) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
|
@ -94,14 +98,15 @@ public class Summary extends CMSContainer {
|
||||||
/**
|
/**
|
||||||
* Generate XML representation of an item summary.
|
* Generate XML representation of an item summary.
|
||||||
*
|
*
|
||||||
* @param state The page state
|
* @param state The page state
|
||||||
* @param parent The parent DOM element
|
* @param parent The parent DOM element
|
||||||
|
*
|
||||||
* @pre ( state != null )
|
* @pre ( state != null )
|
||||||
* @pre ( parent != null )
|
* @pre ( parent != null )
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void generateXML(PageState state, Element parent) {
|
public void generateXML(PageState state, Element parent) {
|
||||||
if ( isVisible(state) ) {
|
if (isVisible(state)) {
|
||||||
|
|
||||||
// Determine the item's environment
|
// Determine the item's environment
|
||||||
ContentItem item = getContentItem(state);
|
ContentItem item = getContentItem(state);
|
||||||
|
|
@ -109,10 +114,10 @@ public class Summary extends CMSContainer {
|
||||||
User user = Web.getWebContext().getUser();
|
User user = Web.getWebContext().getUser();
|
||||||
|
|
||||||
// Setup xml element for item's properties
|
// Setup xml element for item's properties
|
||||||
Element itemElement = new Element("cms:itemSummary",CMS.CMS_XML_NS);
|
Element itemElement = new Element("cms:itemSummary", CMS.CMS_XML_NS);
|
||||||
|
|
||||||
// Determine item's name / url stub
|
// Determine item's name / url stub
|
||||||
itemElement.addAttribute("name",item.getName());
|
itemElement.addAttribute("name", item.getName());
|
||||||
|
|
||||||
// obviously getName() here gets the 'semantically meaningful name'
|
// obviously getName() here gets the 'semantically meaningful name'
|
||||||
// from database using class DataType. It is not localizable! And
|
// from database using class DataType. It is not localizable! And
|
||||||
|
|
@ -126,46 +131,49 @@ public class Summary extends CMSContainer {
|
||||||
// Take advantage of caching in the CMS Dispatcher.
|
// Take advantage of caching in the CMS Dispatcher.
|
||||||
// XMLGenerator xmlGenerator = section.getXMLGenerator();
|
// XMLGenerator xmlGenerator = section.getXMLGenerator();
|
||||||
// xmlGenerator.generateXML(state, parent, SUMMARY);
|
// xmlGenerator.generateXML(state, parent, SUMMARY);
|
||||||
|
|
||||||
String descriptionAttribute = "";
|
String descriptionAttribute = "";
|
||||||
if ( objectType.equals("NewsItem") || objectType.equals("Article") ) {
|
if (objectType.equals("NewsItem") || objectType.equals("Article")) {
|
||||||
descriptionAttribute = "lead";
|
descriptionAttribute = "lead";
|
||||||
} else if ( objectType.equals("FileStorageItem") || objectType.equals("Minutes") ) {
|
} else if (objectType.equals("FileStorageItem") || objectType.equals("Minutes")) {
|
||||||
descriptionAttribute = "description";
|
descriptionAttribute = "description";
|
||||||
} else if ( objectType.equals("Job") ) {
|
} else if (objectType.equals("Job")) {
|
||||||
descriptionAttribute = "jobDescription";
|
descriptionAttribute = "jobDescription";
|
||||||
} else if ( objectType.equals("MultiPartArticle") || objectType.equals("Agenda") || objectType.equals("PressRelease") || objectType.equals("Service") ) {
|
} else if (objectType.equals("MultiPartArticle") || objectType.equals("Agenda")
|
||||||
|
|| objectType.equals("PressRelease") || objectType.equals("Service")) {
|
||||||
descriptionAttribute = "summary";
|
descriptionAttribute = "summary";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !descriptionAttribute.equals("") ) {
|
if (!descriptionAttribute.equals("")) {
|
||||||
itemElement.addAttribute("description",(String)DomainServiceInterfaceExposer.get(item,descriptionAttribute));
|
itemElement.addAttribute("description", (String) DomainServiceInterfaceExposer.get(
|
||||||
|
item, descriptionAttribute));
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ContentPage page = new ContentPage(item.getID());
|
ContentPage page = new ContentPage(item.getID());
|
||||||
itemElement.addAttribute("title",page.getTitle());
|
itemElement.addAttribute("title", page.getTitle());
|
||||||
} catch (DataObjectNotFoundException ex) {
|
} catch (DataObjectNotFoundException ex) {
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
// subject category
|
// subject category
|
||||||
Element subjectsElement = new Element("cms:subjectCategories",CMS.CMS_XML_NS);
|
Element subjectsElement = new Element("cms:subjectCategories", CMS.CMS_XML_NS);
|
||||||
itemElement.addContent(subjectsElement);
|
itemElement.addContent(subjectsElement);
|
||||||
Category itemCategory = null;
|
Category itemCategory = null;
|
||||||
Category subjectCategory = Category.getRootForObject(section,"subject");
|
Category subjectCategory = Category.getRootForObject(section, "subject");
|
||||||
if ( subjectCategory != null ) {
|
if (subjectCategory != null) {
|
||||||
CategoryCollection categories = item.getCategoryCollection();
|
CategoryCollection categories = item.getCategoryCollection();
|
||||||
while (categories.next()) {
|
while (categories.next()) {
|
||||||
Category category = categories.getCategory();
|
Category category = categories.getCategory();
|
||||||
CategoryCollection parents = category.getDefaultAscendants();
|
CategoryCollection parents = category.getDefaultAscendants();
|
||||||
parents.addOrder(Category.DEFAULT_ANCESTORS);
|
parents.addOrder(Category.DEFAULT_ANCESTORS);
|
||||||
if ( parents.next() ) {
|
if (parents.next()) {
|
||||||
Category parentCategory = parents.getCategory();
|
Category parentCategory = parents.getCategory();
|
||||||
if (parentCategory.equals(subjectCategory)) {
|
if (parentCategory.equals(subjectCategory)) {
|
||||||
Element subjectElement = new Element("cms:subjectCategory",CMS.CMS_XML_NS);
|
Element subjectElement = new Element("cms:subjectCategory",
|
||||||
subjectElement.addAttribute("name",category.getName());
|
CMS.CMS_XML_NS);
|
||||||
subjectElement.setText(category.getPreferredQualifiedName(" -> ",true));
|
subjectElement.addAttribute("name", category.getName());
|
||||||
|
subjectElement.setText(category.getPreferredQualifiedName(" -> ",
|
||||||
|
true));
|
||||||
subjectsElement.addContent(subjectElement);
|
subjectsElement.addContent(subjectElement);
|
||||||
}
|
}
|
||||||
parents.close();
|
parents.close();
|
||||||
|
|
@ -174,15 +182,25 @@ public class Summary extends CMSContainer {
|
||||||
}
|
}
|
||||||
|
|
||||||
// URL
|
// URL
|
||||||
Element linkElement = new Element("cms:linkSummary",CMS.CMS_XML_NS);
|
Element linkElement = new Element("cms:linkSummary", CMS.CMS_XML_NS);
|
||||||
linkElement.addAttribute("url","/redirect?oid=" + URLEncoder.encode(item.getDraftVersion().getOID().toString()));
|
try {
|
||||||
|
linkElement.addAttribute("url",
|
||||||
|
String.format("%s/redirect?oid=%s",
|
||||||
|
Web.getWebappContextPath(),
|
||||||
|
URLEncoder.encode(item.getDraftVersion()
|
||||||
|
.getOID()
|
||||||
|
.toString(), "utf-8")));
|
||||||
|
} catch (UnsupportedEncodingException ex) {
|
||||||
|
throw new UncheckedWrapperException(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
//"/redirect?oid=" + URLEncoder.encode(item.getDraftVersion().getOID().toString()));
|
||||||
// WORKFLOW
|
// WORKFLOW
|
||||||
Element workflowElement = new Element("cms:workflowSummary",CMS.CMS_XML_NS);
|
Element workflowElement = new Element("cms:workflowSummary", CMS.CMS_XML_NS);
|
||||||
Workflow workflow = Workflow.getObjectWorkflow(item);
|
Workflow workflow = Workflow.getObjectWorkflow(item);
|
||||||
|
|
||||||
SecurityManager sm = CMS.getContext().getSecurityManager();
|
SecurityManager sm = CMS.getContext().getSecurityManager();
|
||||||
if ( canWorkflowBeExtended(user,item,workflow) ) {
|
if (canWorkflowBeExtended(user, item, workflow)) {
|
||||||
// control event for restarting workflow in edit mode
|
// control event for restarting workflow in edit mode
|
||||||
try {
|
try {
|
||||||
state.setControlEvent(this, RESTART_WORKFLOW, item.getID().toString());
|
state.setControlEvent(this, RESTART_WORKFLOW, item.getID().toString());
|
||||||
|
|
@ -193,10 +211,10 @@ public class Summary extends CMSContainer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( workflow == null ) {
|
if (workflow == null) {
|
||||||
workflowElement.addAttribute("noWorkflow","1");
|
workflowElement.addAttribute("noWorkflow", "1");
|
||||||
} else {
|
} else {
|
||||||
workflowElement.addAttribute("name",workflow.getDisplayName());
|
workflowElement.addAttribute("name", workflow.getDisplayName());
|
||||||
|
|
||||||
TaskCollection tc = workflow.getTaskCollection();
|
TaskCollection tc = workflow.getTaskCollection();
|
||||||
GraphSet g = new GraphSet();
|
GraphSet g = new GraphSet();
|
||||||
|
|
@ -223,9 +241,9 @@ public class Summary extends CMSContainer {
|
||||||
outer:
|
outer:
|
||||||
while (g.nodeCount() > 0) {
|
while (g.nodeCount() > 0) {
|
||||||
List l = Graphs.getSinkNodes(g);
|
List l = Graphs.getSinkNodes(g);
|
||||||
for (Iterator it = l.iterator(); it.hasNext(); ) {
|
for (Iterator it = l.iterator(); it.hasNext();) {
|
||||||
Task t = (Task) it.next();
|
Task t = (Task) it.next();
|
||||||
taskList.add(0,t);
|
taskList.add(0, t);
|
||||||
g.removeNode(t);
|
g.removeNode(t);
|
||||||
continue outer;
|
continue outer;
|
||||||
}
|
}
|
||||||
|
|
@ -235,23 +253,24 @@ public class Summary extends CMSContainer {
|
||||||
Iterator tasks = taskList.iterator();
|
Iterator tasks = taskList.iterator();
|
||||||
|
|
||||||
while (tasks.hasNext()) {
|
while (tasks.hasNext()) {
|
||||||
Task task = (Task)tasks.next();
|
Task task = (Task) tasks.next();
|
||||||
Element taskElement = new Element("cms:task",CMS.CMS_XML_NS);
|
Element taskElement = new Element("cms:task", CMS.CMS_XML_NS);
|
||||||
taskElement.addAttribute("name",task.getDisplayName());
|
taskElement.addAttribute("name", task.getDisplayName());
|
||||||
taskElement.addAttribute("state",task.getStateString());
|
taskElement.addAttribute("state", task.getStateString());
|
||||||
Iterator comments = task.getComments();
|
Iterator comments = task.getComments();
|
||||||
while ( comments.hasNext() ) {
|
while (comments.hasNext()) {
|
||||||
TaskComment comment = (TaskComment)comments.next();
|
TaskComment comment = (TaskComment) comments.next();
|
||||||
Element commentElement = new Element("cms:taskComment",CMS.CMS_XML_NS);
|
Element commentElement = new Element("cms:taskComment", CMS.CMS_XML_NS);
|
||||||
User author = comment.getUser();
|
User author = comment.getUser();
|
||||||
String authorName = "Anonymous";
|
String authorName = "Anonymous";
|
||||||
if ( author != null ) {
|
if (author != null) {
|
||||||
authorName = author.getDisplayName();
|
authorName = author.getDisplayName();
|
||||||
}
|
}
|
||||||
|
|
||||||
commentElement.addAttribute("author",authorName);
|
commentElement.addAttribute("author", authorName);
|
||||||
commentElement.addAttribute("comment",comment.getComment());
|
commentElement.addAttribute("comment", comment.getComment());
|
||||||
commentElement.addAttribute("date",FormatStandards.formatDate(comment.getDate()));
|
commentElement.addAttribute("date", FormatStandards.formatDate(comment
|
||||||
|
.getDate()));
|
||||||
|
|
||||||
taskElement.addContent(commentElement);
|
taskElement.addContent(commentElement);
|
||||||
}
|
}
|
||||||
|
|
@ -261,62 +280,70 @@ public class Summary extends CMSContainer {
|
||||||
}
|
}
|
||||||
|
|
||||||
// REVISION HISTORY
|
// REVISION HISTORY
|
||||||
Element transactionElement = new Element("cms:transactionSummary",CMS.CMS_XML_NS);
|
Element transactionElement = new Element("cms:transactionSummary", CMS.CMS_XML_NS);
|
||||||
transactionElement.addAttribute("creationDate",FormatStandards.formatDate(item.getCreationDate()));
|
transactionElement.addAttribute("creationDate", FormatStandards.formatDate(item
|
||||||
transactionElement.addAttribute("lastModifiedDate",FormatStandards.formatDate(item.getLastModifiedDate()));
|
.getCreationDate()));
|
||||||
|
transactionElement.addAttribute("lastModifiedDate", FormatStandards.formatDate(item
|
||||||
|
.getLastModifiedDate()));
|
||||||
|
|
||||||
TransactionCollection transactions = Versions.getTaggedTransactions(item.getOID());
|
TransactionCollection transactions = Versions.getTaggedTransactions(item.getOID());
|
||||||
while ( transactions.next() ) {
|
while (transactions.next()) {
|
||||||
Transaction transaction = transactions.getTransaction();
|
Transaction transaction = transactions.getTransaction();
|
||||||
Element element = new Element("cms:transaction",CMS.CMS_XML_NS);
|
Element element = new Element("cms:transaction", CMS.CMS_XML_NS);
|
||||||
element.addAttribute("date",FormatStandards.formatDate(transaction.getTimestamp()));
|
element.addAttribute("date", FormatStandards.formatDate(transaction.getTimestamp()));
|
||||||
String authorName = "Anonymous";
|
String authorName = "Anonymous";
|
||||||
User author = transaction.getUser();
|
User author = transaction.getUser();
|
||||||
if ( author != null ) {
|
if (author != null) {
|
||||||
authorName = author.getDisplayName();
|
authorName = author.getDisplayName();
|
||||||
}
|
}
|
||||||
element.addAttribute("author",authorName);
|
element.addAttribute("author", authorName);
|
||||||
|
|
||||||
String url = section.getItemResolver().generateItemURL(state,item,section,CMSDispatcher.PREVIEW) + "?transID=" + transaction.getID();
|
String url = section.getItemResolver().generateItemURL(state, item, section,
|
||||||
element.addAttribute("url",url);
|
CMSDispatcher.PREVIEW)
|
||||||
|
+ "?transID=" + transaction.getID();
|
||||||
|
element.addAttribute("url", url);
|
||||||
transactionElement.addContent(element);
|
transactionElement.addContent(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
transactions.close();
|
transactions.close();
|
||||||
|
|
||||||
// CATEGORY
|
// CATEGORY
|
||||||
Element categoryElement = new Element("cms:categorySummary",CMS.CMS_XML_NS);
|
Element categoryElement = new Element("cms:categorySummary", CMS.CMS_XML_NS);
|
||||||
|
|
||||||
CategoryCollection categories = item.getCategoryCollection();
|
CategoryCollection categories = item.getCategoryCollection();
|
||||||
while (categories.next()) {
|
while (categories.next()) {
|
||||||
Category category = categories.getCategory();
|
Category category = categories.getCategory();
|
||||||
Element element = new Element("cms:category",CMS.CMS_XML_NS);
|
Element element = new Element("cms:category", CMS.CMS_XML_NS);
|
||||||
element.setText(category.getPreferredQualifiedName(" -> ",true));
|
element.setText(category.getPreferredQualifiedName(" -> ", true));
|
||||||
categoryElement.addContent(element);
|
categoryElement.addContent(element);
|
||||||
|
|
||||||
}
|
}
|
||||||
categories.close();
|
categories.close();
|
||||||
|
|
||||||
// LIFECYCLE
|
// LIFECYCLE
|
||||||
Element lifecycleElement = new Element("cms:lifecycleSummary",CMS.CMS_XML_NS);
|
Element lifecycleElement = new Element("cms:lifecycleSummary", CMS.CMS_XML_NS);
|
||||||
|
|
||||||
Lifecycle lifecycle = item.getLifecycle();
|
Lifecycle lifecycle = item.getLifecycle();
|
||||||
if ( lifecycle == null ) {
|
if (lifecycle == null) {
|
||||||
lifecycleElement.addAttribute("noLifecycle","1");
|
lifecycleElement.addAttribute("noLifecycle", "1");
|
||||||
} else {
|
} else {
|
||||||
lifecycleElement.addAttribute("name",lifecycle.getLabel());
|
lifecycleElement.addAttribute("name", lifecycle.getLabel());
|
||||||
lifecycleElement.addAttribute("startDate",FormatStandards.formatDate(lifecycle.getStartDate()));
|
lifecycleElement.addAttribute("startDate", FormatStandards.formatDate(lifecycle
|
||||||
|
.getStartDate()));
|
||||||
|
|
||||||
java.util.Date endDate = lifecycle.getEndDate();
|
java.util.Date endDate = lifecycle.getEndDate();
|
||||||
if ( endDate == null ) {
|
if (endDate == null) {
|
||||||
lifecycleElement.addAttribute("endDateString","last forever");
|
lifecycleElement.addAttribute("endDateString", "last forever");
|
||||||
} else {
|
} else {
|
||||||
lifecycleElement.addAttribute("endDateString","expire on " + FormatStandards.formatDate(endDate));
|
lifecycleElement.addAttribute("endDateString", "expire on " + FormatStandards
|
||||||
lifecycleElement.addAttribute("endDate",FormatStandards.formatDate(endDate));
|
.formatDate(endDate));
|
||||||
|
lifecycleElement.addAttribute("endDate", FormatStandards.formatDate(endDate));
|
||||||
}
|
}
|
||||||
|
|
||||||
lifecycleElement.addAttribute("hasBegun",(new Boolean(lifecycle.hasBegun())).toString());
|
lifecycleElement.addAttribute("hasBegun", (new Boolean(lifecycle.hasBegun()))
|
||||||
lifecycleElement.addAttribute("hasEnded",(new Boolean(lifecycle.hasEnded())).toString());
|
.toString());
|
||||||
|
lifecycleElement.addAttribute("hasEnded", (new Boolean(lifecycle.hasEnded()))
|
||||||
|
.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
parent.addContent(itemElement);
|
parent.addContent(itemElement);
|
||||||
|
|
@ -332,7 +359,9 @@ public class Summary extends CMSContainer {
|
||||||
* Fetch the selected content item.
|
* Fetch the selected content item.
|
||||||
*
|
*
|
||||||
* @param state The page state
|
* @param state The page state
|
||||||
|
*
|
||||||
* @return The selected item
|
* @return The selected item
|
||||||
|
*
|
||||||
* @pre ( state != null )
|
* @pre ( state != null )
|
||||||
*/
|
*/
|
||||||
protected ContentItem getContentItem(PageState state) {
|
protected ContentItem getContentItem(PageState state) {
|
||||||
|
|
@ -345,7 +374,9 @@ public class Summary extends CMSContainer {
|
||||||
* Fetch the current content section.
|
* Fetch the current content section.
|
||||||
*
|
*
|
||||||
* @param state The page state
|
* @param state The page state
|
||||||
|
*
|
||||||
* @return The content section
|
* @return The content section
|
||||||
|
*
|
||||||
* @pre ( state != null )
|
* @pre ( state != null )
|
||||||
*/
|
*/
|
||||||
protected ContentSection getContentSection(PageState state) {
|
protected ContentSection getContentSection(PageState state) {
|
||||||
|
|
@ -362,9 +393,9 @@ public class Summary extends CMSContainer {
|
||||||
ContentSection section = item.getContentSection();
|
ContentSection section = item.getContentSection();
|
||||||
Workflow w = Workflow.getObjectWorkflow(item);
|
Workflow w = Workflow.getObjectWorkflow(item);
|
||||||
|
|
||||||
if ( canWorkflowBeExtended(user,item,w) ) {
|
if (canWorkflowBeExtended(user, item, w)) {
|
||||||
WorkflowTemplate template = w.getWorkflowTemplate();
|
WorkflowTemplate template = w.getWorkflowTemplate();
|
||||||
if ( template != null ) {
|
if (template != null) {
|
||||||
template.extendWorkflow(w);
|
template.extendWorkflow(w);
|
||||||
w.save();
|
w.save();
|
||||||
}
|
}
|
||||||
|
|
@ -375,14 +406,16 @@ public class Summary extends CMSContainer {
|
||||||
if (i.hasNext()) {
|
if (i.hasNext()) {
|
||||||
CMSTask task = (CMSTask) i.next();
|
CMSTask task = (CMSTask) i.next();
|
||||||
|
|
||||||
if ( !task.isLocked() ) {
|
if (!task.isLocked()) {
|
||||||
task.lock(user);
|
task.lock(user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String redirectURL = Web.getConfig().getDispatcherServletPath() + item.getContentSection().getPath() + "/admin/item.jsp?item_id=" + item.getID() + "&set_tab=1";
|
String redirectURL = Web.getConfig().getDispatcherServletPath() + item
|
||||||
throw new RedirectSignal(redirectURL,true);
|
.getContentSection().getPath() + "/admin/item.jsp?item_id=" + item.getID()
|
||||||
|
+ "&set_tab=1";
|
||||||
|
throw new RedirectSignal(redirectURL, true);
|
||||||
} else {
|
} else {
|
||||||
throw new ServletException("Unknown control event: " + key);
|
throw new ServletException("Unknown control event: " + key);
|
||||||
}
|
}
|
||||||
|
|
@ -394,22 +427,22 @@ public class Summary extends CMSContainer {
|
||||||
protected boolean canWorkflowBeExtended(User user, ContentItem item, Workflow workflow) {
|
protected boolean canWorkflowBeExtended(User user, ContentItem item, Workflow workflow) {
|
||||||
boolean canBeExtended = true;
|
boolean canBeExtended = true;
|
||||||
|
|
||||||
if ( workflow == null ) {
|
if (workflow == null) {
|
||||||
canBeExtended = false;
|
canBeExtended = false;
|
||||||
} else if ( !workflow.isFinished() ) {
|
} else if (!workflow.isFinished()) {
|
||||||
canBeExtended = false;
|
canBeExtended = false;
|
||||||
} else if ( workflow.getWorkflowTemplate() == null ) {
|
} else if (workflow.getWorkflowTemplate() == null) {
|
||||||
canBeExtended = false;
|
canBeExtended = false;
|
||||||
} else {
|
} else {
|
||||||
TaskCollection templates = item.getContentSection().getWorkflowTemplates();
|
TaskCollection templates = item.getContentSection().getWorkflowTemplates();
|
||||||
Filter f = templates.addInSubqueryFilter
|
Filter f = templates.addInSubqueryFilter("id",
|
||||||
("id", "com.arsdigita.cms.getWorkflowTemplateUserFilter");
|
"com.arsdigita.cms.getWorkflowTemplateUserFilter");
|
||||||
f.set("userId", Web.getWebContext().getUser().getID());
|
f.set("userId", Web.getWebContext().getUser().getID());
|
||||||
templates.addEqualsFilter(ACSObject.ID, workflow.getWorkflowTemplate().getID());
|
templates.addEqualsFilter(ACSObject.ID, workflow.getWorkflowTemplate().getID());
|
||||||
|
|
||||||
PrivilegeDescriptor pd = PrivilegeDescriptor.get(SecurityConstants.CMS_WORKFLOW_ADMIN);
|
PrivilegeDescriptor pd = PrivilegeDescriptor.get(SecurityConstants.CMS_WORKFLOW_ADMIN);
|
||||||
PermissionDescriptor perm = new PermissionDescriptor(pd, item, user);
|
PermissionDescriptor perm = new PermissionDescriptor(pd, item, user);
|
||||||
if ( !(templates.next() || PermissionService.checkPermission(perm) )) {
|
if (!(templates.next() || PermissionService.checkPermission(perm))) {
|
||||||
canBeExtended = false;
|
canBeExtended = false;
|
||||||
}
|
}
|
||||||
templates.close();
|
templates.close();
|
||||||
|
|
@ -418,4 +451,5 @@ public class Summary extends CMSContainer {
|
||||||
|
|
||||||
return canBeExtended;
|
return canBeExtended;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ public class Navigation extends Application {
|
||||||
return new URL(here.getScheme(),
|
return new URL(here.getScheme(),
|
||||||
here.getServerName(),
|
here.getServerName(),
|
||||||
here.getServerPort(),
|
here.getServerPort(),
|
||||||
"",
|
Web.getWebappContextPath(),
|
||||||
"",
|
"",
|
||||||
"/redirect/", map).toString();
|
"/redirect/", map).toString();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue