BugFix für Anzeige nicht publizierter Inhalte im PPP (Ticket #1361).

git-svn-id: https://svn.libreccm.org/ccm/trunk@1845 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2012-09-01 11:21:57 +00:00
parent 4afbf64b16
commit 0f59c71dc5
1 changed files with 31 additions and 37 deletions

View File

@ -17,12 +17,10 @@
*/ */
package com.arsdigita.cms.contenttypes; package com.arsdigita.cms.contenttypes;
// import com.arsdigita.cms.CMS;
import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.ContentItem;
import com.arsdigita.cms.ContentPage; import com.arsdigita.cms.ContentPage;
import com.arsdigita.cms.contentassets.RelatedLink; import com.arsdigita.cms.contentassets.RelatedLink;
import com.arsdigita.cms.publicpersonalprofile.PublicPersonalProfiles; import com.arsdigita.cms.publicpersonalprofile.PublicPersonalProfiles;
// import com.arsdigita.dispatcher.DispatcherHelper;
import com.arsdigita.domain.DomainObjectFactory; import com.arsdigita.domain.DomainObjectFactory;
import com.arsdigita.persistence.DataCollection; import com.arsdigita.persistence.DataCollection;
import com.arsdigita.ui.UI; import com.arsdigita.ui.UI;
@ -74,13 +72,13 @@ public class PublicPersonalProfileXmlUtil {
} }
final Element navRoot = final Element navRoot =
root.newChildElement("nav:categoryMenu", root.newChildElement("nav:categoryMenu",
"http://ccm.redhat.com/navigation"); "http://ccm.redhat.com/navigation");
navRoot.addAttribute("id", "categoryMenu"); navRoot.addAttribute("id", "categoryMenu");
final Element navList = final Element navList =
navRoot.newChildElement("nav:category", navRoot.newChildElement("nav:category",
"http://ccm.redhat.com/navigation"); "http://ccm.redhat.com/navigation");
navList.addAttribute("AbstractTree", "AbstractTree"); navList.addAttribute("AbstractTree", "AbstractTree");
navList.addAttribute("description", ""); navList.addAttribute("description", "");
navList.addAttribute("id", ""); navList.addAttribute("id", "");
@ -88,16 +86,16 @@ public class PublicPersonalProfileXmlUtil {
navList.addAttribute("sortKey", ""); navList.addAttribute("sortKey", "");
navList.addAttribute("title", "publicPersonalProfileNavList"); navList.addAttribute("title", "publicPersonalProfileNavList");
/*navList.addAttribute("url", String.format("%s/%s", /*navList.addAttribute("url", String.format("%s/%s",
appUrl, appUrl,
profile.getProfileUrl()));*/ profile.getProfileUrl()));*/
navList.addAttribute("url", String.format("/ccm%s", navList.addAttribute("url", String.format("/ccm%s",
UI.getConfig().getRootPage())); UI.getConfig().getRootPage()));
if (config.getShowHomeNavEntry()) { if (config.getShowHomeNavEntry()) {
final Element navHome = final Element navHome =
navList.newChildElement("nav:category", navList.newChildElement("nav:category",
"http://ccm.redhat.com/navigation"); "http://ccm.redhat.com/navigation");
navHome.addAttribute("AbstractTree", "AbstractTree"); navHome.addAttribute("AbstractTree", "AbstractTree");
navHome.addAttribute("description", ""); navHome.addAttribute("description", "");
navHome.addAttribute("id", profile.getID().toString()); navHome.addAttribute("id", profile.getID().toString());
@ -109,7 +107,7 @@ public class PublicPersonalProfileXmlUtil {
navHome.addAttribute("sortKey", ""); navHome.addAttribute("sortKey", "");
/*String homeLabel = homeLabels.get(GlobalizationHelper. /*String homeLabel = homeLabels.get(GlobalizationHelper.
getNegotiatedLocale().getLanguage());*/ getNegotiatedLocale().getLanguage());*/
final String homeLabel = homeLabels.get(profile.getLanguage()); final String homeLabel = homeLabels.get(profile.getLanguage());
if (homeLabel == null) { if (homeLabel == null) {
navHome.addAttribute("title", "Home"); navHome.addAttribute("title", "Home");
@ -125,9 +123,9 @@ public class PublicPersonalProfileXmlUtil {
//Get the available Navigation items //Get the available Navigation items
final PublicPersonalProfileNavItemCollection navItems = final PublicPersonalProfileNavItemCollection navItems =
new PublicPersonalProfileNavItemCollection(); new PublicPersonalProfileNavItemCollection();
/*navItems.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale(). /*navItems.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale().
getLanguage());*/ getLanguage());*/
navItems.addLanguageFilter(profile.getLanguage()); navItems.addLanguageFilter(profile.getLanguage());
final Map<String, PublicPersonalProfileNavItem> navItemMap = final Map<String, PublicPersonalProfileNavItem> navItemMap =
new LinkedHashMap<String, PublicPersonalProfileNavItem>(); new LinkedHashMap<String, PublicPersonalProfileNavItem>();
@ -159,13 +157,13 @@ public class PublicPersonalProfileXmlUtil {
//Get the related links of the profile //Get the related links of the profile
final DataCollection links = final DataCollection links =
RelatedLink.getRelatedLinks(profile, RelatedLink.getRelatedLinks(profile,
PublicPersonalProfile.LINK_LIST_NAME); PublicPersonalProfile.LINK_LIST_NAME);
links.addOrder(Link.ORDER); links.addOrder(Link.ORDER);
RelatedLink link; RelatedLink link;
String navLinkKey; String navLinkKey;
Element navElem; Element navElem;
final List<NavLink> navLinks = new ArrayList<NavLink>(); final List<NavLink> navLinks = new ArrayList<NavLink>();
while (links.next()) { while (links.next()) {
link = (RelatedLink) DomainObjectFactory.newInstance(links. link = (RelatedLink) DomainObjectFactory.newInstance(links.
getDataObject()); getDataObject());
@ -174,31 +172,26 @@ public class PublicPersonalProfileXmlUtil {
navItem = navItemMap.get(navLinkKey); navItem = navItemMap.get(navLinkKey);
if (navItem == null) { if (navItem == null) {
//ToDo continue;
} }
final ContentItem targetItem = link.getTargetItem(); final ContentItem targetItem = link.getTargetItem();
if (!(targetItem instanceof PublicPersonalProfile) if (!(targetItem instanceof PublicPersonalProfile)
&& (targetItem instanceof ContentPage)) { && (targetItem instanceof ContentPage)) {
final ContentPage targetPage = (ContentPage) targetItem; final ContentPage targetPage = (ContentPage) targetItem;
/*if (!(targetPage.getContentBundle().hasInstance(GlobalizationHelper.
getNegotiatedLocale().getLanguage(), if (!(targetPage.getContentBundle().hasInstance(profile.getLanguage(),
false))) {
continue;
}*/
if (!(targetPage.getContentBundle().hasInstance(profile.
getLanguage(),
false))) { false))) {
continue; continue;
} }
navLinks.add(createNavLink(navItem, navLinkKey, targetItem));
} }
navLinks.add(createNavLink(navItem, navLinkKey, targetItem));
} }
Collections.sort(navLinks); Collections.sort(navLinks);
for(NavLink navLink : navLinks) { for (NavLink navLink : navLinks) {
navElem = navElem =
navList.newChildElement("nav:category", navList.newChildElement("nav:category",
"http://ccm.redhat.com/navigation"); "http://ccm.redhat.com/navigation");
@ -234,9 +227,9 @@ public class PublicPersonalProfileXmlUtil {
} }
} }
private NavLink createNavLink(final PublicPersonalProfileNavItem navItem, private NavLink createNavLink(final PublicPersonalProfileNavItem navItem,
final String key, final String key,
final ContentItem target) { final ContentItem target) {
final NavLink navLink = new NavLink(); final NavLink navLink = new NavLink();
navLink.setNavItem(navItem); navLink.setNavItem(navItem);
@ -244,16 +237,17 @@ public class PublicPersonalProfileXmlUtil {
navLink.setTarget(target); navLink.setTarget(target);
return navLink; return navLink;
} }
private class NavLink implements Comparable<NavLink> { private class NavLink implements Comparable<NavLink> {
private PublicPersonalProfileNavItem navItem; private PublicPersonalProfileNavItem navItem;
private String key; private String key;
private ContentItem target; private ContentItem target;
public NavLink() { public NavLink() {
//Nothing //Nothing
} }
public PublicPersonalProfileNavItem getNavItem() { public PublicPersonalProfileNavItem getNavItem() {
return navItem; return navItem;
} }
@ -273,7 +267,7 @@ public class PublicPersonalProfileXmlUtil {
public void setKey(final String key) { public void setKey(final String key) {
this.key = key; this.key = key;
} }
public void setTarget(final ContentItem target) { public void setTarget(final ContentItem target) {
this.target = target; this.target = target;
} }
@ -281,6 +275,6 @@ public class PublicPersonalProfileXmlUtil {
public int compareTo(final NavLink other) { public int compareTo(final NavLink other) {
return navItem.getOrder().compareTo(other.getNavItem().getOrder()); return navItem.getOrder().compareTo(other.getNavItem().getOrder());
} }
} }
} }