Hinweistext für die Suche eingefügt

git-svn-id: https://svn.libreccm.org/ccm/trunk@2435 8810af33-2d31-482b-a856-94f89814c4df
master
quasi 2013-11-14 10:07:04 +00:00
parent d3805612d3
commit 35647b1d2b
4 changed files with 306 additions and 310 deletions

View File

@ -83,7 +83,7 @@ public class ImageStepEdit extends SimpleContainer
m_attachListener = new ImageComponentAttachListener(m_imageComponent,
m_imageStep);
/* Include CMS ImageLibrary to display existing images too select from*/
/* Include CMS ImageLibrary to display existing images too select from */
ImageLibraryComponent library = new ImageLibraryComponent();
library.getForm().addInitListener(m_attachListener);
library.getForm().addProcessListener(m_attachListener);
@ -95,7 +95,7 @@ public class ImageStepEdit extends SimpleContainer
selectors.put(ImageComponent.LIBRARY, library);
add(library);
/* Include CMS Image Upload component to enable uploading new img */
/* Include CMS Image Upload component to enable uploading new img */
ImageUploadComponent upload = new ImageUploadComponent();
upload.getForm().addInitListener(m_attachListener);
upload.getForm().addProcessListener(m_attachListener);

View File

@ -64,72 +64,56 @@ import org.apache.log4j.Logger;
*/
public class ContentSectionPage extends CMSPage implements ActionListener {
private static final Logger s_log = Logger.getLogger
(ContentSectionPage.class);
private static final Logger s_log = Logger.getLogger(ContentSectionPage.class);
public static final String RESOURCE_BUNDLE =
"com.arsdigita.cms.CMSResources";
"com.arsdigita.cms.CMSResources";
/**
* The URL parameter that can be passed in in order to set the
* current folder. This is used in getting back to the correct
* level of folder expansion from content item page.
* The URL parameter that can be passed in in order to set the current
* folder. This is used in getting back to the correct level of folder
* expansion from content item page.
*/
public static final String SET_FOLDER = "set_folder";
/**
* The URL parameter that can be passed in in order to set the
* current template (for setting the content type)
* The URL parameter that can be passed in in order to set the current
* template (for setting the content type)
*/
public static final String SET_TEMPLATE = "set_template";
/**
* The URL parameter that can be passed in in order to set the
* current tab. This is a KLUDGE right now because the
* TabbedDialog's current tab is selected with a local state
* parameter.
* The URL parameter that can be passed in in order to set the current tab.
* This is a KLUDGE right now because the TabbedDialog's current tab is
* selected with a local state parameter.
*/
public static final String SET_TAB = "set_tab";
/**
* Index of the search tab
*/
public static final int SEARCH_TAB = 0;
/**
* Index of the browse tab
*/
public static final int BROWSE_TAB = 1;
/**
* Index of the roles tab
*/
public static final int ROLES_TAB = 2;
/**
* Index of the workflows tab
*/
public static final int WORKFLOW_TAB = 3;
/**
* Index of the lifecycles tab
*/
public static final int LIFECYCLES_TAB = 4;
/**
* Index of the categories tab
*/
public static final int CATEGORIES_TAB = 5;
/**
* Index of the content types tab
*/
public static final int CONTENTTYPES_TAB = 6;
public static final int USER_ADMIN_TAB = 7;
private TabbedPane m_tabbedPane;
private FolderAdminPane m_folderPane;
private BrowsePane m_browsePane;
private ItemSearch m_searchPane;
@ -144,6 +128,8 @@ public class ContentSectionPage extends CMSPage implements ActionListener {
private ReportPane m_reportPane;
private static class TitlePrinter implements PrintListener {
@Override
public void prepare(PrintEvent e) {
final Label l = (Label) e.getTarget();
@ -183,40 +169,39 @@ public class ContentSectionPage extends CMSPage implements ActionListener {
add(m_tabbedPane);
addActionListener(new ActionListener() {
public final void actionPerformed(ActionEvent e) {
final PageState state = e.getPageState();
@Override
public final void actionPerformed(ActionEvent e) {
final PageState state = e.getPageState();
final String tab = state.getRequest().getParameter
(SET_TAB);
final String tab = state.getRequest().getParameter(SET_TAB);
if (tab != null) {
m_tabbedPane.setSelectedIndex
(state, Integer.valueOf(tab).intValue());
}
if (tab != null) {
m_tabbedPane.setSelectedIndex(state, Integer.valueOf(tab).intValue());
}
SecurityManager sm = CMS.getContext().getSecurityManager();
User user = Web.getContext().getUser();
m_tabbedPane.setTabVisible(state, m_userAdminPane, sm.canAccess(user,SecurityConstants.STAFF_ADMIN));
SecurityManager sm = CMS.getContext().getSecurityManager();
User user = Web.getContext().getUser();
m_tabbedPane.setTabVisible(state, m_userAdminPane, sm.canAccess(user, SecurityConstants.STAFF_ADMIN));
if ( ContentSection.getConfig().getHideAdminTabs() ) {
m_tabbedPane.setTabVisible(state, m_workflowPane, sm.canAccess(user,SecurityConstants.WORKFLOW_ADMIN));
m_tabbedPane.setTabVisible(state, m_categoryPane, sm.canAccess(user,SecurityConstants.CATEGORY_ADMIN));
m_tabbedPane.setTabVisible(state, m_lifecyclePane, sm.canAccess(user,SecurityConstants.LIFECYCLE_ADMIN));
m_tabbedPane.setTabVisible(state, m_typePane, sm.canAccess(user,SecurityConstants.CONTENT_TYPE_ADMIN));
m_tabbedPane.setTabVisible(state, m_rolePane, sm.canAccess(user,SecurityConstants.STAFF_ADMIN));
// csePane: should check permission
m_tabbedPane.setTabVisible(state, m_csePane, true);
// TODO Check for reportPane as well
}
}
});
if (ContentSection.getConfig().getHideAdminTabs()) {
m_tabbedPane.setTabVisible(state, m_workflowPane, sm.canAccess(user, SecurityConstants.WORKFLOW_ADMIN));
m_tabbedPane.setTabVisible(state, m_categoryPane, sm.canAccess(user, SecurityConstants.CATEGORY_ADMIN));
m_tabbedPane.setTabVisible(state, m_lifecyclePane, sm.canAccess(user, SecurityConstants.LIFECYCLE_ADMIN));
m_tabbedPane.setTabVisible(state, m_typePane, sm.canAccess(user, SecurityConstants.CONTENT_TYPE_ADMIN));
m_tabbedPane.setTabVisible(state, m_rolePane, sm.canAccess(user, SecurityConstants.STAFF_ADMIN));
// csePane: should check permission
m_tabbedPane.setTabVisible(state, m_csePane, true);
// TODO Check for reportPane as well
}
}
});
add(new DebugPanel());
}
/**
* Creates, and then caches, the browse pane. Overriding this
* method to return null will prevent this tab from appearing.
* Creates, and then caches, the browse pane. Overriding this method to
* return null will prevent this tab from appearing.
*/
protected FolderAdminPane getFolderAdminPane() {
if (m_folderPane == null) {
@ -226,8 +211,8 @@ public class ContentSectionPage extends CMSPage implements ActionListener {
}
/**
* Creates, and then caches, the browse pane. Overriding this
* method to return null will prevent this tab from appearing.
* Creates, and then caches, the browse pane. Overriding this method to
* return null will prevent this tab from appearing.
*/
protected BrowsePane getBrowsePane() {
if (m_browsePane == null) {
@ -237,8 +222,8 @@ public class ContentSectionPage extends CMSPage implements ActionListener {
}
/**
* Creates, and then caches, the search pane. Overriding this
* method to return null will prevent this tab from appearing.
* Creates, and then caches, the search pane. Overriding this method to
* return null will prevent this tab from appearing.
*/
protected ItemSearch getSearchPane() {
if (m_searchPane == null) {
@ -248,7 +233,7 @@ public class ContentSectionPage extends CMSPage implements ActionListener {
}
protected ImagesPane getImagesPane() {
if(m_imagesPane == null) {
if (m_imagesPane == null) {
m_imagesPane = new ImagesPane();
}
return m_imagesPane;
@ -262,9 +247,8 @@ public class ContentSectionPage extends CMSPage implements ActionListener {
}
/**
* Creates, and then caches, the workflow administration
* pane. Overriding this method to return null will prevent this
* tab from appearing.
* Creates, and then caches, the workflow administration pane. Overriding
* this method to return null will prevent this tab from appearing.
*/
protected WorkflowAdminPane getWorkflowAdminPane() {
if (m_workflowPane == null) {
@ -274,9 +258,8 @@ public class ContentSectionPage extends CMSPage implements ActionListener {
}
/**
* Creates, and then caches, the lifecycle administration
* pane. Overriding this method to return null will prevent this tab
* from appearing.
* Creates, and then caches, the lifecycle administration pane. Overriding
* this method to return null will prevent this tab from appearing.
*/
protected LifecycleAdminPane getLifecycleAdminPane() {
if (m_lifecyclePane == null) {
@ -286,9 +269,8 @@ public class ContentSectionPage extends CMSPage implements ActionListener {
}
/**
* Creates, and then caches, the category administration
* pane. Overriding this method to return null will prevent this tab
* from appearing.
* Creates, and then caches, the category administration pane. Overriding
* this method to return null will prevent this tab from appearing.
*/
protected CategoryAdminPane getCategoryAdminPane() {
if (m_categoryPane == null) {
@ -298,9 +280,9 @@ public class ContentSectionPage extends CMSPage implements ActionListener {
}
/**
* Creates, and then caches, the content type administration
* pane. Overriding this method to return null will prevent this
* tab from appearing.
* Creates, and then caches, the content type administration pane.
* Overriding this method to return null will prevent this tab from
* appearing.
*/
protected ContentTypeAdminPane getContentTypeAdminPane() {
if (m_typePane == null) {
@ -329,14 +311,14 @@ public class ContentSectionPage extends CMSPage implements ActionListener {
protected ReportPane getReportPane() {
if (m_reportPane == null) {
m_reportPane = new ReportPane();
m_reportPane = new ReportPane();
}
return m_reportPane;
}
/**
* Adds the specified component, with the specified tab name, to
* the tabbed pane only if it is not null.
* Adds the specified component, with the specified tab name, to the tabbed
* pane only if it is not null.
*
* @param pane The pane to which to add the tab
* @param tabName The name of the tab if it's added
@ -344,28 +326,27 @@ public class ContentSectionPage extends CMSPage implements ActionListener {
*/
protected void addToPane(TabbedPane pane, String tabName, Component comp) {
if (comp != null) {
pane.addTab( new Label(tabName), comp);
pane.addTab(new Label(tabName), comp);
}
}
private void tab(final TabbedPane pane,
final String key,
final Component tab) {
final String key,
final Component tab) {
if (tab != null) {
pane.addTab(new Label(gz(key)), tab);
}
}
/**
* <p>Created the TabbedPane to use for this page. Adds the tabs
* to the pane. The default implementation uses a {@link
* com.arsdigita.bebop.TabbedPane}. This implementation also adds
* browse, search, staff admin, viewers admin, workflow admin,
* category admin, and content type panes.</p>
* <p>Created the TabbedPane to use for this page. Adds the tabs to the
* pane. The default implementation uses a {@link
* com.arsdigita.bebop.TabbedPane}. This implementation also adds browse,
* search, staff admin, viewers admin, workflow admin, category admin, and
* content type panes.</p>
*
* <p>Developers can override this method to add only the tabs
* they want, or to add additional tabs after the default CMS tabs
* are added.</p>
* <p>Developers can override this method to add only the tabs they want, or
* to add additional tabs after the default CMS tabs are added.</p>
*/
protected TabbedPane createTabbedPane() {
final TabbedPane pane = new TabbedPane();
@ -392,6 +373,7 @@ public class ContentSectionPage extends CMSPage implements ActionListener {
* @param request The HTTP request
* @return The current content section
*/
@Override
public ContentSection getContentSection(HttpServletRequest request) {
// Resets all content sections associations.
ContentSection section = super.getContentSection(request);
@ -400,11 +382,12 @@ public class ContentSectionPage extends CMSPage implements ActionListener {
}
/**
* When a new tab is selected, reset the state of the
* formerly-selected pane.
* When a new tab is selected, reset the state of the formerly-selected
* pane.
*
* @param event The event fired by selecting a tab
*/
@Override
public void actionPerformed(ActionEvent event) {
final PageState state = event.getPageState();
@ -443,12 +426,10 @@ public class ContentSectionPage extends CMSPage implements ActionListener {
*/
public static String getSectionURL(ContentItem item, int tab) {
// Get the content section associated with the content item.
ContentSection section = null;
ContentSection section = ContentSection.getContentSection(item);
section = ContentSection.getContentSection(item);
String url = section.getURL() + PageLocations.SECTION_PAGE +
"?" + SET_TAB + "=" + tab;
String url = section.getURL() + PageLocations.SECTION_PAGE
+ "?" + SET_TAB + "=" + tab;
return url;
}

View File

@ -65,12 +65,14 @@ public class ImageLibraryComponent extends SimpleContainer
m_chooser = new ImageChooser(ContentItem.DRAFT, m_mode);
m_chooser.addImageActionListener(new ImageBrowser.LinkActionListener() {
@Override
public void deleteClicked(final PageState state, final BigDecimal imageID) {
ImagesPane.S_LOG.debug("Clicked delete");
final ReusableImageAsset image = new ReusableImageAsset(imageID);
image.delete();
}
@Override
public void linkClicked(final PageState state, final BigDecimal imageID) {
ImagesPane.S_LOG.debug("Clicked select");
try {
@ -137,6 +139,7 @@ public class ImageLibraryComponent extends SimpleContainer
}
}
@Override
public ReusableImageAsset getImage(final FormSectionEvent event) {
final PageState state = event.getPageState();
return (ReusableImageAsset) m_imageModel.getSelectedItem(state);
@ -148,30 +151,36 @@ public class ImageLibraryComponent extends SimpleContainer
page.addComponentStateParam(this, m_imageID);
}
@Override
public String getCaption(final FormSectionEvent event) {
final PageState state = event.getPageState();
return (String) m_caption.getValue(state);
}
@Override
public String getDescription(final FormSectionEvent event) {
final PageState state = event.getPageState();
return (String) m_description.getValue(state);
}
@Override
public String getTitle(final FormSectionEvent event) {
final PageState state = event.getPageState();
return (String) m_title.getValue(state);
}
@Override
public String getUseContext(final FormSectionEvent event) {
final PageState state = event.getPageState();
return (String) m_useContext.getValue(state);
}
@Override
public Form getForm() {
return m_form;
}
@Override
public SaveCancelSection getSaveCancelSection() {
return m_saveCancel;
}
@ -195,6 +204,7 @@ public class ImageLibraryComponent extends SimpleContainer
/**
* Reset this component.
*/
@Override
public void reset(final PageState state) {
// clear selection
m_imageModel.clearSelection(state);

View File

@ -44,260 +44,265 @@ import org.apache.log4j.Logger;
public class ResultsPane extends SimpleComponent {
private static final Logger s_log = Logger.getLogger(ResultsPane.class);
public static final int PAGE_SIZE = 10;
private int m_pageSize = PAGE_SIZE;
private String m_engine;
private QueryGenerator m_query;
private IntegerParameter m_pageNumber;
private boolean m_relative;
private static final Logger s_log = Logger.getLogger(ResultsPane.class);
public static final int PAGE_SIZE = 10;
private int m_pageSize = PAGE_SIZE;
private String m_engine;
private QueryGenerator m_query;
private IntegerParameter m_pageNumber;
private boolean m_relative;
public ResultsPane(QueryGenerator query) {
this(query, null);
}
public ResultsPane(QueryGenerator query) {
this(query, null);
}
/**
* Determines whether the links to the search results will be
* relative or absolute. The default is absolute.
*/
public void setRelativeURLs(boolean relative) {
m_relative = relative;
}
/**
* Determines whether the links to the search results will be relative or
* absolute. The default is absolute.
*/
public void setRelativeURLs(boolean relative) {
m_relative = relative;
}
public ResultsPane(QueryGenerator query,
String engine) {
m_query = query;
m_engine = engine;
m_pageNumber = new IntegerParameter("page");
m_relative = false;
}
public ResultsPane(QueryGenerator query,
String engine) {
m_query = query;
m_engine = engine;
m_pageNumber = new IntegerParameter("page");
m_relative = false;
}
@Override
public void generateXML(PageState state, Element parent) {
if (!m_query.hasQuery(state)) {
if (s_log.isDebugEnabled()) {
s_log.debug("No query available, skipping XMl generation");
}
return;
}
@Override
public void generateXML(PageState state, Element parent) {
if (!m_query.hasQuery(state)) {
if (s_log.isDebugEnabled()) {
s_log.debug("No query available, skipping XMl generation");
}
Element content = Search.newElement("results");
Element info = content.newChildElement("info");
// info.setText(GlobalizationUtil.globalize("cms.ui.search_help").localize().toString());
info.setText("To search for content items, please enter at least 3 letters into the search field. You can narrow the result by using additional parameters.");
parent.addContent(content);
return;
}
QuerySpecification spec = m_query.getQuerySpecification(state);
ResultSet resultSet = null;
try {
resultSet = m_engine == null
? Search.process(spec)
: Search.process(spec, Search.DEFAULT_RESULT_CACHE,
m_engine);
QuerySpecification spec = m_query.getQuerySpecification(state);
ResultSet resultSet = null;
try {
resultSet = m_engine == null
? Search.process(spec)
: Search.process(spec, Search.DEFAULT_RESULT_CACHE,
m_engine);
if (s_log.isDebugEnabled()) {
s_log.debug("Got result set " + resultSet.getClass()
+ " count: " + resultSet.getCount());
}
if (s_log.isDebugEnabled()) {
s_log.debug("Got result set " + resultSet.getClass()
+ " count: " + resultSet.getCount());
}
if (resultSet.getCount() > 0) {
if (resultSet.getCount() > 0) {
Integer page = (Integer) m_pageNumber.transformValue(state.
getRequest());
int pageNumber = (page == null ? 1 : page.intValue());
long objectCount = resultSet.getCount();
int pageCount = (int) Math.ceil((double) objectCount
/ (double) m_pageSize);
Integer page = (Integer) m_pageNumber.transformValue(state.
getRequest());
int pageNumber = (page == null ? 1 : page.intValue());
long objectCount = resultSet.getCount();
int pageCount = (int) Math.ceil((double) objectCount
/ (double) m_pageSize);
if (pageNumber < 1) {
pageNumber = 1;
}
if (pageNumber < 1) {
pageNumber = 1;
}
if (pageNumber > pageCount) {
pageNumber = (pageCount == 0 ? 1 : pageCount);
}
if (pageNumber > pageCount) {
pageNumber = (pageCount == 0 ? 1 : pageCount);
}
long begin = ((pageNumber - 1) * m_pageSize);
int count = (int) Math.min(m_pageSize, (objectCount - begin));
long end = begin + count;
long begin = ((pageNumber - 1) * m_pageSize);
int count = (int) Math.min(m_pageSize, (objectCount - begin));
long end = begin + count;
Iterator results = resultSet.getDocuments(begin, count);
Iterator results = resultSet.getDocuments(begin, count);
Element content = Search.newElement("results");
exportAttributes(content);
Element content = Search.newElement("results");
exportAttributes(content);
if (s_log.isDebugEnabled()) {
s_log.debug("Paginator stats\n page number:" + pageNumber
+ "\n page count: " + pageCount
+ "\n page size: "
+ m_pageSize + "\n start " + begin + "\n end: "
+ end + "\n count: " + objectCount);
}
if (s_log.isDebugEnabled()) {
s_log.debug("Paginator stats\n page number:" + pageNumber
+ "\n page count: " + pageCount
+ "\n page size: "
+ m_pageSize + "\n start " + begin + "\n end: "
+ end + "\n count: " + objectCount);
}
content.addContent(generatePaginatorXML(state,
m_pageNumber.getName(),
pageNumber, pageCount,
m_pageSize, begin, end,
objectCount));
content.addContent(generateDocumentsXML(state, results));
content.addContent(generatePaginatorXML(state,
m_pageNumber.getName(),
pageNumber, pageCount,
m_pageSize, begin, end,
objectCount));
content.addContent(generateDocumentsXML(state, results));
parent.addContent(content);
} else {
// No search result, so we don't need a paginator, but we want
// to inform the user, that there are no results for this search
Element content = Search.newElement("results");
Element info = content.newChildElement("info");
parent.addContent(content);
} else {
// No search result, so we don't need a paginator, but we want
// to inform the user, that there are no results for this search
Element content = Search.newElement("results");
Element info = content.newChildElement("info");
// info.setText(GlobalizationUtil.globalize("cms.ui.search_no_results").localize().toString());
info.setText("Sorry. Your search returned 0 results.");
parent.addContent(content);
}
info.setText("Sorry. Your search returned 0 results.");
parent.addContent(content);
}
} finally {
if (resultSet != null) {
try {
resultSet.close();
} catch (Exception e) {
/*
* If there is a problem closing the result set this probably means
* it has been closed elsewhere and is probably not fatal. We write
* a line to the error log but otherwise ignore the exception allowing
* the code to continue normally. Any issues willemerge in the log.
*/
s_log.error("Error closing resultset: " + e.getMessage());
}
}
}
}
} finally {
if (resultSet != null) {
try {
resultSet.close();
} catch (Exception e) {
/*
* If there is a problem closing the result set this probably means
* it has been closed elsewhere and is probably not fatal. We write
* a line to the error log but otherwise ignore the exception allowing
* the code to continue normally. Any issues willemerge in the log.
*/
s_log.error("Error closing resultset: " + e.getMessage());
}
}
}
}
protected Element generatePaginatorXML(PageState state,
String pageParam,
int pageNumber,
int pageCount,
int pageSize,
long begin,
long end,
long objectCount) {
Element paginator = Search.newElement("paginator");
URL url = Web.getContext().getRequestURL();
protected Element generatePaginatorXML(PageState state,
String pageParam,
int pageNumber,
int pageCount,
int pageSize,
long begin,
long end,
long objectCount) {
Element paginator = Search.newElement("paginator");
URL url = Web.getContext().getRequestURL();
ParameterMap map = new ParameterMap();
Iterator current = url.getParameterMap().keySet().iterator();
while (current.hasNext()) {
String key = (String) current.next();
if (key.equals(pageParam)) {
continue;
}
//map.setParameterValues(key, url.getParameterValues(key));
map.setParameterValues(key,
decodeParameters(url.getParameterValues(key),
state));
}
ParameterMap map = new ParameterMap();
Iterator current = url.getParameterMap().keySet().iterator();
while (current.hasNext()) {
String key = (String) current.next();
if (key.equals(pageParam)) {
continue;
}
//map.setParameterValues(key, url.getParameterValues(key));
map.setParameterValues(key,
decodeParameters(url.getParameterValues(key),
state));
}
paginator.addAttribute("pageParam", m_pageNumber.getName());
paginator.addAttribute("baseURL", URL.there(url.getPathInfo(), map).
toString());
paginator.addAttribute("pageNumber", XML.format(new Integer(pageNumber)));
paginator.addAttribute("pageCount", XML.format(new Integer(pageCount)));
paginator.addAttribute("pageSize", XML.format(new Integer(pageSize)));
paginator.addAttribute("objectBegin", XML.format(new Long(begin + 1)));
paginator.addAttribute("objectEnd", XML.format(new Long(end)));
paginator.addAttribute("objectCount", XML.format(new Long(objectCount)));
return paginator;
}
paginator.addAttribute("pageParam", m_pageNumber.getName());
paginator.addAttribute("baseURL", URL.there(url.getPathInfo(), map).
toString());
paginator.addAttribute("pageNumber", XML.format(new Integer(pageNumber)));
paginator.addAttribute("pageCount", XML.format(new Integer(pageCount)));
paginator.addAttribute("pageSize", XML.format(new Integer(pageSize)));
paginator.addAttribute("objectBegin", XML.format(new Long(begin + 1)));
paginator.addAttribute("objectEnd", XML.format(new Long(end)));
paginator.addAttribute("objectCount", XML.format(new Long(objectCount)));
return paginator;
}
private String[] decodeParameters(final String[] parameters,
final PageState state) {
final String[] decoded = new String[parameters.length];
private String[] decodeParameters(final String[] parameters,
final PageState state) {
final String[] decoded = new String[parameters.length];
for (int i = 0; i < parameters.length; i++) {
decoded[i] = decodeParameter(parameters[i], state);
}
for (int i = 0; i < parameters.length; i++) {
decoded[i] = decodeParameter(parameters[i], state);
}
return decoded;
}
return decoded;
}
private String decodeParameter(final String parameter,
final PageState state) {
String re = state.getRequest().getParameter(Globalization.ENCODING_PARAM_NAME);
if ((re == null) || (re.isEmpty())) {
re = Globalization.getDefaultCharset();
}
if ((parameter == null) || (parameter.isEmpty())) {
return parameter;
} else if(Globalization.getDefaultCharset(state.getRequest()).equals(re)) {
return parameter;
} else {
try {
return new String(parameter.getBytes(Globalization.getDefaultCharset(
state.getRequest())), re);
} catch(UnsupportedEncodingException ex) {
s_log.warn("Unsupported encoding.", ex);
return parameter;
}
}
}
private String decodeParameter(final String parameter,
final PageState state) {
String re = state.getRequest().getParameter(Globalization.ENCODING_PARAM_NAME);
protected Element generateDocumentsXML(PageState state,
Iterator results) {
Element documents = Search.newElement("documents");
if ((re == null) || (re.isEmpty())) {
re = Globalization.getDefaultCharset();
}
if (s_log.isDebugEnabled()) {
s_log.debug("Outputting documents");
}
while (results.hasNext()) {
Document doc = (Document) results.next();
if (s_log.isDebugEnabled()) {
s_log.debug("One doc " + doc.getOID() + " " + doc.getTitle());
}
documents.addContent(generateDocumentXML(state, doc));
}
if ((parameter == null) || (parameter.isEmpty())) {
return parameter;
} else if (Globalization.getDefaultCharset(state.getRequest()).equals(re)) {
return parameter;
} else {
try {
return new String(parameter.getBytes(Globalization.getDefaultCharset(
state.getRequest())), re);
} catch (UnsupportedEncodingException ex) {
s_log.warn("Unsupported encoding.", ex);
return parameter;
}
}
}
return documents;
}
protected Element generateDocumentsXML(PageState state,
Iterator results) {
Element documents = Search.newElement("documents");
protected Element generateDocumentXML(PageState state,
Document doc) {
Element entry = Search.newElement("object");
if (s_log.isDebugEnabled()) {
s_log.debug("Outputting documents");
}
while (results.hasNext()) {
Document doc = (Document) results.next();
if (s_log.isDebugEnabled()) {
s_log.debug("One doc " + doc.getOID() + " " + doc.getTitle());
}
documents.addContent(generateDocumentXML(state, doc));
}
String summary = doc.getSummary();
return documents;
}
java.net.URL url = doc.getURL();
protected Element generateDocumentXML(PageState state,
Document doc) {
Element entry = Search.newElement("object");
entry.addAttribute("oid", XML.format(doc.getOID()));
entry.addAttribute("url", XML.format(m_relative ? url.getPath() + "?"
+ url.getQuery()
: url.toString()));
entry.addAttribute("score", XML.format(doc.getScore()));
entry.addAttribute("title", XML.format(doc.getTitle()));
if (summary != null) {
entry.addAttribute("summary", XML.format(summary));
}
String summary = doc.getSummary();
entry.addAttribute("locale", XML.format(doc.getLocale()));
java.net.URL url = doc.getURL();
Date creationDate = doc.getCreationDate();
if (creationDate != null) {
entry.addAttribute("creationDate", XML.format(
creationDate.toString()));
}
Party creationParty = doc.getCreationParty();
if (creationParty != null) {
entry.addAttribute("creationParty",
XML.format(creationParty.getDisplayName()));
}
entry.addAttribute("oid", XML.format(doc.getOID()));
entry.addAttribute("url", XML.format(m_relative ? url.getPath() + "?"
+ url.getQuery()
: url.toString()));
entry.addAttribute("score", XML.format(doc.getScore()));
entry.addAttribute("title", XML.format(doc.getTitle()));
if (summary != null) {
entry.addAttribute("summary", XML.format(summary));
}
Date lastModifiedDate = doc.getLastModifiedDate();
if (lastModifiedDate != null) {
entry.addAttribute("lastModifiedDate",
XML.format(lastModifiedDate));
}
Party lastModifiedParty = doc.getLastModifiedParty();
if (lastModifiedParty != null) {
entry.addAttribute("lastModifiedParty",
XML.format(lastModifiedParty.getDisplayName()));
}
entry.addAttribute("locale", XML.format(doc.getLocale()));
s_log.debug(
"about to add the contentSectionName from search index Doc to search result xml");
entry.addAttribute("contentSectionName", XML.format(doc.
getContentSection()));
Date creationDate = doc.getCreationDate();
if (creationDate != null) {
entry.addAttribute("creationDate", XML.format(
creationDate.toString()));
}
Party creationParty = doc.getCreationParty();
if (creationParty != null) {
entry.addAttribute("creationParty",
XML.format(creationParty.getDisplayName()));
}
return entry;
}
Date lastModifiedDate = doc.getLastModifiedDate();
if (lastModifiedDate != null) {
entry.addAttribute("lastModifiedDate",
XML.format(lastModifiedDate));
}
Party lastModifiedParty = doc.getLastModifiedParty();
if (lastModifiedParty != null) {
entry.addAttribute("lastModifiedParty",
XML.format(lastModifiedParty.getDisplayName()));
}
s_log.debug(
"about to add the contentSectionName from search index Doc to search result xml");
entry.addAttribute("contentSectionName", XML.format(doc.
getContentSection()));
return entry;
}
}