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-94f89814c4df
master
jensp 2014-09-26 07:20:40 +00:00
parent b7ca4a6670
commit 7e646e8be6
2 changed files with 115 additions and 81 deletions

View File

@ -52,11 +52,13 @@ import com.arsdigita.toolbox.ui.FormatStandards;
import com.arsdigita.util.Assert;
import com.arsdigita.util.GraphSet;
import com.arsdigita.util.Graphs;
import com.arsdigita.util.UncheckedWrapperException;
import com.arsdigita.versioning.Transaction;
import com.arsdigita.versioning.TransactionCollection;
import com.arsdigita.versioning.Versions;
import com.arsdigita.web.RedirectSignal;
import com.arsdigita.web.Web;
import com.arsdigita.web.WebContext;
import com.arsdigita.workflow.simple.Engine;
import com.arsdigita.workflow.simple.Task;
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.WorkflowTemplate;
import com.arsdigita.xml.Element;
import java.io.UnsupportedEncodingException;
/**
* <p>This panel displays basic details about a content item such as
* attributes and associations.</p>
* <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}
* to convert content items into XML.</p>
* <p>
* This panel uses an {@link com.arsdigita.cms.dispatcher.XMLGenerator} to convert content items
* into XML.</p>
*
* @author Michael Pih (pihman@arsdigita.com)
* @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;
public Summary(ItemSelectionModel m) {
super();
@ -96,6 +100,7 @@ public class Summary extends CMSContainer {
*
* @param state The page state
* @param parent The parent DOM element
*
* @pre ( state != null )
* @pre ( parent != null )
*/
@ -126,7 +131,6 @@ public class Summary extends CMSContainer {
// Take advantage of caching in the CMS Dispatcher.
// XMLGenerator xmlGenerator = section.getXMLGenerator();
// xmlGenerator.generateXML(state, parent, SUMMARY);
String descriptionAttribute = "";
if (objectType.equals("NewsItem") || objectType.equals("Article")) {
descriptionAttribute = "lead";
@ -134,12 +138,14 @@ public class Summary extends CMSContainer {
descriptionAttribute = "description";
} else if (objectType.equals("Job")) {
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";
}
if (!descriptionAttribute.equals("")) {
itemElement.addAttribute("description",(String)DomainServiceInterfaceExposer.get(item,descriptionAttribute));
itemElement.addAttribute("description", (String) DomainServiceInterfaceExposer.get(
item, descriptionAttribute));
}
try {
@ -163,9 +169,11 @@ public class Summary extends CMSContainer {
if (parents.next()) {
Category parentCategory = parents.getCategory();
if (parentCategory.equals(subjectCategory)) {
Element subjectElement = new Element("cms:subjectCategory",CMS.CMS_XML_NS);
Element subjectElement = new Element("cms:subjectCategory",
CMS.CMS_XML_NS);
subjectElement.addAttribute("name", category.getName());
subjectElement.setText(category.getPreferredQualifiedName(" -&gt; ",true));
subjectElement.setText(category.getPreferredQualifiedName(" -&gt; ",
true));
subjectsElement.addContent(subjectElement);
}
parents.close();
@ -175,8 +183,18 @@ public class Summary extends CMSContainer {
// URL
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
Element workflowElement = new Element("cms:workflowSummary", CMS.CMS_XML_NS);
Workflow workflow = Workflow.getObjectWorkflow(item);
@ -251,7 +269,8 @@ public class Summary extends CMSContainer {
commentElement.addAttribute("author", authorName);
commentElement.addAttribute("comment", comment.getComment());
commentElement.addAttribute("date",FormatStandards.formatDate(comment.getDate()));
commentElement.addAttribute("date", FormatStandards.formatDate(comment
.getDate()));
taskElement.addContent(commentElement);
}
@ -262,8 +281,10 @@ public class Summary extends CMSContainer {
// REVISION HISTORY
Element transactionElement = new Element("cms:transactionSummary", CMS.CMS_XML_NS);
transactionElement.addAttribute("creationDate",FormatStandards.formatDate(item.getCreationDate()));
transactionElement.addAttribute("lastModifiedDate",FormatStandards.formatDate(item.getLastModifiedDate()));
transactionElement.addAttribute("creationDate", FormatStandards.formatDate(item
.getCreationDate()));
transactionElement.addAttribute("lastModifiedDate", FormatStandards.formatDate(item
.getLastModifiedDate()));
TransactionCollection transactions = Versions.getTaggedTransactions(item.getOID());
while (transactions.next()) {
@ -277,7 +298,9 @@ public class Summary extends CMSContainer {
}
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,
CMSDispatcher.PREVIEW)
+ "?transID=" + transaction.getID();
element.addAttribute("url", url);
transactionElement.addContent(element);
}
@ -305,18 +328,22 @@ public class Summary extends CMSContainer {
lifecycleElement.addAttribute("noLifecycle", "1");
} else {
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();
if (endDate == null) {
lifecycleElement.addAttribute("endDateString", "last forever");
} else {
lifecycleElement.addAttribute("endDateString","expire on " + FormatStandards.formatDate(endDate));
lifecycleElement.addAttribute("endDateString", "expire on " + FormatStandards
.formatDate(endDate));
lifecycleElement.addAttribute("endDate", FormatStandards.formatDate(endDate));
}
lifecycleElement.addAttribute("hasBegun",(new Boolean(lifecycle.hasBegun())).toString());
lifecycleElement.addAttribute("hasEnded",(new Boolean(lifecycle.hasEnded())).toString());
lifecycleElement.addAttribute("hasBegun", (new Boolean(lifecycle.hasBegun()))
.toString());
lifecycleElement.addAttribute("hasEnded", (new Boolean(lifecycle.hasEnded()))
.toString());
}
parent.addContent(itemElement);
@ -332,7 +359,9 @@ public class Summary extends CMSContainer {
* Fetch the selected content item.
*
* @param state The page state
*
* @return The selected item
*
* @pre ( state != null )
*/
protected ContentItem getContentItem(PageState state) {
@ -345,7 +374,9 @@ public class Summary extends CMSContainer {
* Fetch the current content section.
*
* @param state The page state
*
* @return The content section
*
* @pre ( state != null )
*/
protected ContentSection getContentSection(PageState state) {
@ -381,7 +412,9 @@ public class Summary extends CMSContainer {
}
}
String redirectURL = Web.getConfig().getDispatcherServletPath() + item.getContentSection().getPath() + "/admin/item.jsp?item_id=" + item.getID() + "&set_tab=1";
String redirectURL = Web.getConfig().getDispatcherServletPath() + item
.getContentSection().getPath() + "/admin/item.jsp?item_id=" + item.getID()
+ "&set_tab=1";
throw new RedirectSignal(redirectURL, true);
} else {
throw new ServletException("Unknown control event: " + key);
@ -402,8 +435,8 @@ public class Summary extends CMSContainer {
canBeExtended = false;
} else {
TaskCollection templates = item.getContentSection().getWorkflowTemplates();
Filter f = templates.addInSubqueryFilter
("id", "com.arsdigita.cms.getWorkflowTemplateUserFilter");
Filter f = templates.addInSubqueryFilter("id",
"com.arsdigita.cms.getWorkflowTemplateUserFilter");
f.set("userId", Web.getWebContext().getUser().getID());
templates.addEqualsFilter(ACSObject.ID, workflow.getWorkflowTemplate().getID());
@ -418,4 +451,5 @@ public class Summary extends CMSContainer {
return canBeExtended;
}
}

View File

@ -76,7 +76,7 @@ public class Navigation extends Application {
return new URL(here.getScheme(),
here.getServerName(),
here.getServerPort(),
"",
Web.getWebappContextPath(),
"",
"/redirect/", map).toString();
}