UI related code/jsp fixes and cleanup to new ML space/dialog components.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5764 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2007-05-23 16:45:42 +00:00
parent 4e53d4b44d
commit e9e3fecbb9
18 changed files with 922 additions and 985 deletions

View File

@@ -42,183 +42,189 @@ 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;
/** 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;
/** 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)
/**
* @param nodeService The NodeService to set.
*/
public void setNodeService(NodeService nodeService)
{
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;
}
this.nodeService = nodeService;
}
else
public String getLanguage()
{
SelectItem[] elements = { new SelectItem("")}; return elements;
return this.language;
}
}
// 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)
public void setLanguage(String x)
{
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;
}
this.language = x;
Application.setLanguage(FacesContext.getCurrentInstance(), this.language);
}
else
public void setNewlanguage(String x)
{
SelectItem[] elements = { new SelectItem("","")}; return elements;
this.newlanguage = x;
}
}
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;}
}
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.BEAN_NAME);
// 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;
}
}

View File

@@ -262,32 +262,31 @@ public class DocumentDetailsBean extends BaseDetailsBean
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());
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 ;
: 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);
}
@@ -789,7 +788,6 @@ public class DocumentDetailsBean extends BaseDetailsBean
return new Node(multilingualContentService.getTranslationContainer(nodeRef));
}
/**
* Sets the lock service instance the bean should use
*
@@ -824,16 +822,16 @@ public class DocumentDetailsBean extends BaseDetailsBean
* @param multilingualContentService the multilingualContentService to set
*/
public void setMultilingualContentService(
MultilingualContentService multilingualContentService)
MultilingualContentService multilingualContentService)
{
this.multilingualContentService = multilingualContentService;
this.multilingualContentService = multilingualContentService;
}
/**
* @param contentFilterLanguagesService The ContentFilterLanguagesService to set.
*/
public void setContentFilterLanguagesService(ContentFilterLanguagesService contentFilterLanguagesService)
{
this.contentFilterLanguagesService = contentFilterLanguagesService;
this.contentFilterLanguagesService = contentFilterLanguagesService;
}
}

View File

@@ -48,7 +48,6 @@ import org.alfresco.web.ui.common.Utils;
*/
public class AddTranslationWithoutContentDialog extends BaseDialogBean
{
public static String LOCALE_REGEX = "%locale%";
public static String EMPTY_DOCUMENT_EXTENSION = "." + LOCALE_REGEX + "_properties";
@@ -65,7 +64,6 @@ public class AddTranslationWithoutContentDialog extends BaseDialogBean
private String language;
@Override
public void init(Map<String, String> parameters)
{
@@ -76,7 +74,6 @@ public class AddTranslationWithoutContentDialog extends BaseDialogBean
description = null;
author = null;
language = null;
}
@Override
@@ -133,7 +130,6 @@ public class AddTranslationWithoutContentDialog extends BaseDialogBean
this.multilingualContentService = multilingualContentService;
}
/**
* @return the author
*/

View File

@@ -45,7 +45,6 @@ import org.alfresco.web.bean.repository.Node;
*/
public class AddTranslationlDialog extends AddContentDialog
{
private MultilingualContentService multilingualContentService;
private UserPreferencesBean userPreferencesBean;
@@ -58,6 +57,7 @@ public class AddTranslationlDialog extends AddContentDialog
// languages available in the ML container yet
private SelectItem[] unusedLanguages;
/* (non-Javadoc)
* @see org.alfresco.web.bean.content.AddContentDialog#init(java.util.Map)
*/
@@ -70,7 +70,6 @@ public class AddTranslationlDialog extends AddContentDialog
setMlContainer(this.browseBean.getDocument().getNodeRef());
setFileName(null);
unusedLanguages = null;
}
/* (non-Javadoc)
@@ -79,7 +78,6 @@ public class AddTranslationlDialog extends AddContentDialog
@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
// add the new file to the repository
outcome = super.finishImpl(context, outcome);
@@ -94,7 +92,6 @@ public class AddTranslationlDialog extends AddContentDialog
@Override
protected String getDefaultFinishOutcome()
{
return "showDocDetails";
}
@@ -139,7 +136,7 @@ public class AddTranslationlDialog extends AddContentDialog
* 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
* become it's own MLContainer
*/
public void setMlContainer(NodeRef mlContainer)
{
@@ -149,15 +146,17 @@ public class AddTranslationlDialog extends AddContentDialog
{
type = nodeService.getType(mlContainer);
if(ContentModel.TYPE_MULTILINGUAL_CONTAINER.equals(type)){
if(ContentModel.TYPE_MULTILINGUAL_CONTAINER.equals(type))
{
this.mlContainer = mlContainer;
}
else if(ContentModel.TYPE_CONTENT.equals(type)
&& nodeService.hasAspect(mlContainer, ContentModel.ASPECT_MULTILINGUAL_DOCUMENT)){
else if (ContentModel.TYPE_CONTENT.equals(type)
&& nodeService.hasAspect(mlContainer, ContentModel.ASPECT_MULTILINGUAL_DOCUMENT))
{
this.mlContainer = multilingualContentService.getTranslationContainer(mlContainer);
}
else{
else
{
this.mlContainer = null;
}
}
@@ -179,7 +178,6 @@ public class AddTranslationlDialog extends AddContentDialog
public SelectItem[] getUnusedLanguages()
{
if(unusedLanguages == null)
{
unusedLanguages = userPreferencesBean.getAvailablesContentFilterLanguages(getMlContainer(), false);
@@ -189,15 +187,15 @@ public class AddTranslationlDialog extends AddContentDialog
}
public MultilingualContentService getMultilingualContentService()
{
return multilingualContentService;
}
{
return multilingualContentService;
}
public void setMultilingualContentService(
MultilingualContentService multilingualContentService)
{
this.multilingualContentService = multilingualContentService;
}
public void setMultilingualContentService(
MultilingualContentService multilingualContentService)
{
this.multilingualContentService = multilingualContentService;
}
public UserPreferencesBean getUserPreferencesBean()
{

View File

@@ -43,54 +43,50 @@ import org.alfresco.web.bean.repository.Node;
*/
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;
return outcome;
}
/**
* Init the editable Node
*/
@@ -99,25 +95,26 @@ public class EditMLContainerDialog extends BaseDialogBean
return new Node(
multilingualContentService.getTranslationContainer(
this.browseBean.getDocument().getNodeRef())
);
);
}
/**
* @return the editableNode
*/
public Node getEditableNode() {
public Node getEditableNode()
{
return editableNode;
}
@Override
protected String doPostCommitProcessing(FacesContext context, String outcome)
{
this.browseBean.getDocument().reset();
return outcome;
}
// ------------------------------------------------------------------------------
// Bean getters and setters
@@ -127,7 +124,7 @@ public class EditMLContainerDialog extends BaseDialogBean
public MultilingualContentService getMultilingualContentService() {
return multilingualContentService;
}
/**
* @param multilingualContentService the multilingualContentService to set
*/
@@ -135,6 +132,4 @@ public class EditMLContainerDialog extends BaseDialogBean
MultilingualContentService multilingualContentService) {
this.multilingualContentService = multilingualContentService;
}
}

View File

@@ -46,213 +46,215 @@ import org.alfresco.web.bean.repository.Node;
*/
public class MakeMultilingualDialog extends BaseDialogBean
{
private MultilingualContentService multilingualContentService;
private MultilingualContentService multilingualContentService;
private UserPreferencesBean userPreferencesBean;
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";
/** 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 author is a mandatory properties
private String author;
// The langage of the node to make multilingual
private String language;
// 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 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;
// 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);
}
// the node to edit
protected Node editableNode;
// ------------------------------------------------------------------------------
// Bean getters and setters
@Override
public void init(Map<String, String> parameters)
{
super.init(parameters);
/**
* Returns the node being edited
*
* @return The node being edited
*/
public Node getEditableNode()
{
return this.editableNode;
}
// setup the editable node
this.editableNode = initEditableNode();
/**
* @return the author of the new created MLContainer
*/
public String getAuthor()
{
return author;
}
NodeRef nodeRef = this.editableNode.getNodeRef();
/**
* @param author the author of new created MLContainer
*/
public void setAuthor(String author)
{
this.author = author;
}
// 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("");
}
/**
* @return if a new translation must be added after this dialog closes
*/
public boolean isAddTranslationAfter()
{
return addTranslationAfter;
}
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);
}
/**
* @param addTranslationAfter set to true, a new translation will be added after this dialog closes
*/
public void setAddTranslationAfter(boolean addTranslationAfter)
{
this.addTranslationAfter = addTranslationAfter;
}
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);
}
/**
* @return the language of the translation
*/
public String getLanguage()
{
return language;
}
// ------------------------------------------------------------------------------
// Bean getters and setters
/**
* @param language the language of the translation
*/
public void setLanguage(String language)
{
this.language = language;
}
/**
* Returns the node being edited
*
* @return The node being edited
*/
public Node getEditableNode()
{
return this.editableNode;
}
/**
* @param editableNode the node will become a multilingual
*/
public void setEditableNode(Node editableNode)
{
this.editableNode = 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() {
public String getAddingMode()
{
return addingMode;
}
@@ -260,7 +262,8 @@ public class MakeMultilingualDialog extends BaseDialogBean
* @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) {
public void setAddingMode(String addingMode)
{
this.addingMode = addingMode;
}
@@ -273,16 +276,13 @@ public class MakeMultilingualDialog extends BaseDialogBean
}
public void setMultilingualContentService(
MultilingualContentService multilingualContentService)
{
this.multilingualContentService = multilingualContentService;
}
MultilingualContentService multilingualContentService)
{
this.multilingualContentService = multilingualContentService;
}
public void setUserPreferencesBean(UserPreferencesBean userPreferencesBean)
{
this.userPreferencesBean = userPreferencesBean;
}
}

View File

@@ -29,44 +29,37 @@ import javax.faces.context.FacesContext;
import org.alfresco.web.app.AlfrescoNavigationHandler;
import org.alfresco.web.app.Application;
public class CreateMultilingualPropertiesDialog extends CreateMultilingualPropertiesWizard
{
// ------------------------------------------------------------------------------
// Wizard implementation
// ------------------------------------------------------------------------------
// Wizard implementation
@Override
public String getFinishButtonLabel()
{
return Application.getMessage(FacesContext.getCurrentInstance(), "create_multilingual_space");
}
@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";
@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;
}
// 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;
}
}

View File

@@ -41,62 +41,58 @@ import org.alfresco.web.bean.UserPreferencesBean;
public class CreateMultilingualPropertiesWizard extends CreateSpaceWizard
{
@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception
@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"))
{
MLText title, description;
// 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();
// bind to the bean
CreateMultilingualPropertiesBean createMultilingualPropertiesBean = (CreateMultilingualPropertiesBean) FacesHelper.getManagedBean(context, "CreateMultilingualPropertiesBean");
UserPreferencesBean userPreferencesBean = (UserPreferencesBean) FacesHelper.getManagedBean(context, "UserPreferencesBean");
// Modification du casting de l objet r<>cup<75>r<EFBFBD> des getters de MLText en Text
MLPropertyInterceptor.setMLAware(true);
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();
// 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);
// Modification du casting de l objet r<>cup<75>r<EFBFBD> des getters de MLText en Text
MLPropertyInterceptor.setMLAware(true);
if(oTitle instanceof MLText)
{
title = (MLText) oTitle;
}
else
{
title = new MLText();
title.addValue(I18NUtil.parseLocale(userPreferencesBean.getContentFilterLanguage()), oTitle.toString());
}
// 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(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());
if(oTitle instanceof MLText)
{
title = (MLText) oTitle;
}
else
{
title = new MLText();
title.addValue(I18NUtil.parseLocale(userPreferencesBean.getContentFilterLanguage()), oTitle.toString());
}
properties.put(ContentModel.PROP_TITLE, title);
properties.put(ContentModel.PROP_DESCRIPTION, description);
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);
/*
// 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();
@@ -108,53 +104,51 @@ public class CreateMultilingualPropertiesWizard extends CreateSpaceWizard
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";
}
*/
// Modification du casting de l objet r<>cup<75>r<EFBFBD> des getters de MLText en Text
MLPropertyInterceptor.setMLAware(false);
}
/**
* @param preferences The UserPreferencesBean to set
*/
public void setUserPreferencesBean(UserPreferencesBean preferences)
else if (this.createFrom.equals("existing"))
{
this.preferences = preferences;
}
/**
*
* @return the preferences of the user
*/
public UserPreferencesBean getUserPreferencesBean()
else if (this.createFrom.equals("template"))
{
return preferences;
}
if (createMultilingualPropertiesBean.isAdd_new_properties())
{
createMultilingualPropertiesBean.setTitle("");
createMultilingualPropertiesBean.setDescription("");
createMultilingualPropertiesBean.setAdd_new_properties(false);
/** The user preferences bean reference */
protected UserPreferencesBean preferences;
protected CreateMultilingualPropertiesBean createMultilingualPropertiesBean;
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;
}

View File

@@ -32,64 +32,58 @@ import org.alfresco.web.bean.CreateMultilingualPropertiesBean;
public class CreateMultilingualSpaceDialog extends CreateMultilingualSpaceWizard
{
// ------------------------------------------------------------------------------
// Wizard implementation
// ------------------------------------------------------------------------------
// Wizard implementation
@Override
public String getFinishButtonLabel()
@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 Application.getMessage(FacesContext.getCurrentInstance(), "create_multilingual_space");
return "dialog:createMultilingualProperties";
}
@Override
protected String getDefaultCancelOutcome()
else
{
return AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME;
}
}
@Override
protected String getDefaultFinishOutcome()
{
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;
}
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;
}
}
private boolean edit;
public CreateMultilingualPropertiesBean getCreateMultilingualPropertiesBean(){return this.createMultilingualPropertiesBean;}
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;
}
protected CreateMultilingualPropertiesBean createMultilingualPropertiesBean;
}

View File

@@ -48,177 +48,167 @@ 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;
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;
}
/**
* @return Determines whether the edit properties dialog should be
* shown when this one ends
*/
public boolean isShowOtherProperties()
@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"))
{
return this.showOtherProperties;
// 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>(2, 1.0f);
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;
}
/**
* @param showOthers Sets whether the edit properties dialog is shown
*/
public void setShowOtherProperties(boolean showOthers)
// if the user selected to save the space as a template space copy the new
// space to the templates folder
if (this.saveAsTemplate)
{
this.showOtherProperties = showOthers;
// 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;
}
@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
String newSpaceId = null;
CreateMultilingualPropertiesBean createMultilingualPropertiesBean = (CreateMultilingualPropertiesBean) FacesHelper.getManagedBean(context, "CreateMultilingualPropertiesBean");
/**
* @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;
}
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;
/** The user preferences bean reference */
protected UserPreferencesBean preferences;
protected CreateMultilingualPropertiesBean createMultilingualPropertiesBean;
}

View File

@@ -249,7 +249,8 @@ public class CreateSpaceWizard extends BaseWizardBean
}
}
setTitle(""); setDescription("");
setTitle("");
setDescription("");
return outcome;
}