Korrekturen an PublicPersonalProfile
git-svn-id: https://svn.libreccm.org/ccm/trunk@1166 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
f796d6996d
commit
5428418dbc
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<registry>
|
||||
<config class="com.arsdigita.cms.publicpersonalprofile.PublicPersonalProfileConfig"
|
||||
<config class="com.arsdigita.cms.publicpersonalprofile.PublicPersonalProfileConfig"
|
||||
storage="ccm-cms-publicpersonalprofile/profiles.properties"/>
|
||||
</registry>
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import com.arsdigita.cms.ContentPage;
|
|||
import com.arsdigita.cms.ExtraXMLGenerator;
|
||||
import com.arsdigita.cms.publicpersonalprofile.ContentGenerator;
|
||||
import com.arsdigita.cms.publicpersonalprofile.PublicPersonalProfileConfig;
|
||||
import com.arsdigita.cms.publicpersonalprofile.PublicPersonalProfiles;
|
||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||
import java.math.BigDecimal;
|
||||
import com.arsdigita.persistence.OID;
|
||||
|
|
@ -50,7 +51,7 @@ public class PublicPersonalProfile
|
|||
extends ContentPage
|
||||
implements CustomizedPreviewLink {
|
||||
|
||||
private static final PublicPersonalProfileConfig config = PublicPersonalProfileConfig.getConfig();
|
||||
private static final PublicPersonalProfileConfig config = PublicPersonalProfiles.getConfig();
|
||||
public static final String OWNER = "owner";
|
||||
public static final String PROFILE_URL = "profileUrl";
|
||||
public static final String LINK_LIST_NAME = "publicPersonalProfileNavItems";
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import com.arsdigita.cms.contentassets.RelatedLink;
|
|||
import com.arsdigita.cms.publicpersonalprofile.ContentGenerator;
|
||||
import com.arsdigita.cms.publicpersonalprofile.PublicPersonalProfileConfig;
|
||||
import com.arsdigita.cms.publicpersonalprofile.PublicPersonalProfileXmlGenerator;
|
||||
import com.arsdigita.cms.publicpersonalprofile.PublicPersonalProfiles;
|
||||
import com.arsdigita.dispatcher.DispatcherHelper;
|
||||
import com.arsdigita.domain.DomainObjectFactory;
|
||||
import com.arsdigita.globalization.GlobalizationHelper;
|
||||
|
|
@ -25,7 +26,7 @@ import java.lang.reflect.InvocationTargetException;
|
|||
public class PublicPersonalProfileExtraXmlGenerator implements ExtraXMLGenerator {
|
||||
|
||||
private static final PublicPersonalProfileConfig config =
|
||||
PublicPersonalProfileConfig.
|
||||
PublicPersonalProfiles.
|
||||
getConfig();
|
||||
public static final String SHOW_ITEM_PARAM = "showItem";
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
package com.arsdigita.cms.contenttypes;
|
||||
|
||||
import com.arsdigita.cms.contentassets.RelatedLink;
|
||||
import com.arsdigita.cms.publicpersonalprofile.PublicPersonalProfileConfig;
|
||||
import com.arsdigita.cms.publicpersonalprofile.PublicPersonalProfiles;
|
||||
import com.arsdigita.domain.DomainObjectFactory;
|
||||
import com.arsdigita.globalization.GlobalizationHelper;
|
||||
import com.arsdigita.persistence.DataCollection;
|
||||
import com.arsdigita.ui.UI;
|
||||
import com.arsdigita.xml.Element;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
|
@ -17,15 +18,14 @@ import java.util.Map;
|
|||
public class PublicPersonalProfileXmlUtil {
|
||||
|
||||
private final com.arsdigita.cms.publicpersonalprofile.PublicPersonalProfileConfig config =
|
||||
PublicPersonalProfileConfig.
|
||||
getConfig();
|
||||
PublicPersonalProfiles.getConfig();
|
||||
|
||||
public void createNavigation(final PublicPersonalProfile profile,
|
||||
final Element root,
|
||||
final String navPath,
|
||||
final String prefix,
|
||||
final String appPath,
|
||||
final boolean previewMode) {
|
||||
final Element root,
|
||||
final String navPath,
|
||||
final String prefix,
|
||||
final String appPath,
|
||||
final boolean previewMode) {
|
||||
String homeLabelsStr = config.getHomeNavItemLabels();
|
||||
|
||||
Map<String, String> homeLabels = new HashMap<String, String>();
|
||||
|
|
@ -35,7 +35,7 @@ public class PublicPersonalProfileXmlUtil {
|
|||
homeLabelSplit = homeLabelEntry.split(":");
|
||||
if (homeLabelSplit.length == 2) {
|
||||
homeLabels.put(homeLabelSplit[0].trim(),
|
||||
homeLabelSplit[1].trim());
|
||||
homeLabelSplit[1].trim());
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -50,12 +50,12 @@ public class PublicPersonalProfileXmlUtil {
|
|||
|
||||
Element navRoot =
|
||||
root.newChildElement("nav:categoryMenu",
|
||||
"http://ccm.redhat.com/london/navigation");
|
||||
"http://ccm.redhat.com/london/navigation");
|
||||
navRoot.addAttribute("id", "categoryMenu");
|
||||
|
||||
Element navList =
|
||||
navRoot.newChildElement("nav:category",
|
||||
"http://ccm.redhat.com/london/navigation");
|
||||
"http://ccm.redhat.com/london/navigation");
|
||||
navList.addAttribute("AbstractTree", "AbstractTree");
|
||||
navList.addAttribute("description", "");
|
||||
navList.addAttribute("id", "");
|
||||
|
|
@ -64,18 +64,18 @@ public class PublicPersonalProfileXmlUtil {
|
|||
navList.addAttribute("title", "publicPersonalProfileNavList");
|
||||
if (previewMode) {
|
||||
navList.addAttribute("url", String.format("%s/%s",
|
||||
appUrl,
|
||||
profile.getProfileUrl()));
|
||||
appUrl,
|
||||
profile.getProfileUrl()));
|
||||
} else {
|
||||
navList.addAttribute("url", String.format("%s/%s",
|
||||
appUrl,
|
||||
profile.getProfileUrl()));
|
||||
appUrl,
|
||||
profile.getProfileUrl()));
|
||||
}
|
||||
|
||||
if (config.getShowHomeNavEntry()) {
|
||||
Element navHome =
|
||||
navList.newChildElement("nav:category",
|
||||
"http://ccm.redhat.com/london/navigation");
|
||||
"http://ccm.redhat.com/london/navigation");
|
||||
navHome.addAttribute("AbstractTree", "AbstractTree");
|
||||
navHome.addAttribute("description", "");
|
||||
navHome.addAttribute("id", profile.getID().toString());
|
||||
|
|
@ -85,26 +85,32 @@ public class PublicPersonalProfileXmlUtil {
|
|||
navHome.addAttribute("isSelected", "false");
|
||||
}
|
||||
navHome.addAttribute("sortKey", "");
|
||||
<<<<<<< .mine
|
||||
String homeLabel = homeLabels.get(DispatcherHelper.getNegotiatedLocale().
|
||||
=======
|
||||
String homeLabel = homeLabels.get(GlobalizationHelper.
|
||||
getNegotiatedLocale().
|
||||
>>>>>>> .r1165
|
||||
getLanguage());
|
||||
if (homeLabel == null) {
|
||||
navHome.addAttribute("title", "Home");
|
||||
} else {
|
||||
navHome.addAttribute("title", homeLabel);
|
||||
}
|
||||
navHome.addAttribute("url", String.format("%s/%s",
|
||||
appUrl,
|
||||
profile.getProfileUrl()));
|
||||
//navHome.addAttribute("url", String.format("%s/%s",
|
||||
// appUrl,
|
||||
// profile.getProfileUrl()));
|
||||
navHome.addAttribute("url", String.format("/ccm/%s",
|
||||
UI.getConfig().getRootPage()));
|
||||
}
|
||||
|
||||
//Get the available Navigation items
|
||||
PublicPersonalProfileNavItemCollection navItems =
|
||||
new PublicPersonalProfileNavItemCollection();
|
||||
new PublicPersonalProfileNavItemCollection();
|
||||
navItems.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale().
|
||||
getLanguage());
|
||||
final Map<String, PublicPersonalProfileNavItem> navItemMap =
|
||||
new HashMap<String, PublicPersonalProfileNavItem>();
|
||||
new HashMap<String, PublicPersonalProfileNavItem>();
|
||||
PublicPersonalProfileNavItem navItem;
|
||||
while (navItems.next()) {
|
||||
navItem = navItems.getNavItem();
|
||||
|
|
@ -112,26 +118,27 @@ public class PublicPersonalProfileXmlUtil {
|
|||
}
|
||||
|
||||
final Element pathElem =
|
||||
root.newChildElement("nav:categoryPath",
|
||||
"http://ccm.redhat.com/london/navigation");
|
||||
root.newChildElement("nav:categoryPath",
|
||||
"http://ccm.redhat.com/london/navigation");
|
||||
final Element homeElem =
|
||||
pathElem.newChildElement("nav:category",
|
||||
"http://ccm.redhat.com/london/navigation");
|
||||
homeElem.addAttribute("url", String.format("%s/%s",
|
||||
appUrl,
|
||||
profile.getProfileUrl()));
|
||||
pathElem.newChildElement("nav:category",
|
||||
"http://ccm.redhat.com/london/navigation");
|
||||
//homeElem.addAttribute("url", String.format("%s/%s",
|
||||
// appUrl,
|
||||
// profile.getProfileUrl()));
|
||||
homeElem.addAttribute("url", String.format("/ccm/%s",
|
||||
UI.getConfig().getRootPage()));
|
||||
|
||||
//Get the related links of the profiles
|
||||
DataCollection links =
|
||||
RelatedLink.getRelatedLinks(profile,
|
||||
PublicPersonalProfile.LINK_LIST_NAME);
|
||||
RelatedLink.getRelatedLinks(profile,
|
||||
PublicPersonalProfile.LINK_LIST_NAME);
|
||||
links.addOrder(Link.ORDER);
|
||||
RelatedLink link;
|
||||
String navLinkKey;
|
||||
Element navElem;
|
||||
while (links.next()) {
|
||||
link = (RelatedLink) DomainObjectFactory.newInstance(links.
|
||||
getDataObject());
|
||||
link = (RelatedLink) DomainObjectFactory.newInstance(links.getDataObject());
|
||||
|
||||
navLinkKey = link.getTitle();
|
||||
navItem = navItemMap.get(navLinkKey);
|
||||
|
|
@ -141,22 +148,22 @@ public class PublicPersonalProfileXmlUtil {
|
|||
}
|
||||
|
||||
navElem =
|
||||
navList.newChildElement("nav:category",
|
||||
"http://ccm.redhat.com/london/navigation");
|
||||
navList.newChildElement("nav:category",
|
||||
"http://ccm.redhat.com/london/navigation");
|
||||
navElem.addAttribute("AbstractTree", "AbstractTree");
|
||||
navElem.addAttribute("description", "");
|
||||
//navHome.addAttribute("id", "");
|
||||
if ((navPath != null) && navPath.equals(navLinkKey)) {
|
||||
navElem.addAttribute("isSelected", "true");
|
||||
final Element currentPathElem =
|
||||
pathElem.newChildElement("nav:category",
|
||||
"http://ccm.redhat.com/london/navigation");
|
||||
pathElem.newChildElement("nav:category",
|
||||
"http://ccm.redhat.com/london/navigation");
|
||||
currentPathElem.addAttribute("title", navItem.getLabel());
|
||||
currentPathElem.addAttribute("url",
|
||||
String.format("%s/%s/%s",
|
||||
appUrl,
|
||||
profile.getProfileUrl(),
|
||||
navLinkKey));
|
||||
String.format("%s/%s/%s",
|
||||
appUrl,
|
||||
profile.getProfileUrl(),
|
||||
navLinkKey));
|
||||
} else {
|
||||
navElem.addAttribute("isSelected", "false");
|
||||
}
|
||||
|
|
@ -167,9 +174,9 @@ public class PublicPersonalProfileXmlUtil {
|
|||
navElem.addAttribute("title", navItem.getLabel());
|
||||
}
|
||||
navElem.addAttribute("url", String.format("%s/%s/%s",
|
||||
appUrl,
|
||||
profile.getProfileUrl(),
|
||||
navLinkKey));
|
||||
appUrl,
|
||||
profile.getProfileUrl(),
|
||||
navLinkKey));
|
||||
|
||||
navElem.addAttribute("navItem", navLinkKey);
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import com.arsdigita.cms.ItemSelectionModel;
|
|||
import com.arsdigita.cms.contenttypes.GenericPerson;
|
||||
import com.arsdigita.cms.contenttypes.PublicPersonalProfile;
|
||||
import com.arsdigita.cms.publicpersonalprofile.PublicPersonalProfileConfig;
|
||||
import com.arsdigita.cms.publicpersonalprofile.PublicPersonalProfiles;
|
||||
import com.arsdigita.cms.ui.authoring.ApplyWorkflowFormSection;
|
||||
import com.arsdigita.cms.ui.authoring.CreationSelector;
|
||||
import com.arsdigita.cms.ui.authoring.LanguageWidget;
|
||||
|
|
@ -48,7 +49,7 @@ public class PublicPersonalProfileCreate extends PageCreate {
|
|||
|
||||
private static final String SELECTED_PERSON = "selectedPerson";
|
||||
private static final PublicPersonalProfileConfig config =
|
||||
PublicPersonalProfileConfig.getConfig();
|
||||
PublicPersonalProfiles.getConfig();
|
||||
|
||||
public PublicPersonalProfileCreate(final ItemSelectionModel itemModel,
|
||||
final CreationSelector parent) {
|
||||
|
|
|
|||
|
|
@ -20,9 +20,9 @@ public class PublicPersonalProfileConfig extends AbstractConfig {
|
|||
private final Parameter showPersonInfoEverywhere;
|
||||
// private final Parameter contactType;
|
||||
|
||||
static {
|
||||
/*static {
|
||||
config.load();
|
||||
}
|
||||
}*/
|
||||
|
||||
public PublicPersonalProfileConfig() {
|
||||
personType =
|
||||
|
|
@ -90,7 +90,7 @@ public class PublicPersonalProfileConfig extends AbstractConfig {
|
|||
return (String) get(contactType);
|
||||
}*/
|
||||
|
||||
public static PublicPersonalProfileConfig getConfig() {
|
||||
/*public static PublicPersonalProfileConfig getConfig() {
|
||||
return config;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,9 +14,13 @@ import java.math.BigDecimal;
|
|||
public class PublicPersonalProfiles extends Application {
|
||||
|
||||
public static final String BASE_DATA_OBJECT_TYPE =
|
||||
"com.arsdigita.cms.publicpersonalprofile.PublicPersonalProfile";
|
||||
private final static PublicPersonalProfileConfig config = PublicPersonalProfileConfig.getConfig();
|
||||
|
||||
"com.arsdigita.cms.publicpersonalprofile.PublicPersonalProfile";
|
||||
private final static PublicPersonalProfileConfig config = new PublicPersonalProfileConfig(); // PublicPersonalProfileConfig.getConfig();
|
||||
|
||||
static {
|
||||
config.load();
|
||||
}
|
||||
|
||||
public PublicPersonalProfiles(final DataObject dobj) {
|
||||
super(dobj);
|
||||
}
|
||||
|
|
@ -35,4 +39,8 @@ public class PublicPersonalProfiles extends Application {
|
|||
public String getServletPath() {
|
||||
return "/profiles/";
|
||||
}
|
||||
|
||||
public static PublicPersonalProfileConfig getConfig() {
|
||||
return config;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,34 +58,33 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
|||
|
||||
private static final long serialVersionUID = -1495852395804455609L;
|
||||
private static final Logger logger =
|
||||
Logger.getLogger(
|
||||
Logger.getLogger(
|
||||
PublicPersonalProfilesServlet.class);
|
||||
private static final String ADMIN = "admin";
|
||||
private static final String PREVIEW = "preview";
|
||||
private static final String PPP_NS =
|
||||
"http://www.arsdigita.com/PublicPersonalProfile/1.0";
|
||||
"http://www.arsdigita.com/PublicPersonalProfile/1.0";
|
||||
public static final String SELECTED_NAV_ITEM = "selectedNavItem";
|
||||
private final PublicPersonalProfileConfig config =
|
||||
PublicPersonalProfileConfig.
|
||||
getConfig();
|
||||
PublicPersonalProfiles.getConfig();
|
||||
|
||||
@Override
|
||||
protected void doService(final HttpServletRequest request,
|
||||
final HttpServletResponse response,
|
||||
final Application app) throws ServletException,
|
||||
IOException {
|
||||
final HttpServletResponse response,
|
||||
final Application app) throws ServletException,
|
||||
IOException {
|
||||
String path = "";
|
||||
|
||||
logger.debug("PublicPersonalProfileServlet is starting...");
|
||||
logger.debug(String.format("pathInfo = '%s'", request.getPathInfo()));
|
||||
|
||||
logger.debug("Extracting path from pathInfo by removing leading and "
|
||||
+ "trailing slashes...");
|
||||
+ "trailing slashes...");
|
||||
if (request.getPathInfo() != null) {
|
||||
if ("/".equals(request.getPathInfo())) {
|
||||
path = "";
|
||||
} else if (request.getPathInfo().startsWith("/")
|
||||
&& request.getPathInfo().endsWith("/")) {
|
||||
&& request.getPathInfo().endsWith("/")) {
|
||||
path = request.getPathInfo().substring(1, request.getPathInfo().
|
||||
length() - 1);
|
||||
} else if (request.getPathInfo().startsWith("/")) {
|
||||
|
|
@ -116,7 +115,7 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
|||
|
||||
|
||||
page = PageFactory.buildPage("PublicPersonalProfile",
|
||||
"");
|
||||
"");
|
||||
|
||||
if (pathTokens.length < 1) {
|
||||
//ToDo: Fehlerbehandlung?
|
||||
|
|
@ -149,16 +148,16 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
|||
final Session session = SessionManager.getSession();
|
||||
|
||||
DataCollection profiles =
|
||||
session.retrieve(
|
||||
session.retrieve(
|
||||
com.arsdigita.cms.contenttypes.PublicPersonalProfile.BASE_DATA_OBJECT_TYPE);
|
||||
profiles.addFilter(String.format("profileUrl = '%s'",
|
||||
profileOwner));
|
||||
profileOwner));
|
||||
if (preview) {
|
||||
profiles.addFilter(String.format("version = '%s'",
|
||||
ContentItem.DRAFT));
|
||||
ContentItem.DRAFT));
|
||||
} else {
|
||||
profiles.addFilter(String.format("version = '%s'",
|
||||
ContentItem.LIVE));
|
||||
ContentItem.LIVE));
|
||||
}
|
||||
|
||||
if (profiles.size() == 0) {
|
||||
|
|
@ -169,18 +168,17 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
|||
"More than one matching members found...");
|
||||
} else {
|
||||
final PageState state = new PageState(page,
|
||||
request,
|
||||
response);
|
||||
request,
|
||||
response);
|
||||
|
||||
profiles.next();
|
||||
PublicPersonalProfile profile =
|
||||
(PublicPersonalProfile) DomainObjectFactory.
|
||||
newInstance(profiles.getDataObject());
|
||||
(PublicPersonalProfile) DomainObjectFactory.newInstance(profiles.getDataObject());
|
||||
profiles.close();
|
||||
|
||||
if (config.getEmbedded()) {
|
||||
final ContentSection section =
|
||||
profile.getContentSection();
|
||||
profile.getContentSection();
|
||||
final ItemResolver resolver = section.getItemResolver();
|
||||
|
||||
String context;
|
||||
|
|
@ -190,11 +188,10 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
|||
context = ContentItem.LIVE;
|
||||
}
|
||||
|
||||
final String url = String.format("/ccm%s", resolver.
|
||||
generateItemURL(state,
|
||||
profile,
|
||||
section,
|
||||
context));
|
||||
final String url = String.format("/ccm%s", resolver.generateItemURL(state,
|
||||
profile,
|
||||
section,
|
||||
context));
|
||||
|
||||
throw new RedirectSignal(url, false);
|
||||
}
|
||||
|
|
@ -209,14 +206,15 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
|||
Element profileOwnerName = profileElem.newChildElement(
|
||||
"ppp:ownerName", PPP_NS);
|
||||
profileOwnerName.setText(owner.getFullName());
|
||||
|
||||
final DataCollection images = ItemImageAttachment.getImageAttachments(profile);
|
||||
|
||||
final DataCollection images = ItemImageAttachment.getImageAttachments(profile);
|
||||
if (!images.isEmpty()) {
|
||||
images.next();
|
||||
final Element profileImageElem = profileElem.newChildElement("profileImage");
|
||||
|
||||
final Element attachmentElem = profileImageElem.newChildElement("imageAttachments");
|
||||
final ItemImageAttachment attachment = new ItemImageAttachment(images.getDataObject());
|
||||
final Element profileImageElem = profileElem.newChildElement("ppp:profileImage",
|
||||
PPP_NS);
|
||||
|
||||
final Element attachmentElem = profileImageElem.newChildElement("imageAttachments");
|
||||
final ItemImageAttachment attachment = new ItemImageAttachment(images.getDataObject());
|
||||
attachmentElem.addAttribute("oid", attachment.getOID().toString());
|
||||
final Element caption = attachmentElem.newChildElement("caption");
|
||||
caption.setText(attachment.getCaption());
|
||||
|
|
@ -233,38 +231,38 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
|||
nameElem.setText(image.getName());
|
||||
final Element idElem = imageElem.newChildElement("id");
|
||||
idElem.setText(image.getID().toString());
|
||||
final Element displayNameElem = imageElem.newChildElement("displayName");
|
||||
final Element displayNameElem = imageElem.newChildElement("displayName");
|
||||
displayNameElem.setText(image.getDisplayName());
|
||||
|
||||
|
||||
images.close();
|
||||
}
|
||||
|
||||
|
||||
final PublicPersonalProfileXmlUtil util =
|
||||
new PublicPersonalProfileXmlUtil();
|
||||
new PublicPersonalProfileXmlUtil();
|
||||
String prefix =
|
||||
DispatcherHelper.getDispatcherPrefix(request);
|
||||
DispatcherHelper.getDispatcherPrefix(request);
|
||||
if (prefix == null) {
|
||||
prefix = "";
|
||||
}
|
||||
util.createNavigation(profile,
|
||||
root,
|
||||
navPath,
|
||||
prefix,
|
||||
app.getPath(),
|
||||
preview);
|
||||
root,
|
||||
navPath,
|
||||
prefix,
|
||||
app.getPath(),
|
||||
preview);
|
||||
|
||||
if (navPath == null) {
|
||||
final PublicPersonalProfileXmlGenerator generator =
|
||||
new PublicPersonalProfileXmlGenerator(
|
||||
new PublicPersonalProfileXmlGenerator(
|
||||
profile);
|
||||
generator.generateXML(state, root, "");
|
||||
|
||||
|
||||
} else {
|
||||
final DataCollection links =
|
||||
RelatedLink.getRelatedLinks(profile,
|
||||
PublicPersonalProfile.LINK_LIST_NAME);
|
||||
RelatedLink.getRelatedLinks(profile,
|
||||
PublicPersonalProfile.LINK_LIST_NAME);
|
||||
links.addFilter(String.format("linkTitle = '%s'",
|
||||
navPath));
|
||||
navPath));
|
||||
|
||||
if (links.size() == 0) {
|
||||
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
|
||||
|
|
@ -272,32 +270,31 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
|||
} else {
|
||||
if (config.getShowPersonInfoEverywhere()) {
|
||||
generateProfileOwnerXml(profileElem, owner,
|
||||
state);
|
||||
state);
|
||||
}
|
||||
|
||||
PublicPersonalProfileNavItemCollection navItems =
|
||||
new PublicPersonalProfileNavItemCollection();
|
||||
navItems.addLanguageFilter(GlobalizationHelper.
|
||||
getNegotiatedLocale().
|
||||
new PublicPersonalProfileNavItemCollection();
|
||||
navItems.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale().
|
||||
getLanguage());
|
||||
navItems.addKeyFilter(navPath);
|
||||
navItems.next();
|
||||
|
||||
if (navItems.getNavItem().getGeneratorClass()
|
||||
!= null) {
|
||||
!= null) {
|
||||
try {
|
||||
Object generatorObj =
|
||||
Class.forName(navItems.getNavItem().
|
||||
Class.forName(navItems.getNavItem().
|
||||
getGeneratorClass()).getConstructor().
|
||||
newInstance();
|
||||
|
||||
if (generatorObj instanceof ContentGenerator) {
|
||||
final ContentGenerator generator =
|
||||
(ContentGenerator) generatorObj;
|
||||
(ContentGenerator) generatorObj;
|
||||
|
||||
generator.generateContent(profileElem,
|
||||
owner,
|
||||
state);
|
||||
owner,
|
||||
state);
|
||||
|
||||
} else {
|
||||
throw new ServletException(String.format(
|
||||
|
|
@ -329,16 +326,15 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
|||
|
||||
links.next();
|
||||
final RelatedLink link =
|
||||
(RelatedLink) DomainObjectFactory.
|
||||
newInstance(links.getDataObject());
|
||||
(RelatedLink) DomainObjectFactory.newInstance(links.getDataObject());
|
||||
links.close();
|
||||
final ContentItem item = link.getTargetItem();
|
||||
final PublicPersonalProfileXmlGenerator generator =
|
||||
new PublicPersonalProfileXmlGenerator(
|
||||
new PublicPersonalProfileXmlGenerator(
|
||||
item);
|
||||
generator.generateXML(state,
|
||||
root,
|
||||
"");
|
||||
root,
|
||||
"");
|
||||
}
|
||||
|
||||
navItems.close();
|
||||
|
|
@ -346,39 +342,38 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
|||
}
|
||||
}
|
||||
|
||||
PresentationManager presentationManager = Templating.
|
||||
getPresentationManager();
|
||||
PresentationManager presentationManager = Templating.getPresentationManager();
|
||||
presentationManager.servePage(document, request, response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void generateProfileOwnerXml(final Element profileElem,
|
||||
final GenericPerson owner,
|
||||
final PageState state) {
|
||||
final GenericPerson owner,
|
||||
final PageState state) {
|
||||
Element profileOwnerElem = profileElem.newChildElement(
|
||||
"profileOwner");
|
||||
if ((owner.getSurname() != null)
|
||||
&& !owner.getSurname().trim().isEmpty()) {
|
||||
&& !owner.getSurname().trim().isEmpty()) {
|
||||
Element surname =
|
||||
profileOwnerElem.newChildElement("surname");
|
||||
surname.setText(owner.getSurname());
|
||||
}
|
||||
if ((owner.getGivenName() != null)
|
||||
&& !owner.getGivenName().trim().isEmpty()) {
|
||||
&& !owner.getGivenName().trim().isEmpty()) {
|
||||
Element givenName = profileOwnerElem.newChildElement(
|
||||
"givenName");
|
||||
givenName.setText(owner.getGivenName());
|
||||
}
|
||||
if ((owner.getTitlePre() != null)
|
||||
&& !owner.getTitlePre().trim().isEmpty()) {
|
||||
&& !owner.getTitlePre().trim().isEmpty()) {
|
||||
Element titlePre = profileOwnerElem.newChildElement("titlePre");
|
||||
titlePre.setText(owner.getTitlePre());
|
||||
}
|
||||
if ((owner.getTitlePost() != null)
|
||||
&& !owner.getTitlePost().trim().isEmpty()) {
|
||||
&& !owner.getTitlePost().trim().isEmpty()) {
|
||||
Element titlePost = profileOwnerElem.newChildElement(
|
||||
"titlePost");
|
||||
titlePost.setText(owner.getTitlePost());
|
||||
|
|
@ -386,12 +381,12 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
|||
|
||||
if (owner.hasContacts()) {
|
||||
final GenericPersonContactCollection contacts = owner.getContacts();
|
||||
|
||||
|
||||
if (contacts.size() > 0) {
|
||||
contacts.next();
|
||||
generateContactXml(profileOwnerElem,
|
||||
contacts.getContact(),
|
||||
state);
|
||||
contacts.getContact(),
|
||||
state);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -410,13 +405,13 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
|||
}
|
||||
|
||||
private void generateContactXml(final Element profileOwnerElem,
|
||||
final GenericContact contact,
|
||||
final PageState state) {
|
||||
final GenericContact contact,
|
||||
final PageState state) {
|
||||
final Element contactElem = profileOwnerElem.newChildElement("contact");
|
||||
final Element entriesElem = contactElem.newChildElement("entries");
|
||||
|
||||
final GenericContactEntryCollection entries =
|
||||
contact.getContactEntries();
|
||||
contact.getContactEntries();
|
||||
Element entryElem;
|
||||
GenericContactEntry entry;
|
||||
while (entries.next()) {
|
||||
|
|
@ -452,20 +447,20 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
|||
}
|
||||
|
||||
private void showAdminPage(final Page page,
|
||||
final HttpServletRequest request,
|
||||
final HttpServletResponse response)
|
||||
final HttpServletRequest request,
|
||||
final HttpServletResponse response)
|
||||
throws ServletException {
|
||||
|
||||
page.addRequestListener(new ApplicationAuthenticationListener());
|
||||
|
||||
final Form form = new Form("PublicPersonalProfileAdmin");
|
||||
|
||||
|
||||
page.setClassAttr("adminPage");
|
||||
|
||||
final StringParameter navItemKeyParam = new StringParameter(
|
||||
"selectedNavItem");
|
||||
final ParameterSingleSelectionModel navItemSelect =
|
||||
new ParameterSingleSelectionModel(
|
||||
new ParameterSingleSelectionModel(
|
||||
navItemKeyParam);
|
||||
|
||||
page.addGlobalStateParam(navItemKeyParam);
|
||||
|
|
@ -474,10 +469,10 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
|||
final FormSection tableSection = new FormSection(box);
|
||||
|
||||
final PublicPersonalProfileNavItemsAddForm addForm =
|
||||
new PublicPersonalProfileNavItemsAddForm(
|
||||
new PublicPersonalProfileNavItemsAddForm(
|
||||
navItemSelect);
|
||||
final PublicPersonalProfileNavItemsTable table =
|
||||
new PublicPersonalProfileNavItemsTable(
|
||||
new PublicPersonalProfileNavItemsTable(
|
||||
navItemSelect);
|
||||
|
||||
box.add(table);
|
||||
|
|
@ -490,8 +485,7 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
|||
|
||||
final Document document = page.buildDocument(request, response);
|
||||
|
||||
final PresentationManager presentationManager = Templating.
|
||||
getPresentationManager();
|
||||
final PresentationManager presentationManager = Templating.getPresentationManager();
|
||||
presentationManager.servePage(document, request, response);
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue