mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Phase one of merge of EC multilingual work
These files are their changes plus adjustments for formatting and immediate clashes I anticipate that this will break the build, but there are too many changes coming to risk it. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5740 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -30,6 +30,7 @@ import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -132,6 +133,15 @@ public class BrowseBean implements IContextListener
|
||||
this.searchService = searchService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param userPreferencesBean The UserPreferencesBean to set.
|
||||
*/
|
||||
public void setUserPreferencesBean(UserPreferencesBean userPreferencesBean)
|
||||
{
|
||||
this.userPreferencesBean = userPreferencesBean;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param lockService The Lock Service to set.
|
||||
*/
|
||||
@@ -481,6 +491,7 @@ public class BrowseBean implements IContextListener
|
||||
node.addPropertyResolver("fileType16", this.resolverFileType16);
|
||||
node.addPropertyResolver("fileType32", this.resolverFileType32);
|
||||
node.addPropertyResolver("size", this.resolverSize);
|
||||
node.addPropertyResolver("lang", this.resolverLang);
|
||||
}
|
||||
|
||||
|
||||
@@ -630,7 +641,7 @@ public class BrowseBean implements IContextListener
|
||||
|
||||
// look for Space folder node
|
||||
if (this.dictionaryService.isSubClass(type, ContentModel.TYPE_FOLDER) == true &&
|
||||
this.dictionaryService.isSubClass(type, ContentModel.TYPE_SYSTEM_FOLDER) == false)
|
||||
this.dictionaryService.isSubClass(type, ContentModel.TYPE_SYSTEM_FOLDER) == false)
|
||||
{
|
||||
// create our Node representation
|
||||
node = new MapNode(nodeRef, this.nodeService, true);
|
||||
@@ -659,6 +670,7 @@ public class BrowseBean implements IContextListener
|
||||
node.addPropertyResolver("fileType16", this.resolverFileType16);
|
||||
node.addPropertyResolver("fileType32", this.resolverFileType32);
|
||||
node.addPropertyResolver("size", this.resolverSize);
|
||||
node.addPropertyResolver("lang", this.resolverLang);
|
||||
|
||||
this.contentNodes.add(node);
|
||||
}
|
||||
@@ -823,6 +835,7 @@ public class BrowseBean implements IContextListener
|
||||
node.addPropertyResolver("fileType16", this.resolverFileType16);
|
||||
node.addPropertyResolver("fileType32", this.resolverFileType32);
|
||||
node.addPropertyResolver("size", this.resolverSize);
|
||||
node.addPropertyResolver("lang", this.resolverLang);
|
||||
node.addPropertyResolver("path", this.resolverPath);
|
||||
node.addPropertyResolver("displayPath", this.resolverDisplayPath);
|
||||
|
||||
@@ -1043,6 +1056,39 @@ public class BrowseBean implements IContextListener
|
||||
}
|
||||
};
|
||||
|
||||
public NodePropertyResolver resolverLang = new NodePropertyResolver() {
|
||||
public Object get(Node node) {
|
||||
|
||||
String lang = null;
|
||||
|
||||
if(node.getAspects().contains(ContentModel.ASPECT_MULTILINGUAL_DOCUMENT))
|
||||
{
|
||||
Locale locale = (Locale) node.getProperties().get(ContentModel.PROP_LOCALE);
|
||||
|
||||
// the content filter lang defined by the user
|
||||
String userLang = userPreferencesBean.getContentFilterLanguage();
|
||||
// the node lang
|
||||
String nodeLang = locale.getLanguage();
|
||||
|
||||
// if filter equals all languages : display the lang for each translation
|
||||
if(nodeLang == null)
|
||||
{
|
||||
lang = nodeLang;
|
||||
}
|
||||
|
||||
// if filter is different : display the lang
|
||||
else if (!nodeLang.equalsIgnoreCase(userLang))
|
||||
{
|
||||
lang = nodeLang;
|
||||
}
|
||||
|
||||
// else if the filter is equal to the lang node : nothing to do [lang = null]
|
||||
|
||||
}
|
||||
|
||||
return lang;
|
||||
}
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Navigation action event handlers
|
||||
@@ -1357,6 +1403,7 @@ public class BrowseBean implements IContextListener
|
||||
node.addPropertyResolver("fileType32", this.resolverFileType32);
|
||||
node.addPropertyResolver("mimetype", this.resolverMimetype);
|
||||
node.addPropertyResolver("size", this.resolverSize);
|
||||
node.addPropertyResolver("lang", this.resolverLang);
|
||||
|
||||
for (NodeEventListener listener : getNodeEventListeners())
|
||||
{
|
||||
@@ -1727,6 +1774,9 @@ public class BrowseBean implements IContextListener
|
||||
/** The NavigationBean bean reference */
|
||||
protected NavigationBean navigator;
|
||||
|
||||
/** The UserPreferencesBean to be used by the bean */
|
||||
protected UserPreferencesBean userPreferencesBean;
|
||||
|
||||
/** The DictionaryService bean reference */
|
||||
protected DictionaryService dictionaryService;
|
||||
|
||||
|
@@ -0,0 +1,224 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program 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 General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.web.bean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.model.SelectItem;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.node.MLPropertyInterceptor;
|
||||
import org.alfresco.service.cmr.repository.MLText;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
|
||||
public class CreateMultilingualPropertiesBean
|
||||
{
|
||||
/** binding with edit of Other Options */
|
||||
private String language = null;
|
||||
private String newlanguage = null;
|
||||
private String title = null;
|
||||
private String description = null;
|
||||
protected boolean add_new_properties = false;
|
||||
|
||||
/** The NodeService to be used by the bean */
|
||||
protected NodeService nodeService;
|
||||
/** The user preferences bean reference */
|
||||
protected UserPreferencesBean preferences;
|
||||
|
||||
|
||||
/**
|
||||
* @param nodeService The NodeService to set.
|
||||
*/
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
public String getLanguage()
|
||||
{
|
||||
return this.language;
|
||||
}
|
||||
|
||||
public void setLanguage(String x)
|
||||
{
|
||||
this.language = x;
|
||||
Application.setLanguage(FacesContext.getCurrentInstance(), this.language);
|
||||
}
|
||||
|
||||
public void setNewlanguage(String x)
|
||||
{
|
||||
this.newlanguage = x;
|
||||
}
|
||||
|
||||
public String getNewlanguage()
|
||||
{
|
||||
return this.newlanguage;
|
||||
}
|
||||
|
||||
|
||||
public void setUserPreferencesBean(UserPreferencesBean preferences)
|
||||
{
|
||||
this.preferences = preferences;
|
||||
}
|
||||
|
||||
public UserPreferencesBean getUserPreferencesBean()
|
||||
{
|
||||
return preferences;
|
||||
}
|
||||
|
||||
public void setTitle(String x)
|
||||
{
|
||||
this.title = x;
|
||||
}
|
||||
|
||||
public void setDescription(String x)
|
||||
{
|
||||
this.description = x;
|
||||
}
|
||||
|
||||
public String getTitle()
|
||||
{
|
||||
return this.title;
|
||||
}
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return this.description;
|
||||
}
|
||||
|
||||
|
||||
// Display the list of all multilingual properties
|
||||
public SelectItem[] getListAllDescriptionsProperties()
|
||||
{
|
||||
MLPropertyInterceptor.setMLAware(true);
|
||||
BrowseBean browseBean = (BrowseBean) FacesHelper.getManagedBean(FacesContext.getCurrentInstance(), "BrowseBean");
|
||||
|
||||
// create the space (just create a folder for now)
|
||||
NodeRef nodeRef = browseBean.getDocument().getNodeRef();
|
||||
|
||||
if(nodeService.getProperty(nodeRef, ContentModel.PROP_DESCRIPTION) != null)
|
||||
{
|
||||
List<SelectItem> sel = new ArrayList<SelectItem>();
|
||||
|
||||
if (nodeService.getProperty(nodeRef, ContentModel.PROP_DESCRIPTION) instanceof MLText)
|
||||
{
|
||||
MLText descriptions = (MLText) nodeService.getProperty(nodeRef, ContentModel.PROP_DESCRIPTION);
|
||||
|
||||
for(Map.Entry<Locale, String> description : descriptions.entrySet())
|
||||
{
|
||||
sel.add(new SelectItem(description.getKey().toString(), description.getValue().toString()));
|
||||
}
|
||||
|
||||
MLPropertyInterceptor.setMLAware(false);
|
||||
|
||||
// Create the table
|
||||
SelectItem[] items = new SelectItem[sel.size()];
|
||||
|
||||
// Copy into table
|
||||
sel.toArray(items);
|
||||
|
||||
if(sel.size() > 0)
|
||||
{
|
||||
return items;
|
||||
}
|
||||
else
|
||||
{
|
||||
SelectItem[] elements = { new SelectItem("","")}; return elements;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SelectItem[] elements = { new SelectItem("","")}; return elements;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SelectItem[] elements = { new SelectItem("")}; return elements;
|
||||
}
|
||||
}
|
||||
|
||||
// Display the list of all multilingual properties
|
||||
public SelectItem[] getListAllTitlesProperties()
|
||||
{
|
||||
MLPropertyInterceptor.setMLAware(true);
|
||||
BrowseBean browseBean = (BrowseBean) FacesHelper.getManagedBean(FacesContext.getCurrentInstance(), "BrowseBean");
|
||||
|
||||
// create the space (just create a folder for now)
|
||||
NodeRef nodeRef = browseBean.getDocument().getNodeRef();
|
||||
|
||||
if(nodeService.getProperty(nodeRef, ContentModel.PROP_DESCRIPTION) != null)
|
||||
{
|
||||
List<SelectItem> sel = new ArrayList<SelectItem>();
|
||||
|
||||
if (nodeService.getProperty(nodeRef, ContentModel.PROP_DESCRIPTION) instanceof MLText)
|
||||
{
|
||||
MLText descriptions = (MLText) nodeService.getProperty(nodeRef, ContentModel.PROP_TITLE);
|
||||
|
||||
for(Map.Entry<Locale, String> description : descriptions.entrySet())
|
||||
{
|
||||
sel.add(new SelectItem(description.getKey().toString(), description.getValue()));
|
||||
}
|
||||
|
||||
MLPropertyInterceptor.setMLAware(false);
|
||||
// Create the table
|
||||
SelectItem[] items = new SelectItem[sel.size()];
|
||||
// Copy into table
|
||||
sel.toArray(items);
|
||||
|
||||
if(sel.size() > 0)
|
||||
{
|
||||
return items;
|
||||
}
|
||||
else
|
||||
{
|
||||
SelectItem[] elements = { new SelectItem("","")}; return elements;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SelectItem[] elements = { new SelectItem("","")}; return elements;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SelectItem[] elements = { new SelectItem("","")}; return elements;
|
||||
}
|
||||
}
|
||||
|
||||
public SelectItem[] getContentFilterLanguages()
|
||||
{
|
||||
return preferences.getContentFilterLanguages(false);
|
||||
}
|
||||
public boolean isAdd_new_properties() {return this.add_new_properties;}
|
||||
public void setAdd_new_properties(boolean x){this.add_new_properties = x;}
|
||||
}
|
||||
|
@@ -30,6 +30,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.application.FacesMessage;
|
||||
@@ -79,6 +80,8 @@ public class DocumentDetailsBean extends BaseDetailsBean
|
||||
protected LockService lockService;
|
||||
protected VersionService versionService;
|
||||
protected CheckOutCheckInService cociService;
|
||||
protected MultilingualContentService multilingualContentService;
|
||||
protected ContentFilterLanguagesService contentFilterLanguagesService;
|
||||
|
||||
private NodeRef addedCategory;
|
||||
private List categories;
|
||||
@@ -96,6 +99,8 @@ public class DocumentDetailsBean extends BaseDetailsBean
|
||||
|
||||
// initial state of some panels that don't use the default
|
||||
panels.put("version-history-panel", false);
|
||||
panels.put("ml-info-panel", false);
|
||||
panels.put("related-translation-panel", false);
|
||||
}
|
||||
|
||||
|
||||
@@ -184,6 +189,14 @@ public class DocumentDetailsBean extends BaseDetailsBean
|
||||
return getDocument().hasAspect(ApplicationModel.ASPECT_INLINEEDITABLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the current document has the 'inlineeditable' aspect applied
|
||||
*/
|
||||
public boolean isMultilingual()
|
||||
{
|
||||
return getDocument().hasAspect(ContentModel.ASPECT_MULTILINGUAL_DOCUMENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of objects representing the versions of the
|
||||
* current document
|
||||
@@ -220,6 +233,69 @@ public class DocumentDetailsBean extends BaseDetailsBean
|
||||
return versions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of objects representing the editions of the
|
||||
* logical document
|
||||
*
|
||||
* @return List of editions
|
||||
*/
|
||||
public List getEditionHistory()
|
||||
{
|
||||
List<MapNode> editions = new ArrayList<MapNode>();
|
||||
|
||||
if (getDocument().getType().equals(ContentModel.TYPE_MULTILINGUAL_CONTAINER))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return editions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of objects representing the translations of the
|
||||
* current document
|
||||
*
|
||||
* @return List of translations
|
||||
*/
|
||||
public List getTranslations()
|
||||
{
|
||||
List<MapNode> translations = new ArrayList<MapNode>();
|
||||
|
||||
if (getDocument().hasAspect(ContentModel.ASPECT_MULTILINGUAL_DOCUMENT))
|
||||
{
|
||||
|
||||
Map<Locale, NodeRef> translationsMap = this.multilingualContentService.getTranslations(getDocument().getNodeRef());
|
||||
|
||||
if (translationsMap != null && translationsMap.size() > 0)
|
||||
{
|
||||
for (Map.Entry entry : translationsMap.entrySet())
|
||||
{
|
||||
NodeRef nodeRef = (NodeRef) entry.getValue();
|
||||
|
||||
// create a map node representation of the translation
|
||||
MapNode mapNode = new MapNode(nodeRef);
|
||||
|
||||
Locale locale = (Locale) nodeService.getProperty(nodeRef, ContentModel.PROP_LOCALE);
|
||||
|
||||
String lgge = (locale != null) ?
|
||||
// convert the locale into new ISO codes
|
||||
contentFilterLanguagesService.convertToNewISOCode(locale.getLanguage()).toUpperCase()
|
||||
: null ;
|
||||
|
||||
mapNode.put("name", nodeService.getProperty(nodeRef, ContentModel.PROP_NAME));
|
||||
mapNode.put("language", lgge);
|
||||
mapNode.put("url", DownloadContentServlet.generateBrowserURL(nodeRef, mapNode.getName()));
|
||||
|
||||
// add the client side version to the list
|
||||
translations.add(mapNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return translations;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determines whether the current document has any categories applied
|
||||
*
|
||||
@@ -699,6 +775,19 @@ public class DocumentDetailsBean extends BaseDetailsBean
|
||||
return this.getNode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ml container of the document this bean is currently representing
|
||||
*
|
||||
* @return The document multilingual container NodeRef
|
||||
*/
|
||||
public Node getDocumentMlContainer()
|
||||
{
|
||||
NodeRef nodeRef = getNode().getNodeRef();
|
||||
|
||||
return new Node(multilingualContentService.getTranslationContainer(nodeRef));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the lock service instance the bean should use
|
||||
*
|
||||
@@ -728,4 +817,21 @@ public class DocumentDetailsBean extends BaseDetailsBean
|
||||
{
|
||||
this.cociService = cociService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param multilingualContentService the multilingualContentService to set
|
||||
*/
|
||||
public void setMultilingualContentService(
|
||||
MultilingualContentService multilingualContentService)
|
||||
{
|
||||
this.multilingualContentService = multilingualContentService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param contentFilterLanguagesService The ContentFilterLanguagesService to set.
|
||||
*/
|
||||
public void setContentFilterLanguagesService(ContentFilterLanguagesService contentFilterLanguagesService)
|
||||
{
|
||||
this.contentFilterLanguagesService = contentFilterLanguagesService;
|
||||
}
|
||||
}
|
||||
|
@@ -35,6 +35,10 @@ import javax.faces.model.SelectItem;
|
||||
import org.alfresco.config.Config;
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.i18n.I18NUtil;
|
||||
import org.alfresco.service.cmr.ml.ContentFilterLanguagesService;
|
||||
import org.alfresco.service.cmr.ml.MultilingualContentService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.app.context.UIContextService;
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
@@ -51,7 +55,12 @@ public class UserPreferencesBean
|
||||
private static final String PREF_STARTLOCATION = "start-location";
|
||||
|
||||
private static final String PREF_CONTENTFILTERLANGUAGE = "content-filter-language";
|
||||
private static final String MSG_CONTENTALLLANGUAGES = "content_all_languages";
|
||||
|
||||
/**
|
||||
* Remplacement message for set the filter at 'all languages'.
|
||||
* Must be considered as a null value.
|
||||
*/
|
||||
public static final String MSG_CONTENTALLLANGUAGES = "content_all_languages";
|
||||
|
||||
/** language locale selection */
|
||||
private String language = null;
|
||||
@@ -59,6 +68,14 @@ public class UserPreferencesBean
|
||||
/** content language locale selection */
|
||||
private String contentFilterLanguage = null;
|
||||
|
||||
/** the injected MultilingualContentService */
|
||||
MultilingualContentService multilingualContentService;
|
||||
|
||||
/** the injected ContentFilterLanguagesService */
|
||||
ContentFilterLanguagesService contentFilterLanguagesService;
|
||||
|
||||
/** the injected NodeService */
|
||||
NodeService nodeService;
|
||||
|
||||
/**
|
||||
* @return the list of available languages
|
||||
@@ -66,7 +83,7 @@ public class UserPreferencesBean
|
||||
public SelectItem[] getLanguages()
|
||||
{
|
||||
// Get the item selection list
|
||||
SelectItem[] items = getLanguageItems(false);
|
||||
SelectItem[] items = getLanguageItems();
|
||||
// Change the current language
|
||||
if (this.language == null)
|
||||
{
|
||||
@@ -120,56 +137,134 @@ public class UserPreferencesBean
|
||||
// Null means All Languages
|
||||
if (locale == null)
|
||||
{
|
||||
this.contentFilterLanguage = MSG_CONTENTALLLANGUAGES;
|
||||
this.contentFilterLanguage = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.contentFilterLanguage = locale.toString();
|
||||
}
|
||||
}
|
||||
return (contentFilterLanguage.equals(MSG_CONTENTALLLANGUAGES)) ? null : contentFilterLanguage;
|
||||
|
||||
// set the content filter locale on the core
|
||||
I18NUtil.setContentLocale(I18NUtil.parseLocale(this.contentFilterLanguage));
|
||||
|
||||
return this.contentFilterLanguage;
|
||||
//return (contentFilterLanguage.equals(MSG_CONTENTALLLANGUAGES)) ? "en" : contentFilterLanguage;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param languageStr A valid locale string or {@link #MSG_CONTENTALLLANGUAGES}
|
||||
*/
|
||||
public void setContentFilterLanguage(String languageStr)
|
||||
public void setContentFilterLanguage(String contentFilterLanguage)
|
||||
{
|
||||
this.contentFilterLanguage = languageStr;
|
||||
this.contentFilterLanguage = contentFilterLanguage;
|
||||
Locale language = null;
|
||||
if (languageStr.equals(MSG_CONTENTALLLANGUAGES))
|
||||
if (contentFilterLanguage.equals(MSG_CONTENTALLLANGUAGES))
|
||||
{
|
||||
// The generic "All Languages" was selected - persist this as a null
|
||||
this.contentFilterLanguage = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
// It should be a proper locale string
|
||||
language = I18NUtil.parseLocale(languageStr);
|
||||
language = I18NUtil.parseLocale(contentFilterLanguage);
|
||||
}
|
||||
PreferencesService.getPreferences().setValue(PREF_CONTENTFILTERLANGUAGE, language);
|
||||
|
||||
// set the content filter locale on the core
|
||||
I18NUtil.setContentLocale(language);
|
||||
|
||||
// Ensure a refresh
|
||||
UIContextService.getInstance(FacesContext.getCurrentInstance()).notifyBeans();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list of items for the content filtering language selection
|
||||
* @return list of items for the content filtering language selection include the label 'all langaguages'
|
||||
*/
|
||||
public SelectItem[] getContentFilterLanguages()
|
||||
{
|
||||
// Get the item selection list
|
||||
SelectItem[] items = getLanguageItems(true);
|
||||
|
||||
return items;
|
||||
return getContentFilterLanguages(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param includeAllLanguages if true, the list must include the label 'all languages'
|
||||
* @return list of items for the content filtering language selection
|
||||
*/
|
||||
public SelectItem[] getContentFilterLanguages(boolean includeAllLanguages)
|
||||
{
|
||||
FacesContext fc = FacesContext.getCurrentInstance();
|
||||
ResourceBundle msg = Application.getBundle(fc);
|
||||
|
||||
// get the list of filter languages
|
||||
List<String> languages = contentFilterLanguagesService.getFilterLanguages();
|
||||
|
||||
// set the item selection list
|
||||
SelectItem[] items = new SelectItem[(includeAllLanguages) ? languages.size() + 1 : languages.size()];
|
||||
int idx = 0;
|
||||
|
||||
// include the <All Languages> item if needed
|
||||
if (includeAllLanguages)
|
||||
{
|
||||
String allLanguagesStr = msg.getString(MSG_CONTENTALLLANGUAGES);
|
||||
items[idx] = new SelectItem(MSG_CONTENTALLLANGUAGES, allLanguagesStr);
|
||||
idx++;
|
||||
}
|
||||
|
||||
for(String lang : languages)
|
||||
{
|
||||
String label = contentFilterLanguagesService.getLabelByCode(lang);
|
||||
|
||||
items[idx] = new SelectItem(
|
||||
lang,
|
||||
label);
|
||||
|
||||
idx++;
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* return the list of languages in which the given node hasn't be translated yet.
|
||||
*
|
||||
* @param translation the translatable node ref
|
||||
* @param returnTranslationLanguage if true, return the language of the given translation.
|
||||
* @return the list of languages
|
||||
*/
|
||||
public SelectItem[] getAvailablesContentFilterLanguages(NodeRef translation, boolean returnTranslationLanguage)
|
||||
{
|
||||
// get the list of missing translation of this node
|
||||
List<Locale> missingLocales = multilingualContentService.getMissingTranslations(translation, returnTranslationLanguage);
|
||||
|
||||
// set the item selection list
|
||||
SelectItem[] items = new SelectItem[missingLocales.size()];
|
||||
int idx = 0;
|
||||
|
||||
for(Locale locale : missingLocales)
|
||||
{
|
||||
String label = contentFilterLanguagesService.getLabelByCode(locale.getLanguage());
|
||||
|
||||
items[idx] = new SelectItem(
|
||||
locale.toString(),
|
||||
label);
|
||||
idx++;
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper to return the available language items
|
||||
*
|
||||
* @param includeAllLanguages True to include a marker item for "All Languages"
|
||||
* @return Array of SelectItem objects
|
||||
*/
|
||||
private static SelectItem[] getLanguageItems(boolean includeAllLanguages)
|
||||
private static SelectItem[] getLanguageItems()
|
||||
{
|
||||
FacesContext fc = FacesContext.getCurrentInstance();
|
||||
Config config = Application.getConfigService(fc).getConfig("Languages");
|
||||
@@ -178,11 +273,7 @@ public class UserPreferencesBean
|
||||
|
||||
List<String> languages = langConfig.getLanguages();
|
||||
List<SelectItem> items = new ArrayList<SelectItem>(10);
|
||||
if (includeAllLanguages)
|
||||
{
|
||||
String allLanguagesStr = Application.getMessage(fc, MSG_CONTENTALLLANGUAGES);
|
||||
items.add(new SelectItem(MSG_CONTENTALLLANGUAGES, allLanguagesStr));
|
||||
}
|
||||
|
||||
for (String locale : languages)
|
||||
{
|
||||
// get label associated to the locale
|
||||
@@ -258,4 +349,46 @@ public class UserPreferencesBean
|
||||
{
|
||||
return Application.getClientConfig(FacesContext.getCurrentInstance()).getAllowGuestConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the multilingualContentService
|
||||
*/
|
||||
public MultilingualContentService getMultilingualContentService()
|
||||
{
|
||||
return multilingualContentService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param multilingualContentService the multilingualContentService to set
|
||||
*/
|
||||
public void setMultilingualContentService(
|
||||
MultilingualContentService multilingualContentService)
|
||||
{
|
||||
this.multilingualContentService = multilingualContentService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the nodeService
|
||||
*/
|
||||
public NodeService getNodeService()
|
||||
{
|
||||
return nodeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nodeService the nodeService to set
|
||||
*/
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param contentFilterLanguagesService the contentFilterLanguagesService to set
|
||||
*/
|
||||
public void setContentFilterLanguagesService(
|
||||
ContentFilterLanguagesService contentFilterLanguagesService)
|
||||
{
|
||||
this.contentFilterLanguagesService = contentFilterLanguagesService;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program 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 General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.web.bean.generator;
|
||||
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.component.UISelectItems;
|
||||
import javax.faces.component.UISelectOne;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.model.SelectItem;
|
||||
|
||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
import org.alfresco.web.bean.UserPreferencesBean;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.ui.repo.component.property.PropertySheetItem;
|
||||
import org.alfresco.web.ui.repo.component.property.UIPropertySheet;
|
||||
import org.alfresco.web.ui.repo.converter.LanguageConverter;
|
||||
|
||||
/**
|
||||
* Generates a LANGUAGE selector component.
|
||||
*
|
||||
* @author yanipig
|
||||
*/
|
||||
public class LanguageSelectorGenerator extends BaseComponentGenerator
|
||||
{
|
||||
protected Node node;
|
||||
|
||||
protected UserPreferencesBean userPreferencesBean;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public UIComponent generate(FacesContext context, String id)
|
||||
{
|
||||
UIComponent component = context.getApplication().
|
||||
createComponent(UISelectOne.COMPONENT_TYPE);
|
||||
FacesHelper.setupComponentId(context, component, id);
|
||||
|
||||
// create the list of choices
|
||||
UISelectItems itemsComponent = (UISelectItems)context.getApplication().
|
||||
createComponent("javax.faces.SelectItems");
|
||||
|
||||
itemsComponent.setValue(getLanguageItems());
|
||||
|
||||
// add the items as a child component
|
||||
component.getChildren().add(itemsComponent);
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
protected SelectItem[] getLanguageItems()
|
||||
{
|
||||
SelectItem[] items = userPreferencesBean.getAvailablesContentFilterLanguages(node.getNodeRef(), true);
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected UIComponent createComponent(FacesContext context, UIPropertySheet propertySheet, PropertySheetItem item) {
|
||||
|
||||
this.node = propertySheet.getNode();
|
||||
|
||||
return super.createComponent(context, propertySheet, item);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupConverter(FacesContext context,
|
||||
UIPropertySheet propertySheet, PropertySheetItem property,
|
||||
PropertyDefinition propertyDef, UIComponent component)
|
||||
{
|
||||
createAndSetConverter(context, LanguageConverter.CONVERTER_ID, component);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupMandatoryValidation(FacesContext context,
|
||||
UIPropertySheet propertySheet, PropertySheetItem item,
|
||||
UIComponent component, boolean realTimeChecking, String idSuffix)
|
||||
{
|
||||
// null is may be a right value for a language
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the injected userPreferencesBean
|
||||
*
|
||||
* @param userPreferencesBean
|
||||
*/
|
||||
public void setUserPreferencesBean(UserPreferencesBean userPreferencesBean)
|
||||
{
|
||||
this.userPreferencesBean = userPreferencesBean;
|
||||
}
|
||||
}
|
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program 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 General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.web.bean.generator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.model.SelectItem;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.cmr.ml.ContentFilterLanguagesService;
|
||||
import org.alfresco.service.cmr.ml.MultilingualContentService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
|
||||
|
||||
/**
|
||||
* Generates a LANGUAGE selector component for display a list of language
|
||||
* for a ML container.
|
||||
*
|
||||
* The list of languages must contains the languages of each of this <b>non-empty</b>
|
||||
* translations.
|
||||
*
|
||||
* @author yanipig
|
||||
*/
|
||||
public class MlContainerLanguageSelectorGenerator extends LanguageSelectorGenerator
|
||||
{
|
||||
protected MultilingualContentService multilingualContentService;
|
||||
protected ContentFilterLanguagesService contentFilterLanguagesService;
|
||||
protected NodeService nodeService;
|
||||
|
||||
protected SelectItem[] getLanguageItems()
|
||||
{
|
||||
Map<Locale, NodeRef> translations = multilingualContentService.getTranslations(node.getNodeRef());
|
||||
|
||||
List<SelectItem> items = new ArrayList<SelectItem>();
|
||||
|
||||
for(Map.Entry<Locale, NodeRef> entry : translations.entrySet())
|
||||
{
|
||||
if(!nodeService.hasAspect(entry.getValue(), ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION))
|
||||
{
|
||||
Locale loc = entry.getKey();
|
||||
|
||||
items.add(new SelectItem(
|
||||
loc.getLanguage(),
|
||||
contentFilterLanguagesService.getLabelByCode(loc.toString())));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
SelectItem[] itemsArray = new SelectItem[items.size()];
|
||||
items.toArray(itemsArray);
|
||||
|
||||
return itemsArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the injected contentFilterLanguagesService
|
||||
*
|
||||
* @param contentFilterLanguagesService
|
||||
*/
|
||||
public void setContentFilterLanguagesService(
|
||||
ContentFilterLanguagesService contentFilterLanguagesService)
|
||||
{
|
||||
this.contentFilterLanguagesService = contentFilterLanguagesService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the injected multilingualContentService
|
||||
*
|
||||
* @param multilingualContentService
|
||||
*/
|
||||
public void setMultilingualContentService(
|
||||
MultilingualContentService multilingualContentService)
|
||||
{
|
||||
this.multilingualContentService = multilingualContentService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the injected nodeService
|
||||
*
|
||||
* @param nodeService the nodeService to set
|
||||
*/
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
}
|
@@ -0,0 +1,225 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program 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 General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.web.bean.ml;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.model.SelectItem;
|
||||
|
||||
import org.alfresco.i18n.I18NUtil;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.cmr.ml.MultilingualContentService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.web.app.servlet.DownloadContentServlet;
|
||||
import org.alfresco.web.bean.UserPreferencesBean;
|
||||
import org.alfresco.web.bean.dialog.BaseDialogBean;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
|
||||
/**
|
||||
* Dialog bean to add a new translation without content. I means, a new node is created
|
||||
* but it doesn't content the propertie <code>{http://www.alfresco.org/model/content/1.0}content</code>
|
||||
*
|
||||
* @author yanipig
|
||||
*/
|
||||
public class AddTranslationWithoutContentDialog extends BaseDialogBean
|
||||
{
|
||||
|
||||
public static String LOCALE_REGEX = "%locale%";
|
||||
public static String EMPTY_DOCUMENT_EXTENSION = "." + LOCALE_REGEX + "_properties";
|
||||
|
||||
private MultilingualContentService multilingualContentService;
|
||||
private UserPreferencesBean userPreferencesBean;
|
||||
|
||||
// the translation being to be created
|
||||
protected NodeRef newTranslation;
|
||||
|
||||
private String name;
|
||||
private String title;
|
||||
private String description;
|
||||
private String author;
|
||||
private String language;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void init(Map<String, String> parameters)
|
||||
{
|
||||
super.init(parameters);
|
||||
|
||||
name = null;
|
||||
title = null;
|
||||
description = null;
|
||||
author = null;
|
||||
language = null;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome) throws Exception
|
||||
{
|
||||
// get the reference node
|
||||
NodeRef refNode = this.browseBean.getDocument().getNodeRef();
|
||||
|
||||
// get the required properties to create the new node and to make it multilingual
|
||||
Locale locale = I18NUtil.parseLocale(language);
|
||||
|
||||
// rename the translation like [name].[lang]_properties
|
||||
String extension = EMPTY_DOCUMENT_EXTENSION.replaceAll(LOCALE_REGEX, language);
|
||||
this.name += extension;
|
||||
|
||||
// add the empty translation
|
||||
newTranslation = multilingualContentService.addEmptyTranslation(refNode, name, locale);
|
||||
|
||||
// set the properties
|
||||
nodeService.setProperty(newTranslation, ContentModel.PROP_DESCRIPTION, description);
|
||||
nodeService.setProperty(newTranslation, ContentModel.PROP_AUTHOR, author);
|
||||
nodeService.setProperty(newTranslation, ContentModel.PROP_TITLE, title);
|
||||
|
||||
// set the current browse node
|
||||
Node browse = new Node(newTranslation);
|
||||
|
||||
// get the content data of the pivot translation
|
||||
NodeRef pivot = multilingualContentService.getPivotTranslation(refNode);
|
||||
|
||||
Map<String, Object> browseProp = browse.getProperties();
|
||||
browseProp.put("size", 0);
|
||||
browseProp.put("mimetype", extension);
|
||||
browseProp.put("fileType32", Utils.getFileTypeImage(name, false));
|
||||
browseProp.put("url", DownloadContentServlet.generateDownloadURL(pivot, name));
|
||||
|
||||
this.browseBean.setDocument(browse);
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param userPreferencesBean the userPreferencesBean to set
|
||||
*/
|
||||
public void setUserPreferencesBean(UserPreferencesBean userPreferencesBean)
|
||||
{
|
||||
this.userPreferencesBean = userPreferencesBean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param multilingualContentService the multilingualContentService to set
|
||||
*/
|
||||
public void setMultilingualContentService(
|
||||
MultilingualContentService multilingualContentService)
|
||||
{
|
||||
this.multilingualContentService = multilingualContentService;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the author
|
||||
*/
|
||||
public String getAuthor()
|
||||
{
|
||||
return author;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param author the author to set
|
||||
*/
|
||||
public void setAuthor(String author)
|
||||
{
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the description
|
||||
*/
|
||||
public String getDescription()
|
||||
{
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param description the description to set
|
||||
*/
|
||||
public void setDescription(String description)
|
||||
{
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the language
|
||||
*/
|
||||
public String getLanguage()
|
||||
{
|
||||
return language;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param language the language to set
|
||||
*/
|
||||
public void setLanguage(String language)
|
||||
{
|
||||
this.language = language;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name the name to set
|
||||
*/
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the title
|
||||
*/
|
||||
public String getTitle()
|
||||
{
|
||||
return title;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param title the title to set
|
||||
*/
|
||||
public void setTitle(String title)
|
||||
{
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the unusedLanguages
|
||||
*/
|
||||
public SelectItem[] getUnusedLanguages()
|
||||
{
|
||||
return userPreferencesBean.getAvailablesContentFilterLanguages(this.browseBean.getDocument().getNodeRef(), false);
|
||||
}
|
||||
}
|
211
source/java/org/alfresco/web/bean/ml/AddTranslationlDialog.java
Normal file
211
source/java/org/alfresco/web/bean/ml/AddTranslationlDialog.java
Normal file
@@ -0,0 +1,211 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program 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 General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.web.bean.ml;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.model.SelectItem;
|
||||
|
||||
import org.alfresco.i18n.I18NUtil;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.cmr.ml.MultilingualContentService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.web.bean.UserPreferencesBean;
|
||||
import org.alfresco.web.bean.content.AddContentDialog;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
|
||||
/**
|
||||
* Dialog bean to upload a new document and to add it to an existing MLContainer.
|
||||
*
|
||||
* @author yanipig
|
||||
*/
|
||||
public class AddTranslationlDialog extends AddContentDialog
|
||||
{
|
||||
|
||||
private MultilingualContentService multilingualContentService;
|
||||
private UserPreferencesBean userPreferencesBean;
|
||||
|
||||
// the multilingual container where to add this translation
|
||||
protected NodeRef mlContainer;
|
||||
|
||||
// Locale of the new translation
|
||||
private String language;
|
||||
|
||||
// languages available in the ML container yet
|
||||
private SelectItem[] unusedLanguages;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.web.bean.content.AddContentDialog#init(java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public void init(Map<String, String> parameters)
|
||||
{
|
||||
super.init(parameters);
|
||||
|
||||
this.language = null;
|
||||
setMlContainer(this.browseBean.getDocument().getNodeRef());
|
||||
setFileName(null);
|
||||
unusedLanguages = null;
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.web.bean.content.AddContentDialog#finishImpl(javax.faces.context.FacesContext, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome) throws Exception
|
||||
{
|
||||
|
||||
// add the new file to the repository
|
||||
outcome = super.finishImpl(context, outcome);
|
||||
|
||||
// add a new translation
|
||||
multilingualContentService.addTranslation(this.createdNode, this.mlContainer, I18NUtil.parseLocale(this.language));
|
||||
|
||||
this.browseBean.setDocument(new Node(this.createdNode));
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultFinishOutcome()
|
||||
{
|
||||
|
||||
return "showDocDetails";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String cancel()
|
||||
{
|
||||
super.cancel();
|
||||
|
||||
return getDefaultFinishOutcome();
|
||||
}
|
||||
|
||||
public boolean finishButtonDisabled()
|
||||
{
|
||||
return author == null || author.length() < 1 || language == null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the locale of this new translation
|
||||
*/
|
||||
public String getLanguage()
|
||||
{
|
||||
return language;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param language the locale of this new translation
|
||||
*/
|
||||
public void setLanguage(String language)
|
||||
{
|
||||
this.language = language;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the Multilingual container where the translation will be associated
|
||||
*/
|
||||
public NodeRef getMlContainer()
|
||||
{
|
||||
return mlContainer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Multilingual container where the translation will be associated.
|
||||
*
|
||||
* @param mlContainer mlContainer is a MLDocument, the the MLContainer will
|
||||
* become it's own MLContainer
|
||||
*/
|
||||
public void setMlContainer(NodeRef mlContainer)
|
||||
{
|
||||
QName type = null;
|
||||
|
||||
if(mlContainer != null)
|
||||
{
|
||||
type = nodeService.getType(mlContainer);
|
||||
|
||||
if(ContentModel.TYPE_MULTILINGUAL_CONTAINER.equals(type)){
|
||||
this.mlContainer = mlContainer;
|
||||
}
|
||||
else if(ContentModel.TYPE_CONTENT.equals(type)
|
||||
&& nodeService.hasAspect(mlContainer, ContentModel.ASPECT_MULTILINGUAL_DOCUMENT)){
|
||||
|
||||
this.mlContainer = multilingualContentService.getTranslationContainer(mlContainer);
|
||||
}
|
||||
else{
|
||||
this.mlContainer = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param unusedLanguages
|
||||
*/
|
||||
public void setUnusedLanguages(SelectItem[] unusedLanguages)
|
||||
{
|
||||
this.unusedLanguages = unusedLanguages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method calls by the dialog to limit the list of languages.
|
||||
*
|
||||
* @return the list of availables translation in the MLContainer
|
||||
*/
|
||||
|
||||
public SelectItem[] getUnusedLanguages()
|
||||
{
|
||||
|
||||
if(unusedLanguages == null)
|
||||
{
|
||||
unusedLanguages = userPreferencesBean.getAvailablesContentFilterLanguages(getMlContainer(), false);
|
||||
}
|
||||
|
||||
return unusedLanguages;
|
||||
}
|
||||
|
||||
public MultilingualContentService getMultilingualContentService()
|
||||
{
|
||||
return multilingualContentService;
|
||||
}
|
||||
|
||||
public void setMultilingualContentService(
|
||||
MultilingualContentService multilingualContentService)
|
||||
{
|
||||
this.multilingualContentService = multilingualContentService;
|
||||
}
|
||||
|
||||
public UserPreferencesBean getUserPreferencesBean()
|
||||
{
|
||||
return userPreferencesBean;
|
||||
}
|
||||
|
||||
public void setUserPreferencesBean(UserPreferencesBean userPreferencesBean)
|
||||
{
|
||||
this.userPreferencesBean = userPreferencesBean;
|
||||
}
|
||||
}
|
140
source/java/org/alfresco/web/bean/ml/EditMLContainerDialog.java
Normal file
140
source/java/org/alfresco/web/bean/ml/EditMLContainerDialog.java
Normal file
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program 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 General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.web.bean.ml;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.service.cmr.ml.MultilingualContentService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.dialog.BaseDialogBean;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
|
||||
/**
|
||||
* Dialog bean to edit an existing multilingual container.
|
||||
*
|
||||
* @author yanipig
|
||||
*/
|
||||
public class EditMLContainerDialog extends BaseDialogBean
|
||||
{
|
||||
|
||||
MultilingualContentService multilingualContentService;
|
||||
|
||||
private Node editableNode;
|
||||
|
||||
@Override
|
||||
public void init(Map<String, String> parameters)
|
||||
{
|
||||
super.init(parameters);
|
||||
|
||||
this.editableNode = initEditableNode();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getFinishButtonDisabled()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String getFinishButtonLabel()
|
||||
{
|
||||
return Application.getMessage(FacesContext.getCurrentInstance(), "ok");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome) throws Exception
|
||||
{
|
||||
// get the container node ref
|
||||
NodeRef container = editableNode.getNodeRef();
|
||||
|
||||
// get the modified properties
|
||||
Map<String, Object> editProperties = this.editableNode.getProperties();
|
||||
|
||||
// modify the properties of the container with the user modified properties
|
||||
for(Map.Entry<String, Object> entry : editProperties.entrySet())
|
||||
{
|
||||
QName qname = QName.createQName(entry.getKey());
|
||||
|
||||
nodeService.setProperty(container, qname, (Serializable) entry.getValue());
|
||||
}
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
/**
|
||||
* Init the editable Node
|
||||
*/
|
||||
protected Node initEditableNode()
|
||||
{
|
||||
return new Node(
|
||||
multilingualContentService.getTranslationContainer(
|
||||
this.browseBean.getDocument().getNodeRef())
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the editableNode
|
||||
*/
|
||||
public Node getEditableNode() {
|
||||
return editableNode;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String doPostCommitProcessing(FacesContext context, String outcome)
|
||||
{
|
||||
this.browseBean.getDocument().reset();
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Bean getters and setters
|
||||
|
||||
/**
|
||||
* @return the multilingualContentService
|
||||
*/
|
||||
public MultilingualContentService getMultilingualContentService() {
|
||||
return multilingualContentService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param multilingualContentService the multilingualContentService to set
|
||||
*/
|
||||
public void setMultilingualContentService(
|
||||
MultilingualContentService multilingualContentService) {
|
||||
this.multilingualContentService = multilingualContentService;
|
||||
}
|
||||
|
||||
|
||||
}
|
288
source/java/org/alfresco/web/bean/ml/MakeMultilingualDialog.java
Normal file
288
source/java/org/alfresco/web/bean/ml/MakeMultilingualDialog.java
Normal file
@@ -0,0 +1,288 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program 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 General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.web.bean.ml;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.model.SelectItem;
|
||||
|
||||
import org.alfresco.i18n.I18NUtil;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.cmr.ml.MultilingualContentService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
import org.alfresco.web.bean.UserPreferencesBean;
|
||||
import org.alfresco.web.bean.dialog.BaseDialogBean;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
|
||||
/**
|
||||
* Dialog bean to make a node multilingual
|
||||
*
|
||||
* @author yanipig
|
||||
*/
|
||||
public class MakeMultilingualDialog extends BaseDialogBean
|
||||
{
|
||||
|
||||
private MultilingualContentService multilingualContentService;
|
||||
|
||||
private UserPreferencesBean userPreferencesBean;
|
||||
|
||||
/** if needed, add a new translation with content after this dialog closed */
|
||||
public static final String OPT_ADD_WITH_CONTENT = "ADD_WITH_CONTENT";
|
||||
/** if needed, add a new translation without content after this dialog closed */
|
||||
public static final String OPT_ADD_WITHOUT_CONTENT = "ADD_WITHOUT_CONTENT";
|
||||
|
||||
// The author is a mandatory properties
|
||||
private String author;
|
||||
|
||||
// The langage of the node to make multilingual
|
||||
private String language;
|
||||
|
||||
// set to true, a new translation will be added at the end of this dialog
|
||||
private boolean addTranslationAfter = true;
|
||||
|
||||
// set if the new translation to add will be an empty document or not
|
||||
private String addingMode = OPT_ADD_WITH_CONTENT;
|
||||
|
||||
// the node to edit
|
||||
protected Node editableNode;
|
||||
|
||||
@Override
|
||||
public void init(Map<String, String> parameters)
|
||||
{
|
||||
super.init(parameters);
|
||||
|
||||
// setup the editable node
|
||||
this.editableNode = initEditableNode();
|
||||
|
||||
NodeRef nodeRef = this.editableNode.getNodeRef();
|
||||
|
||||
// propose the author and the language of the content for the properties of the MLContainer
|
||||
if(this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_AUTHOR) == true
|
||||
&& this.nodeService.getProperty(nodeRef, ContentModel.PROP_AUTHOR) != null)
|
||||
{
|
||||
setAuthor((String) this.nodeService.getProperty(nodeRef, ContentModel.PROP_AUTHOR));
|
||||
}
|
||||
else
|
||||
{
|
||||
setAuthor("");
|
||||
}
|
||||
|
||||
if(this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_LOCALIZED) == true
|
||||
&& this.nodeService.getProperty(nodeRef, ContentModel.PROP_LOCALE) != null)
|
||||
{
|
||||
setLanguage(((Locale) this.nodeService.getProperty(nodeRef, ContentModel.PROP_LOCALE)).toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
setLanguage(null);
|
||||
}
|
||||
|
||||
addTranslationAfter = false;
|
||||
addingMode = OPT_ADD_WITH_CONTENT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Init the editable Node
|
||||
*/
|
||||
protected Node initEditableNode()
|
||||
{
|
||||
return new Node(this.browseBean.getDocument().getNodeRef());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.web.bean.dialog.BaseDialogBean#finishImpl(javax.faces.context.FacesContext, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome) throws Exception
|
||||
{
|
||||
Locale loc = I18NUtil.parseLocale(getLanguage());
|
||||
|
||||
NodeRef nodeRef = this.editableNode.getNodeRef();
|
||||
|
||||
// make this node multilingual
|
||||
NodeRef mlContainer = multilingualContentService.makeTranslation(nodeRef, loc);
|
||||
|
||||
// set the local of the current node.
|
||||
nodeService.setProperty(nodeRef, ContentModel.PROP_LOCALE, getLanguage());
|
||||
|
||||
// if the author of the node is not set, set it with the default author name of
|
||||
// the new ML Container
|
||||
String nodeAuthor = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_AUTHOR);
|
||||
if(nodeAuthor == null || nodeAuthor.length() < 1)
|
||||
nodeService.setProperty(nodeRef, ContentModel.PROP_AUTHOR, getAuthor());
|
||||
|
||||
// set properties of the ml container
|
||||
nodeService.setProperty(mlContainer, ContentModel.PROP_AUTHOR, getAuthor());
|
||||
nodeService.setProperty(mlContainer, ContentModel.PROP_LOCALE, getLanguage());
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.web.bean.dialog.BaseDialogBean#doPostCommitProcessing(javax.faces.context.FacesContext, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
protected String doPostCommitProcessing(FacesContext context, String outcome)
|
||||
{
|
||||
// reset the document held by the browse bean as it's just been updated
|
||||
this.browseBean.getDocument().reset();
|
||||
|
||||
// go to the set add translation dialog if asked
|
||||
// to otherwise just return
|
||||
if (this.addTranslationAfter)
|
||||
{
|
||||
if(addingMode.equalsIgnoreCase(OPT_ADD_WITHOUT_CONTENT))
|
||||
{
|
||||
return "dialog:addTranslationWithoutContent";
|
||||
}
|
||||
else
|
||||
{
|
||||
AddTranslationlDialog dialog = (AddTranslationlDialog) FacesHelper.getManagedBean(FacesContext.getCurrentInstance(), "AddTranslationDialog");
|
||||
dialog.start(null);
|
||||
return "addTranslation";
|
||||
}
|
||||
}
|
||||
// close the dialog
|
||||
return outcome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getFinishButtonDisabled()
|
||||
{
|
||||
return !(author != null && author.length() > 0 && language != null);
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Bean getters and setters
|
||||
|
||||
/**
|
||||
* Returns the node being edited
|
||||
*
|
||||
* @return The node being edited
|
||||
*/
|
||||
public Node getEditableNode()
|
||||
{
|
||||
return this.editableNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the author of the new created MLContainer
|
||||
*/
|
||||
public String getAuthor()
|
||||
{
|
||||
return author;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param author the author of new created MLContainer
|
||||
*/
|
||||
public void setAuthor(String author)
|
||||
{
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return if a new translation must be added after this dialog closes
|
||||
*/
|
||||
public boolean isAddTranslationAfter()
|
||||
{
|
||||
return addTranslationAfter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param addTranslationAfter set to true, a new translation will be added after this dialog closes
|
||||
*/
|
||||
public void setAddTranslationAfter(boolean addTranslationAfter)
|
||||
{
|
||||
this.addTranslationAfter = addTranslationAfter;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the language of the translation
|
||||
*/
|
||||
public String getLanguage()
|
||||
{
|
||||
return language;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param language the language of the translation
|
||||
*/
|
||||
public void setLanguage(String language)
|
||||
{
|
||||
this.language = language;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param editableNode the node will become a multilingual
|
||||
*/
|
||||
public void setEditableNode(Node editableNode)
|
||||
{
|
||||
this.editableNode = editableNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return if the new translation must be added at the end of this dialog,
|
||||
* this mode defines if the translation will be an empty document or not
|
||||
*/
|
||||
public String getAddingMode() {
|
||||
return addingMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param addingMode if the new translation must be added at the end of this dialog,
|
||||
* this mode defines if the translation will be an empty document or not
|
||||
*/
|
||||
public void setAddingMode(String addingMode) {
|
||||
this.addingMode = addingMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the complete list of available languages for the multilinguism
|
||||
*/
|
||||
public SelectItem[] getFilterLanguages()
|
||||
{
|
||||
return userPreferencesBean.getContentFilterLanguages(false);
|
||||
}
|
||||
|
||||
public void setMultilingualContentService(
|
||||
MultilingualContentService multilingualContentService)
|
||||
{
|
||||
this.multilingualContentService = multilingualContentService;
|
||||
}
|
||||
|
||||
public void setUserPreferencesBean(UserPreferencesBean userPreferencesBean)
|
||||
{
|
||||
this.userPreferencesBean = userPreferencesBean;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program 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 General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.web.bean.spaces;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.web.app.AlfrescoNavigationHandler;
|
||||
import org.alfresco.web.app.Application;
|
||||
|
||||
|
||||
public class CreateMultilingualPropertiesDialog extends CreateMultilingualPropertiesWizard
|
||||
{
|
||||
// ------------------------------------------------------------------------------
|
||||
// Wizard implementation
|
||||
|
||||
@Override
|
||||
public String getFinishButtonLabel()
|
||||
{
|
||||
return Application.getMessage(FacesContext.getCurrentInstance(), "create_multilingual_space");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultCancelOutcome()
|
||||
{
|
||||
return AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME + AlfrescoNavigationHandler.OUTCOME_SEPARATOR + "browse";
|
||||
|
||||
// return AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultFinishOutcome()
|
||||
{
|
||||
// return AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME + AlfrescoNavigationHandler.OUTCOME_SEPARATOR + "browse";
|
||||
|
||||
return AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME;
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected String doPostCommitProcessing(FacesContext context, String outcome)
|
||||
{
|
||||
// do nothing by default, subclasses can override if necessary
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,160 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program 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 General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.web.bean.spaces;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.i18n.I18NUtil;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.node.MLPropertyInterceptor;
|
||||
import org.alfresco.service.cmr.repository.MLText;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.util.PropertyMap;
|
||||
import org.alfresco.web.app.AlfrescoNavigationHandler;
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
import org.alfresco.web.bean.CreateMultilingualPropertiesBean;
|
||||
import org.alfresco.web.bean.UserPreferencesBean;
|
||||
|
||||
public class CreateMultilingualPropertiesWizard extends CreateSpaceWizard
|
||||
{
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome) throws Exception
|
||||
{
|
||||
MLText title, description;
|
||||
|
||||
// bind to the bean
|
||||
CreateMultilingualPropertiesBean createMultilingualPropertiesBean = (CreateMultilingualPropertiesBean) FacesHelper.getManagedBean(context, "CreateMultilingualPropertiesBean");
|
||||
UserPreferencesBean userPreferencesBean = (UserPreferencesBean) FacesHelper.getManagedBean(context, "UserPreferencesBean");
|
||||
|
||||
if (this.createFrom.equals("scratch"))
|
||||
{
|
||||
// create the space (just create a folder for now)
|
||||
NodeRef nodeRef = this.browseBean.getDocument().getNodeRef();
|
||||
// Add aspect (PropertyMap is a extension of HashMap with key LOCALE)
|
||||
PropertyMap properties = new PropertyMap();
|
||||
|
||||
// Modification du casting de l objet r<>cup<75>r<EFBFBD> des getters de MLText en Text
|
||||
MLPropertyInterceptor.setMLAware(true);
|
||||
|
||||
// MLText is a HashMap composed by key and description The Function addValue is the same that the function put() but the key is the Locale value
|
||||
Serializable oTitle = nodeService.getProperty(nodeRef, ContentModel.PROP_TITLE);
|
||||
Serializable oDescription = nodeService.getProperty(nodeRef, ContentModel.PROP_DESCRIPTION);
|
||||
|
||||
|
||||
if(oTitle instanceof MLText)
|
||||
{
|
||||
title = (MLText) oTitle;
|
||||
}
|
||||
else
|
||||
{
|
||||
title = new MLText();
|
||||
title.addValue(I18NUtil.parseLocale(userPreferencesBean.getContentFilterLanguage()), oTitle.toString());
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(oDescription instanceof MLText)
|
||||
{
|
||||
description = (MLText) oDescription;
|
||||
}
|
||||
else
|
||||
{
|
||||
description = new MLText();
|
||||
title.addValue(I18NUtil.parseLocale(userPreferencesBean.getContentFilterLanguage()), oDescription.toString());
|
||||
}
|
||||
|
||||
title.addValue(I18NUtil.parseLocale(createMultilingualPropertiesBean.getNewlanguage()), createMultilingualPropertiesBean.getTitle());
|
||||
description.addValue(I18NUtil.parseLocale(createMultilingualPropertiesBean.getNewlanguage()), createMultilingualPropertiesBean.getDescription());
|
||||
|
||||
properties.put(ContentModel.PROP_TITLE, title);
|
||||
properties.put(ContentModel.PROP_DESCRIPTION, description);
|
||||
|
||||
|
||||
// Ajout de l'aspect multilingue sur le titre
|
||||
this.nodeService.addAspect(nodeRef, ContentModel.ASPECT_TITLED, properties);
|
||||
/*
|
||||
MLText descriptionss = (MLText) nodeService.getProperty(nodeRef, ContentModel.PROP_DESCRIPTION);
|
||||
|
||||
List<SelectItem> sel = new ArrayList();
|
||||
|
||||
for(Map.Entry<Locale, String> dd : descriptionss.entrySet())
|
||||
{
|
||||
sel.add(new SelectItem(dd.getKey().toString(), dd.getValue()));
|
||||
}
|
||||
|
||||
SelectItem[] items = new SelectItem[sel.size()];
|
||||
sel.toArray(items);
|
||||
*/
|
||||
// Modification du casting de l objet r<>cup<75>r<EFBFBD> des getters de MLText en Text
|
||||
MLPropertyInterceptor.setMLAware(false);
|
||||
}
|
||||
else if (this.createFrom.equals("existing"))
|
||||
{
|
||||
}
|
||||
else if (this.createFrom.equals("template"))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
if (createMultilingualPropertiesBean.isAdd_new_properties())
|
||||
{
|
||||
createMultilingualPropertiesBean.setTitle("");
|
||||
createMultilingualPropertiesBean.setDescription("");
|
||||
createMultilingualPropertiesBean.setAdd_new_properties(false);
|
||||
|
||||
return "dialog:createMultilingualProperties";
|
||||
}
|
||||
else
|
||||
{
|
||||
return AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME + AlfrescoNavigationHandler.OUTCOME_SEPARATOR + "browse";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param preferences The UserPreferencesBean to set
|
||||
*/
|
||||
public void setUserPreferencesBean(UserPreferencesBean preferences)
|
||||
{
|
||||
this.preferences = preferences;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the preferences of the user
|
||||
*/
|
||||
public UserPreferencesBean getUserPreferencesBean()
|
||||
{
|
||||
return preferences;
|
||||
}
|
||||
|
||||
|
||||
/** The user preferences bean reference */
|
||||
protected UserPreferencesBean preferences;
|
||||
protected CreateMultilingualPropertiesBean createMultilingualPropertiesBean;
|
||||
}
|
||||
|
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program 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 General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.web.bean.spaces;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.web.app.AlfrescoNavigationHandler;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.CreateMultilingualPropertiesBean;
|
||||
|
||||
public class CreateMultilingualSpaceDialog extends CreateMultilingualSpaceWizard
|
||||
{
|
||||
// ------------------------------------------------------------------------------
|
||||
// Wizard implementation
|
||||
|
||||
@Override
|
||||
public String getFinishButtonLabel()
|
||||
{
|
||||
return Application.getMessage(FacesContext.getCurrentInstance(), "create_multilingual_space");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultCancelOutcome()
|
||||
{
|
||||
return AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultFinishOutcome()
|
||||
{
|
||||
return AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME;
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected String doPostCommitProcessing(FacesContext context, String outcome)
|
||||
{
|
||||
// do nothing by default, subclasses can override if necessary
|
||||
if(isEdit())
|
||||
{
|
||||
return "dialog:createMultilingualProperties";
|
||||
}
|
||||
else
|
||||
{
|
||||
return AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setCreateMultilingualPropertiesBean(CreateMultilingualPropertiesBean x)
|
||||
{
|
||||
this.createMultilingualPropertiesBean = x;
|
||||
}
|
||||
|
||||
public boolean isEdit()
|
||||
{
|
||||
return this.edit;
|
||||
}
|
||||
|
||||
public void setEdit(boolean x)
|
||||
{
|
||||
this.edit=x;
|
||||
}
|
||||
|
||||
|
||||
private boolean edit;
|
||||
|
||||
public CreateMultilingualPropertiesBean getCreateMultilingualPropertiesBean(){return this.createMultilingualPropertiesBean;}
|
||||
|
||||
protected CreateMultilingualPropertiesBean createMultilingualPropertiesBean;
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,224 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program 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 General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.web.bean.spaces;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.i18n.I18NUtil;
|
||||
import org.alfresco.model.ApplicationModel;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.repository.MLText;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.DynamicNamespacePrefixResolver;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
import org.alfresco.web.bean.CreateMultilingualPropertiesBean;
|
||||
import org.alfresco.web.bean.UserPreferencesBean;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
|
||||
|
||||
public class CreateMultilingualSpaceWizard extends CreateSpaceWizard
|
||||
{
|
||||
|
||||
protected boolean showOtherProperties = true;
|
||||
|
||||
|
||||
/**
|
||||
* @return Determines whether the edit properties dialog should be
|
||||
* shown when this one ends
|
||||
*/
|
||||
public boolean isShowOtherProperties()
|
||||
{
|
||||
return this.showOtherProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param showOthers Sets whether the edit properties dialog is shown
|
||||
*/
|
||||
public void setShowOtherProperties(boolean showOthers)
|
||||
{
|
||||
this.showOtherProperties = showOthers;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome) throws Exception
|
||||
{
|
||||
String newSpaceId = null;
|
||||
CreateMultilingualPropertiesBean createMultilingualPropertiesBean = (CreateMultilingualPropertiesBean) FacesHelper.getManagedBean(context, "CreateMultilingualPropertiesBean");
|
||||
|
||||
|
||||
if (this.createFrom.equals("scratch"))
|
||||
{
|
||||
// create the space (just create a folder for now)
|
||||
NodeRef parentNodeRef;
|
||||
|
||||
String nodeId = this.navigator.getCurrentNodeId();
|
||||
|
||||
if (nodeId == null)
|
||||
{
|
||||
parentNodeRef = this.nodeService.getRootNode(Repository.getStoreRef());
|
||||
}
|
||||
else
|
||||
{
|
||||
parentNodeRef = new NodeRef(Repository.getStoreRef(), nodeId);
|
||||
}
|
||||
|
||||
|
||||
FileInfo fileInfo = fileFolderService.create(parentNodeRef, this.name, Repository.resolveToQName(this.spaceType));
|
||||
NodeRef nodeRef = fileInfo.getNodeRef();
|
||||
newSpaceId = nodeRef.getId();
|
||||
|
||||
// apply the uifacets aspect - icon, title and description props
|
||||
Map<QName, Serializable> uiFacetsProps = new HashMap<QName, Serializable>(5);
|
||||
|
||||
uiFacetsProps.put(ApplicationModel.PROP_ICON, this.icon);
|
||||
// uiFacetsProps.put(ContentModel.PROP_TITLE, this.title);
|
||||
// uiFacetsProps.put(ContentModel.PROP_DESCRIPTION, this.description);
|
||||
|
||||
|
||||
// Ajout de l icone
|
||||
this.nodeService.addAspect(nodeRef, ApplicationModel.ASPECT_UIFACETS, uiFacetsProps);
|
||||
|
||||
Locale language = I18NUtil.parseLocale(createMultilingualPropertiesBean.getNewlanguage());
|
||||
|
||||
this.nodeService.setProperty(nodeRef, ContentModel.PROP_TITLE, new MLText(language, this.title));
|
||||
this.nodeService.setProperty(nodeRef, ContentModel.PROP_DESCRIPTION, new MLText(language, this.description));
|
||||
|
||||
|
||||
// remember the created node
|
||||
this.createdNode = nodeRef;
|
||||
// Passer le noeud en parametre afin de le recuperer dans un autre dialogue
|
||||
this.browseBean.setDocument(new Node(this.createdNode));
|
||||
|
||||
setTitle(""); setDescription(""); setName("");
|
||||
}
|
||||
else if (this.createFrom.equals("existing"))
|
||||
{
|
||||
// copy the selected space and update the name, description and icon
|
||||
NodeRef sourceNode = this.existingSpaceId;
|
||||
NodeRef parentSpace = new NodeRef(Repository.getStoreRef(), this.navigator.getCurrentNodeId());
|
||||
|
||||
// copy from existing
|
||||
NodeRef copiedNode = this.fileFolderService.copy(sourceNode, parentSpace, this.name).getNodeRef();
|
||||
|
||||
Locale usrLocale = I18NUtil.parseLocale(getUserPreferencesBean().getContentFilterLanguage());
|
||||
|
||||
// also need to set the new title, description and icon properties
|
||||
|
||||
this.nodeService.setProperty(copiedNode, ContentModel.PROP_TITLE, new MLText(usrLocale, this.title));
|
||||
this.nodeService.setProperty(copiedNode, ContentModel.PROP_DESCRIPTION, new MLText(usrLocale, this.description));
|
||||
this.nodeService.setProperty(copiedNode, ApplicationModel.PROP_ICON, this.icon);
|
||||
|
||||
newSpaceId = copiedNode.getId();
|
||||
|
||||
// remember the created node
|
||||
this.createdNode = copiedNode;
|
||||
}
|
||||
else if (this.createFrom.equals("template"))
|
||||
{
|
||||
// copy the selected space and update the name, description and icon
|
||||
NodeRef sourceNode = new NodeRef(Repository.getStoreRef(), this.templateSpaceId);
|
||||
NodeRef parentSpace = new NodeRef(Repository.getStoreRef(), this.navigator.getCurrentNodeId());
|
||||
|
||||
// copy from the template
|
||||
NodeRef copiedNode = this.fileFolderService.copy(sourceNode, parentSpace, this.name).getNodeRef();
|
||||
// also need to set the new title, description and icon properties
|
||||
this.nodeService.setProperty(copiedNode, ContentModel.PROP_TITLE, this.title);
|
||||
this.nodeService.setProperty(copiedNode, ContentModel.PROP_DESCRIPTION, this.description);
|
||||
this.nodeService.setProperty(copiedNode, ApplicationModel.PROP_ICON, this.icon);
|
||||
|
||||
newSpaceId = copiedNode.getId();
|
||||
|
||||
|
||||
// remember the created node
|
||||
this.createdNode = copiedNode;
|
||||
}
|
||||
|
||||
// if the user selected to save the space as a template space copy the new
|
||||
// space to the templates folder
|
||||
if (this.saveAsTemplate)
|
||||
{
|
||||
// get hold of the Templates node
|
||||
DynamicNamespacePrefixResolver namespacePrefixResolver = new DynamicNamespacePrefixResolver(null);
|
||||
namespacePrefixResolver.registerNamespace(NamespaceService.APP_MODEL_PREFIX, NamespaceService.APP_MODEL_1_0_URI);
|
||||
|
||||
String xpath = Application.getRootPath(FacesContext.getCurrentInstance()) + "/" +
|
||||
Application.getGlossaryFolderName(FacesContext.getCurrentInstance()) + "/" +
|
||||
Application.getSpaceTemplatesFolderName(FacesContext.getCurrentInstance());
|
||||
|
||||
NodeRef rootNodeRef = this.nodeService.getRootNode(Repository.getStoreRef());
|
||||
List<NodeRef> templateNodeList = this.searchService.selectNodes(
|
||||
rootNodeRef,
|
||||
xpath, null, namespacePrefixResolver, false);
|
||||
if (templateNodeList.size() == 1)
|
||||
{
|
||||
// get the first item in the list as we from test above there is only one!
|
||||
NodeRef templateNode = templateNodeList.get(0);
|
||||
NodeRef sourceNode = new NodeRef(Repository.getStoreRef(), newSpaceId);
|
||||
// copy this to the template location
|
||||
fileFolderService.copy(sourceNode, templateNode, this.templateName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param preferences The UserPreferencesBean to set
|
||||
*/
|
||||
public void setUserPreferencesBean(UserPreferencesBean preferences)
|
||||
{
|
||||
this.preferences = preferences;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the preferences of the user
|
||||
*/
|
||||
public UserPreferencesBean getUserPreferencesBean()
|
||||
{
|
||||
return preferences;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** The user preferences bean reference */
|
||||
protected UserPreferencesBean preferences;
|
||||
protected CreateMultilingualPropertiesBean createMultilingualPropertiesBean;
|
||||
}
|
||||
|
@@ -15,11 +15,11 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.web.bean.spaces;
|
||||
@@ -60,7 +60,7 @@ import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Bean responsible for the create space wizard
|
||||
*
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class CreateSpaceWizard extends BaseWizardBean
|
||||
@@ -68,7 +68,7 @@ public class CreateSpaceWizard extends BaseWizardBean
|
||||
public static final String DEFAULT_SPACE_ICON_NAME = "space-icon-default";
|
||||
public static final String DEFAULT_SPACE_ICON_PATH = "";
|
||||
public static final String DEFAULT_SPACE_TYPE_ICON_PATH = "/images/icons/space.gif";
|
||||
|
||||
|
||||
private static Log logger = LogFactory.getLog(CreateSpaceWizard.class);
|
||||
|
||||
protected String spaceType;
|
||||
@@ -85,27 +85,27 @@ public class CreateSpaceWizard extends BaseWizardBean
|
||||
protected List<SelectItem> templates;
|
||||
protected List<UIListItem> folderTypes;
|
||||
protected List<UIDescription> folderTypeDescriptions;
|
||||
|
||||
|
||||
// the NodeRef of the node created during finish
|
||||
protected NodeRef createdNode;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Wizard implementation
|
||||
|
||||
|
||||
/**
|
||||
* Initialises the wizard
|
||||
*/
|
||||
public void init(Map<String, String> parameters)
|
||||
{
|
||||
super.init(parameters);
|
||||
|
||||
|
||||
// clear the cached query results
|
||||
if (this.templates != null)
|
||||
{
|
||||
this.templates.clear();
|
||||
this.templates = null;
|
||||
}
|
||||
|
||||
|
||||
// reset all variables
|
||||
this.createFrom = "scratch";
|
||||
this.spaceType = ContentModel.TYPE_FOLDER.toString();
|
||||
@@ -119,7 +119,7 @@ public class CreateSpaceWizard extends BaseWizardBean
|
||||
this.templateName = null;
|
||||
this.saveAsTemplate = false;
|
||||
}
|
||||
|
||||
|
||||
public String next()
|
||||
{
|
||||
// if the user has chosen to create the space from an existing
|
||||
@@ -134,15 +134,15 @@ public class CreateSpaceWizard extends BaseWizardBean
|
||||
NodeRef templateNode = new NodeRef(Repository.getStoreRef(), this.templateSpaceId);
|
||||
this.spaceType = this.nodeService.getType(templateNode).toString();
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome) throws Exception
|
||||
{
|
||||
String newSpaceId = null;
|
||||
|
||||
|
||||
if (this.createFrom.equals("scratch"))
|
||||
{
|
||||
// create the space (just create a folder for now)
|
||||
@@ -156,14 +156,14 @@ public class CreateSpaceWizard extends BaseWizardBean
|
||||
{
|
||||
parentNodeRef = new NodeRef(Repository.getStoreRef(), nodeId);
|
||||
}
|
||||
|
||||
|
||||
FileInfo fileInfo = fileFolderService.create(
|
||||
parentNodeRef,
|
||||
this.name,
|
||||
Repository.resolveToQName(this.spaceType));
|
||||
NodeRef nodeRef = fileInfo.getNodeRef();
|
||||
newSpaceId = nodeRef.getId();
|
||||
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Created folder node with name: " + this.name);
|
||||
|
||||
@@ -173,10 +173,10 @@ public class CreateSpaceWizard extends BaseWizardBean
|
||||
uiFacetsProps.put(ContentModel.PROP_TITLE, this.title);
|
||||
uiFacetsProps.put(ContentModel.PROP_DESCRIPTION, this.description);
|
||||
this.nodeService.addAspect(nodeRef, ApplicationModel.ASPECT_UIFACETS, uiFacetsProps);
|
||||
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Added uifacets aspect with properties: " + uiFacetsProps);
|
||||
|
||||
|
||||
// remember the created node
|
||||
this.createdNode = nodeRef;
|
||||
}
|
||||
@@ -185,20 +185,20 @@ public class CreateSpaceWizard extends BaseWizardBean
|
||||
// copy the selected space and update the name, description and icon
|
||||
NodeRef sourceNode = this.existingSpaceId;
|
||||
NodeRef parentSpace = new NodeRef(Repository.getStoreRef(), this.navigator.getCurrentNodeId());
|
||||
|
||||
|
||||
// copy from existing
|
||||
NodeRef copiedNode = this.fileFolderService.copy(sourceNode, parentSpace, this.name).getNodeRef();
|
||||
|
||||
NodeRef copiedNode = this.fileFolderService.copy(sourceNode, parentSpace, this.name).getNodeRef();
|
||||
|
||||
// also need to set the new title, description and icon properties
|
||||
this.nodeService.setProperty(copiedNode, ContentModel.PROP_TITLE, this.title);
|
||||
this.nodeService.setProperty(copiedNode, ContentModel.PROP_DESCRIPTION, this.description);
|
||||
this.nodeService.setProperty(copiedNode, ApplicationModel.PROP_ICON, this.icon);
|
||||
|
||||
|
||||
newSpaceId = copiedNode.getId();
|
||||
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Copied space with id of " + sourceNode.getId() + " to " + this.name);
|
||||
|
||||
|
||||
// remember the created node
|
||||
this.createdNode = copiedNode;
|
||||
}
|
||||
@@ -213,16 +213,16 @@ public class CreateSpaceWizard extends BaseWizardBean
|
||||
this.nodeService.setProperty(copiedNode, ContentModel.PROP_TITLE, this.title);
|
||||
this.nodeService.setProperty(copiedNode, ContentModel.PROP_DESCRIPTION, this.description);
|
||||
this.nodeService.setProperty(copiedNode, ApplicationModel.PROP_ICON, this.icon);
|
||||
|
||||
|
||||
newSpaceId = copiedNode.getId();
|
||||
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Copied template space with id of " + sourceNode.getId() + " to " + this.name);
|
||||
|
||||
|
||||
// remember the created node
|
||||
this.createdNode = copiedNode;
|
||||
}
|
||||
|
||||
|
||||
// if the user selected to save the space as a template space copy the new
|
||||
// space to the templates folder
|
||||
if (this.saveAsTemplate)
|
||||
@@ -230,11 +230,11 @@ public class CreateSpaceWizard extends BaseWizardBean
|
||||
// get hold of the Templates node
|
||||
DynamicNamespacePrefixResolver namespacePrefixResolver = new DynamicNamespacePrefixResolver(null);
|
||||
namespacePrefixResolver.registerNamespace(NamespaceService.APP_MODEL_PREFIX, NamespaceService.APP_MODEL_1_0_URI);
|
||||
|
||||
|
||||
String xpath = Application.getRootPath(FacesContext.getCurrentInstance()) + "/" +
|
||||
Application.getGlossaryFolderName(FacesContext.getCurrentInstance()) + "/" +
|
||||
Application.getSpaceTemplatesFolderName(FacesContext.getCurrentInstance());
|
||||
|
||||
|
||||
NodeRef rootNodeRef = this.nodeService.getRootNode(Repository.getStoreRef());
|
||||
List<NodeRef> templateNodeList = this.searchService.selectNodes(
|
||||
rootNodeRef,
|
||||
@@ -248,13 +248,15 @@ public class CreateSpaceWizard extends BaseWizardBean
|
||||
fileFolderService.copy(sourceNode, templateNode, this.templateName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
setTitle(""); setDescription("");
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Bean Getters and Setters
|
||||
|
||||
|
||||
/**
|
||||
* @return Returns the copyPolicy.
|
||||
*/
|
||||
@@ -270,7 +272,7 @@ public class CreateSpaceWizard extends BaseWizardBean
|
||||
{
|
||||
this.copyPolicy = copyPolicy;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Returns the createFrom.
|
||||
*/
|
||||
@@ -294,14 +296,14 @@ public class CreateSpaceWizard extends BaseWizardBean
|
||||
{
|
||||
return description;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param description The description to set.
|
||||
*/
|
||||
public void setDescription(String description)
|
||||
{
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the existingSpaceId.
|
||||
@@ -310,7 +312,7 @@ public class CreateSpaceWizard extends BaseWizardBean
|
||||
{
|
||||
return existingSpaceId;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param existingSpaceId The existingSpaceId to set.
|
||||
*/
|
||||
@@ -318,7 +320,7 @@ public class CreateSpaceWizard extends BaseWizardBean
|
||||
{
|
||||
this.existingSpaceId = existingSpaceId;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Returns the icon.
|
||||
*/
|
||||
@@ -326,7 +328,7 @@ public class CreateSpaceWizard extends BaseWizardBean
|
||||
{
|
||||
return icon;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param icon The icon to set.
|
||||
*/
|
||||
@@ -334,7 +336,7 @@ public class CreateSpaceWizard extends BaseWizardBean
|
||||
{
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Returns the name.
|
||||
*/
|
||||
@@ -342,15 +344,15 @@ public class CreateSpaceWizard extends BaseWizardBean
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param name The name to set.
|
||||
*/
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
this.name = name.trim();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Returns the title.
|
||||
*/
|
||||
@@ -358,7 +360,7 @@ public class CreateSpaceWizard extends BaseWizardBean
|
||||
{
|
||||
return title;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param title The title to set.
|
||||
*/
|
||||
@@ -366,7 +368,7 @@ public class CreateSpaceWizard extends BaseWizardBean
|
||||
{
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Returns the saveAsTemplate.
|
||||
*/
|
||||
@@ -374,7 +376,7 @@ public class CreateSpaceWizard extends BaseWizardBean
|
||||
{
|
||||
return saveAsTemplate;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param saveAsTemplate The saveAsTemplate to set.
|
||||
*/
|
||||
@@ -390,7 +392,7 @@ public class CreateSpaceWizard extends BaseWizardBean
|
||||
{
|
||||
return spaceType;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param spaceType The spaceType to set.
|
||||
*/
|
||||
@@ -398,7 +400,7 @@ public class CreateSpaceWizard extends BaseWizardBean
|
||||
{
|
||||
this.spaceType = spaceType;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Returns the templateName.
|
||||
*/
|
||||
@@ -406,7 +408,7 @@ public class CreateSpaceWizard extends BaseWizardBean
|
||||
{
|
||||
return templateName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param templateName The templateName to set.
|
||||
*/
|
||||
@@ -414,7 +416,7 @@ public class CreateSpaceWizard extends BaseWizardBean
|
||||
{
|
||||
this.templateName = templateName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Returns the templateSpaceId.
|
||||
*/
|
||||
@@ -422,7 +424,7 @@ public class CreateSpaceWizard extends BaseWizardBean
|
||||
{
|
||||
return templateSpaceId;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param templateSpaceId The templateSpaceId to set.
|
||||
*/
|
||||
@@ -430,7 +432,7 @@ public class CreateSpaceWizard extends BaseWizardBean
|
||||
{
|
||||
this.templateSpaceId = templateSpaceId;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Returns the summary data for the wizard.
|
||||
*/
|
||||
@@ -438,7 +440,7 @@ public class CreateSpaceWizard extends BaseWizardBean
|
||||
{
|
||||
String summaryCreateType = null;
|
||||
ResourceBundle bundle = Application.getBundle(FacesContext.getCurrentInstance());
|
||||
|
||||
|
||||
if (this.createFrom.equals("scratch"))
|
||||
{
|
||||
summaryCreateType = bundle.getString("scratch");
|
||||
@@ -451,11 +453,11 @@ public class CreateSpaceWizard extends BaseWizardBean
|
||||
{
|
||||
summaryCreateType = bundle.getString("a_template");
|
||||
}
|
||||
|
||||
|
||||
// String summarySaveAsTemplate = this.saveAsTemplate ? bundle.getString("yes") : bundle.getString("no");
|
||||
// bundle.getString("save_as_template"), bundle.getString("template_name")},
|
||||
// summarySaveAsTemplate, this.templateName
|
||||
|
||||
|
||||
String spaceTypeLabel = null;
|
||||
for (UIListItem item : this.getFolderTypes())
|
||||
{
|
||||
@@ -465,28 +467,28 @@ public class CreateSpaceWizard extends BaseWizardBean
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return buildSummary(
|
||||
new String[] {bundle.getString("space_type"), bundle.getString("name"),
|
||||
new String[] {bundle.getString("space_type"), bundle.getString("name"),
|
||||
bundle.getString("description"), bundle.getString("creating_from")},
|
||||
new String[] {spaceTypeLabel, this.name, this.description, summaryCreateType});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Returns a list of template spaces currently in the system
|
||||
*/
|
||||
public List<SelectItem> getTemplateSpaces()
|
||||
{
|
||||
{
|
||||
if (this.templates == null)
|
||||
{
|
||||
this.templates = new ArrayList<SelectItem>();
|
||||
|
||||
|
||||
FacesContext context = FacesContext.getCurrentInstance();
|
||||
String xpath = Application.getRootPath(context) + "/" + Application.getGlossaryFolderName(context) +
|
||||
"/" + Application.getSpaceTemplatesFolderName(context) + "/*";
|
||||
NodeRef rootNodeRef = this.nodeService.getRootNode(Repository.getStoreRef());
|
||||
NodeRef rootNodeRef = this.nodeService.getRootNode(Repository.getStoreRef());
|
||||
List<NodeRef> results = this.searchService.selectNodes(rootNodeRef, xpath, null, this.namespaceService, false);
|
||||
|
||||
|
||||
if (results.size() > 0)
|
||||
{
|
||||
for (NodeRef assocRef : results)
|
||||
@@ -497,23 +499,23 @@ public class CreateSpaceWizard extends BaseWizardBean
|
||||
this.templates.add(new SelectItem(childNode.getId(), childNode.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// make sure the list is sorted by the label
|
||||
QuickSort sorter = new QuickSort(this.templates, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
|
||||
sorter.sort();
|
||||
}
|
||||
|
||||
|
||||
// add an entry (at the start) to instruct the user to select a template
|
||||
this.templates.add(0, new SelectItem("none", Application.getMessage(FacesContext.getCurrentInstance(), "select_a_template")));
|
||||
}
|
||||
|
||||
|
||||
return this.templates;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of UIListItem objects representing the folder types
|
||||
* Returns a list of UIListItem objects representing the folder types
|
||||
* and also constructs the list of descriptions for each type
|
||||
*
|
||||
*
|
||||
* @return List of UIListItem components
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -524,7 +526,7 @@ public class CreateSpaceWizard extends BaseWizardBean
|
||||
FacesContext context = FacesContext.getCurrentInstance();
|
||||
this.folderTypes = new ArrayList<UIListItem>(2);
|
||||
this.folderTypeDescriptions = new ArrayList<UIDescription>(2);
|
||||
|
||||
|
||||
// add the well known 'container space' type to start with
|
||||
UIListItem defaultItem = new UIListItem();
|
||||
String defaultLabel = Application.getMessage(context, "container");
|
||||
@@ -533,12 +535,12 @@ public class CreateSpaceWizard extends BaseWizardBean
|
||||
defaultItem.setTooltip(defaultLabel);
|
||||
defaultItem.setImage(DEFAULT_SPACE_TYPE_ICON_PATH);
|
||||
this.folderTypes.add(defaultItem);
|
||||
|
||||
|
||||
UIDescription defaultDesc = new UIDescription();
|
||||
defaultDesc.setControlValue(ContentModel.TYPE_FOLDER.toString());
|
||||
defaultDesc.setText(Application.getMessage(context, "container_desc"));
|
||||
this.folderTypeDescriptions.add(defaultDesc);
|
||||
|
||||
|
||||
// add any configured content sub-types to the list
|
||||
Config wizardCfg = Application.getConfigService(FacesContext.getCurrentInstance()).
|
||||
getConfig("Space Wizards");
|
||||
@@ -546,54 +548,54 @@ public class CreateSpaceWizard extends BaseWizardBean
|
||||
{
|
||||
ConfigElement typesCfg = wizardCfg.getConfigElement("folder-types");
|
||||
if (typesCfg != null)
|
||||
{
|
||||
{
|
||||
for (ConfigElement child : typesCfg.getChildren())
|
||||
{
|
||||
QName idQName = Repository.resolveToQName(child.getAttribute("name"));
|
||||
TypeDefinition typeDef = this.dictionaryService.getType(idQName);
|
||||
|
||||
|
||||
if (typeDef != null)
|
||||
{
|
||||
if (this.dictionaryService.isSubClass(typeDef.getName(), ContentModel.TYPE_FOLDER))
|
||||
{
|
||||
// try and get the label from config
|
||||
String label = Utils.getDisplayLabel(context, child);
|
||||
|
||||
|
||||
// if there wasn't a client based label try and get it from the dictionary
|
||||
if (label == null)
|
||||
{
|
||||
label = typeDef.getTitle();
|
||||
}
|
||||
|
||||
|
||||
// finally use the localname if we still haven't found a label
|
||||
if (label == null)
|
||||
{
|
||||
label = idQName.getLocalName();
|
||||
}
|
||||
|
||||
|
||||
// resolve a description string for the type
|
||||
String description = Utils.getDescription(context, child);
|
||||
|
||||
|
||||
// if we don't have a local description just use the label
|
||||
if (description == null)
|
||||
{
|
||||
description = label;
|
||||
}
|
||||
|
||||
|
||||
// extract the icon to use from the config
|
||||
String icon = child.getAttribute("icon");
|
||||
if (icon == null || icon.length() == 0)
|
||||
{
|
||||
icon = DEFAULT_SPACE_TYPE_ICON_PATH;
|
||||
}
|
||||
|
||||
|
||||
UIListItem item = new UIListItem();
|
||||
item.setValue(idQName.toString());
|
||||
item.setLabel(label);
|
||||
item.setTooltip(label);
|
||||
item.setImage(icon);
|
||||
this.folderTypes.add(item);
|
||||
|
||||
|
||||
UIDescription desc = new UIDescription();
|
||||
desc.setControlValue(idQName.toString());
|
||||
desc.setText(description);
|
||||
@@ -601,13 +603,13 @@ public class CreateSpaceWizard extends BaseWizardBean
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.warn("Failed to add '" + child.getAttribute("name") +
|
||||
logger.warn("Failed to add '" + child.getAttribute("name") +
|
||||
"' to the list of folder types as the type is not a subtype of cm:folder");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.warn("Failed to add '" + child.getAttribute("name") +
|
||||
logger.warn("Failed to add '" + child.getAttribute("name") +
|
||||
"' to the list of folder types as the type is not recognised");
|
||||
}
|
||||
}
|
||||
@@ -621,15 +623,15 @@ public class CreateSpaceWizard extends BaseWizardBean
|
||||
{
|
||||
logger.warn("Could not find 'Space Wizards' configuration section");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return this.folderTypes;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a list of UIDescription objects for the folder types
|
||||
*
|
||||
*
|
||||
* @return A list of UIDescription objects
|
||||
*/
|
||||
public List<UIDescription> getFolderTypeDescriptions()
|
||||
@@ -639,14 +641,14 @@ public class CreateSpaceWizard extends BaseWizardBean
|
||||
// call the getFolderType method to construct the list
|
||||
getFolderTypes();
|
||||
}
|
||||
|
||||
|
||||
return this.folderTypeDescriptions;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a list of icons to allow the user to select from.
|
||||
* The list can change according to the type of space being created.
|
||||
*
|
||||
*
|
||||
* @return A list of icons
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -654,13 +656,13 @@ public class CreateSpaceWizard extends BaseWizardBean
|
||||
{
|
||||
// NOTE: we can't cache this list as it depends on the space type
|
||||
// which the user can change during the advanced space wizard
|
||||
|
||||
|
||||
List<UIListItem> icons = null;
|
||||
List<String> iconNames = new ArrayList<String>(8);
|
||||
|
||||
|
||||
QName type = QName.createQName(this.spaceType);
|
||||
String typePrefixForm = type.toPrefixString(this.namespaceService);
|
||||
|
||||
|
||||
Config config = Application.getConfigService(FacesContext.getCurrentInstance()).
|
||||
getConfig(typePrefixForm + " icons");
|
||||
if (config != null)
|
||||
@@ -673,14 +675,14 @@ public class CreateSpaceWizard extends BaseWizardBean
|
||||
{
|
||||
String iconName = icon.getAttribute("name");
|
||||
String iconPath = icon.getAttribute("path");
|
||||
|
||||
|
||||
if (iconName != null && iconPath != null)
|
||||
{
|
||||
if (first)
|
||||
{
|
||||
// if this is the first icon create the list and make
|
||||
// if this is the first icon create the list and make
|
||||
// the first icon in the list the default
|
||||
|
||||
|
||||
icons = new ArrayList<UIListItem>(iconsCfg.getChildCount());
|
||||
if (this.icon == null)
|
||||
{
|
||||
@@ -689,7 +691,7 @@ public class CreateSpaceWizard extends BaseWizardBean
|
||||
}
|
||||
first = false;
|
||||
}
|
||||
|
||||
|
||||
UIListItem item = new UIListItem();
|
||||
item.setValue(iconName);
|
||||
item.setImage(iconPath);
|
||||
@@ -699,36 +701,36 @@ public class CreateSpaceWizard extends BaseWizardBean
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// if we didn't find any icons display one default choice
|
||||
if (icons == null)
|
||||
{
|
||||
icons = new ArrayList<UIListItem>(1);
|
||||
this.icon = DEFAULT_SPACE_ICON_NAME;
|
||||
|
||||
|
||||
UIListItem item = new UIListItem();
|
||||
item.setValue(DEFAULT_SPACE_ICON_NAME);
|
||||
item.setImage("/images/icons/space-icon-default.gif");
|
||||
icons.add(item);
|
||||
iconNames.add(DEFAULT_SPACE_ICON_NAME);
|
||||
}
|
||||
|
||||
// make sure the current value for the icon is valid for the
|
||||
|
||||
// make sure the current value for the icon is valid for the
|
||||
// current list of icons about to be displayed
|
||||
if (iconNames.contains(this.icon) == false)
|
||||
{
|
||||
this.icon = iconNames.get(0);
|
||||
}
|
||||
|
||||
|
||||
return icons;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Helper methods
|
||||
|
||||
|
||||
/**
|
||||
* Formats the error message to display if an error occurs during finish processing
|
||||
*
|
||||
*
|
||||
* @param exception The exception
|
||||
* @return The formatted message
|
||||
*/
|
||||
@@ -738,13 +740,13 @@ public class CreateSpaceWizard extends BaseWizardBean
|
||||
if (exception instanceof FileExistsException)
|
||||
{
|
||||
return MessageFormat.format(Application.getMessage(
|
||||
FacesContext.getCurrentInstance(), Repository.ERROR_EXISTS),
|
||||
FacesContext.getCurrentInstance(), Repository.ERROR_EXISTS),
|
||||
((FileExistsException)exception).getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
return MessageFormat.format(Application.getMessage(
|
||||
FacesContext.getCurrentInstance(), "error_space"),
|
||||
FacesContext.getCurrentInstance(), "error_space"),
|
||||
exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
@@ -15,11 +15,11 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.web.bean.spaces;
|
||||
@@ -38,34 +38,35 @@ import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.web.app.AlfrescoNavigationHandler;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
|
||||
/**
|
||||
* Dialog bean to edit an existing space.
|
||||
*
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class EditSpaceDialog extends CreateSpaceDialog
|
||||
{
|
||||
protected Node editableNode;
|
||||
|
||||
|
||||
@Override
|
||||
public void init(Map<String, String> parameters)
|
||||
{
|
||||
super.init(parameters);
|
||||
|
||||
|
||||
// setup the space being edited
|
||||
this.editableNode = initEditableNode();
|
||||
this.spaceType = this.editableNode.getType().toString();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean getFinishButtonDisabled()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Init the editable Node
|
||||
*/
|
||||
@@ -73,71 +74,71 @@ public class EditSpaceDialog extends CreateSpaceDialog
|
||||
{
|
||||
return new Node(this.browseBean.getActionSpace().getNodeRef());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getFinishButtonLabel()
|
||||
{
|
||||
return Application.getMessage(FacesContext.getCurrentInstance(), "ok");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome) throws Exception
|
||||
{
|
||||
// update the existing node in the repository
|
||||
NodeRef nodeRef = this.editableNode.getNodeRef();
|
||||
Map<String, Object> editedProps = this.editableNode.getProperties();
|
||||
|
||||
|
||||
// handle the name property separately, perform a rename in case it changed
|
||||
String name = (String)editedProps.get(ContentModel.PROP_NAME);
|
||||
if (name != null)
|
||||
{
|
||||
this.fileFolderService.rename(nodeRef, name);
|
||||
}
|
||||
|
||||
|
||||
// get the current set of properties from the repository
|
||||
Map<QName, Serializable> repoProps = this.nodeService.getProperties(nodeRef);
|
||||
|
||||
|
||||
// add the "uifacets" aspect if required, properties will get set below
|
||||
if (this.nodeService.hasAspect(nodeRef, ApplicationModel.ASPECT_UIFACETS) == false)
|
||||
{
|
||||
this.nodeService.addAspect(nodeRef, ApplicationModel.ASPECT_UIFACETS, null);
|
||||
}
|
||||
|
||||
|
||||
// overwrite the current properties with the edited ones
|
||||
Iterator<String> iterProps = editedProps.keySet().iterator();
|
||||
while (iterProps.hasNext())
|
||||
{
|
||||
String propName = iterProps.next();
|
||||
QName qname = QName.createQName(propName);
|
||||
|
||||
|
||||
// make sure the property is represented correctly
|
||||
Serializable propValue = (Serializable)editedProps.get(propName);
|
||||
|
||||
|
||||
// check for empty strings when using number types, set to null in this case
|
||||
if ((propValue != null) && (propValue instanceof String) &&
|
||||
if ((propValue != null) && (propValue instanceof String) &&
|
||||
(propValue.toString().length() == 0))
|
||||
{
|
||||
PropertyDefinition propDef = this.dictionaryService.getProperty(qname);
|
||||
if (propDef != null)
|
||||
{
|
||||
if (propDef.getDataType().getName().equals(DataTypeDefinition.DOUBLE) ||
|
||||
if (propDef.getDataType().getName().equals(DataTypeDefinition.DOUBLE) ||
|
||||
propDef.getDataType().getName().equals(DataTypeDefinition.FLOAT) ||
|
||||
propDef.getDataType().getName().equals(DataTypeDefinition.INT) ||
|
||||
propDef.getDataType().getName().equals(DataTypeDefinition.INT) ||
|
||||
propDef.getDataType().getName().equals(DataTypeDefinition.LONG))
|
||||
{
|
||||
propValue = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
repoProps.put(qname, propValue);
|
||||
}
|
||||
|
||||
|
||||
// send the properties back to the repository
|
||||
this.nodeService.setProperties(nodeRef, repoProps);
|
||||
|
||||
|
||||
// we also need to persist any association changes that may have been made
|
||||
|
||||
|
||||
// add any associations added in the UI
|
||||
Map<String, Map<String, AssociationRef>> addedAssocs = this.editableNode.getAddedAssociations();
|
||||
for (Map<String, AssociationRef> typedAssoc : addedAssocs.values())
|
||||
@@ -147,7 +148,7 @@ public class EditSpaceDialog extends CreateSpaceDialog
|
||||
this.nodeService.createAssociation(assoc.getSourceRef(), assoc.getTargetRef(), assoc.getTypeQName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// remove any association removed in the UI
|
||||
Map<String, Map<String, AssociationRef>> removedAssocs = this.editableNode.getRemovedAssociations();
|
||||
for (Map<String, AssociationRef> typedAssoc : removedAssocs.values())
|
||||
@@ -157,7 +158,7 @@ public class EditSpaceDialog extends CreateSpaceDialog
|
||||
this.nodeService.removeAssociation(assoc.getSourceRef(), assoc.getTargetRef(), assoc.getTypeQName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// add any child associations added in the UI
|
||||
Map<String, Map<String, ChildAssociationRef>> addedChildAssocs = this.editableNode.getAddedChildAssociations();
|
||||
for (Map<String, ChildAssociationRef> typedAssoc : addedChildAssocs.values())
|
||||
@@ -167,7 +168,7 @@ public class EditSpaceDialog extends CreateSpaceDialog
|
||||
this.nodeService.addChild(assoc.getParentRef(), assoc.getChildRef(), assoc.getTypeQName(), assoc.getTypeQName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// remove any child association removed in the UI
|
||||
Map<String, Map<String, ChildAssociationRef>> removedChildAssocs = this.editableNode.getRemovedChildAssociations();
|
||||
for (Map<String, ChildAssociationRef> typedAssoc : removedChildAssocs.values())
|
||||
@@ -177,29 +178,54 @@ public class EditSpaceDialog extends CreateSpaceDialog
|
||||
this.nodeService.removeChild(assoc.getParentRef(), assoc.getChildRef());
|
||||
}
|
||||
}
|
||||
|
||||
return outcome;
|
||||
|
||||
|
||||
// do nothing by default, subclasses can override if necessary
|
||||
if(isEdit())
|
||||
{
|
||||
this.browseBean.setDocument(this.getEditableNode()); // (this.editableNode.getNodeRef());
|
||||
|
||||
return "dialog:createMultilingualProperties";
|
||||
}
|
||||
else
|
||||
{
|
||||
return AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected String doPostCommitProcessing(FacesContext context, String outcome)
|
||||
{
|
||||
this.browseBean.getActionSpace().reset();
|
||||
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Bean getters and setters
|
||||
|
||||
/**
|
||||
* Returns the node being edited
|
||||
*
|
||||
*
|
||||
* @return The node being edited
|
||||
*/
|
||||
public Node getEditableNode()
|
||||
{
|
||||
return this.editableNode;
|
||||
}
|
||||
|
||||
public boolean isEdit()
|
||||
{
|
||||
return this.edit;
|
||||
}
|
||||
|
||||
public void setEdit(boolean x)
|
||||
{
|
||||
this.edit=x;
|
||||
}
|
||||
|
||||
|
||||
private boolean edit;
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user