From 7a65f3f33b592ad5dffb3a28c1a52769de696dff Mon Sep 17 00:00:00 2001 From: Dave Ward Date: Mon, 6 Jun 2011 10:57:20 +0000 Subject: [PATCH] Merged V3.4-BUG-FIX to HEAD 28158: ALF-8925: Merged V3.3 to V3.4-BUG-FIX 28121: ALF-8878: Prevent authentication errors in SMBSrvSession.cleanupSession() 28159: Merged HEAD to V3.4-BUG-FIX (RECORD ONLY) 27951: Fixed merge issue in ContentDiskDriverTest 28161: ALF-8861: Fix from Bitrock to kill OpenOffice process on uninstallation if all else fails 28165: ALF-8260: Corrected French translations of 'Library' 28166: Fix for ALF-8751 - Dates are not localized in Document Lists dashlet 28167: Fix for ALF-8493 28169: ALF-5797: Translation corrections to complex strings 28171: Merged DEV TO V3.4-BUG-FIX ALF-8808 : CLONE - NFS: User with editor role cannot edit content - unit test required 28181: Fixed ALF-280: Unfriendly message appears when trying to specify non-existent file-store 28184: Merged BRANCHES/DEV/BELARUS/V3.4-BUG-FIX-2011_04_12 to BRANCHES/DEV/V3.4-BUG-FIX: 28179: ALF-8754: Cannot preview content on other webapp folder than ROOT (merged w/ trivial clean-up) 28185: Fixed ALF-8020: Multivalue date in document details causes error in alfresco share NOTE: We do not support any multi-valued fields other than text currently, this fix is therefore to handle the case where a multivalued date or dateTime field is configured in a form. The form will list the dates in view mode but in create and edit modes the control is not displayed at all when there are multiple values, if there is only one value the control continues to function as it has done previously. 28188: Fix for ALF-731 - in a cluster environment (high availibility), when a node goes down, the users are asked to login git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@28208 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../web-client-config-custom.xml.sample | 2 +- .../alfresco/messages/webclient_de.properties | 12 +-- .../alfresco/messages/webclient_es.properties | 16 ++-- .../alfresco/messages/webclient_fr.properties | 12 +-- .../alfresco/messages/webclient_it.properties | 16 ++-- .../alfresco/messages/webclient_ja.properties | 16 ++-- .../generator/StoreSelectorGenerator.java | 41 ++++++++++ .../web/ui/repo/component/UIActions.java | 19 ++++- .../ui/repo/component/UIStoreSelector.java | 81 +++++++++++++++++++ source/web/WEB-INF/faces-config-beans.xml | 9 +++ source/web/WEB-INF/faces-config-repo.xml | 5 ++ 11 files changed, 191 insertions(+), 38 deletions(-) create mode 100644 source/java/org/alfresco/web/bean/generator/StoreSelectorGenerator.java create mode 100644 source/java/org/alfresco/web/ui/repo/component/UIStoreSelector.java diff --git a/config/alfresco/extension/web-client-config-custom.xml.sample b/config/alfresco/extension/web-client-config-custom.xml.sample index d7ac00b077..c31665617d 100644 --- a/config/alfresco/extension/web-client-config-custom.xml.sample +++ b/config/alfresco/extension/web-client-config-custom.xml.sample @@ -106,7 +106,7 @@ - + diff --git a/config/alfresco/messages/webclient_de.properties b/config/alfresco/messages/webclient_de.properties index 1c91c20d78..8b912e80fd 100644 --- a/config/alfresco/messages/webclient_de.properties +++ b/config/alfresco/messages/webclient_de.properties @@ -874,19 +874,19 @@ regenerate_renditions_desc=Anhand dieses Assistenten k\u00f6nnen Sie Renditions regenerate_renditions_select_renditions_title=Renditions ausw\u00e4hlen regenerate_renditions_select_renditions_step_title=Renditions ausw\u00e4hlen regenerate_renditions_select_renditions_desc=Die Renditions ausw\u00e4hlen, die erneuert werden sollen. -regenerate_renditions_select_renditions_select_item_desc={0} \u00e4hnliche {0,choice,0#renditions|1#rendition|1. + */ +package org.alfresco.web.bean.generator; + +import javax.faces.component.UIComponent; +import javax.faces.context.FacesContext; + +import org.alfresco.web.app.servlet.FacesHelper; +import org.alfresco.web.ui.repo.component.UIStoreSelector; + +/** + * Generates a content store selector component. + */ +public class StoreSelectorGenerator extends BaseComponentGenerator +{ + public UIComponent generate(FacesContext context, String id) + { + UIComponent component = context.getApplication(). + createComponent(UIStoreSelector.COMPONENT_TYPE); + FacesHelper.setupComponentId(context, component, id); + + return component; + } + +} diff --git a/source/java/org/alfresco/web/ui/repo/component/UIActions.java b/source/java/org/alfresco/web/ui/repo/component/UIActions.java index e046b0c188..0dfd366e71 100644 --- a/source/java/org/alfresco/web/ui/repo/component/UIActions.java +++ b/source/java/org/alfresco/web/ui/repo/component/UIActions.java @@ -19,6 +19,9 @@ package org.alfresco.web.ui.repo.component; import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.math.BigInteger; +import java.nio.charset.Charset; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -35,6 +38,7 @@ import javax.faces.el.ValueBinding; import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.util.GUID; import org.alfresco.web.app.Application; import org.alfresco.web.bean.repository.Node; import org.alfresco.web.config.ActionsConfigElement; @@ -646,7 +650,20 @@ public class UIActions extends SelfRenderingComponent */ private static String createUniqueId() { - return "id_" + Short.toString(++id); + String guidString = GUID.generate(); + byte[] guidBytes = null; + try + { + guidBytes = guidString.getBytes("ISO8859_1"); + } + catch (UnsupportedEncodingException e) + { + //probably unreachable block, so just in case + Charset defaultCharset = Charset.defaultCharset(); + logger.warn("Can't get GUID bytes for encoding ISO8859_1, use default " + defaultCharset); + guidBytes = guidString.getBytes(defaultCharset); + } + return "id_" + new BigInteger(guidBytes).toString(Character.MAX_RADIX); } // ------------------------------------------------------------------------------ diff --git a/source/java/org/alfresco/web/ui/repo/component/UIStoreSelector.java b/source/java/org/alfresco/web/ui/repo/component/UIStoreSelector.java new file mode 100644 index 0000000000..a343af4faf --- /dev/null +++ b/source/java/org/alfresco/web/ui/repo/component/UIStoreSelector.java @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2005-2011 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.web.ui.repo.component; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import javax.faces.component.UISelectItems; +import javax.faces.component.UISelectOne; +import javax.faces.context.FacesContext; +import javax.faces.model.SelectItem; + +import org.alfresco.repo.dictionary.constraint.ConstraintRegistry; +import org.alfresco.repo.dictionary.constraint.ListOfValuesConstraint; +import org.alfresco.service.cmr.dictionary.Constraint; +import org.alfresco.web.data.IDataContainer; +import org.alfresco.web.data.QuickSort; + +/** + * Component that holds a list of content stores configured in the repository. + */ +public class UIStoreSelector extends UISelectOne +{ + public static final String COMPONENT_TYPE = "org.alfresco.faces.StoreSelector"; + public static final String COMPONENT_FAMILY = "javax.faces.SelectOne"; + + @Override + @SuppressWarnings("unchecked") + public void encodeBegin(FacesContext context) throws IOException + { + if (getChildren().size() == 0) + { + UISelectItems items = (UISelectItems)context.getApplication(). + createComponent("javax.faces.SelectItems"); + items.setId(this.getId() + "_items"); + items.setValue(createList()); + + // add the child component + getChildren().add(items); + } + + // do the default processing + super.encodeBegin(context); + } + + /** + * @return List of SelectItem components + */ + protected List createList() + { + List items = new ArrayList(5); + Constraint storesConstraint = ConstraintRegistry.getInstance().getConstraint("defaultStoreSelector"); + for(String store : ((ListOfValuesConstraint) storesConstraint).getAllowedValues()) + { + items.add(new SelectItem(store, store)); + } + + // make sure the list is sorted by the values + QuickSort sorter = new QuickSort(items, "label", true, IDataContainer.SORT_CASEINSENSITIVE); + sorter.sort(); + + return items; + } +} diff --git a/source/web/WEB-INF/faces-config-beans.xml b/source/web/WEB-INF/faces-config-beans.xml index 871d4bc44c..0817f56f46 100644 --- a/source/web/WEB-INF/faces-config-beans.xml +++ b/source/web/WEB-INF/faces-config-beans.xml @@ -4618,6 +4618,15 @@ request + + + Bean that generates a stores selector component + + StoreSelectorGenerator + org.alfresco.web.bean.generator.StoreSelectorGenerator + request + + Bean that generates a charset selector component diff --git a/source/web/WEB-INF/faces-config-repo.xml b/source/web/WEB-INF/faces-config-repo.xml index 06172a7e43..275b57c1fd 100644 --- a/source/web/WEB-INF/faces-config-repo.xml +++ b/source/web/WEB-INF/faces-config-repo.xml @@ -74,6 +74,11 @@ org.alfresco.web.ui.repo.component.UIMimeTypeSelector + + org.alfresco.faces.StoreSelector + org.alfresco.web.ui.repo.component.UIStoreSelector + + org.alfresco.faces.LanguageSelector org.alfresco.web.ui.repo.component.UILanguageSelector