Verbesserung des Verhaltens von PublicPersonalProfile für Sprachumschaltung (Ticket 994) sowie Verbesserung des 404
Handlings in PublicPersonalProfile (Ticket 1000) git-svn-id: https://svn.libreccm.org/ccm/trunk@1411 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
ed23691edb
commit
6d9b30e682
|
|
@ -5,3 +5,20 @@ import com.arsdigita.web.Application;
|
||||||
object type PublicPersonalProfile extends Application {
|
object type PublicPersonalProfile extends Application {
|
||||||
reference key (publicpersonalprofile.application_id);
|
reference key (publicpersonalprofile.application_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Subquery for AbstractObjectList used as a filter
|
||||||
|
// to figure out which object have a match in the
|
||||||
|
// selected languages and don't have to match to a
|
||||||
|
// language independent content item
|
||||||
|
query getParentIDsOfMatchedItems {
|
||||||
|
BigDecimal parent;
|
||||||
|
|
||||||
|
do {
|
||||||
|
select parent_id
|
||||||
|
from cms_items
|
||||||
|
where version = 'live'
|
||||||
|
and language = :language
|
||||||
|
} map {
|
||||||
|
parent = parent_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -24,7 +24,6 @@ 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.dispatcher.DispatcherHelper;
|
||||||
import com.arsdigita.domain.DomainObjectFactory;
|
import com.arsdigita.domain.DomainObjectFactory;
|
||||||
import com.arsdigita.globalization.GlobalizationHelper;
|
|
||||||
import com.arsdigita.persistence.DataCollection;
|
import com.arsdigita.persistence.DataCollection;
|
||||||
import com.arsdigita.ui.UI;
|
import com.arsdigita.ui.UI;
|
||||||
import com.arsdigita.xml.Element;
|
import com.arsdigita.xml.Element;
|
||||||
|
|
@ -105,8 +104,9 @@ public class PublicPersonalProfileXmlUtil {
|
||||||
}
|
}
|
||||||
navHome.addAttribute("sortKey", "");
|
navHome.addAttribute("sortKey", "");
|
||||||
|
|
||||||
String homeLabel = homeLabels.get(GlobalizationHelper.
|
/*String homeLabel = homeLabels.get(GlobalizationHelper.
|
||||||
getNegotiatedLocale().getLanguage());
|
getNegotiatedLocale().getLanguage());*/
|
||||||
|
String homeLabel = homeLabels.get(profile.getLanguage());
|
||||||
if (homeLabel == null) {
|
if (homeLabel == null) {
|
||||||
navHome.addAttribute("title", "Home");
|
navHome.addAttribute("title", "Home");
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -122,8 +122,9 @@ public class PublicPersonalProfileXmlUtil {
|
||||||
//Get the available Navigation items
|
//Get the available Navigation items
|
||||||
PublicPersonalProfileNavItemCollection navItems =
|
PublicPersonalProfileNavItemCollection navItems =
|
||||||
new PublicPersonalProfileNavItemCollection();
|
new PublicPersonalProfileNavItemCollection();
|
||||||
navItems.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale().
|
/*navItems.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale().
|
||||||
getLanguage());
|
getLanguage());*/
|
||||||
|
navItems.addLanguageFilter(profile.getLanguage());
|
||||||
final Map<String, PublicPersonalProfileNavItem> navItemMap =
|
final Map<String, PublicPersonalProfileNavItem> navItemMap =
|
||||||
new HashMap<String, PublicPersonalProfileNavItem>();
|
new HashMap<String, PublicPersonalProfileNavItem>();
|
||||||
PublicPersonalProfileNavItem navItem;
|
PublicPersonalProfileNavItem navItem;
|
||||||
|
|
@ -175,10 +176,15 @@ public class PublicPersonalProfileXmlUtil {
|
||||||
if (!(targetItem instanceof PublicPersonalProfile)
|
if (!(targetItem instanceof PublicPersonalProfile)
|
||||||
&& (targetItem instanceof ContentPage)) {
|
&& (targetItem instanceof ContentPage)) {
|
||||||
ContentPage targetPage = (ContentPage) targetItem;
|
ContentPage targetPage = (ContentPage) targetItem;
|
||||||
if (!(targetPage.getContentBundle().hasInstance(GlobalizationHelper.
|
/*if (!(targetPage.getContentBundle().hasInstance(GlobalizationHelper.
|
||||||
getNegotiatedLocale().getLanguage(),
|
getNegotiatedLocale().getLanguage(),
|
||||||
false))) {
|
false))) {
|
||||||
continue;
|
continue;
|
||||||
|
}*/
|
||||||
|
if (!(targetPage.getContentBundle().hasInstance(profile.
|
||||||
|
getLanguage(),
|
||||||
|
false))) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,8 @@ import com.arsdigita.globalization.GlobalizationHelper;
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
import com.arsdigita.globalization.GlobalizedMessage;
|
||||||
import com.arsdigita.mimetypes.MimeType;
|
import com.arsdigita.mimetypes.MimeType;
|
||||||
import com.arsdigita.util.UncheckedWrapperException;
|
import com.arsdigita.util.UncheckedWrapperException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.TooManyListenersException;
|
import java.util.TooManyListenersException;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
|
@ -52,6 +54,7 @@ public class PublicPersonalProfileNavigationAddForm
|
||||||
private final String ITEM_SEARCH = "itemSearch";
|
private final String ITEM_SEARCH = "itemSearch";
|
||||||
private ItemSelectionModel itemModel;
|
private ItemSelectionModel itemModel;
|
||||||
private SimpleEditStep editStep;
|
private SimpleEditStep editStep;
|
||||||
|
private List<String> autoNavItemKeys = new ArrayList<String>();
|
||||||
|
|
||||||
public PublicPersonalProfileNavigationAddForm(
|
public PublicPersonalProfileNavigationAddForm(
|
||||||
final ItemSelectionModel itemModel,
|
final ItemSelectionModel itemModel,
|
||||||
|
|
@ -92,18 +95,26 @@ public class PublicPersonalProfileNavigationAddForm
|
||||||
navItems.addLanguageFilter(GlobalizationHelper.
|
navItems.addLanguageFilter(GlobalizationHelper.
|
||||||
getNegotiatedLocale().
|
getNegotiatedLocale().
|
||||||
getLanguage());
|
getLanguage());
|
||||||
if (showGenerated()) {
|
/*if (showGenerated()) {
|
||||||
navItems.addFilter("generatorClass is not null");
|
navItems.addFilter("generatorClass is not null");
|
||||||
} else {
|
} else {
|
||||||
navItems.addFilter("generatorClass is null");
|
navItems.addFilter("generatorClass is null");
|
||||||
}
|
}*/
|
||||||
|
|
||||||
PublicPersonalProfileNavItem navItem;
|
PublicPersonalProfileNavItem navItem;
|
||||||
|
String label;
|
||||||
while (navItems.next()) {
|
while (navItems.next()) {
|
||||||
navItem = navItems.getNavItem();
|
navItem = navItems.getNavItem();
|
||||||
|
|
||||||
select.addOption(new Option(navItem.getKey(),
|
if (navItem.getGeneratorClass() == null) {
|
||||||
navItem.getLabel()));
|
label = navItem.getLabel();
|
||||||
|
} else {
|
||||||
|
label = String.format("%s (auto)",
|
||||||
|
navItem.getLabel());
|
||||||
|
autoNavItemKeys.add(navItem.getKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
select.addOption(new Option(navItem.getKey(), label));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -132,15 +143,14 @@ public class PublicPersonalProfileNavigationAddForm
|
||||||
}*/
|
}*/
|
||||||
add(navItemSelect);
|
add(navItemSelect);
|
||||||
|
|
||||||
if (!showGenerated()) {
|
//if (!showGenerated()) {
|
||||||
add(new Label((String) PublicPersonalProfileGlobalizationUtil.
|
add(new Label((String) PublicPersonalProfileGlobalizationUtil.globalize(
|
||||||
globalize(
|
|
||||||
"publicpersonalprofile.ui.nav.select_target").
|
"publicpersonalprofile.ui.nav.select_target").
|
||||||
localize()));
|
localize()));
|
||||||
itemSearch = new ItemSearchWidget(ITEM_SEARCH);
|
itemSearch = new ItemSearchWidget(ITEM_SEARCH);
|
||||||
itemSearch.addValidationListener(this);
|
itemSearch.addValidationListener(this);
|
||||||
add(this.itemSearch);
|
add(this.itemSearch);
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -178,11 +188,15 @@ public class PublicPersonalProfileNavigationAddForm
|
||||||
link.setTargetType(Link.INTERNAL_LINK);
|
link.setTargetType(Link.INTERNAL_LINK);
|
||||||
|
|
||||||
ContentItem targetItem;
|
ContentItem targetItem;
|
||||||
if (showGenerated()) {
|
//if (showGenerated()) {
|
||||||
//For generated content the target is the profile itself.
|
//For generated content the target is the profile itself.
|
||||||
targetItem = profile;
|
//targetItem = profile;
|
||||||
} else {
|
//} else {
|
||||||
targetItem = (ContentItem) data.get(ITEM_SEARCH);
|
targetItem = (ContentItem) data.get(ITEM_SEARCH);
|
||||||
|
//
|
||||||
|
//}
|
||||||
|
if (targetItem == null) {
|
||||||
|
targetItem = profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (targetItem.getParent() instanceof ContentBundle) {
|
if (targetItem.getParent() instanceof ContentBundle) {
|
||||||
|
|
@ -200,7 +214,10 @@ public class PublicPersonalProfileNavigationAddForm
|
||||||
PageState state = fse.getPageState();
|
PageState state = fse.getPageState();
|
||||||
FormData data = fse.getFormData();
|
FormData data = fse.getFormData();
|
||||||
|
|
||||||
if (!showGenerated() && data.get(ITEM_SEARCH) == null) {
|
//if (!showGenerated() && data.get(ITEM_SEARCH) == null) {
|
||||||
|
if (!(autoNavItemKeys.contains(
|
||||||
|
(String) data.get(PublicPersonalProfileNavItem.KEY)))
|
||||||
|
&& data.get(ITEM_SEARCH) == null) {
|
||||||
data.addError(
|
data.addError(
|
||||||
new GlobalizedMessage(
|
new GlobalizedMessage(
|
||||||
"parameter_is_required",
|
"parameter_is_required",
|
||||||
|
|
@ -209,7 +226,7 @@ public class PublicPersonalProfileNavigationAddForm
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean showGenerated() {
|
/*protected boolean showGenerated() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,8 @@ public class PublicPersonalProfileNavigationGeneratedAddForm extends PublicPerso
|
||||||
super("PublicPersonalProfileNavGeneratedAddForm", itemModel, editStep);
|
super("PublicPersonalProfileNavGeneratedAddForm", itemModel, editStep);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/*@Override
|
||||||
public boolean showGenerated() {
|
public boolean showGenerated() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ public class PublicPersonalProfileNavigationStep extends SimpleEditStep {
|
||||||
new WorkflowLockedComponentAccess(editNavItemSheet, itemModel),
|
new WorkflowLockedComponentAccess(editNavItemSheet, itemModel),
|
||||||
editNavItemSheet.getSaveCancelSection().getCancelButton());
|
editNavItemSheet.getSaveCancelSection().getCancelButton());
|
||||||
|
|
||||||
BasicItemForm editGeneratedNavItemSheet =
|
/*BasicItemForm editGeneratedNavItemSheet =
|
||||||
new PublicPersonalProfileNavigationGeneratedAddForm(
|
new PublicPersonalProfileNavigationGeneratedAddForm(
|
||||||
itemModel,
|
itemModel,
|
||||||
this);
|
this);
|
||||||
|
|
@ -48,7 +48,7 @@ public class PublicPersonalProfileNavigationStep extends SimpleEditStep {
|
||||||
localize(),
|
localize(),
|
||||||
new WorkflowLockedComponentAccess(editGeneratedNavItemSheet,
|
new WorkflowLockedComponentAccess(editGeneratedNavItemSheet,
|
||||||
itemModel),
|
itemModel),
|
||||||
editGeneratedNavItemSheet.getSaveCancelSection().getCancelButton());
|
editGeneratedNavItemSheet.getSaveCancelSection().getCancelButton());*/
|
||||||
|
|
||||||
PublicPersonalProfileNavigationTable navTable =
|
PublicPersonalProfileNavigationTable navTable =
|
||||||
new PublicPersonalProfileNavigationTable(
|
new PublicPersonalProfileNavigationTable(
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ import com.arsdigita.cms.dispatcher.ItemResolver;
|
||||||
import com.arsdigita.cms.dispatcher.Utilities;
|
import com.arsdigita.cms.dispatcher.Utilities;
|
||||||
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
||||||
import com.arsdigita.globalization.GlobalizationHelper;
|
import com.arsdigita.globalization.GlobalizationHelper;
|
||||||
|
import com.arsdigita.kernel.Kernel;
|
||||||
import com.arsdigita.persistence.DataCollection;
|
import com.arsdigita.persistence.DataCollection;
|
||||||
import com.arsdigita.util.LockableImpl;
|
import com.arsdigita.util.LockableImpl;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
@ -146,19 +147,32 @@ public class PublicPersonalProfileNavigationTable
|
||||||
PublicPersonalProfileNavItem navItem;
|
PublicPersonalProfileNavItem navItem;
|
||||||
|
|
||||||
navItem = navItems.getNavItem(key, GlobalizationHelper.
|
navItem = navItems.getNavItem(key, GlobalizationHelper.
|
||||||
getNegotiatedLocale().
|
getNegotiatedLocale().getLanguage());
|
||||||
getLanguage());
|
navItems.reset();
|
||||||
|
if ((navItem == null) && (Kernel.getConfig().languageIndependentItems())) {
|
||||||
|
navItem = navItems.getNavItem(key, GlobalizationHelper.
|
||||||
|
LANG_INDEPENDENT);
|
||||||
|
}
|
||||||
navItems.reset();
|
navItems.reset();
|
||||||
|
|
||||||
switch (columnIndex) {
|
switch (columnIndex) {
|
||||||
case 0:
|
case 0:
|
||||||
//return mockNav[index];
|
//return mockNav[index];
|
||||||
return navItem.getLabel();
|
|
||||||
case 1:
|
|
||||||
if (navItem.getGeneratorClass() == null) {
|
if (navItem.getGeneratorClass() == null) {
|
||||||
|
return navItem.getLabel();
|
||||||
|
} else {
|
||||||
|
return String.format("%s (auto)", navItem.getLabel());
|
||||||
|
}
|
||||||
|
case 1:
|
||||||
|
/*if (navItem.getGeneratorClass() == null) {
|
||||||
return targetItem;
|
return targetItem;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
|
}*/
|
||||||
|
if (targetItem instanceof PublicPersonalProfile) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return targetItem;
|
||||||
}
|
}
|
||||||
case 2:
|
case 2:
|
||||||
return PublicPersonalProfileGlobalizationUtil.globalize(
|
return PublicPersonalProfileGlobalizationUtil.globalize(
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,11 @@ public interface ContentGenerator {
|
||||||
* @param parent XML element to attach the content to
|
* @param parent XML element to attach the content to
|
||||||
* @param person The person to be used as data source
|
* @param person The person to be used as data source
|
||||||
* @param state The current page state.
|
* @param state The current page state.
|
||||||
|
* @param profileLanguage
|
||||||
*/
|
*/
|
||||||
void generateContent(Element parent, GenericPerson person, PageState state);
|
void generateContent(Element parent,
|
||||||
|
GenericPerson person,
|
||||||
|
PageState state,
|
||||||
|
String profileLanguage);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,8 @@ import com.arsdigita.globalization.GlobalizationHelper;
|
||||||
import com.arsdigita.kernel.Kernel;
|
import com.arsdigita.kernel.Kernel;
|
||||||
import com.arsdigita.persistence.DataCollection;
|
import com.arsdigita.persistence.DataCollection;
|
||||||
import com.arsdigita.persistence.DataObject;
|
import com.arsdigita.persistence.DataObject;
|
||||||
|
import com.arsdigita.persistence.Filter;
|
||||||
|
import com.arsdigita.persistence.FilterFactory;
|
||||||
import com.arsdigita.persistence.OID;
|
import com.arsdigita.persistence.OID;
|
||||||
import com.arsdigita.persistence.Session;
|
import com.arsdigita.persistence.Session;
|
||||||
import com.arsdigita.persistence.SessionManager;
|
import com.arsdigita.persistence.SessionManager;
|
||||||
|
|
@ -82,6 +84,270 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
||||||
final HttpServletResponse response,
|
final HttpServletResponse response,
|
||||||
final Application app) throws ServletException,
|
final Application app) throws ServletException,
|
||||||
IOException {
|
IOException {
|
||||||
|
|
||||||
|
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...");
|
||||||
|
|
||||||
|
final String pathStr = getPath(request);
|
||||||
|
|
||||||
|
logger.debug(String.format("path = %s", pathStr));
|
||||||
|
|
||||||
|
//Displays a text/plain page with a message.
|
||||||
|
if (pathStr.isEmpty()) {
|
||||||
|
logger.debug("pathInfo is null, responding with default...");
|
||||||
|
|
||||||
|
response.setContentType("text/plain");
|
||||||
|
response.getWriter().append("Please choose an application.");
|
||||||
|
} else {
|
||||||
|
final Path path;
|
||||||
|
try {
|
||||||
|
path = new Path(pathStr);
|
||||||
|
} catch (IllegalArgumentException ex) {
|
||||||
|
response.sendError(HttpServletResponse.SC_BAD_REQUEST,
|
||||||
|
ex.getMessage());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Page page = PageFactory.buildPage("PublicPersonalProfile",
|
||||||
|
"");
|
||||||
|
|
||||||
|
if (path.getAdmin()) {
|
||||||
|
showAdminPage(page, request, response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
page.lock();
|
||||||
|
|
||||||
|
final Document document = page.buildDocument(request, response);
|
||||||
|
final Element root = document.getRootElement();
|
||||||
|
|
||||||
|
final Session session = SessionManager.getSession();
|
||||||
|
|
||||||
|
/*final DataCollection profiles = getProfiles(session,
|
||||||
|
path.getProfileOwner(),
|
||||||
|
path.getPreview(),
|
||||||
|
GlobalizationHelper.
|
||||||
|
getNegotiatedLocale().getLanguage());
|
||||||
|
|
||||||
|
if (profiles.isEmpty()) {
|
||||||
|
response.sendError(HttpServletResponse.SC_NOT_FOUND);
|
||||||
|
return;
|
||||||
|
} else if (profiles.size() > 1) {
|
||||||
|
throw new IllegalStateException(
|
||||||
|
"More than one matching members found.");
|
||||||
|
}
|
||||||
|
|
||||||
|
profiles.next();
|
||||||
|
PublicPersonalProfile profile =
|
||||||
|
(PublicPersonalProfile) DomainObjectFactory.
|
||||||
|
newInstance(profiles.getDataObject());
|
||||||
|
profiles.close();*/
|
||||||
|
|
||||||
|
PublicPersonalProfile profile = getProfile(
|
||||||
|
session,
|
||||||
|
path.getProfileOwner(),
|
||||||
|
path.getPreview(),
|
||||||
|
GlobalizationHelper.getNegotiatedLocale().getLanguage());
|
||||||
|
|
||||||
|
if (profile == null) {
|
||||||
|
response.sendError(HttpServletResponse.SC_NOT_FOUND);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (path.getNavPath() != null) {
|
||||||
|
final DataCollection links = RelatedLink.getRelatedLinks(
|
||||||
|
profile,
|
||||||
|
PublicPersonalProfile.LINK_LIST_NAME);
|
||||||
|
links.addFilter(String.format("linkTitle = '%s'",
|
||||||
|
path.getNavPath()));
|
||||||
|
if (links.isEmpty()) {
|
||||||
|
profile = getProfile(session,
|
||||||
|
path.getProfileOwner(),
|
||||||
|
path.getPreview(),
|
||||||
|
GlobalizationHelper.LANG_INDEPENDENT,
|
||||||
|
false);
|
||||||
|
} else {
|
||||||
|
links.next();
|
||||||
|
final RelatedLink link = (RelatedLink) DomainObjectFactory.
|
||||||
|
newInstance(
|
||||||
|
links.getDataObject());
|
||||||
|
links.close();
|
||||||
|
|
||||||
|
ContentItem item = link.getTargetItem();
|
||||||
|
|
||||||
|
if ((item instanceof ContentPage)
|
||||||
|
&& !(item instanceof PublicPersonalProfile)) {
|
||||||
|
ContentPage contentPage =
|
||||||
|
(ContentPage) item;
|
||||||
|
|
||||||
|
if (contentPage.getContentBundle().hasInstance(profile.
|
||||||
|
getLanguage(),
|
||||||
|
false)) {
|
||||||
|
contentPage =
|
||||||
|
(ContentPage) contentPage.getContentBundle().
|
||||||
|
getInstance(profile.getLanguage());
|
||||||
|
item = (ContentItem) contentPage;
|
||||||
|
} else {
|
||||||
|
profile =
|
||||||
|
getProfile(session,
|
||||||
|
path.getProfileOwner(),
|
||||||
|
path.getPreview(),
|
||||||
|
GlobalizationHelper.LANG_INDEPENDENT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final PageState state = new PageState(page,
|
||||||
|
request,
|
||||||
|
response);
|
||||||
|
|
||||||
|
if (path.getPreview()) {
|
||||||
|
if (Kernel.getContext().getParty() == null) {
|
||||||
|
throw new LoginSignal(request);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
com.arsdigita.cms.SecurityManager securityManager =
|
||||||
|
Utilities.
|
||||||
|
getSecurityManager(state);
|
||||||
|
|
||||||
|
final boolean canEdit = securityManager.canAccess(
|
||||||
|
state.getRequest(),
|
||||||
|
com.arsdigita.cms.SecurityManager.PREVIEW_PAGES,
|
||||||
|
profile);
|
||||||
|
|
||||||
|
if (!canEdit) {
|
||||||
|
throw new AccessDeniedException("user "
|
||||||
|
+ Kernel.getContext().
|
||||||
|
getParty().getOID()
|
||||||
|
+ " doesn't have the "
|
||||||
|
+ com.arsdigita.cms.SecurityManager.EDIT_ITEM
|
||||||
|
+ " privilege on "
|
||||||
|
+ profile.getOID().
|
||||||
|
toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.getEmbedded()) {
|
||||||
|
final ContentSection section =
|
||||||
|
profile.getContentSection();
|
||||||
|
final ItemResolver resolver = section.getItemResolver();
|
||||||
|
|
||||||
|
String context;
|
||||||
|
if (path.getPreview()) {
|
||||||
|
context = CMSDispatcher.PREVIEW;
|
||||||
|
} else {
|
||||||
|
context = ContentItem.LIVE;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String url = String.format("/ccm%s", resolver.
|
||||||
|
generateItemURL(state,
|
||||||
|
profile,
|
||||||
|
section,
|
||||||
|
context));
|
||||||
|
|
||||||
|
throw new RedirectSignal(url, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
Element profileElem =
|
||||||
|
root.newChildElement("ppp:profile", PPP_NS);
|
||||||
|
GenericPerson owner = profile.getOwner();
|
||||||
|
if (owner == null) {
|
||||||
|
throw new IllegalStateException(
|
||||||
|
"Failed to get owner of profile.");
|
||||||
|
}
|
||||||
|
Element profileOwnerName = profileElem.newChildElement(
|
||||||
|
"ppp:ownerName", PPP_NS);
|
||||||
|
profileOwnerName.setText(owner.getFullName());
|
||||||
|
//Add an attribute with the lang of the owner item of debugging.
|
||||||
|
profileOwnerName.addAttribute("ownerItemLang", owner.getLanguage());
|
||||||
|
|
||||||
|
final DataCollection images = ItemImageAttachment.
|
||||||
|
getImageAttachments(profile);
|
||||||
|
if (!images.isEmpty()) {
|
||||||
|
images.next();
|
||||||
|
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());
|
||||||
|
final ReusableImageAsset image = attachment.getImage();
|
||||||
|
final Element imageElem =
|
||||||
|
attachmentElem.newChildElement("image");
|
||||||
|
imageElem.addAttribute("oid", image.getOID().toString());
|
||||||
|
final Element widthElem = imageElem.newChildElement(
|
||||||
|
"width");
|
||||||
|
widthElem.setText(image.getWidth().toString());
|
||||||
|
final Element heightElem = imageElem.newChildElement(
|
||||||
|
"height");
|
||||||
|
heightElem.setText(image.getHeight().toString());
|
||||||
|
final Element descElem = imageElem.newChildElement(
|
||||||
|
"description");
|
||||||
|
descElem.setText(image.getDescription());
|
||||||
|
final Element nameElem = imageElem.newChildElement(
|
||||||
|
"name");
|
||||||
|
nameElem.setText(image.getName());
|
||||||
|
final Element idElem = imageElem.newChildElement("id");
|
||||||
|
idElem.setText(image.getID().toString());
|
||||||
|
final Element displayNameElem = imageElem.newChildElement(
|
||||||
|
"displayName");
|
||||||
|
displayNameElem.setText(image.getDisplayName());
|
||||||
|
|
||||||
|
images.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
final PublicPersonalProfileXmlUtil util =
|
||||||
|
new PublicPersonalProfileXmlUtil();
|
||||||
|
String prefix =
|
||||||
|
DispatcherHelper.getDispatcherPrefix(request);
|
||||||
|
if (prefix == null) {
|
||||||
|
prefix = "";
|
||||||
|
}
|
||||||
|
util.createNavigation(profile,
|
||||||
|
root,
|
||||||
|
path.getNavPath(),
|
||||||
|
prefix,
|
||||||
|
app.getPath(),
|
||||||
|
path.getPreview());
|
||||||
|
|
||||||
|
if (path.getNavPath() == null) {
|
||||||
|
final PublicPersonalProfileXmlGenerator generator =
|
||||||
|
new PublicPersonalProfileXmlGenerator(
|
||||||
|
profile);
|
||||||
|
generator.generateXML(state, root, "");
|
||||||
|
} else {
|
||||||
|
if (path.getItemPath() == null) {
|
||||||
|
showNavItem(response, profile, path, root,
|
||||||
|
profileElem, state);
|
||||||
|
} else {
|
||||||
|
showItem(response, profile, path, root,
|
||||||
|
profileElem, state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PresentationManager presentationManager = Templating.
|
||||||
|
getPresentationManager();
|
||||||
|
presentationManager.servePage(document, request, response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//@Override
|
||||||
|
protected void olddoService(final HttpServletRequest request,
|
||||||
|
final HttpServletResponse response,
|
||||||
|
final Application app) throws ServletException,
|
||||||
|
IOException {
|
||||||
String path = "";
|
String path = "";
|
||||||
|
|
||||||
logger.debug("PublicPersonalProfileServlet is starting...");
|
logger.debug("PublicPersonalProfileServlet is starting...");
|
||||||
|
|
@ -179,7 +445,9 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
||||||
profileOwner,
|
profileOwner,
|
||||||
preview,
|
preview,
|
||||||
GlobalizationHelper.
|
GlobalizationHelper.
|
||||||
getNegotiatedLocale().getLanguage());
|
getNegotiatedLocale().getLanguage(),
|
||||||
|
Kernel.getConfig().
|
||||||
|
languageIndependentItems());
|
||||||
|
|
||||||
/*if (profiles.isEmpty()) {
|
/*if (profiles.isEmpty()) {
|
||||||
profiles = getProfiles(session,
|
profiles = getProfiles(session,
|
||||||
|
|
@ -189,7 +457,7 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
if (profiles.size() == 0) {
|
if (profiles.size() == 0) {
|
||||||
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
|
response.sendError(HttpServletResponse.SC_NOT_FOUND);
|
||||||
return;
|
return;
|
||||||
} else if (profiles.size() > 1) {
|
} else if (profiles.size() > 1) {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(
|
||||||
|
|
@ -337,7 +605,7 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
||||||
navPath));
|
navPath));
|
||||||
|
|
||||||
if (links.size() == 0) {
|
if (links.size() == 0) {
|
||||||
response.setStatus(
|
response.sendError(
|
||||||
HttpServletResponse.SC_NOT_FOUND);
|
HttpServletResponse.SC_NOT_FOUND);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -370,7 +638,8 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
||||||
generator.generateContent(
|
generator.generateContent(
|
||||||
profileElem,
|
profileElem,
|
||||||
owner,
|
owner,
|
||||||
state);
|
state,
|
||||||
|
profile.getLanguage());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
throw new ServletException(String.
|
throw new ServletException(String.
|
||||||
|
|
@ -440,7 +709,7 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
||||||
Kernel.getConfig().
|
Kernel.getConfig().
|
||||||
languageIndependentItems(),
|
languageIndependentItems(),
|
||||||
GlobalizationHelper.LANG_INDEPENDENT));
|
GlobalizationHelper.LANG_INDEPENDENT));
|
||||||
response.setStatus(
|
response.sendError(
|
||||||
HttpServletResponse.SC_NOT_FOUND);
|
HttpServletResponse.SC_NOT_FOUND);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -497,7 +766,7 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
||||||
Kernel.getConfig().
|
Kernel.getConfig().
|
||||||
languageIndependentItems(),
|
languageIndependentItems(),
|
||||||
GlobalizationHelper.LANG_INDEPENDENT));
|
GlobalizationHelper.LANG_INDEPENDENT));
|
||||||
response.setStatus(
|
response.sendError(
|
||||||
HttpServletResponse.SC_NOT_FOUND);
|
HttpServletResponse.SC_NOT_FOUND);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -520,7 +789,7 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
||||||
"Item '%s' not found: ",
|
"Item '%s' not found: ",
|
||||||
itemPath),
|
itemPath),
|
||||||
ex);
|
ex);
|
||||||
response.setStatus(
|
response.sendError(
|
||||||
HttpServletResponse.SC_NOT_FOUND);
|
HttpServletResponse.SC_NOT_FOUND);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -694,11 +963,228 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showNavItem(final HttpServletResponse response,
|
||||||
|
final PublicPersonalProfile profile,
|
||||||
|
final Path path,
|
||||||
|
final Element root,
|
||||||
|
final Element profileElem,
|
||||||
|
final PageState state) throws IOException,
|
||||||
|
ServletException {
|
||||||
|
final DataCollection links =
|
||||||
|
RelatedLink.getRelatedLinks(
|
||||||
|
profile,
|
||||||
|
PublicPersonalProfile.LINK_LIST_NAME);
|
||||||
|
links.addFilter(String.format("linkTitle = '%s'",
|
||||||
|
path.getNavPath()));
|
||||||
|
|
||||||
|
if (links.size() == 0) {
|
||||||
|
response.sendError(
|
||||||
|
HttpServletResponse.SC_NOT_FOUND);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.getShowPersonInfoEverywhere()) {
|
||||||
|
generateProfileOwnerXml(profileElem, profile.getOwner(), state);
|
||||||
|
}
|
||||||
|
|
||||||
|
final PublicPersonalProfileNavItemCollection navItems =
|
||||||
|
new PublicPersonalProfileNavItemCollection();
|
||||||
|
navItems.addLanguageFilter(profile.getLanguage());
|
||||||
|
navItems.addKeyFilter(path.getNavPath());
|
||||||
|
navItems.next();
|
||||||
|
|
||||||
|
links.next();
|
||||||
|
final RelatedLink link = (RelatedLink) DomainObjectFactory.newInstance(
|
||||||
|
links.getDataObject());
|
||||||
|
links.close();
|
||||||
|
|
||||||
|
ContentItem item = link.getTargetItem();
|
||||||
|
|
||||||
|
if ((item instanceof ContentPage)
|
||||||
|
&& !(item instanceof PublicPersonalProfile)) {
|
||||||
|
ContentPage contentPage =
|
||||||
|
(ContentPage) item;
|
||||||
|
/*logger.debug("contentPage.getContentBundle().hasInstance(GlobalizationHelper.getNegotiatedLocale().getLanguage()) = "
|
||||||
|
+ contentPage.getContentBundle().
|
||||||
|
hasInstance(GlobalizationHelper.getNegotiatedLocale().
|
||||||
|
getLanguage()));
|
||||||
|
if (contentPage.getContentBundle().
|
||||||
|
hasInstance(GlobalizationHelper.getNegotiatedLocale().
|
||||||
|
getLanguage())) {
|
||||||
|
contentPage =
|
||||||
|
(ContentPage) contentPage.getContentBundle().
|
||||||
|
getInstance(GlobalizationHelper.getNegotiatedLocale().
|
||||||
|
getLanguage());
|
||||||
|
item = (ContentItem) contentPage;
|
||||||
|
} else {
|
||||||
|
logger.error(
|
||||||
|
String.format(
|
||||||
|
"Item '%s' not found in a suitable language variant. Negotiated langauge: %s, langugage independent items allowed is %s, language independent code is %s ",
|
||||||
|
path.getNavPath(),
|
||||||
|
GlobalizationHelper.getNegotiatedLocale().
|
||||||
|
getLanguage(),
|
||||||
|
Kernel.getConfig().
|
||||||
|
languageIndependentItems(),
|
||||||
|
GlobalizationHelper.LANG_INDEPENDENT));
|
||||||
|
response.sendError(
|
||||||
|
HttpServletResponse.SC_NOT_FOUND);
|
||||||
|
return;
|
||||||
|
}*/
|
||||||
|
if (contentPage.getContentBundle().hasInstance(profile.getLanguage(),
|
||||||
|
false)) {
|
||||||
|
contentPage =
|
||||||
|
(ContentPage) contentPage.getContentBundle().
|
||||||
|
getInstance(profile.getLanguage());
|
||||||
|
item = (ContentItem) contentPage;
|
||||||
|
} else {
|
||||||
|
response.sendError(
|
||||||
|
HttpServletResponse.SC_NOT_FOUND);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
final Element contentPanelElem =
|
||||||
|
root.newChildElement("cms:contentPanel",
|
||||||
|
CMS.CMS_XML_NS);
|
||||||
|
final PublicPersonalProfileXmlGenerator generator =
|
||||||
|
new PublicPersonalProfileXmlGenerator(
|
||||||
|
item);
|
||||||
|
generator.generateXML(state,
|
||||||
|
contentPanelElem,
|
||||||
|
"");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (navItems.getNavItem().getGeneratorClass() != null) {
|
||||||
|
try {
|
||||||
|
Object generatorObj =
|
||||||
|
Class.forName(navItems.getNavItem().
|
||||||
|
getGeneratorClass()).
|
||||||
|
getConstructor().
|
||||||
|
newInstance();
|
||||||
|
|
||||||
|
if (generatorObj instanceof ContentGenerator) {
|
||||||
|
final ContentGenerator generator =
|
||||||
|
(ContentGenerator) generatorObj;
|
||||||
|
|
||||||
|
generator.generateContent(profileElem,
|
||||||
|
profile.getOwner(),
|
||||||
|
state,
|
||||||
|
profile.getLanguage());
|
||||||
|
|
||||||
|
} else {
|
||||||
|
throw new ServletException(String.format(
|
||||||
|
"Class '%s' is not a ContentGenerator.",
|
||||||
|
navItems.getNavItem().
|
||||||
|
getGeneratorClass()));
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (InstantiationException ex) {
|
||||||
|
throw new ServletException(
|
||||||
|
"Failed to create generator", ex);
|
||||||
|
} catch (IllegalAccessException ex) {
|
||||||
|
throw new ServletException(
|
||||||
|
"Failed to create generator", ex);
|
||||||
|
} catch (IllegalArgumentException ex) {
|
||||||
|
throw new ServletException(
|
||||||
|
"Failed to create generator", ex);
|
||||||
|
} catch (InvocationTargetException ex) {
|
||||||
|
throw new ServletException(
|
||||||
|
"Failed to create generator", ex);
|
||||||
|
} catch (ClassNotFoundException ex) {
|
||||||
|
throw new ServletException(
|
||||||
|
"Failed to create generator", ex);
|
||||||
|
} catch (NoSuchMethodException ex) {
|
||||||
|
throw new ServletException(
|
||||||
|
"Failed to create generator", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
navItems.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showItem(final HttpServletResponse response,
|
||||||
|
final PublicPersonalProfile profile,
|
||||||
|
final Path path,
|
||||||
|
final Element root,
|
||||||
|
final Element profileElem,
|
||||||
|
final PageState state) throws IOException {
|
||||||
|
if (config.getShowPersonInfoEverywhere()) {
|
||||||
|
generateProfileOwnerXml(profileElem, profile.getOwner(), state);
|
||||||
|
}
|
||||||
|
|
||||||
|
final OID itemOid = OID.valueOf(path.getItemPath());
|
||||||
|
|
||||||
|
try {
|
||||||
|
ContentItem item =
|
||||||
|
(ContentItem) DomainObjectFactory.newInstance(
|
||||||
|
itemOid);
|
||||||
|
|
||||||
|
if (item instanceof ContentPage) {
|
||||||
|
ContentPage contentPage = (ContentPage) item;
|
||||||
|
/*logger.debug("contentPage.getContentBundle().hasInstance(GlobalizationHelper.getNegotiatedLocale().getLanguage()) = "
|
||||||
|
+ contentPage.getContentBundle().
|
||||||
|
hasInstance(GlobalizationHelper.getNegotiatedLocale().
|
||||||
|
getLanguage()));
|
||||||
|
if (contentPage.getContentBundle().
|
||||||
|
hasInstance(GlobalizationHelper.getNegotiatedLocale().
|
||||||
|
getLanguage())) {
|
||||||
|
contentPage = (ContentPage) contentPage.getContentBundle().
|
||||||
|
getInstance(GlobalizationHelper.getNegotiatedLocale().
|
||||||
|
getLanguage());
|
||||||
|
item = (ContentItem) contentPage;
|
||||||
|
} else {
|
||||||
|
logger.error(
|
||||||
|
String.format(
|
||||||
|
"Item '%s' not found in a suitable language variant. Negotiated langauge: %s, langugage independent items allowed is %s, language independent code is %s ",
|
||||||
|
path.getItemPath(),
|
||||||
|
GlobalizationHelper.getNegotiatedLocale().
|
||||||
|
getLanguage(),
|
||||||
|
Kernel.getConfig().
|
||||||
|
languageIndependentItems(),
|
||||||
|
GlobalizationHelper.LANG_INDEPENDENT));
|
||||||
|
response.sendError(
|
||||||
|
HttpServletResponse.SC_NOT_FOUND);
|
||||||
|
return;
|
||||||
|
}*/
|
||||||
|
if (contentPage.getContentBundle().hasInstance(profile.
|
||||||
|
getLanguage(), false)) {
|
||||||
|
contentPage = (ContentPage) contentPage.getContentBundle().
|
||||||
|
getInstance(profile.getLanguage());
|
||||||
|
} else {
|
||||||
|
response.sendError(
|
||||||
|
HttpServletResponse.SC_NOT_FOUND);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
final Element contentPanelElem =
|
||||||
|
root.newChildElement("cms:contentPanel",
|
||||||
|
CMS.CMS_XML_NS);
|
||||||
|
|
||||||
|
final PublicPersonalProfileXmlGenerator generator =
|
||||||
|
new PublicPersonalProfileXmlGenerator(
|
||||||
|
item);
|
||||||
|
generator.generateXML(state,
|
||||||
|
contentPanelElem,
|
||||||
|
"");
|
||||||
|
} catch (DataObjectNotFoundException ex) {
|
||||||
|
logger.error(String.format(
|
||||||
|
"Item '%s' not found: ",
|
||||||
|
path.getItemPath()),
|
||||||
|
ex);
|
||||||
|
response.sendError(
|
||||||
|
HttpServletResponse.SC_NOT_FOUND);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private DataCollection getProfiles(final Session session,
|
private DataCollection getProfiles(final Session session,
|
||||||
final String profileOwner,
|
final String profileOwner,
|
||||||
final boolean preview,
|
final boolean preview,
|
||||||
final String language) {
|
final String language,
|
||||||
DataCollection profiles =
|
final boolean allowLangIndependent) {
|
||||||
|
final DataCollection profiles =
|
||||||
session.retrieve(
|
session.retrieve(
|
||||||
com.arsdigita.cms.contenttypes.PublicPersonalProfile.BASE_DATA_OBJECT_TYPE);
|
com.arsdigita.cms.contenttypes.PublicPersonalProfile.BASE_DATA_OBJECT_TYPE);
|
||||||
profiles.addFilter(String.format("profileUrl = '%s'",
|
profiles.addFilter(String.format("profileUrl = '%s'",
|
||||||
|
|
@ -711,8 +1197,150 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
||||||
ContentItem.LIVE));
|
ContentItem.LIVE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (allowLangIndependent) {
|
||||||
|
FilterFactory ff = profiles.getFilterFactory();
|
||||||
|
Filter filter = ff.or().
|
||||||
|
addFilter(ff.equals("language", language)).
|
||||||
|
addFilter(ff.and().
|
||||||
|
addFilter(ff.equals("language",
|
||||||
|
GlobalizationHelper.LANG_INDEPENDENT)).
|
||||||
|
addFilter(ff.notIn("parent",
|
||||||
|
"com.arsdigita.navigation.getParentIDsOfMatchedItems").
|
||||||
|
set("language", language)));
|
||||||
|
profiles.addFilter(filter);
|
||||||
|
} else {
|
||||||
profiles.addFilter(String.format("language = '%s'", language));
|
profiles.addFilter(String.format("language = '%s'", language));
|
||||||
|
}
|
||||||
|
|
||||||
return profiles;
|
return profiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private PublicPersonalProfile getProfile(final Session session,
|
||||||
|
final String profileOwner,
|
||||||
|
final boolean preview,
|
||||||
|
final String language) {
|
||||||
|
return getProfile(session,
|
||||||
|
profileOwner,
|
||||||
|
preview,
|
||||||
|
language,
|
||||||
|
Kernel.getConfig().languageIndependentItems());
|
||||||
|
}
|
||||||
|
|
||||||
|
private PublicPersonalProfile getProfile(final Session session,
|
||||||
|
final String profileOwner,
|
||||||
|
final boolean preview,
|
||||||
|
final String language,
|
||||||
|
final boolean allowLangIndependent) {
|
||||||
|
final DataCollection profiles = getProfiles(session,
|
||||||
|
profileOwner,
|
||||||
|
preview,
|
||||||
|
language,
|
||||||
|
allowLangIndependent);
|
||||||
|
|
||||||
|
if (profiles.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
} else if (profiles.size() > 1) {
|
||||||
|
throw new IllegalStateException(
|
||||||
|
"More than one matching members found.");
|
||||||
|
} else {
|
||||||
|
profiles.next();
|
||||||
|
PublicPersonalProfile profile =
|
||||||
|
(PublicPersonalProfile) DomainObjectFactory.
|
||||||
|
newInstance(profiles.getDataObject());
|
||||||
|
profiles.close();
|
||||||
|
|
||||||
|
return profile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getPath(final HttpServletRequest request) {
|
||||||
|
String path = "";
|
||||||
|
|
||||||
|
if (request.getPathInfo() != null) {
|
||||||
|
if ("/".equals(request.getPathInfo())) {
|
||||||
|
path = "";
|
||||||
|
} else if (request.getPathInfo().startsWith("/")
|
||||||
|
&& request.getPathInfo().endsWith("/")) {
|
||||||
|
path = request.getPathInfo().substring(1, request.getPathInfo().
|
||||||
|
length() - 1);
|
||||||
|
} else if (request.getPathInfo().startsWith("/")) {
|
||||||
|
path = request.getPathInfo().substring(1);
|
||||||
|
} else if (request.getPathInfo().endsWith("/")) {
|
||||||
|
path = request.getPathInfo().substring(0, request.getPathInfo().
|
||||||
|
length() - 1);
|
||||||
|
} else {
|
||||||
|
path = request.getPathInfo();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class Path {
|
||||||
|
|
||||||
|
private final boolean admin;
|
||||||
|
private final boolean preview;
|
||||||
|
private final String profileOwner;
|
||||||
|
private final String navPath;
|
||||||
|
private final String itemPath;
|
||||||
|
|
||||||
|
public Path(final String path) {
|
||||||
|
final String[] pathTokens = path.split("/");
|
||||||
|
final int ownerTokenPos;
|
||||||
|
|
||||||
|
if (pathTokens.length < 1) {
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
"Illegal path. Missing profile owner.");
|
||||||
|
} else {
|
||||||
|
admin = ADMIN.equals(pathTokens[0]);
|
||||||
|
|
||||||
|
preview = PREVIEW.equals(pathTokens[0]);
|
||||||
|
|
||||||
|
if (preview) {
|
||||||
|
ownerTokenPos = 1;
|
||||||
|
} else {
|
||||||
|
ownerTokenPos = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pathTokens.length < (ownerTokenPos + 1)) {
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
"Illegal path. Missing profile owner.");
|
||||||
|
} else {
|
||||||
|
profileOwner = pathTokens[ownerTokenPos];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pathTokens.length > (ownerTokenPos + 1)) {
|
||||||
|
navPath = pathTokens[ownerTokenPos + 1];
|
||||||
|
} else {
|
||||||
|
navPath = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pathTokens.length > (ownerTokenPos + 2)) {
|
||||||
|
itemPath = pathTokens[ownerTokenPos + 2];
|
||||||
|
} else {
|
||||||
|
itemPath = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getAdmin() {
|
||||||
|
return admin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getPreview() {
|
||||||
|
return preview;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProfileOwner() {
|
||||||
|
return profileOwner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNavPath() {
|
||||||
|
return navPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getItemPath() {
|
||||||
|
return itemPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,6 @@ import com.arsdigita.kernel.permissions.PermissionService;
|
||||||
import com.arsdigita.persistence.DataAssociation;
|
import com.arsdigita.persistence.DataAssociation;
|
||||||
import com.arsdigita.persistence.DataAssociationCursor;
|
import com.arsdigita.persistence.DataAssociationCursor;
|
||||||
import com.arsdigita.persistence.DataObject;
|
import com.arsdigita.persistence.DataObject;
|
||||||
import com.arsdigita.persistence.FilterFactory;
|
|
||||||
import com.arsdigita.persistence.OID;
|
import com.arsdigita.persistence.OID;
|
||||||
import com.arsdigita.persistence.metadata.Property;
|
import com.arsdigita.persistence.metadata.Property;
|
||||||
import com.arsdigita.util.Assert;
|
import com.arsdigita.util.Assert;
|
||||||
|
|
|
||||||
|
|
@ -14,10 +14,9 @@ import com.arsdigita.domain.DomainObjectFactory;
|
||||||
import com.arsdigita.globalization.GlobalizationHelper;
|
import com.arsdigita.globalization.GlobalizationHelper;
|
||||||
import com.arsdigita.kernel.Kernel;
|
import com.arsdigita.kernel.Kernel;
|
||||||
import com.arsdigita.persistence.DataCollection;
|
import com.arsdigita.persistence.DataCollection;
|
||||||
import com.arsdigita.persistence.Filter;
|
|
||||||
import com.arsdigita.persistence.FilterFactory;
|
|
||||||
import com.arsdigita.persistence.OID;
|
import com.arsdigita.persistence.OID;
|
||||||
import com.arsdigita.xml.Element;
|
import com.arsdigita.xml.Element;
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
|
@ -56,8 +55,10 @@ public class PersonalProjects implements ContentGenerator {
|
||||||
|
|
||||||
public void generateContent(final Element parent,
|
public void generateContent(final Element parent,
|
||||||
final GenericPerson person,
|
final GenericPerson person,
|
||||||
final PageState state) {
|
final PageState state,
|
||||||
final List<SciProject> projects = collectProjects(person);
|
final String profileLanguage) {
|
||||||
|
final List<SciProject> projects = collectProjects(person,
|
||||||
|
profileLanguage);
|
||||||
|
|
||||||
final Element personalProjectsElem = parent.newChildElement(
|
final Element personalProjectsElem = parent.newChildElement(
|
||||||
"personalProjects");
|
"personalProjects");
|
||||||
|
|
@ -87,17 +88,19 @@ public class PersonalProjects implements ContentGenerator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<SciProject> collectProjects(final GenericPerson person) {
|
private List<SciProject> collectProjects(final GenericPerson person,
|
||||||
|
final String language) {
|
||||||
final List<SciProject> projects = new ArrayList<SciProject>();
|
final List<SciProject> projects = new ArrayList<SciProject>();
|
||||||
|
|
||||||
final DataCollection collection = (DataCollection) person.get(
|
/*final DataCollection collection = (DataCollection) person.get(
|
||||||
"organizationalunit");
|
"organizationalunit");
|
||||||
if (Kernel.getConfig().languageIndependentItems()) {
|
if (Kernel.getConfig().languageIndependentItems()) {*/
|
||||||
FilterFactory ff = collection.getFilterFactory();
|
/* FilterFactory ff = collection.getFilterFactory();
|
||||||
Filter filter = ff.or().
|
Filter filter = ff.or().*/
|
||||||
addFilter(ff.equals("language",
|
/*addFilter(ff.equals("language",
|
||||||
com.arsdigita.globalization.GlobalizationHelper.
|
com.arsdigita.globalization.GlobalizationHelper.
|
||||||
getNegotiatedLocale().getLanguage())).
|
getNegotiatedLocale().getLanguage())).*/
|
||||||
|
/*addFilter(ff.equals("language", language)).
|
||||||
addFilter(ff.and().
|
addFilter(ff.and().
|
||||||
addFilter(ff.equals("language",
|
addFilter(ff.equals("language",
|
||||||
GlobalizationHelper.LANG_INDEPENDENT)).
|
GlobalizationHelper.LANG_INDEPENDENT)).
|
||||||
|
|
@ -106,26 +109,53 @@ public class PersonalProjects implements ContentGenerator {
|
||||||
set("language",
|
set("language",
|
||||||
com.arsdigita.globalization.GlobalizationHelper.
|
com.arsdigita.globalization.GlobalizationHelper.
|
||||||
getNegotiatedLocale().getLanguage())));
|
getNegotiatedLocale().getLanguage())));
|
||||||
collection.addFilter(filter);
|
collection.addFilter(filter);*/
|
||||||
|
/*collection.addFilter(
|
||||||
|
String.format("(language = '%s' or language = '%s')",
|
||||||
|
language,
|
||||||
|
GlobalizationHelper.LANG_INDEPENDENT));
|
||||||
} else {
|
} else {
|
||||||
collection.addEqualsFilter("language",
|
/*collection.addEqualsFilter("language",
|
||||||
com.arsdigita.globalization.GlobalizationHelper.
|
com.arsdigita.globalization.GlobalizationHelper.
|
||||||
getNegotiatedLocale().getLanguage());
|
getNegotiatedLocale().getLanguage());*/
|
||||||
}
|
/* collection.addEqualsFilter("language", language);
|
||||||
|
}*/
|
||||||
|
final List<BigDecimal> processed = new ArrayList<BigDecimal>();
|
||||||
|
final DataCollection collection = (DataCollection) person.get(
|
||||||
|
"organizationalunit");
|
||||||
|
collection.addFilter(String.format("language = '%s'", language));
|
||||||
DomainObject obj;
|
DomainObject obj;
|
||||||
while (collection.next()) {
|
while (collection.next()) {
|
||||||
obj = DomainObjectFactory.newInstance(collection.getDataObject());
|
obj = DomainObjectFactory.newInstance(collection.getDataObject());
|
||||||
if (obj instanceof SciProject) {
|
if (obj instanceof SciProject) {
|
||||||
|
processed.add(((SciProject) obj).getParent().getID());
|
||||||
projects.add((SciProject) obj);
|
projects.add((SciProject) obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Kernel.getConfig().languageIndependentItems()) {
|
||||||
|
final DataCollection collectionLi = (DataCollection) person.get(
|
||||||
|
"organizationalunit");
|
||||||
|
collectionLi.addFilter(
|
||||||
|
String.format("language = '%s'",
|
||||||
|
GlobalizationHelper.LANG_INDEPENDENT));
|
||||||
|
|
||||||
|
while (collectionLi.next()) {
|
||||||
|
obj =
|
||||||
|
DomainObjectFactory.newInstance(collectionLi.getDataObject());
|
||||||
|
if (obj instanceof SciProject) {
|
||||||
|
if (!(processed.contains(((SciProject) obj).getParent().
|
||||||
|
getID()))) {
|
||||||
|
projects.add((SciProject) obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (person.getAlias() != null) {
|
if (person.getAlias() != null) {
|
||||||
collectProjects(person.getAlias(), projects);
|
collectProjects(person.getAlias(), projects);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return projects;
|
return projects;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,8 @@ import com.arsdigita.domain.DomainObjectFactory;
|
||||||
import com.arsdigita.globalization.GlobalizationHelper;
|
import com.arsdigita.globalization.GlobalizationHelper;
|
||||||
import com.arsdigita.kernel.Kernel;
|
import com.arsdigita.kernel.Kernel;
|
||||||
import com.arsdigita.persistence.DataQuery;
|
import com.arsdigita.persistence.DataQuery;
|
||||||
|
import com.arsdigita.persistence.Filter;
|
||||||
|
import com.arsdigita.persistence.FilterFactory;
|
||||||
import com.arsdigita.persistence.OID;
|
import com.arsdigita.persistence.OID;
|
||||||
import com.arsdigita.persistence.SessionManager;
|
import com.arsdigita.persistence.SessionManager;
|
||||||
import com.arsdigita.xml.Element;
|
import com.arsdigita.xml.Element;
|
||||||
|
|
@ -46,12 +48,13 @@ public class PersonalPublications implements ContentGenerator {
|
||||||
@Override
|
@Override
|
||||||
public void generateContent(final Element parent,
|
public void generateContent(final Element parent,
|
||||||
final GenericPerson person,
|
final GenericPerson person,
|
||||||
final PageState state) {
|
final PageState state,
|
||||||
|
final String language) {
|
||||||
final long start = System.currentTimeMillis();
|
final long start = System.currentTimeMillis();
|
||||||
|
|
||||||
final DataQuery allQuery = SessionManager.getSession().retrieveQuery(
|
final DataQuery allQuery = SessionManager.getSession().retrieveQuery(
|
||||||
"com.arsdigita.cms.contenttypes.getPublicationsForAuthor");
|
"com.arsdigita.cms.contenttypes.getPublicationsForAuthor");
|
||||||
applyAuthorFilter(person, allQuery, true);
|
applyAuthorFilter(person, allQuery, true, language);
|
||||||
|
|
||||||
final Element personalPubsElem = parent.newChildElement(
|
final Element personalPubsElem = parent.newChildElement(
|
||||||
"personalPublications");
|
"personalPublications");
|
||||||
|
|
@ -83,7 +86,8 @@ public class PersonalPublications implements ContentGenerator {
|
||||||
createGroupQuery(person,
|
createGroupQuery(person,
|
||||||
entry.getKey(),
|
entry.getKey(),
|
||||||
entry.getValue(),
|
entry.getValue(),
|
||||||
groupQueries);
|
groupQueries,
|
||||||
|
language);
|
||||||
logger.debug(String.format("3: %d ms until now...", System.
|
logger.debug(String.format("3: %d ms until now...", System.
|
||||||
currentTimeMillis() - start));
|
currentTimeMillis() - start));
|
||||||
}
|
}
|
||||||
|
|
@ -92,7 +96,7 @@ public class PersonalPublications implements ContentGenerator {
|
||||||
final DataQuery miscQuery = SessionManager.getSession().
|
final DataQuery miscQuery = SessionManager.getSession().
|
||||||
retrieveQuery(
|
retrieveQuery(
|
||||||
"com.arsdigita.cms.contenttypes.getPublicationsForAuthor");
|
"com.arsdigita.cms.contenttypes.getPublicationsForAuthor");
|
||||||
applyAuthorFilter(person, miscQuery, true);
|
applyAuthorFilter(person, miscQuery, true, language);
|
||||||
miscQuery.addFilter(miscFilter);
|
miscQuery.addFilter(miscFilter);
|
||||||
groupQueries.put(MISC, miscQuery);
|
groupQueries.put(MISC, miscQuery);
|
||||||
logger.debug(String.format("4: %d ms until now...", System.
|
logger.debug(String.format("4: %d ms until now...", System.
|
||||||
|
|
@ -192,7 +196,8 @@ public class PersonalPublications implements ContentGenerator {
|
||||||
|
|
||||||
private void applyAuthorFilter(final GenericPerson person,
|
private void applyAuthorFilter(final GenericPerson person,
|
||||||
final DataQuery query,
|
final DataQuery query,
|
||||||
final boolean addOrders) {
|
final boolean addOrders,
|
||||||
|
final String language) {
|
||||||
final StringBuilder authorFilterBuilder = new StringBuilder();
|
final StringBuilder authorFilterBuilder = new StringBuilder();
|
||||||
authorFilterBuilder.append('(');
|
authorFilterBuilder.append('(');
|
||||||
authorFilterBuilder.append(String.format("authorId = %s",
|
authorFilterBuilder.append(String.format("authorId = %s",
|
||||||
|
|
@ -208,23 +213,27 @@ public class PersonalPublications implements ContentGenerator {
|
||||||
/*query.addFilter(String.format("authorId = %s",
|
/*query.addFilter(String.format("authorId = %s",
|
||||||
person.getID().toString()));*/
|
person.getID().toString()));*/
|
||||||
if (Kernel.getConfig().languageIndependentItems()) {
|
if (Kernel.getConfig().languageIndependentItems()) {
|
||||||
/*FilterFactory ff = query.getFilterFactory();
|
FilterFactory ff = query.getFilterFactory();
|
||||||
Filter filter = ff.or().
|
Filter filter = ff.or().
|
||||||
addFilter(ff.equals("language", com.arsdigita.globalization.GlobalizationHelper.getNegotiatedLocale().getLanguage())).
|
addFilter(ff.equals("language", language)).
|
||||||
addFilter(ff.and().
|
addFilter(ff.and().
|
||||||
addFilter(ff.equals("language", GlobalizationHelper.LANG_INDEPENDENT)).
|
addFilter(ff.equals("language", GlobalizationHelper.LANG_INDEPENDENT)).
|
||||||
addFilter(ff.notIn("parent", "com.arsdigita.navigation.getParentIDsOfMatchedItems")
|
addFilter(ff.notIn("parent", "com.arsdigita.navigation.getParentIDsOfMatchedItems")
|
||||||
.set("language", com.arsdigita.globalization.GlobalizationHelper.getNegotiatedLocale().getLanguage())));
|
.set("language", language)));
|
||||||
query.addFilter(filter);*/
|
query.addFilter(filter);
|
||||||
query.addFilter(
|
/*query.addFilter(
|
||||||
String.format("(language = '%s' or language = '%s')",
|
String.format("(language = '%s' or language = '%s')",
|
||||||
GlobalizationHelper.getNegotiatedLocale().
|
GlobalizationHelper.getNegotiatedLocale().
|
||||||
getLanguage(),
|
getLanguage(),
|
||||||
GlobalizationHelper.LANG_INDEPENDENT));
|
GlobalizationHelper.LANG_INDEPENDENT));*/
|
||||||
|
/*query.addFilter(String.format("language = '%s' or language = '%s'",
|
||||||
|
language,
|
||||||
|
GlobalizationHelper.LANG_INDEPENDENT));*/
|
||||||
} else {
|
} else {
|
||||||
query.addEqualsFilter("language",
|
/*query.addEqualsFilter("language",
|
||||||
com.arsdigita.globalization.GlobalizationHelper.
|
com.arsdigita.globalization.GlobalizationHelper.
|
||||||
getNegotiatedLocale().getLanguage());
|
getNegotiatedLocale().getLanguage());*/
|
||||||
|
query.addEqualsFilter("language", language);
|
||||||
}
|
}
|
||||||
if (addOrders) {
|
if (addOrders) {
|
||||||
final String[] orders = config.getOrder().split(",");
|
final String[] orders = config.getOrder().split(",");
|
||||||
|
|
@ -236,7 +245,8 @@ public class PersonalPublications implements ContentGenerator {
|
||||||
|
|
||||||
private void addAliasToFilter(final StringBuilder builder,
|
private void addAliasToFilter(final StringBuilder builder,
|
||||||
final GenericPerson alias) {
|
final GenericPerson alias) {
|
||||||
builder.append(String.format("or authorId = %s", alias.getID().toString()));
|
builder.append(String.format("or authorId = %s",
|
||||||
|
alias.getID().toString()));
|
||||||
|
|
||||||
if (alias.getAlias() != null) {
|
if (alias.getAlias() != null) {
|
||||||
addAliasToFilter(builder, alias.getAlias());
|
addAliasToFilter(builder, alias.getAlias());
|
||||||
|
|
@ -430,10 +440,11 @@ public class PersonalPublications implements ContentGenerator {
|
||||||
private void createGroupQuery(final GenericPerson author,
|
private void createGroupQuery(final GenericPerson author,
|
||||||
final String groupName,
|
final String groupName,
|
||||||
final List<String> typeTokens,
|
final List<String> typeTokens,
|
||||||
final Map<String, DataQuery> groupQueries) {
|
final Map<String, DataQuery> groupQueries,
|
||||||
|
final String language) {
|
||||||
final DataQuery query = SessionManager.getSession().retrieveQuery(
|
final DataQuery query = SessionManager.getSession().retrieveQuery(
|
||||||
"com.arsdigita.cms.contenttypes.getPublicationsForAuthor");
|
"com.arsdigita.cms.contenttypes.getPublicationsForAuthor");
|
||||||
applyAuthorFilter(author, query, true);
|
applyAuthorFilter(author, query, true, language);
|
||||||
applyFiltersForTypeTokens(typeTokens, query);
|
applyFiltersForTypeTokens(typeTokens, query);
|
||||||
|
|
||||||
groupQueries.put(groupName, query);
|
groupQueries.put(groupName, query);
|
||||||
|
|
|
||||||
|
|
@ -172,6 +172,7 @@ query getPublicationsForAuthor {
|
||||||
String language;
|
String language;
|
||||||
Boolean reviewed;
|
Boolean reviewed;
|
||||||
String authors;
|
String authors;
|
||||||
|
BigDecimal parent;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
select cms_pages.item_id,
|
select cms_pages.item_id,
|
||||||
|
|
@ -181,7 +182,8 @@ query getPublicationsForAuthor {
|
||||||
ct_publications.year,
|
ct_publications.year,
|
||||||
cms_items.language,
|
cms_items.language,
|
||||||
ct_publications.reviewed,
|
ct_publications.reviewed,
|
||||||
ct_publications.authors
|
ct_publications.authors,
|
||||||
|
cms_items.parent_id
|
||||||
from cms_pages
|
from cms_pages
|
||||||
join ct_publications on cms_pages.item_id = ct_publications.publication_id
|
join ct_publications on cms_pages.item_id = ct_publications.publication_id
|
||||||
join ct_publications_authorship on ct_publications.publication_id = ct_publications_authorship.publication_id
|
join ct_publications_authorship on ct_publications.publication_id = ct_publications_authorship.publication_id
|
||||||
|
|
@ -196,6 +198,7 @@ query getPublicationsForAuthor {
|
||||||
language = ct_items.language;
|
language = ct_items.language;
|
||||||
reviewed = ct_publications.reviewed;
|
reviewed = ct_publications.reviewed;
|
||||||
authors = ct_publications.authors;
|
authors = ct_publications.authors;
|
||||||
|
parent = cms_items.parent_id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
import com.arsdigita.bebop.PageState;
|
import com.arsdigita.bebop.PageState;
|
||||||
import com.arsdigita.cms.ContentItem;
|
import com.arsdigita.cms.ContentItem;
|
||||||
|
import com.arsdigita.cms.RelationAttributeCollection;
|
||||||
import com.arsdigita.cms.contenttypes.GenericContact;
|
import com.arsdigita.cms.contenttypes.GenericContact;
|
||||||
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnit;
|
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnit;
|
||||||
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnitContactCollection;
|
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnitContactCollection;
|
||||||
|
|
@ -10,6 +11,7 @@ import com.arsdigita.cms.contenttypes.GenericOrganizationalUnitSubordinateCollec
|
||||||
import com.arsdigita.cms.contenttypes.GenericPerson;
|
import com.arsdigita.cms.contenttypes.GenericPerson;
|
||||||
import com.arsdigita.cms.contenttypes.SciDepartment;
|
import com.arsdigita.cms.contenttypes.SciDepartment;
|
||||||
import com.arsdigita.cms.dispatcher.SimpleXMLGenerator;
|
import com.arsdigita.cms.dispatcher.SimpleXMLGenerator;
|
||||||
|
import com.arsdigita.globalization.GlobalizationHelper;
|
||||||
import com.arsdigita.xml.Element;
|
import com.arsdigita.xml.Element;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
@ -172,11 +174,13 @@ public class SciDepartmentSummaryTab implements GenericOrgaUnitTab {
|
||||||
final long start = System.currentTimeMillis();
|
final long start = System.currentTimeMillis();
|
||||||
|
|
||||||
if (!(orgaunit instanceof SciDepartment)) {
|
if (!(orgaunit instanceof SciDepartment)) {
|
||||||
throw new IllegalArgumentException(String.format("Can't process "
|
throw new IllegalArgumentException(String.format(
|
||||||
|
"Can't process "
|
||||||
+ "orgaunit '%s' as sub department because the orgaunit is "
|
+ "orgaunit '%s' as sub department because the orgaunit is "
|
||||||
+ "not a SciDepartment but of type '%s'.",
|
+ "not a SciDepartment but of type '%s'.",
|
||||||
orgaunit.getName(),
|
orgaunit.getName(),
|
||||||
orgaunit.getClass().getName()));
|
orgaunit.getClass().
|
||||||
|
getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
final SciDepartment subDepartment = (SciDepartment) orgaunit;
|
final SciDepartment subDepartment = (SciDepartment) orgaunit;
|
||||||
|
|
@ -233,7 +237,10 @@ public class SciDepartmentSummaryTab implements GenericOrgaUnitTab {
|
||||||
final Element contactsElem = parent.newChildElement("contacts");
|
final Element contactsElem = parent.newChildElement("contacts");
|
||||||
|
|
||||||
while (contacts.next()) {
|
while (contacts.next()) {
|
||||||
generateContactXml(contacts.getContact(), contactsElem, state);
|
generateContactXml(contacts.getContact(),
|
||||||
|
contacts.getContactType(),
|
||||||
|
contactsElem,
|
||||||
|
state);
|
||||||
}
|
}
|
||||||
logger.debug(String.format("Generated XML for contacts of project '%s'"
|
logger.debug(String.format("Generated XML for contacts of project '%s'"
|
||||||
+ " in %d ms.",
|
+ " in %d ms.",
|
||||||
|
|
@ -242,18 +249,41 @@ public class SciDepartmentSummaryTab implements GenericOrgaUnitTab {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void generateContactXml(final GenericContact contact,
|
protected void generateContactXml(final GenericContact contact,
|
||||||
|
final String contactType,
|
||||||
final Element parent,
|
final Element parent,
|
||||||
final PageState state) {
|
final PageState state) {
|
||||||
final long start = System.currentTimeMillis();
|
final long start = System.currentTimeMillis();
|
||||||
final XmlGenerator generator = new XmlGenerator(contact);
|
final XmlGenerator generator = new XmlGenerator(contact);
|
||||||
generator.setUseExtraXml(false);
|
generator.setUseExtraXml(false);
|
||||||
generator.setItemElemName("contact", "");
|
generator.setItemElemName("contact", "");
|
||||||
|
generator.addItemAttribute("contactType",
|
||||||
|
getContactTypeName(contactType));
|
||||||
generator.generateXML(state, parent, "");
|
generator.generateXML(state, parent, "");
|
||||||
logger.debug(String.format("Generated XML for contact '%s' in %d ms.",
|
logger.debug(String.format("Generated XML for contact '%s' in %d ms.",
|
||||||
contact.getName(),
|
contact.getName(),
|
||||||
System.currentTimeMillis() - start));
|
System.currentTimeMillis() - start));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getContactTypeName(final String contactTypeKey) {
|
||||||
|
final RelationAttributeCollection relAttrs =
|
||||||
|
new RelationAttributeCollection();
|
||||||
|
relAttrs.addFilter(String.format("attribute = '%s'",
|
||||||
|
"GenericContactTypes"));
|
||||||
|
relAttrs.addFilter(String.format("attr_key = '%s'", contactTypeKey));
|
||||||
|
relAttrs.addFilter(String.format("lang = '%s'", GlobalizationHelper.
|
||||||
|
getNegotiatedLocale().getLanguage()));
|
||||||
|
|
||||||
|
if (relAttrs.isEmpty()) {
|
||||||
|
return contactTypeKey;
|
||||||
|
} else {
|
||||||
|
relAttrs.next();
|
||||||
|
final String result = relAttrs.getName();
|
||||||
|
relAttrs.close();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private class XmlGenerator extends SimpleXMLGenerator {
|
private class XmlGenerator extends SimpleXMLGenerator {
|
||||||
|
|
||||||
private final ContentItem item;
|
private final ContentItem item;
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
import com.arsdigita.bebop.PageState;
|
import com.arsdigita.bebop.PageState;
|
||||||
import com.arsdigita.cms.ContentItem;
|
import com.arsdigita.cms.ContentItem;
|
||||||
|
import com.arsdigita.cms.RelationAttributeCollection;
|
||||||
import com.arsdigita.cms.contenttypes.GenericContact;
|
import com.arsdigita.cms.contenttypes.GenericContact;
|
||||||
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnit;
|
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnit;
|
||||||
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnitContactCollection;
|
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnitContactCollection;
|
||||||
|
|
@ -10,6 +11,7 @@ import com.arsdigita.cms.contenttypes.GenericOrganizationalUnitSubordinateCollec
|
||||||
import com.arsdigita.cms.contenttypes.GenericPerson;
|
import com.arsdigita.cms.contenttypes.GenericPerson;
|
||||||
import com.arsdigita.cms.contenttypes.SciInstitute;
|
import com.arsdigita.cms.contenttypes.SciInstitute;
|
||||||
import com.arsdigita.cms.dispatcher.SimpleXMLGenerator;
|
import com.arsdigita.cms.dispatcher.SimpleXMLGenerator;
|
||||||
|
import com.arsdigita.globalization.GlobalizationHelper;
|
||||||
import com.arsdigita.xml.Element;
|
import com.arsdigita.xml.Element;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
@ -286,7 +288,10 @@ public class SciInstituteSummaryTab implements GenericOrgaUnitTab {
|
||||||
final Element contactsElem = parent.newChildElement("contacts");
|
final Element contactsElem = parent.newChildElement("contacts");
|
||||||
|
|
||||||
while (contacts.next()) {
|
while (contacts.next()) {
|
||||||
generateContactXml(contacts.getContact(), contactsElem, state);
|
generateContactXml(contacts.getContact(),
|
||||||
|
contacts.getContactType(),
|
||||||
|
contactsElem,
|
||||||
|
state);
|
||||||
}
|
}
|
||||||
logger.debug(String.format("Generated XML for contacts of project '%s'"
|
logger.debug(String.format("Generated XML for contacts of project '%s'"
|
||||||
+ " in %d ms.",
|
+ " in %d ms.",
|
||||||
|
|
@ -295,18 +300,41 @@ public class SciInstituteSummaryTab implements GenericOrgaUnitTab {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void generateContactXml(final GenericContact contact,
|
protected void generateContactXml(final GenericContact contact,
|
||||||
|
final String contactType,
|
||||||
final Element parent,
|
final Element parent,
|
||||||
final PageState state) {
|
final PageState state) {
|
||||||
final long start = System.currentTimeMillis();
|
final long start = System.currentTimeMillis();
|
||||||
final XmlGenerator generator = new XmlGenerator(contact);
|
final XmlGenerator generator = new XmlGenerator(contact);
|
||||||
generator.setUseExtraXml(false);
|
generator.setUseExtraXml(false);
|
||||||
generator.setItemElemName("contact", "");
|
generator.setItemElemName("contact", "");
|
||||||
|
generator.addItemAttribute("contactType",
|
||||||
|
getContactTypeName(contactType));
|
||||||
generator.generateXML(state, parent, "");
|
generator.generateXML(state, parent, "");
|
||||||
logger.debug(String.format("Generated XML for contact '%s' in %d ms.",
|
logger.debug(String.format("Generated XML for contact '%s' in %d ms.",
|
||||||
contact.getName(),
|
contact.getName(),
|
||||||
System.currentTimeMillis() - start));
|
System.currentTimeMillis() - start));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getContactTypeName(final String contactTypeKey) {
|
||||||
|
final RelationAttributeCollection relAttrs =
|
||||||
|
new RelationAttributeCollection();
|
||||||
|
relAttrs.addFilter(String.format("attribute = '%s'",
|
||||||
|
"GenericContactTypes"));
|
||||||
|
relAttrs.addFilter(String.format("attr_key = '%s'", contactTypeKey));
|
||||||
|
relAttrs.addFilter(String.format("lang = '%s'", GlobalizationHelper.
|
||||||
|
getNegotiatedLocale().getLanguage()));
|
||||||
|
|
||||||
|
if (relAttrs.isEmpty()) {
|
||||||
|
return contactTypeKey;
|
||||||
|
} else {
|
||||||
|
relAttrs.next();
|
||||||
|
final String result = relAttrs.getName();
|
||||||
|
relAttrs.close();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private class XmlGenerator extends SimpleXMLGenerator {
|
private class XmlGenerator extends SimpleXMLGenerator {
|
||||||
|
|
||||||
private final ContentItem item;
|
private final ContentItem item;
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
import com.arsdigita.bebop.PageState;
|
import com.arsdigita.bebop.PageState;
|
||||||
import com.arsdigita.cms.ContentItem;
|
import com.arsdigita.cms.ContentItem;
|
||||||
|
import com.arsdigita.cms.RelationAttributeCollection;
|
||||||
import com.arsdigita.cms.contenttypes.GenericContact;
|
import com.arsdigita.cms.contenttypes.GenericContact;
|
||||||
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnit;
|
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnit;
|
||||||
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnitContactCollection;
|
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnitContactCollection;
|
||||||
|
|
@ -293,7 +294,10 @@ public class SciProjectSummaryTab implements GenericOrgaUnitTab {
|
||||||
final Element contactsElem = parent.newChildElement("contacts");
|
final Element contactsElem = parent.newChildElement("contacts");
|
||||||
|
|
||||||
while (contacts.next()) {
|
while (contacts.next()) {
|
||||||
generateContactXml(contacts.getContact(), contactsElem, state);
|
generateContactXml(contacts.getContact(),
|
||||||
|
contacts.getContactType(),
|
||||||
|
contactsElem,
|
||||||
|
state);
|
||||||
}
|
}
|
||||||
logger.debug(String.format("Generated XML for contacts of project '%s'"
|
logger.debug(String.format("Generated XML for contacts of project '%s'"
|
||||||
+ " in %d ms.",
|
+ " in %d ms.",
|
||||||
|
|
@ -302,18 +306,41 @@ public class SciProjectSummaryTab implements GenericOrgaUnitTab {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void generateContactXml(final GenericContact contact,
|
protected void generateContactXml(final GenericContact contact,
|
||||||
|
final String contactType,
|
||||||
final Element parent,
|
final Element parent,
|
||||||
final PageState state) {
|
final PageState state) {
|
||||||
final long start = System.currentTimeMillis();
|
final long start = System.currentTimeMillis();
|
||||||
final XmlGenerator generator = new XmlGenerator(contact);
|
final XmlGenerator generator = new XmlGenerator(contact);
|
||||||
generator.setUseExtraXml(false);
|
generator.setUseExtraXml(false);
|
||||||
generator.setItemElemName("contact", "");
|
generator.setItemElemName("contact", "");
|
||||||
|
generator.addItemAttribute("contactType",
|
||||||
|
getContactTypeName(contactType));
|
||||||
generator.generateXML(state, parent, "");
|
generator.generateXML(state, parent, "");
|
||||||
logger.debug(String.format("Generated XML for contact '%s' in %d ms.",
|
logger.debug(String.format("Generated XML for contact '%s' in %d ms.",
|
||||||
contact.getName(),
|
contact.getName(),
|
||||||
System.currentTimeMillis() - start));
|
System.currentTimeMillis() - start));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getContactTypeName(final String contactTypeKey) {
|
||||||
|
final RelationAttributeCollection relAttrs =
|
||||||
|
new RelationAttributeCollection();
|
||||||
|
relAttrs.addFilter(String.format("attribute = '%s'",
|
||||||
|
"GenericContactTypes"));
|
||||||
|
relAttrs.addFilter(String.format("attr_key = '%s'", contactTypeKey));
|
||||||
|
relAttrs.addFilter(String.format("lang = '%s'", GlobalizationHelper.
|
||||||
|
getNegotiatedLocale().getLanguage()));
|
||||||
|
|
||||||
|
if (relAttrs.isEmpty()) {
|
||||||
|
return contactTypeKey;
|
||||||
|
} else {
|
||||||
|
relAttrs.next();
|
||||||
|
final String result = relAttrs.getName();
|
||||||
|
relAttrs.close();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
protected void generateInvolvedOrgasXml(final SciProject project,
|
protected void generateInvolvedOrgasXml(final SciProject project,
|
||||||
final Element parent,
|
final Element parent,
|
||||||
final PageState state) {
|
final PageState state) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue