Fixing the translation problem in the content center (see #1630).

git-svn-id: https://svn.libreccm.org/ccm/trunk@2085 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2013-03-16 09:49:19 +00:00
parent de925fdb3b
commit 9b263bec1a
11 changed files with 400 additions and 346 deletions

View File

@ -1113,3 +1113,10 @@ cms.ui.clear=Clear
cms.ui.item_search.create.folder_missing=No folder selected
cms.ui.images_links=
cms.contenttypes.ui.person.alias.delete.label=Delete
cms.ui.contentcenter.mainpage.search=Search
cms.ui.contentcenter.mainpage.taskssections=Tasks/Sections
cms.ui.contentcenter.section=Section
cms.ui.contentcenter.action=Action
cms.ui.set_home_folder=Set as home folder
cms.ui.go_to_home_folder=Go to home folder
cms.ui.no_home_folder_selected=No home folder selected

View File

@ -845,7 +845,7 @@ cms.ui.workflow.tasks=Aufgaben
cms.ui.workflow.task.view_locked=Reservierte Aufgaben anzeigen
cms.ui.workflow.task.view_unlocked=Freigegebene Aufgaben anzeigen
cms.ui.workflow.task.view_all=Alle Aufgaben anzeigen
cms.ui.workflow.task.item_title=Item Title
cms.ui.workflow.task.item_title=Titel des Dokuments
cms.ui.workflow.task.locking_user=Reserviert von\:
cms.ui.workflow.unlock_tasks=Alle meine Aufgaben f\u00fcr diesen Typ freigeben
cms.ui.workflow.your_tasks=Zugewiesene Aufgaben
@ -1105,4 +1105,11 @@ cms.ui.type.minimum_number_of_values_bigger_than_maximum_number_of_values=Maxima
cms.ui.type.minimummaximum_number_of_values_cannot_be_negative=Keine negativen Werte erlaubt
cms.ui.item_search.create.folder_missing=kein Ordner ausgew\u00e4hlt
cms.ui.images_links=
cms.contenttypes.ui.person.alias.delete.label=
cms.contenttypes.ui.person.alias.delete.label=L\u00f6schen
cms.ui.contentcenter.mainpage.search=Suche
cms.ui.contentcenter.mainpage.taskssections=Aufgaben/Content Sections
cms.ui.contentcenter.section=Content Section
cms.ui.contentcenter.action=Aktion
cms.ui.set_home_folder=Als Start-Ordner festlegen
cms.ui.go_to_home_folder=Zum Start-Ordner
cms.ui.no_home_folder_selected=Kein Start-Ordner festgelegt

View File

@ -52,3 +52,10 @@ cms.ui.clear=
cms.ui.item_search.create.folder_missing=
cms.ui.images_links=
cms.contenttypes.ui.person.alias.delete.label=
cms.ui.contentcenter.mainpage.search=
cms.ui.contentcenter.mainpage.taskssections=
cms.ui.contentcenter.section=
cms.ui.contentcenter.action=
cms.ui.set_home_folder=
cms.ui.go_to_home_folder=
cms.ui.no_home_folder_selected=

View File

@ -583,3 +583,10 @@ cms.ui.clear=
cms.ui.item_search.create.folder_missing=
cms.ui.images_links=
cms.contenttypes.ui.person.alias.delete.label=
cms.ui.contentcenter.mainpage.search=
cms.ui.contentcenter.mainpage.taskssections=
cms.ui.contentcenter.section=
cms.ui.contentcenter.action=
cms.ui.set_home_folder=
cms.ui.go_to_home_folder=
cms.ui.no_home_folder_selected=

View File

@ -18,7 +18,6 @@
*/
package com.arsdigita.cms.ui;
import com.arsdigita.bebop.ActionLink;
import com.arsdigita.bebop.Form;
import com.arsdigita.bebop.FormProcessException;
@ -92,34 +91,27 @@ public class FlatItemList extends SegmentedPanel
private static final String CMS_PRIVILEGES = "com.arsdigita.cms.getPrivileges";
private static final String PRIVILEGE = "privilege";
private static final String PRIVILEGE_NAME = "prettyName";
// The folder selectors
private FolderSelectionModel m_folderSel;
private FolderRequestLocal m_folder;
private NewItemForm m_newItem;
private SingleSelectionModel m_typeSel;
private CreationSelector m_selector;
private FolderManipulator m_folderManip;
private FolderCreator m_folderCreator;
private ActionLink m_setHomeFolderAction;
private ActionLink m_createFolderAction;
private ActionLink m_togglePrivateAction;
private Label m_homeFolderLabel;
private Segment m_browseSeg;
private Segment m_newItemSeg;
private Segment m_newFolderSeg;
private Segment m_editFolderSeg;
private Segment m_permissionsSeg;
private CMSPermissionsPane m_permPane;
// Folder edit/rename functionality.
private ActionLink m_editFolderAction;
private FolderEditor m_folderEditor;
private Label m_contentLabel;
private ItemPath m_itemPath;
private Label m_chooseLabel;
@ -135,11 +127,12 @@ public class FlatItemList extends SegmentedPanel
m_folder = folder;
m_folderSel = model;
m_folderSel.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
PageState s = e.getPageState();
reset(s);
}
});
public void stateChanged(ChangeEvent e) {
PageState s = e.getPageState();
reset(s);
}
});
setIdAttr("flat-item-list");
@ -189,26 +182,34 @@ public class FlatItemList extends SegmentedPanel
m_editFolderAction.addActionListener(this);
browseActions.addAction(m_editFolderAction);
m_setHomeFolderAction = new ActionLink(new Label("Set as home folder"));
m_setHomeFolderAction = new ActionLink(new Label(globalize("cms.ui.set_home_folder")));
m_setHomeFolderAction.addActionListener(this);
browseActions.addAction(m_setHomeFolderAction);
m_homeFolderLabel = new Label(new PrintListener() {
public final void prepare(final PrintEvent e) {
Label label = (Label)e.getTarget();
User user = Web.getContext().getUser();
m_homeFolderLabel = new Label(new PrintListener() {
public final void prepare(final PrintEvent e) {
Label label = (Label) e.getTarget();
User user = Web.getContext().getUser();
Folder folder = Folder.getUserHomeFolder(user,CMS.getContext().getContentSection());
if ( folder != null ) {
String url = folder.getContentSection().getURL() + PageLocations.SECTION_PAGE + "?" + ContentSectionPage.SET_FOLDER + "=" + folder.getID();
label.setLabel("Go to home folder: <a href=\"" + url + "\">" + folder.getLabel() + "</a>");
} else {
label.setLabel("<font color=\"red\">No home folder selected</font>");
}
label.setOutputEscaping(false);
Folder folder = Folder.getUserHomeFolder(user, CMS.getContext().getContentSection());
if (folder != null) {
String url = folder.getContentSection().getURL() + PageLocations.SECTION_PAGE + "?"
+ ContentSectionPage.SET_FOLDER + "=" + folder.getID();
//label.setLabel("Go to home folder: <a href=\"" + url + "\">" + folder.getLabel() + "</a>");
label.setLabel(String.format("%s: <a href=\"%s\">%s</a>",
(String) globalize("cms.ui.go_to_home_folder").localize(),
url,
folder.getLabel()));
} else {
//label.setLabel("<font color=\"red\">No home folder selected</font>");
label.setLabel(String.format("<span style=\"color: red\">%s</span>",
(String)globalize("cms.ui.no_home_folder_selected").localize()));
}
});
browseActions.addAction(m_homeFolderLabel);
label.setOutputEscaping(false);
}
});
browseActions.addAction(m_homeFolderLabel);
m_newItem = new SectionNewItemForm("newItem");
m_newItem.addProcessListener(this);
@ -236,29 +237,30 @@ public class FlatItemList extends SegmentedPanel
}
query.close();
m_permPane = new CMSPermissionsPane
((PrivilegeDescriptor[]) privs.toArray
(new PrivilegeDescriptor[privs.size()]),
privNameMap,
m_folderSel);
m_permPane =
new CMSPermissionsPane((PrivilegeDescriptor[]) privs.toArray(new PrivilegeDescriptor[privs.size()]),
privNameMap,
m_folderSel);
permActions.setSubject(m_permPane);
// An action
m_togglePrivateAction = new ActionLink(new Label(new PrintListener() {
public void prepare(PrintEvent e) {
PageState state = e.getPageState();
Label target = (Label) e.getTarget();
Folder currentFolder = m_folder.getFolder(state);
// ACSObject parent = currentFolder.getParent();
DataObject context = PermissionService.getContext(currentFolder);
if (context == null) {
target.setLabel( (String) GlobalizationUtil.globalize("cms.ui.restore_default_permissions").localize());
} else {
target.setLabel( (String) GlobalizationUtil.globalize("cms.ui.use_custom_permissions").localize());
}
public void prepare(PrintEvent e) {
PageState state = e.getPageState();
Label target = (Label) e.getTarget();
Folder currentFolder = m_folder.getFolder(state);
// ACSObject parent = currentFolder.getParent();
DataObject context = PermissionService.getContext(currentFolder);
if (context == null) {
target.setLabel((String) GlobalizationUtil.globalize("cms.ui.restore_default_permissions").
localize());
} else {
target.setLabel((String) GlobalizationUtil.globalize("cms.ui.use_custom_permissions").localize());
}
}));
}
}));
m_togglePrivateAction.addActionListener(this);
permActions.addAction(m_togglePrivateAction);
@ -286,8 +288,8 @@ public class FlatItemList extends SegmentedPanel
m_folderEditor.addSubmissionListener(this);
m_folderEditor.addProcessListener(this);
Form folderEditorForm = new Form( "fedit_form" );
folderEditorForm.add( m_folderEditor );
Form folderEditorForm = new Form("fedit_form");
folderEditorForm.add(m_folderEditor);
m_editFolderSeg.add(folderEditorForm);
m_editFolderSeg.add(new Label("<br/>", false));
}
@ -304,14 +306,15 @@ public class FlatItemList extends SegmentedPanel
p.addComponentStateParam(this, m_typeSel.getStateParameter());
p.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
final PageState state = e.getPageState();
public void actionPerformed(ActionEvent e) {
final PageState state = e.getPageState();
if (state.isVisibleOnPage(FlatItemList.this)) {
showHideSegments(state);
}
if (state.isVisibleOnPage(FlatItemList.this)) {
showHideSegments(state);
}
});
}
});
}
/**
@ -328,9 +331,9 @@ public class FlatItemList extends SegmentedPanel
// MP: This should be checked on the current folder instead of just
// the content section.
boolean newItem =
sm.canAccess(state.getRequest(),
SecurityManager.NEW_ITEM,
folder);
sm.canAccess(state.getRequest(),
SecurityManager.NEW_ITEM,
folder);
if (!newItem) {
browseMode(state);
@ -346,9 +349,9 @@ public class FlatItemList extends SegmentedPanel
User user = (User) Kernel.getContext().getParty();
PermissionDescriptor perm =
new PermissionDescriptor(PrivilegeDescriptor.ADMIN,
folder,
user);
new PermissionDescriptor(PrivilegeDescriptor.ADMIN,
folder,
user);
if (PermissionService.checkPermission(perm)) {
m_permissionsSeg.setVisible(state, true);
@ -381,19 +384,19 @@ public class FlatItemList extends SegmentedPanel
}
public void submitted(FormSectionEvent e)
throws FormProcessException {
throws FormProcessException {
PageState s = e.getPageState();
if ( e.getSource() == m_folderCreator
&& m_folderCreator.isCancelled(s) ) {
if (e.getSource() == m_folderCreator
&& m_folderCreator.isCancelled(s)) {
browseMode(s);
throw new FormProcessException( (String) GlobalizationUtil.globalize("cms.ui.cancelled").localize());
throw new FormProcessException((String) GlobalizationUtil.globalize("cms.ui.cancelled").localize());
} else if (e.getSource() == m_folderEditor && m_folderEditor.isCancelled(s)) {
browseMode(s);
throw new FormProcessException( (String) GlobalizationUtil.globalize("cms.ui.cancelled").localize());
} else if ( e.getSource() == m_folderManip.getTargetSelector() ) {
throw new FormProcessException((String) GlobalizationUtil.globalize("cms.ui.cancelled").localize());
} else if (e.getSource() == m_folderManip.getTargetSelector()) {
// This only works if this submission listener is run
// after the target selector's one
if ( ! m_folderManip.getTargetSelector().isVisible(s) ) {
if (!m_folderManip.getTargetSelector().isVisible(s)) {
browseMode(s);
}
}
@ -421,8 +424,8 @@ public class FlatItemList extends SegmentedPanel
public void stateChanged(ChangeEvent e) {
PageState s = e.getPageState();
if ( e.getSource().equals(m_typeSel) ) {
if ( ! m_typeSel.isSelected(s) ) {
if (e.getSource().equals(m_typeSel)) {
if (!m_typeSel.isSelected(s)) {
browseMode(s);
}
}
@ -431,20 +434,19 @@ public class FlatItemList extends SegmentedPanel
public void actionPerformed(ActionEvent e) {
PageState s = e.getPageState();
Object source = e.getSource();
if ( source == m_createFolderAction ) {
if (source == m_createFolderAction) {
newFolderMode(s);
} else if (source == m_editFolderAction) {
m_permissionsSeg.setVisible(s, false);
m_editFolderSeg.setVisible(s, true);
}
else if (source == m_togglePrivateAction) {
} else if (source == m_togglePrivateAction) {
togglePermissions(s);
} else if ( source == m_setHomeFolderAction ) {
User user = Web.getContext().getUser();
Folder folder = m_folder.getFolder(s);
user = (User)DomainObjectFactory.newInstance(user.getOID());
Folder.setUserHomeFolder(user,folder);
}
} else if (source == m_setHomeFolderAction) {
User user = Web.getContext().getUser();
Folder folder = m_folder.getFolder(s);
user = (User) DomainObjectFactory.newInstance(user.getOID());
Folder.setUserHomeFolder(user, folder);
}
}
private void togglePermissions(PageState state) {
@ -470,8 +472,8 @@ public class FlatItemList extends SegmentedPanel
if (section != null) {
PermissionService.setContext(currentFolder, section);
} else {
throw new IllegalStateException("Cannot set the context for a folder with " +
"no parent and no Content Section");
throw new IllegalStateException("Cannot set the context for a folder with "
+ "no parent and no Content Section");
}
}
@ -485,8 +487,8 @@ public class FlatItemList extends SegmentedPanel
if (liveSection != null) {
PermissionService.setContext(liveVersion, liveSection);
} else {
throw new IllegalStateException("Cannot set the context for a folder with " +
"no parent and no Content Section");
throw new IllegalStateException("Cannot set the context for a folder with "
+ "no parent and no Content Section");
}
}
}
@ -505,7 +507,8 @@ public class FlatItemList extends SegmentedPanel
ObjectPermissionCollection livePerms = PermissionService.getGrantedPermissions(liveVersion.getOID());
while (livePerms.next()) {
if (!livePerms.isInherited()) {
PermissionDescriptor desc2 = new PermissionDescriptor(livePerms.getPrivilege(), liveVersion.getOID(),
PermissionDescriptor desc2 = new PermissionDescriptor(livePerms.getPrivilege(), liveVersion.
getOID(),
livePerms.getGranteeOID());
PermissionService.revokePermission(desc2);
}
@ -535,7 +538,7 @@ public class FlatItemList extends SegmentedPanel
public void setPermissionLinkVis(PageState state) {
if (!Utilities.getSecurityManager(state).
canAccess(state.getRequest(), SecurityManager.STAFF_ADMIN)) {
canAccess(state.getRequest(), SecurityManager.STAFF_ADMIN)) {
m_togglePrivateAction.setVisible(state, false);
}
}
@ -549,6 +552,7 @@ public class FlatItemList extends SegmentedPanel
public ContentSection getContentSection(PageState s) {
return CMS.getContext().getContentSection();
}
}
/**

View File

@ -85,7 +85,7 @@ public abstract class NewItemForm extends Form {
m_emptyLabel.setIdAttr("empty_label");
panel.add(m_emptyLabel);
m_createLabel = new Label(globalize("cms.ui.authoring.create_new"), false);
m_createLabel = new Label((String)globalize("cms.ui.authoring.create_new").localize(), false);
m_createLabel.setIdAttr("create_label");
panel.add(m_createLabel);

View File

@ -291,7 +291,11 @@ public class ContentSectionContainer extends CMSContainer {
// add columns to the table
TableColumnModel columnModel = getColumnModel();
TableColumn contentSectionColumn = new TableColumn(colNo, COLUMN_SECTION);
//TableColumn contentSectionColumn = new TableColumn(colNo, COLUMN_SECTION);
TableColumn contentSectionColumn = new TableColumn(
colNo,
(String)GlobalizationUtil.globalize("cms.ui.contentcenter.section").localize(),
COLUMN_SECTION);
contentSectionColumn.setCellRenderer(new AdminURLTableCellRenderer());
columnModel.add(contentSectionColumn);
@ -302,7 +306,10 @@ public class ContentSectionContainer extends CMSContainer {
columnModel.add(locationColumn);
}
TableColumn actionColumn = new TableColumn(colNo ++, COLUMN_ACTION);
TableColumn actionColumn = new TableColumn(
colNo++,
(String)GlobalizationUtil.globalize("cms.ui.contentcenter.action").localize(),
COLUMN_ACTION);
actionColumn.setCellRenderer(new ActionTableCellRenderer());
columnModel.add(actionColumn);

View File

@ -145,8 +145,14 @@ public class MainPage extends CMSApplicationPage implements ActionListener {
protected TabbedPane createTabbedPane() {
TabbedPane pane = new TabbedPane();
pane.setClassAttr(XSL_CLASS);
addToPane(pane, "Tasks/Sections", getTasksPane(m_typeSel, m_sectionSel));
addToPane(pane, "Search", getSearchPane());
//addToPane(pane, "Tasks/Sections", getTasksPane(m_typeSel, m_sectionSel));
//addToPane(pane, "Search", getSearchPane());
addToPane(pane,
(String)GlobalizationUtil.globalize("cms.ui.contentcenter.mainpage.taskssections").localize(),
getTasksPane(m_typeSel, m_sectionSel));
addToPane(pane,
(String)GlobalizationUtil.globalize("cms.ui.contentcenter.mainpage.search").localize(),
getSearchPane());
pane.addActionListener(this);
return pane;
}

View File

@ -18,7 +18,6 @@
*/
package com.arsdigita.cms.ui.contentcenter;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.HashMap;
@ -89,29 +88,24 @@ import com.arsdigita.xml.Element;
public class TasksPanel extends CMSContainer {
private static Logger s_log =
Logger.getLogger(TasksPanel.class);
Logger.getLogger(TasksPanel.class);
// The default number of rows to show
private static final int DEFAULT_MAX_ROWS = 15;
// Number of tasks to show
private final int m_maxRows;
private TaskList m_taskList;
private ActionLink m_viewAllLink;
private ActionLink m_viewShortLink;
private Paginator m_paginator;
private ActionLink m_viewLockLink,m_viewUnlockLink,m_viewAllLockLink;
private Label m_viewLockLabel,m_viewUnlockLabel,m_viewAllLockLabel;
private ActionLink m_viewLockLink, m_viewUnlockLink, m_viewAllLockLink;
private Label m_viewLockLabel, m_viewUnlockLabel, m_viewAllLockLabel;
private StringParameter m_sortDirectionParam;
private StringParameter m_sortTypeParam;
private StringParameter m_lockFilterParam;
// control link variable
private static final String TASK_ACTION = "taskAction";
private static final String SORT_DOWN = "sortActionUp";
private static final String SORT_UP = "sortActionDown";
private static final String LOCK_FILTER_TYPE = "lockFilterType";
private static final String SORT_TYPE = "sortType";
private static final String SORT_DIRECTION = "sortDirection";
@ -121,13 +115,11 @@ public class TasksPanel extends CMSContainer {
private static final String SORT_TITLE = "title";
private static final String SORT_USER = "user";
private static final String SORT_WORKFLOW = "workflow";
// IMAGES
public static final String UP_ARROW_IMAGE =
"/themes/heirfloom/images/gray-triangle-up.gif";
public static final String DOWN_ARROW_IMAGE =
"/themes/heirfloom/images/gray-triangle-down.gif";
// CREATION PANE CONSTANTS
private Label m_selectorLabel;
private CreationSelector m_selector;
@ -143,7 +135,7 @@ public class TasksPanel extends CMSContainer {
**/
public TasksPanel(ACSObjectSelectionModel typeModel,
ACSObjectSelectionModel sectionModel) {
this(DEFAULT_MAX_ROWS,typeModel,sectionModel);
this(DEFAULT_MAX_ROWS, typeModel, sectionModel);
}
/**
@ -154,7 +146,7 @@ public class TasksPanel extends CMSContainer {
*
* @pre maxRows != null
**/
public TasksPanel(int maxRows,ACSObjectSelectionModel typeModel,
public TasksPanel(int maxRows, ACSObjectSelectionModel typeModel,
ACSObjectSelectionModel sectionModel) {
super();
m_maxRows = maxRows;
@ -168,7 +160,6 @@ public class TasksPanel extends CMSContainer {
addComponents();
}
/**
* Adds the components to this tasks panel
**/
@ -178,26 +169,27 @@ public class TasksPanel extends CMSContainer {
// A label that says "Create $content_type in $section"
m_selectorLabel = new Label(new PrintListener() {
public void prepare(PrintEvent e) {
PageState s = e.getPageState();
Label t = (Label)e.getTarget();
public void prepare(PrintEvent e) {
PageState s = e.getPageState();
Label t = (Label) e.getTarget();
ContentType type = (ContentType) m_typeSel.getSelectedObject(s);
ContentSection sec =
(ContentSection) m_sectionSel.getSelectedObject(s);
ContentType type = (ContentType) m_typeSel.getSelectedObject(s);
ContentSection sec =
(ContentSection) m_sectionSel.getSelectedObject(s);
StringBuffer buf = new StringBuffer(
GlobalizationUtil
.globalize("cms.ui.create").localize() + " ");
buf.append(type.getLabel());
buf.append(" in ");
buf.append(sec.getName());
StringBuffer buf = new StringBuffer(
GlobalizationUtil
.globalize("cms.ui.create").localize() + " ");
buf.append(type.getLabel());
buf.append(" in ");
buf.append(sec.getName());
t.setLabel(buf.toString());
t.setFontWeight(Label.BOLD);
t.setClassAttr("creationLabel");
}
});
t.setLabel(buf.toString());
t.setFontWeight(Label.BOLD);
t.setClassAttr("creationLabel");
}
});
m_selectorLabel.setClassAttr("creationLabel");
m_creationPane.add(m_selectorLabel);
@ -215,66 +207,67 @@ public class TasksPanel extends CMSContainer {
// When a new type is selected, show the creation UI.
// When the selection is cleared, return to section list
m_typeSel.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
PageState s = e.getPageState();
boolean isSelected = m_typeSel.isSelected(s);
public void stateChanged(ChangeEvent e) {
PageState s = e.getPageState();
boolean isSelected = m_typeSel.isSelected(s);
m_sections.setVisible(s, !isSelected);
m_creationPane.setVisible(s, isSelected);
}
});
m_sections.setVisible(s, !isSelected);
m_creationPane.setVisible(s, isSelected);
}
m_viewLockLink = new ActionLink(new
Label(GlobalizationUtil
.globalize("cms.ui.workflow.task.view_locked")));
});
m_viewLockLink = new ActionLink(new Label(GlobalizationUtil
.globalize("cms.ui.workflow.task.view_locked")));
m_viewLockLink.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
PageState ps = e.getPageState();
ps.setValue(m_lockFilterParam, "lock");
}
});
public void actionPerformed(ActionEvent e) {
PageState ps = e.getPageState();
ps.setValue(m_lockFilterParam, "lock");
}
m_viewUnlockLink = new ActionLink(new
Label(GlobalizationUtil
.globalize("cms.ui.workflow.task.view_unlocked")));
});
m_viewUnlockLink = new ActionLink(new Label(GlobalizationUtil
.globalize("cms.ui.workflow.task.view_unlocked")));
m_viewUnlockLink.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
PageState ps = e.getPageState();
ps.setValue(m_lockFilterParam, "unlock");
}
});
public void actionPerformed(ActionEvent e) {
PageState ps = e.getPageState();
ps.setValue(m_lockFilterParam, "unlock");
}
m_viewAllLockLink = new ActionLink(new
Label(GlobalizationUtil
.globalize("cms.ui.workflow.task.view_all")));
});
m_viewAllLockLink = new ActionLink(new Label(GlobalizationUtil
.globalize("cms.ui.workflow.task.view_all")));
m_viewAllLockLink.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
PageState ps = e.getPageState();
ps.setValue(m_lockFilterParam, "all");
}
});
public void actionPerformed(ActionEvent e) {
PageState ps = e.getPageState();
ps.setValue(m_lockFilterParam, "all");
}
});
m_viewLockLabel = new Label(GlobalizationUtil
.globalize("cms.ui.workflow.task.view_locked"));
.globalize("cms.ui.workflow.task.view_locked"));
m_viewLockLabel.setFontWeight(Label.BOLD);
m_viewUnlockLabel = new Label(GlobalizationUtil
.globalize("cms.ui.workflow.task.view_unlocked"));
.globalize("cms.ui.workflow.task.view_unlocked"));
m_viewUnlockLabel.setFontWeight(Label.BOLD);
m_viewAllLockLabel = new Label(GlobalizationUtil
.globalize("cms.ui.workflow.task.view_all"));
.globalize("cms.ui.workflow.task.view_all"));
m_viewAllLockLabel.setFontWeight(Label.BOLD);
add(new Label("<br />",false));
add(new Label("<br />", false));
add(m_viewLockLink);
add(m_viewLockLabel);
add(new Label("&nbsp;",false));
add(new Label("&nbsp;", false));
add(m_viewUnlockLink);
add(m_viewUnlockLabel);
add(new Label("&nbsp;",false));
add(new Label("&nbsp;", false));
add(m_viewAllLockLink);
add(m_viewAllLockLabel);
add(new Label("<br />",false));
add(new Label("<br />",false));
add(new Label("<br />", false));
add(new Label("<br />", false));
add(getTasksList());
add(getPaginator());
@ -303,35 +296,36 @@ public class TasksPanel extends CMSContainer {
p.setVisibleDefault(m_viewAllLockLink, false);
p.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
final PageState state = e.getPageState();
public void actionPerformed(ActionEvent e) {
final PageState state = e.getPageState();
String lockFilterType = getLockFilterType(state);
String lockFilterType = getLockFilterType(state);
if ( lockFilterType.equals("lock") ) {
m_viewLockLabel.setVisible(state,true);
m_viewLockLink.setVisible(state,false);
m_viewUnlockLabel.setVisible(state,false);
m_viewUnlockLink.setVisible(state,true);
m_viewAllLockLabel.setVisible(state,false);
m_viewAllLockLink.setVisible(state,true);
} else if ( lockFilterType.equals("unlock") ) {
m_viewLockLabel.setVisible(state,false);
m_viewLockLink.setVisible(state,true);
m_viewUnlockLabel.setVisible(state,true);
m_viewUnlockLink.setVisible(state,false);
m_viewAllLockLabel.setVisible(state,false);
m_viewAllLockLink.setVisible(state,true);
} else {
m_viewLockLabel.setVisible(state,false);
m_viewLockLink.setVisible(state,true);
m_viewUnlockLabel.setVisible(state,false);
m_viewUnlockLink.setVisible(state,true);
m_viewAllLockLabel.setVisible(state,true);
m_viewAllLockLink.setVisible(state,false);
}
if (lockFilterType.equals("lock")) {
m_viewLockLabel.setVisible(state, true);
m_viewLockLink.setVisible(state, false);
m_viewUnlockLabel.setVisible(state, false);
m_viewUnlockLink.setVisible(state, true);
m_viewAllLockLabel.setVisible(state, false);
m_viewAllLockLink.setVisible(state, true);
} else if (lockFilterType.equals("unlock")) {
m_viewLockLabel.setVisible(state, false);
m_viewLockLink.setVisible(state, true);
m_viewUnlockLabel.setVisible(state, true);
m_viewUnlockLink.setVisible(state, false);
m_viewAllLockLabel.setVisible(state, false);
m_viewAllLockLink.setVisible(state, true);
} else {
m_viewLockLabel.setVisible(state, false);
m_viewLockLink.setVisible(state, true);
m_viewUnlockLabel.setVisible(state, false);
m_viewUnlockLink.setVisible(state, true);
m_viewAllLockLabel.setVisible(state, true);
m_viewAllLockLink.setVisible(state, false);
}
});
}
});
}
public void reset(PageState state) {
@ -347,7 +341,6 @@ public class TasksPanel extends CMSContainer {
return m_paginator;
}
/**
* Returns the bebop List component to display the tasks
**/
@ -366,24 +359,24 @@ public class TasksPanel extends CMSContainer {
}
protected String getSortType(PageState state) {
String sortType = (String)state.getValue(m_sortTypeParam);
if ( sortType == null ) {
String sortType = (String) state.getValue(m_sortTypeParam);
if (sortType == null) {
sortType = SORT_DATE;
}
return sortType;
}
protected String getSortDirection(PageState state) {
String sortDirection = (String)state.getValue(m_sortDirectionParam);
if ( sortDirection == null ) {
String sortDirection = (String) state.getValue(m_sortDirectionParam);
if (sortDirection == null) {
sortDirection = SORT_UP;
}
return sortDirection;
}
protected String getLockFilterType(PageState state) {
String lockFilterType = (String)state.getValue(m_lockFilterParam);
if ( lockFilterType == null || lockFilterType.equals("") ) {
String lockFilterType = (String) state.getValue(m_lockFilterParam);
if (lockFilterType == null || lockFilterType.equals("")) {
lockFilterType = "lock";
}
return lockFilterType;
@ -392,47 +385,48 @@ public class TasksPanel extends CMSContainer {
/*
* Adds filters to the task query
*/
protected void addQueryFilters(DataQuery query,Party party,PageState state){
protected void addQueryFilters(DataQuery query, Party party, PageState state) {
query.setParameter("userId", party.getID());
FilterFactory ff = query.getFilterFactory();
FilterFactory ff = query.getFilterFactory();
// TODO: remove this hard coding of "Author", "Edit", and "Deploy"
// TODO: remove this hard coding of "Author", "Edit", and "Deploy"
CompoundFilter authorFilter = ff.and();
//cg query changed to refer to task type id
authorFilter.addFilter(ff.equals("taskType",CMSTaskType.AUTHOR));
authorFilter.addFilter(getTaskFilter(CMSTaskType.retrieve(CMSTaskType.AUTHOR),
party, ff));
CompoundFilter approveFilter = ff.and();
approveFilter.addFilter(ff.equals("taskType",CMSTaskType.EDIT));
approveFilter.addFilter(getTaskFilter(CMSTaskType.retrieve(CMSTaskType.EDIT),
// TODO: remove this hard coding of "Author", "Edit", and "Deploy"
CompoundFilter authorFilter = ff.and();
//cg query changed to refer to task type id
authorFilter.addFilter(ff.equals("taskType", CMSTaskType.AUTHOR));
authorFilter.addFilter(getTaskFilter(CMSTaskType.retrieve(CMSTaskType.AUTHOR),
party, ff));
CompoundFilter deployFilter = ff.and();
deployFilter.addFilter(ff.equals("taskType",CMSTaskType.DEPLOY));
deployFilter.addFilter(getTaskFilter(CMSTaskType.retrieve(CMSTaskType.DEPLOY),
party, ff));
CompoundFilter approveFilter = ff.and();
approveFilter.addFilter(ff.equals("taskType", CMSTaskType.EDIT));
approveFilter.addFilter(getTaskFilter(CMSTaskType.retrieve(CMSTaskType.EDIT),
party, ff));
CompoundFilter permissionFilter = ff.or();
permissionFilter.addFilter(authorFilter);
permissionFilter.addFilter(approveFilter);
permissionFilter.addFilter(deployFilter);
CompoundFilter deployFilter = ff.and();
deployFilter.addFilter(ff.equals("taskType", CMSTaskType.DEPLOY));
deployFilter.addFilter(getTaskFilter(CMSTaskType.retrieve(CMSTaskType.DEPLOY),
party, ff));
query.addFilter(permissionFilter);
CompoundFilter permissionFilter = ff.or();
permissionFilter.addFilter(authorFilter);
permissionFilter.addFilter(approveFilter);
permissionFilter.addFilter(deployFilter);
String lockFilterType = getLockFilterType(state);
if ( lockFilterType.equals("lock") ) {
query.addEqualsFilter("isLocked","t");
query.addEqualsFilter("status","1");
} else if ( lockFilterType.equals("unlock") ) {
query.addEqualsFilter("isLocked","f");
} // else show all
query.addFilter(permissionFilter);
String lockFilterType = getLockFilterType(state);
if (lockFilterType.equals("lock")) {
query.addEqualsFilter("isLocked", "t");
query.addEqualsFilter("status", "1");
} else if (lockFilterType.equals("unlock")) {
query.addEqualsFilter("isLocked", "f");
} // else show all
}
private static class RootFolderSelectionModel
extends FolderSelectionModel {
extends FolderSelectionModel {
ACSObjectSelectionModel m_sectionSel;
public RootFolderSelectionModel(ACSObjectSelectionModel sectionSel) {
@ -445,18 +439,20 @@ public class TasksPanel extends CMSContainer {
ContentSection sec = (ContentSection) m_sectionSel.getSelectedObject(s);
Assert.exists(sec);
User user = Web.getContext().getUser();
if ( user != null ) {
Folder folder = Folder.getUserHomeFolder(user,sec);
if ( folder != null ) {
User user = Web.getContext().getUser();
if (user != null) {
Folder folder = Folder.getUserHomeFolder(user, sec);
if (folder != null) {
return folder.getID();
}
}
return sec.getRootFolder().getID();
}
}
private class TasksPaginationModelBuilder implements PaginationModelBuilder {
public int getTotalSize(Paginator paginator,
PageState state) {
return numberTasksForUser(state);
@ -465,13 +461,13 @@ public class TasksPanel extends CMSContainer {
public boolean isVisible(PageState state) {
return numberTasksForUser(state) > m_maxRows;
}
}
private class TaskList extends SimpleComponent {
private final static String QUERY_NAME =
"com.arsdigita.cms.workflow.getEnabledUserTasks";
"com.arsdigita.cms.workflow.getEnabledUserTasks";
private boolean m_paginate = false;
public TaskList(boolean paginate) {
@ -479,11 +475,11 @@ public class TasksPanel extends CMSContainer {
}
private DataQuery makeQuery(PageState state) {
User user = (User)Kernel.getContext().getParty();
User user = (User) Kernel.getContext().getParty();
DataQuery query = SessionManager.getSession()
.retrieveQuery(QUERY_NAME);
addQueryFilters(query,user,state);
.retrieveQuery(QUERY_NAME);
addQueryFilters(query, user, state);
return query;
}
@ -498,6 +494,7 @@ public class TasksPanel extends CMSContainer {
DataQuery query = makeQuery(state);
return new Long(query.size());
}
};
@Override
@ -509,7 +506,7 @@ public class TasksPanel extends CMSContainer {
DataQuery query = makeQuery(state);
String lockFilterType = getLockFilterType(state);
content.addAttribute("lockFilterType",lockFilterType);
content.addAttribute("lockFilterType", lockFilterType);
if (m_paginate) {
query.setRange(new Integer(m_paginator.getFirst(state)),
@ -523,43 +520,34 @@ public class TasksPanel extends CMSContainer {
sortPostfix = " desc";
}
if ( sortKey.equals(SORT_TITLE) ) {
query.setOrder("lower(pageTitle) " + sortPostfix +
", lower(status) asc, dueDate desc");
} else if ( sortKey.equals(SORT_DATE) ) {
query.setOrder("dueDate " + sortPostfix +
", lower(status) asc, lower(pageTitle) asc");
} else if ( sortKey.equals(SORT_USER) ) {
query.setOrder("lockingUserID " + sortPostfix +
", lower(status) asc, dueDate desc " +
", lower(pageTitle) asc");
} else if ( sortKey.equals(SORT_STATUS) ) {
query.setOrder("lower(status) " + sortPostfix +
", dueDate desc " +
", lower(pageTitle) asc");
if (sortKey.equals(SORT_TITLE)) {
query.setOrder("lower(pageTitle) " + sortPostfix + ", lower(status) asc, dueDate desc");
} else if (sortKey.equals(SORT_DATE)) {
query.setOrder("dueDate " + sortPostfix + ", lower(status) asc, lower(pageTitle) asc");
} else if (sortKey.equals(SORT_USER)) {
query.setOrder("lockingUserID " + sortPostfix + ", lower(status) asc, dueDate desc "
+ ", lower(pageTitle) asc");
} else if (sortKey.equals(SORT_STATUS)) {
query.setOrder("lower(status) " + sortPostfix + ", dueDate desc " + ", lower(pageTitle) asc");
} else if ( sortKey.equals(SORT_ACTION) ) {
query.setOrder("taskType " + sortPostfix +
", lower(status) asc, dueDate desc " +
", lower(pageTitle) asc"
);
} else if ( sortKey.equals(SORT_WORKFLOW) ) {
query.setOrder("processLabel " + sortPostfix +
", lower(status) asc, dueDate desc " +
", lower(pageTitle) asc"
);
} else if (sortKey.equals(SORT_ACTION)) {
query.setOrder("taskType " + sortPostfix + ", lower(status) asc, dueDate desc "
+ ", lower(pageTitle) asc");
} else if (sortKey.equals(SORT_WORKFLOW)) {
query.setOrder("processLabel " + sortPostfix + ", lower(status) asc, dueDate desc "
+ ", lower(pageTitle) asc");
}
HashMap sections = new HashMap();
while (query.next()) {
BigDecimal sectionID = (BigDecimal)query.get("sectionID");
String sectionPath = (String)sections.get(sectionID);
BigDecimal sectionID = (BigDecimal) query.get("sectionID");
String sectionPath = (String) sections.get(sectionID);
if (sectionPath == null) {
try {
ContentSection section = (ContentSection)DomainObjectFactory
.newInstance(new OID(ContentSection.BASE_DATA_OBJECT_TYPE,
sectionID));
ContentSection section = (ContentSection) DomainObjectFactory
.newInstance(new OID(ContentSection.BASE_DATA_OBJECT_TYPE,
sectionID));
sectionPath = section.getPath();
} catch (DataObjectNotFoundException ex) {
throw new UncheckedWrapperException("cannot find content section", ex);
@ -570,19 +558,19 @@ public class TasksPanel extends CMSContainer {
Element task = content.newChildElement("cms:tasksPanelTask",
CMS.CMS_XML_NS);
BigDecimal itemID = (BigDecimal)query.get("itemID");
String taskType = (String)query.get("taskType");
BigDecimal itemID = (BigDecimal) query.get("itemID");
String taskType = (String) query.get("taskType");
task.addAttribute("taskID", query.get("taskID").toString());
task.addAttribute("processID", query.get("processID").toString());
task.addAttribute("taskLabel", (String)query.get("taskLabel"));
task.addAttribute("taskDescription", (String)query.get("taskDescription"));
task.addAttribute("processLabel", (String)query.get("processLabel"));
task.addAttribute("taskLabel", (String) query.get("taskLabel"));
task.addAttribute("taskDescription", (String) query.get("taskDescription"));
task.addAttribute("processLabel", (String) query.get("processLabel"));
String isLocked = (String)query.get("isLocked");
String isLocked = (String) query.get("isLocked");
task.addAttribute("isLocked", isLocked);
if (query.get("dueDate") != null) {
java.util.Date d = (java.util.Date)query.get("dueDate");
java.util.Date d = (java.util.Date) query.get("dueDate");
SimpleDateFormat df = new SimpleDateFormat("EEE, MMM d, yyyy");
task.addAttribute("dueDate", df.format(d));
@ -591,21 +579,21 @@ public class TasksPanel extends CMSContainer {
task.addAttribute("itemID", itemID.toString());
task.addAttribute("sectionID", query.get("sectionID").toString());
task.addAttribute("sectionPath", sectionPath);
task.addAttribute("pageName", (String)query.get("pageName"));
task.addAttribute("pageTitle", (String)query.get("pageTitle"));
task.addAttribute("pageName", (String) query.get("pageName"));
task.addAttribute("pageTitle", (String) query.get("pageTitle"));
BigDecimal lockingUserID = (BigDecimal)query.get("lockingUserID");
BigDecimal lockingUserID = (BigDecimal) query.get("lockingUserID");
if (lockingUserID != null) {
task.addAttribute("lockingUserID", lockingUserID.toString());
if ( !"f".equals(isLocked) ) {
if (!"f".equals(isLocked)) {
User lockingUser = User.retrieve(lockingUserID);
if ( lockingUser != null ) {
task.addAttribute("assignee",lockingUser.getDisplayName());
if (lockingUser != null) {
task.addAttribute("assignee", lockingUser.getDisplayName());
}
}
}
task.addAttribute("taskType", taskType);
task.addAttribute("taskTypeClass", (String)query.get("taskTypeClass"));
task.addAttribute("taskTypeClass", (String) query.get("taskTypeClass"));
task.addAttribute("status", query.get("status").toString());
// control event for locking a task
@ -628,14 +616,13 @@ public class TasksPanel extends CMSContainer {
// m_actionLabel.generateXML(state, content);
String[][] sortableHeaders =
{{SORT_TITLE, "cms.ui.workflow.task.item_title"},
{SORT_ACTION, "cms.ui.action"},
{SORT_DATE, "cms.ui.tasks_due_date"},
{SORT_STATUS, "cms.ui.tasks_status_no_colon"},
{SORT_USER, "cms.ui.workflow.task.locking_user"},
{SORT_WORKFLOW, "cms.ui.workflow"}};
for (int i=0;i<sortableHeaders.length;i++) {
String[][] sortableHeaders = {{SORT_TITLE, "cms.ui.workflow.task.item_title"},
{SORT_ACTION, "cms.ui.action"},
{SORT_DATE, "cms.ui.tasks_due_date"},
{SORT_STATUS, "cms.ui.tasks_status_no_colon"},
{SORT_USER, "cms.ui.workflow.task.locking_user"},
{SORT_WORKFLOW, "cms.ui.workflow"}};
for (int i = 0; i < sortableHeaders.length; i++) {
String header = sortableHeaders[i][0];
String labelKey = sortableHeaders[i][1];
if (sortDirection.equals(SORT_UP) && header.equals(sortKey)) {
@ -644,7 +631,7 @@ public class TasksPanel extends CMSContainer {
state.setControlEvent(this, SORT_UP, header);
}
SimpleContainer container = new SimpleContainer();
container.add(new Label(GlobalizationUtil.globalize(labelKey)));
container.add(new Label((String)GlobalizationUtil.globalize(labelKey).localize()));
if (header.equals(sortKey)) {
String imageURLStub = null;
if (SORT_UP.equals(sortDirection)) {
@ -664,7 +651,6 @@ public class TasksPanel extends CMSContainer {
}
}
@Override
public void respond(PageState state) throws ServletException {
String key = state.getControlEventName();
@ -678,7 +664,7 @@ public class TasksPanel extends CMSContainer {
int tabNumber = ContentItemPage.AUTHORING_TAB;
String sectionPath = item.getContentSection().getPath();
if ( wf != null ) {
if (wf != null) {
User user = Web.getContext().getUser();
Engine engine = Engine.getInstance(CMSEngine.CMS_ENGINE_TYPE);
Iterator i = engine.getEnabledTasks(user, wf.getID()).iterator();
@ -686,11 +672,11 @@ public class TasksPanel extends CMSContainer {
CMSTask task = (CMSTask) i.next();
Integer taskType = task.getTaskType().getID();
if (taskType.equals(CMSTaskType.DEPLOY) ) {
if (taskType.equals(CMSTaskType.DEPLOY)) {
tabNumber = ContentItemPage.PUBLISHING_TAB;
} else {
// see if item is locked; if not, lock
if ( !task.isLocked() ) {
if (!task.isLocked()) {
task.lock(user);
}
}
@ -700,11 +686,11 @@ public class TasksPanel extends CMSContainer {
String redirectURL = Web.getConfig().getDispatcherServletPath()
+ sectionPath + "/admin/item.jsp?item_id="
+ itemID + "&set_tab=" + tabNumber;
throw new RedirectSignal(redirectURL,true);
throw new RedirectSignal(redirectURL, true);
} catch (DataObjectNotFoundException ex) {
throw new ServletException("Unknown content ID" + itemID);
}
} else if ( SORT_UP.equals(key) || SORT_DOWN.equals(key)) {
} else if (SORT_UP.equals(key) || SORT_DOWN.equals(key)) {
state.setValue(m_sortTypeParam, value);
if (SORT_DOWN.equals(key)) {
state.setValue(m_sortDirectionParam, SORT_DOWN);
@ -715,17 +701,17 @@ public class TasksPanel extends CMSContainer {
throw new ServletException("Unknown control event: " + key);
}
}
}
private static Filter getTaskFilter(CMSTaskType taskType
, Party party, FilterFactory factory) {
private static Filter getTaskFilter(CMSTaskType taskType, Party party, FilterFactory factory) {
PrivilegeDescriptor privilege;
String queryName;
String queryType;
OID partyOID = party.getOID();
privilege = taskType.getPrivilege();
return PermissionService.getFilterQuery(factory,"itemID",privilege,partyOID);
return PermissionService.getFilterQuery(factory, "itemID", privilege, partyOID);
}
}
}

View File

@ -32,8 +32,10 @@ import com.arsdigita.globalization.GlobalizedMessage;
public class GlobalizationUtil {
/** */
// public static String s_bundleName =
// "com.arsdigita.cms.util.CMSResourceBundle";
public static String s_bundleName =
"com.arsdigita.cms.util.CMSResourceBundle";
"com.arsdigita.cms.CMSResources";
public static GlobalizedMessage globalize(String key) {
return new GlobalizedMessage(key, getBundleName());

View File

@ -44,8 +44,7 @@ import org.apache.log4j.Logger;
*/
public class GlobalizedMessage {
private static final Logger s_cat =
Logger.getLogger(GlobalizedMessage.class.getName());
private static final Logger LOGGER = Logger.getLogger(GlobalizedMessage.class.getName());
private String m_key = "";
private String m_bundleName = "";
private Object[] m_args = null;
@ -60,7 +59,7 @@ public class GlobalizedMessage {
*
* @param key The key to use to look up a message in the ResourceBundle.
*/
public GlobalizedMessage(String key) {
public GlobalizedMessage(final String key) {
setKey(key);
setBundleName();
}
@ -74,7 +73,7 @@ public class GlobalizedMessage {
* @param key The key to use to look up a message in the ResourceBundle.
* @param bundleName The base name of the target ResourceBundle.
*/
public GlobalizedMessage(String key, String bundleName) {
public GlobalizedMessage(final String key, final String bundleName) {
setKey(key);
setBundleName(bundleName);
}
@ -92,7 +91,7 @@ public class GlobalizedMessage {
* @param args An Object[] of arguments to interpolate into the retrieved
* message.
*/
public GlobalizedMessage(String key, Object[] args) {
public GlobalizedMessage(final String key, final Object[] args) {
this(key);
setArgs(args);
}
@ -109,7 +108,7 @@ public class GlobalizedMessage {
* @param args An Object[] of arguments to interpolate into the retrieved
* message.
*/
public GlobalizedMessage(String key, String bundleName, Object[] args) {
public GlobalizedMessage(final String key, final String bundleName, final Object[] args) {
this(key, bundleName);
setArgs(args);
}
@ -129,7 +128,7 @@ public class GlobalizedMessage {
*
* @param key
*/
private void setKey(String key) {
private void setKey(final String key) {
if (key == null || key.length() == 0) {
throw new IllegalArgumentException("key cannot be empty.");
}
@ -146,7 +145,7 @@ public class GlobalizedMessage {
setBundleName("com.arsdigita.dummy.DummyResources");
}
private void setBundleName(String bundleName) {
private void setBundleName(final String bundleName) {
if (bundleName == null || bundleName.length() == 0) {
throw new IllegalArgumentException("bundleName cannot be empty.");
}
@ -154,7 +153,7 @@ public class GlobalizedMessage {
m_bundleName = bundleName;
}
private void setArgs(Object[] args) {
private void setArgs(final Object[] args) {
m_args = args;
}
@ -192,7 +191,7 @@ public class GlobalizedMessage {
* java.text.MessageFormat class.
* </p>
*
* @param req The current running request.
* @param request The current running request.
*
* @return Object Represents the localized version of this
* message. The reason this method returns an Object and
@ -201,7 +200,7 @@ public class GlobalizedMessage {
* bites. Maybe this class should have been called
* GlobalizedObject?
*/
public Object localize(HttpServletRequest request) {
public Object localize(final HttpServletRequest request) {
return localize(com.arsdigita.globalization.GlobalizationHelper.getNegotiatedLocale());
}
@ -226,34 +225,54 @@ public class GlobalizedMessage {
* bites. Maybe this class should have been called
* GlobalizedObject?
*/
public Object localize(Locale locale) {
public Object localize(final Locale locale) {
Object message = getKey();
ResourceBundle rb = null;
ResourceBundle resourceBundle = null;
if (locale == null) {
throw new IllegalArgumentException("locale cannot be null.");
}
try {
rb = ResourceBundle.getBundle(getBundleName(), locale);
// jensp 2013-03-16:
// Previously, ResourceBundle#getBundle(String, Locale) was called here. That was causing problems under
// specific circumstances:
// - The browser of the user is set the english (britain), languge code en_GB
// - The system language of the server running CCM is set to german (de_DE).
// In this case, the ResourceBundle.getBundle method first tries to find a ResourceBundle for en_GB, than
// for en. Usally, both attempts will fail because the english labels are in the default bundle
// (no language code). The standard search algorithm of ResourceBundle#getBundle than falls back to the
// system language (the language of the SERVER), which is German is this case. Therefore the content center
// was shown with german texts...
// Luckily, there is a simple solution: The search algorithm is implemented in the inner class
// ResourceBundle.Control. There are also variants of the getBundle method which allow it to pass an
// custom implementation of ResouceBundle.Control. Also ResourceBundle.Control has a factory method which
// offers an implementation of ResourceBundle.Control which does not use the system language.
// Therefore, all what was to do was to change the call of getBundle here from
// ResourceBundle#getBundle(String, Locale) to ResourceBundle#getBundle(String, Locale, ResourceControl)
// with ResourceBundle.Control.getNoFallbackControl(List<String>).
resourceBundle = ResourceBundle.getBundle(
getBundleName(),
locale,
ResourceBundle.Control.getNoFallbackControl(ResourceBundle.Control.FORMAT_PROPERTIES));
} catch (MissingResourceException e) {
if (s_cat.isDebugEnabled()) {
s_cat.debug(
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(
"ResourceBundle " + getBundleName() + " was not found.");
}
}
try {
if (rb != null) {
message = rb.getObject(getKey());
} else {
if (s_cat.isDebugEnabled()) {
s_cat.debug("No ResourceBundle available");
if (resourceBundle == null) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("No ResourceBundle available");
}
} else {
message = resourceBundle.getObject(getKey());
}
} catch (MissingResourceException e2) {
if (s_cat.isDebugEnabled()) {
s_cat.debug(getKey() + " was not found in the ResourceBundle.");
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(getKey() + " was not found in the ResourceBundle.");
}
}
@ -282,7 +301,9 @@ public class GlobalizedMessage {
*
* @return The contents in String form for debugging.
*/
@Override
public String toString() {
return getBundleName() + "#" + getKey();
}
}