mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
- Fixed regression in rules wizards
- Added title to create/edit space dialogs - Changed space dialogs to use required field icon - Converted all forums and removed all old legacy beans and JSPs git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2903 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,316 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* Licensed under the Mozilla Public License version 1.1
|
||||
* with a permitted attribution clause. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.alfresco.org/legal/license.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*/
|
||||
package org.alfresco.web.bean.wizard;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.Serializable;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.repo.content.filestore.FileContentReader;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.FileUploadBean;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
|
||||
/**
|
||||
* Handler class used by the Add Content Wizard
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class AddContentWizard extends BaseContentWizard
|
||||
{
|
||||
// TODO: retrieve these from the config service
|
||||
private static final String WIZARD_TITLE_ID = "add_content_title";
|
||||
private static final String WIZARD_DESC_ID = "add_content_desc";
|
||||
private static final String STEP1_TITLE_ID = "add_conent_step1_title";
|
||||
private static final String STEP1_DESCRIPTION_ID = "add_conent_step1_desc";
|
||||
private static final String STEP2_TITLE_ID = "add_conent_step2_title";
|
||||
private static final String STEP2_DESCRIPTION_ID = "add_conent_step2_desc";
|
||||
|
||||
// add content wizard specific properties
|
||||
private File file;
|
||||
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.wizard.AbstractWizardBean#next()
|
||||
*/
|
||||
public String next()
|
||||
{
|
||||
String outcome = super.next();
|
||||
|
||||
// if the outcome is "properties" we pre-set the content type and other
|
||||
// fields accordingly
|
||||
if (outcome.equals("properties"))
|
||||
{
|
||||
this.contentType = Repository.getMimeTypeForFileName(
|
||||
FacesContext.getCurrentInstance(), this.fileName);
|
||||
|
||||
// set default for in-line editing flag
|
||||
this.inlineEdit = (this.contentType.equals(MimetypeMap.MIMETYPE_HTML));
|
||||
|
||||
// Try and extract metadata from the file
|
||||
ContentReader cr = new FileContentReader(this.file);
|
||||
cr.setMimetype(this.contentType);
|
||||
// create properties for content type
|
||||
Map<QName, Serializable> contentProps = new HashMap<QName, Serializable>(5, 1.0f);
|
||||
|
||||
if (Repository.extractMetadata(FacesContext.getCurrentInstance(), cr, contentProps))
|
||||
{
|
||||
this.author = (String)(contentProps.get(ContentModel.PROP_AUTHOR));
|
||||
this.title = (String)(contentProps.get(ContentModel.PROP_TITLE));
|
||||
this.description = (String)(contentProps.get(ContentModel.PROP_DESCRIPTION));
|
||||
}
|
||||
if (this.title == null)
|
||||
{
|
||||
this.title = this.fileName;
|
||||
}
|
||||
}
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deals with the finish button being pressed
|
||||
*
|
||||
* @return outcome
|
||||
*/
|
||||
public String finish()
|
||||
{
|
||||
String outcome = saveContent(this.file, null);
|
||||
|
||||
// now we know the new details are in the repository, reset the
|
||||
// client side node representation so the new details are retrieved
|
||||
if (this.editMode)
|
||||
{
|
||||
this.browseBean.getDocument().reset();
|
||||
}
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.wizard.AbstractWizardBean#getWizardDescription()
|
||||
*/
|
||||
public String getWizardDescription()
|
||||
{
|
||||
return Application.getMessage(FacesContext.getCurrentInstance(), WIZARD_DESC_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.wizard.AbstractWizardBean#getWizardTitle()
|
||||
*/
|
||||
public String getWizardTitle()
|
||||
{
|
||||
return Application.getMessage(FacesContext.getCurrentInstance(), WIZARD_TITLE_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.wizard.AbstractWizardBean#getStepDescription()
|
||||
*/
|
||||
public String getStepDescription()
|
||||
{
|
||||
String stepDesc = null;
|
||||
|
||||
switch (this.currentStep)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
stepDesc = Application.getMessage(FacesContext.getCurrentInstance(), STEP1_DESCRIPTION_ID);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
stepDesc = Application.getMessage(FacesContext.getCurrentInstance(), STEP2_DESCRIPTION_ID);
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
stepDesc = Application.getMessage(FacesContext.getCurrentInstance(), SUMMARY_DESCRIPTION_ID);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
stepDesc = "";
|
||||
}
|
||||
}
|
||||
|
||||
return stepDesc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.wizard.AbstractWizardBean#getStepTitle()
|
||||
*/
|
||||
public String getStepTitle()
|
||||
{
|
||||
String stepTitle = null;
|
||||
|
||||
switch (this.currentStep)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
stepTitle = Application.getMessage(FacesContext.getCurrentInstance(), STEP1_TITLE_ID);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
stepTitle = Application.getMessage(FacesContext.getCurrentInstance(), STEP2_TITLE_ID);
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
stepTitle = Application.getMessage(FacesContext.getCurrentInstance(), SUMMARY_TITLE_ID);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
stepTitle = "";
|
||||
}
|
||||
}
|
||||
|
||||
return stepTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialises the wizard
|
||||
*/
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
|
||||
clearUpload();
|
||||
|
||||
this.file = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the message to display when a file has been uploaded
|
||||
*/
|
||||
public String getFileUploadSuccessMsg()
|
||||
{
|
||||
String msg = Application.getMessage(FacesContext.getCurrentInstance(), "file_upload_success");
|
||||
return MessageFormat.format(msg, new Object[] {getFileName()});
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the name of the file
|
||||
*/
|
||||
public String getFileName()
|
||||
{
|
||||
// try and retrieve the file and filename from the file upload bean
|
||||
// representing the file we previously uploaded.
|
||||
FacesContext ctx = FacesContext.getCurrentInstance();
|
||||
FileUploadBean fileBean = (FileUploadBean)ctx.getExternalContext().getSessionMap().
|
||||
get(FileUploadBean.FILE_UPLOAD_BEAN_NAME);
|
||||
if (fileBean != null)
|
||||
{
|
||||
this.file = fileBean.getFile();
|
||||
this.fileName = fileBean.getFileName();
|
||||
}
|
||||
|
||||
return this.fileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param fileName The name of the file
|
||||
*/
|
||||
public void setFileName(String fileName)
|
||||
{
|
||||
this.fileName = fileName;
|
||||
|
||||
// we also need to keep the file upload bean in sync
|
||||
FacesContext ctx = FacesContext.getCurrentInstance();
|
||||
FileUploadBean fileBean = (FileUploadBean)ctx.getExternalContext().getSessionMap().
|
||||
get(FileUploadBean.FILE_UPLOAD_BEAN_NAME);
|
||||
if (fileBean != null)
|
||||
{
|
||||
fileBean.setFileName(this.fileName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the summary data for the wizard.
|
||||
*/
|
||||
public String getSummary()
|
||||
{
|
||||
ResourceBundle bundle = Application.getBundle(FacesContext.getCurrentInstance());
|
||||
|
||||
return buildSummary(
|
||||
new String[] {bundle.getString("file_name"), bundle.getString("type"),
|
||||
bundle.getString("content_type"), bundle.getString("title"),
|
||||
bundle.getString("description"), bundle.getString("author"),
|
||||
bundle.getString("inline_editable")},
|
||||
new String[] {this.fileName, getSummaryObjectType(), getSummaryContentType(), this.title,
|
||||
this.description, this.author, Boolean.toString(this.inlineEdit)});
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.wizard.AbstractWizardBean#determineOutcomeForStep(int)
|
||||
*/
|
||||
protected String determineOutcomeForStep(int step)
|
||||
{
|
||||
String outcome = null;
|
||||
|
||||
switch(step)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
outcome = "upload";
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
outcome = "properties";
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
outcome = "summary";
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
outcome = CANCEL_OUTCOME;
|
||||
}
|
||||
}
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the uploaded file and removes the FileUploadBean from the session
|
||||
*/
|
||||
private void clearUpload()
|
||||
{
|
||||
// delete the temporary file we uploaded earlier
|
||||
if (this.file != null)
|
||||
{
|
||||
this.file.delete();
|
||||
}
|
||||
|
||||
// remove the file upload bean from the session
|
||||
FacesContext ctx = FacesContext.getCurrentInstance();
|
||||
ctx.getExternalContext().getSessionMap().remove(FileUploadBean.FILE_UPLOAD_BEAN_NAME);
|
||||
}
|
||||
}
|
@@ -1,629 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* Licensed under the Mozilla Public License version 1.1
|
||||
* with a permitted attribution clause. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.alfresco.org/legal/license.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*/
|
||||
package org.alfresco.web.bean.wizard;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.Serializable;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.model.SelectItem;
|
||||
import javax.transaction.UserTransaction;
|
||||
|
||||
import org.alfresco.config.Config;
|
||||
import org.alfresco.config.ConfigElement;
|
||||
import org.alfresco.config.ConfigService;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.dictionary.TypeDefinition;
|
||||
import org.alfresco.service.cmr.model.FileExistsException;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.repository.ContentData;
|
||||
import org.alfresco.service.cmr.repository.ContentService;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.service.cmr.repository.MimetypeService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.data.IDataContainer;
|
||||
import org.alfresco.web.data.QuickSort;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Base Handler class used by the Content Wizards
|
||||
*
|
||||
* @author gavinc kevinr
|
||||
*/
|
||||
public abstract class BaseContentWizard extends AbstractWizardBean
|
||||
{
|
||||
private static Log logger = LogFactory.getLog(BaseContentWizard.class);
|
||||
|
||||
protected static final String FINISH_INSTRUCTION_ID = "content_finish_instruction";
|
||||
|
||||
// content wizard specific attributes
|
||||
protected String fileName;
|
||||
protected String author;
|
||||
protected String title;
|
||||
protected String description;
|
||||
protected String contentType;
|
||||
protected String objectType;
|
||||
protected boolean inlineEdit;
|
||||
protected List<SelectItem> contentTypes;
|
||||
protected List<SelectItem> objectTypes;
|
||||
protected ContentService contentService;
|
||||
protected DictionaryService dictionaryService;
|
||||
|
||||
// the NodeRef of the node created during finish
|
||||
protected NodeRef createdNode;
|
||||
|
||||
/**
|
||||
* Save the specified content using the currently set wizard attributes
|
||||
*
|
||||
* @param fileContent File content to save
|
||||
* @param strContent String content to save
|
||||
*/
|
||||
protected String saveContent(File fileContent, String strContent)
|
||||
{
|
||||
String outcome = FINISH_OUTCOME;
|
||||
|
||||
UserTransaction tx = null;
|
||||
|
||||
try
|
||||
{
|
||||
FacesContext context = FacesContext.getCurrentInstance();
|
||||
tx = Repository.getUserTransaction(context);
|
||||
tx.begin();
|
||||
|
||||
if (this.editMode)
|
||||
{
|
||||
// update the existing node in the repository
|
||||
Node currentDocument = this.browseBean.getDocument();
|
||||
NodeRef nodeRef = currentDocument.getNodeRef();
|
||||
|
||||
// move the file - location and name checks will be performed
|
||||
this.fileFolderService.move(nodeRef, null, this.fileName);
|
||||
// set up the content data
|
||||
// update the modified timestamp and other content props
|
||||
Map<QName, Serializable> contentProps = this.nodeService.getProperties(nodeRef);
|
||||
contentProps.put(ContentModel.PROP_TITLE, this.title);
|
||||
contentProps.put(ContentModel.PROP_DESCRIPTION, this.description);
|
||||
|
||||
// add author property
|
||||
if (this.author != null && this.author.length() != 0)
|
||||
{
|
||||
if (this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_AUTHOR) == false)
|
||||
{
|
||||
Map<QName, Serializable> authorProps = new HashMap<QName, Serializable>(1, 1.0f);
|
||||
authorProps.put(ContentModel.PROP_AUTHOR, this.author);
|
||||
this.nodeService.addAspect(nodeRef, ContentModel.ASPECT_AUTHOR, authorProps);
|
||||
}
|
||||
else
|
||||
{
|
||||
contentProps.put(ContentModel.PROP_AUTHOR, this.author);
|
||||
}
|
||||
}
|
||||
|
||||
// set up content properties - copy or create the compound property
|
||||
ContentData contentData = (ContentData)contentProps.get(ContentModel.PROP_CONTENT);
|
||||
if (contentData == null)
|
||||
{
|
||||
contentData = new ContentData(null, this.contentType, 0L, "UTF-8");
|
||||
}
|
||||
else
|
||||
{
|
||||
contentData = new ContentData(
|
||||
contentData.getContentUrl(),
|
||||
this.contentType,
|
||||
contentData.getSize(),
|
||||
contentData.getEncoding());
|
||||
}
|
||||
contentProps.put(ContentModel.PROP_CONTENT, contentData);
|
||||
|
||||
if (this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_INLINEEDITABLE) == false)
|
||||
{
|
||||
Map<QName, Serializable> editProps = new HashMap<QName, Serializable>(1, 1.0f);
|
||||
editProps.put(ContentModel.PROP_EDITINLINE, this.inlineEdit);
|
||||
this.nodeService.addAspect(nodeRef, ContentModel.ASPECT_INLINEEDITABLE, editProps);
|
||||
}
|
||||
else
|
||||
{
|
||||
contentProps.put(ContentModel.PROP_EDITINLINE, this.inlineEdit);
|
||||
}
|
||||
this.nodeService.setProperties(nodeRef, contentProps);
|
||||
}
|
||||
else
|
||||
{
|
||||
// get the node ref of the node that will contain the content
|
||||
NodeRef containerNodeRef;
|
||||
String nodeId = getNavigator().getCurrentNodeId();
|
||||
if (nodeId == null)
|
||||
{
|
||||
containerNodeRef = this.nodeService.getRootNode(Repository.getStoreRef());
|
||||
}
|
||||
else
|
||||
{
|
||||
containerNodeRef = new NodeRef(Repository.getStoreRef(), nodeId);
|
||||
}
|
||||
|
||||
FileInfo fileInfo = fileFolderService.create(
|
||||
containerNodeRef,
|
||||
this.fileName,
|
||||
Repository.resolveToQName(this.objectType));
|
||||
NodeRef fileNodeRef = fileInfo.getNodeRef();
|
||||
|
||||
// set the author aspect (if we have one)
|
||||
if (this.author != null && this.author.length() > 0)
|
||||
{
|
||||
Map<QName, Serializable> authorProps = new HashMap<QName, Serializable>(1, 1.0f);
|
||||
authorProps.put(ContentModel.PROP_AUTHOR, this.author);
|
||||
this.nodeService.addAspect(fileNodeRef, ContentModel.ASPECT_AUTHOR, authorProps);
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Created file node for file: " + this.fileName);
|
||||
|
||||
// apply the titled aspect - title and description
|
||||
Map<QName, Serializable> titledProps = new HashMap<QName, Serializable>(3, 1.0f);
|
||||
titledProps.put(ContentModel.PROP_TITLE, this.title);
|
||||
titledProps.put(ContentModel.PROP_DESCRIPTION, this.description);
|
||||
this.nodeService.addAspect(fileNodeRef, ContentModel.ASPECT_TITLED, titledProps);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Added titled aspect with properties: " + titledProps);
|
||||
|
||||
// apply the inlineeditable aspect
|
||||
if (this.inlineEdit == true)
|
||||
{
|
||||
Map<QName, Serializable> editProps = new HashMap<QName, Serializable>(1, 1.0f);
|
||||
editProps.put(ContentModel.PROP_EDITINLINE, this.inlineEdit);
|
||||
this.nodeService.addAspect(fileNodeRef, ContentModel.ASPECT_INLINEEDITABLE, editProps);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Added inlineeditable aspect with properties: " + editProps);
|
||||
}
|
||||
|
||||
// get a writer for the content and put the file
|
||||
ContentWriter writer = contentService.getWriter(fileNodeRef, ContentModel.PROP_CONTENT, true);
|
||||
// set the mimetype and encoding
|
||||
writer.setMimetype(this.contentType);
|
||||
writer.setEncoding("UTF-8");
|
||||
if (fileContent != null)
|
||||
{
|
||||
writer.putContent(fileContent);
|
||||
}
|
||||
else if (strContent != null)
|
||||
{
|
||||
writer.putContent(strContent);
|
||||
}
|
||||
|
||||
// remember the created node now
|
||||
this.createdNode = fileNodeRef;
|
||||
}
|
||||
|
||||
// give subclasses a chance to perform custom processing before committing
|
||||
performCustomProcessing();
|
||||
|
||||
// commit the transaction
|
||||
tx.commit();
|
||||
}
|
||||
catch (FileExistsException e)
|
||||
{
|
||||
// rollback the transaction
|
||||
try { if (tx != null) {tx.rollback();} } catch (Exception ex) {}
|
||||
// print status message
|
||||
String statusMsg = MessageFormat.format(
|
||||
Application.getMessage(
|
||||
FacesContext.getCurrentInstance(), "error_exists"),
|
||||
e.getExisting().getName());
|
||||
Utils.addErrorMessage(statusMsg);
|
||||
// no outcome
|
||||
outcome = null;
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
// rollback the transaction
|
||||
try { if (tx != null) {tx.rollback();} } catch (Exception ex) {}
|
||||
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
|
||||
FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), e.getMessage()), e);
|
||||
outcome = null;
|
||||
}
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.wizard.AbstractWizardBean#getStepInstructions()
|
||||
*/
|
||||
public String getStepInstructions()
|
||||
{
|
||||
String stepInstruction = null;
|
||||
|
||||
switch (this.currentStep)
|
||||
{
|
||||
case 3:
|
||||
{
|
||||
stepInstruction = Application.getMessage(FacesContext.getCurrentInstance(), FINISH_INSTRUCTION_ID);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
stepInstruction = Application.getMessage(FacesContext.getCurrentInstance(), DEFAULT_INSTRUCTION_ID);
|
||||
}
|
||||
}
|
||||
|
||||
return stepInstruction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialises the wizard
|
||||
*/
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
|
||||
this.fileName = null;
|
||||
this.author = null;
|
||||
this.title = null;
|
||||
this.description = null;
|
||||
this.contentType = null;
|
||||
this.inlineEdit = false;
|
||||
this.contentTypes = null;
|
||||
this.objectTypes = null;
|
||||
|
||||
this.objectType = ContentModel.TYPE_CONTENT.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.wizard.AbstractWizardBean#populate()
|
||||
*/
|
||||
public void populate()
|
||||
{
|
||||
// get hold of the current document and populate the appropriate values
|
||||
Node currentDocument = this.browseBean.getDocument();
|
||||
Map<String, Object> props = currentDocument.getProperties();
|
||||
|
||||
Boolean inline = (Boolean)props.get("editInline");
|
||||
this.inlineEdit = inline != null ? inline.booleanValue() : false;
|
||||
this.author = (String)props.get("creator");
|
||||
this.contentType = null;
|
||||
ContentData contentData = (ContentData)props.get(ContentModel.PROP_CONTENT);
|
||||
if (contentData != null)
|
||||
{
|
||||
this.contentType = contentData.getMimetype();
|
||||
}
|
||||
this.description = (String)props.get("description");
|
||||
this.fileName = currentDocument.getName();
|
||||
this.title = (String)props.get("title");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the contentService.
|
||||
*/
|
||||
public ContentService getContentService()
|
||||
{
|
||||
return contentService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param contentService The contentService to set.
|
||||
*/
|
||||
public void setContentService(ContentService contentService)
|
||||
{
|
||||
this.contentService = contentService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the dictionary service
|
||||
*
|
||||
* @param dictionaryService the dictionary service
|
||||
*/
|
||||
public void setDictionaryService(DictionaryService dictionaryService)
|
||||
{
|
||||
this.dictionaryService = dictionaryService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the name of the file
|
||||
*/
|
||||
public String getFileName()
|
||||
{
|
||||
return this.fileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param fileName The name of the file
|
||||
*/
|
||||
public void setFileName(String fileName)
|
||||
{
|
||||
this.fileName = fileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the author
|
||||
*/
|
||||
public String getAuthor()
|
||||
{
|
||||
return this.author;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param author Sets the author
|
||||
*/
|
||||
public void setAuthor(String author)
|
||||
{
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the content type currenty selected
|
||||
*/
|
||||
public String getContentType()
|
||||
{
|
||||
return this.contentType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param contentType Sets the currently selected content type
|
||||
*/
|
||||
public void setContentType(String contentType)
|
||||
{
|
||||
this.contentType = contentType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the object type currenty selected
|
||||
*/
|
||||
public String getObjectType()
|
||||
{
|
||||
return this.objectType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param objectType Sets the currently selected object type
|
||||
*/
|
||||
public void setObjectType(String objectType)
|
||||
{
|
||||
this.objectType = objectType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the description
|
||||
*/
|
||||
public String getDescription()
|
||||
{
|
||||
return this.description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param description Sets the description
|
||||
*/
|
||||
public void setDescription(String description)
|
||||
{
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the title
|
||||
*/
|
||||
public String getTitle()
|
||||
{
|
||||
return this.title;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param title Sets the title
|
||||
*/
|
||||
public void setTitle(String title)
|
||||
{
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the inline edit flag.
|
||||
*/
|
||||
public boolean isInlineEdit()
|
||||
{
|
||||
return this.inlineEdit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param inlineEdit The inline edit flag to set.
|
||||
*/
|
||||
public void setInlineEdit(boolean inlineEdit)
|
||||
{
|
||||
this.inlineEdit = inlineEdit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns a list of content types to allow the user to select from
|
||||
*/
|
||||
public List<SelectItem> getContentTypes()
|
||||
{
|
||||
if (this.contentTypes == null)
|
||||
{
|
||||
this.contentTypes = new ArrayList<SelectItem>(80);
|
||||
ServiceRegistry registry = Repository.getServiceRegistry(FacesContext.getCurrentInstance());
|
||||
MimetypeService mimetypeService = registry.getMimetypeService();
|
||||
|
||||
// get the mime type display names
|
||||
Map<String, String> mimeTypes = mimetypeService.getDisplaysByMimetype();
|
||||
for (String mimeType : mimeTypes.keySet())
|
||||
{
|
||||
this.contentTypes.add(new SelectItem(mimeType, mimeTypes.get(mimeType)));
|
||||
}
|
||||
|
||||
// make sure the list is sorted by the values
|
||||
QuickSort sorter = new QuickSort(this.contentTypes, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
|
||||
sorter.sort();
|
||||
}
|
||||
|
||||
return this.contentTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns a list of object types to allow the user to select from
|
||||
*/
|
||||
public List<SelectItem> getObjectTypes()
|
||||
{
|
||||
if (this.objectTypes == null)
|
||||
{
|
||||
FacesContext context = FacesContext.getCurrentInstance();
|
||||
|
||||
// add the well known object type to start with
|
||||
this.objectTypes = new ArrayList<SelectItem>(5);
|
||||
this.objectTypes.add(new SelectItem(ContentModel.TYPE_CONTENT.toString(),
|
||||
Application.getMessage(context, "content")));
|
||||
|
||||
// add any configured content sub-types to the list
|
||||
ConfigService svc = Application.getConfigService(FacesContext.getCurrentInstance());
|
||||
Config wizardCfg = svc.getConfig("Content Wizards");
|
||||
if (wizardCfg != null)
|
||||
{
|
||||
ConfigElement typesCfg = wizardCfg.getConfigElement("content-types");
|
||||
if (typesCfg != null)
|
||||
{
|
||||
for (ConfigElement child : typesCfg.getChildren())
|
||||
{
|
||||
QName idQName = Repository.resolveToQName(child.getAttribute("name"));
|
||||
if (idQName != null)
|
||||
{
|
||||
TypeDefinition typeDef = this.dictionaryService.getType(idQName);
|
||||
|
||||
if (typeDef != null)
|
||||
{
|
||||
if (this.dictionaryService.isSubClass(typeDef.getName(), ContentModel.TYPE_CONTENT))
|
||||
{
|
||||
// try and get the display 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, just use the localname
|
||||
if (label == null)
|
||||
{
|
||||
label = idQName.getLocalName();
|
||||
}
|
||||
|
||||
this.objectTypes.add(new SelectItem(idQName.toString(), label));
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.warn("Failed to add '" + child.getAttribute("name") +
|
||||
"' to the list of content types as the type is not a subtype of cm:content");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.warn("Failed to add '" + child.getAttribute("name") +
|
||||
"' to the list of content types as the type is not recognised");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// make sure the list is sorted by the label
|
||||
QuickSort sorter = new QuickSort(this.objectTypes, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
|
||||
sorter.sort();
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.warn("Could not find 'content-types' configuration element");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.warn("Could not find 'Content Wizards' configuration section");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return this.objectTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Determines whether the next and finish button should be enabled
|
||||
*/
|
||||
public boolean getNextFinishDisabled()
|
||||
{
|
||||
boolean disabled = false;
|
||||
|
||||
if (this.fileName == null || this.fileName.length() == 0 ||
|
||||
this.title == null || this.title.length() == 0 ||
|
||||
this.contentType == null)
|
||||
{
|
||||
disabled = true;
|
||||
}
|
||||
|
||||
return disabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the display label for the content type currently chosen
|
||||
*
|
||||
* @return The human readable version of the content type
|
||||
*/
|
||||
protected String getSummaryContentType()
|
||||
{
|
||||
ServiceRegistry registry = Repository.getServiceRegistry(FacesContext.getCurrentInstance());
|
||||
MimetypeService mimetypeService = registry.getMimetypeService();
|
||||
|
||||
// get the mime type display name
|
||||
Map<String, String> mimeTypes = mimetypeService.getDisplaysByMimetype();
|
||||
return mimeTypes.get(this.contentType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the display label for the currently selected object type
|
||||
*
|
||||
* @return The objevt type label
|
||||
*/
|
||||
protected String getSummaryObjectType()
|
||||
{
|
||||
String objType = null;
|
||||
|
||||
for (SelectItem item : this.getObjectTypes())
|
||||
{
|
||||
if (item.getValue().equals(this.objectType))
|
||||
{
|
||||
objType = item.getLabel();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return objType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs any processing sub classes may wish to do before commit is called
|
||||
*/
|
||||
protected void performCustomProcessing() throws Exception
|
||||
{
|
||||
// used by subclasses if necessary
|
||||
}
|
||||
}
|
@@ -1,296 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* Licensed under the Mozilla Public License version 1.1
|
||||
* with a permitted attribution clause. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.alfresco.org/legal/license.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*/
|
||||
package org.alfresco.web.bean.wizard;
|
||||
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.event.ValueChangeEvent;
|
||||
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
|
||||
/**
|
||||
* Handler class used by the Create In-line Content Wizard
|
||||
*
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
public class CreateContentWizard extends BaseContentWizard
|
||||
{
|
||||
protected static final String CONTENT_TEXT = "txt";
|
||||
protected static final String CONTENT_HTML = "html";
|
||||
|
||||
// TODO: retrieve these from the config service
|
||||
private static final String WIZARD_TITLE_ID = "create_content_title";
|
||||
private static final String WIZARD_DESC_ID = "create_content_desc";
|
||||
private static final String STEP1_TITLE_ID = "create_content_step1_title";
|
||||
private static final String STEP1_DESCRIPTION_ID = "create_content_step1_desc";
|
||||
private static final String STEP2_TITLE_ID = "create_content_step2_title";
|
||||
private static final String STEP2_DESCRIPTION_ID = "create_content_step2_desc";
|
||||
private static final String STEP3_TITLE_ID = "create_content_step3_title";
|
||||
private static final String STEP3_DESCRIPTION_ID = "create_content_step3_desc";
|
||||
|
||||
// create content wizard specific properties
|
||||
protected String content;
|
||||
protected String createType = CONTENT_HTML;
|
||||
|
||||
|
||||
/**
|
||||
* Deals with the finish button being pressed
|
||||
*
|
||||
* @return outcome
|
||||
*/
|
||||
public String finish()
|
||||
{
|
||||
return saveContent(null, this.content);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.wizard.AbstractWizardBean#getWizardDescription()
|
||||
*/
|
||||
public String getWizardDescription()
|
||||
{
|
||||
return Application.getMessage(FacesContext.getCurrentInstance(), WIZARD_DESC_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.wizard.AbstractWizardBean#getWizardTitle()
|
||||
*/
|
||||
public String getWizardTitle()
|
||||
{
|
||||
return Application.getMessage(FacesContext.getCurrentInstance(), WIZARD_TITLE_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.wizard.AbstractWizardBean#getStepDescription()
|
||||
*/
|
||||
public String getStepDescription()
|
||||
{
|
||||
String stepDesc = null;
|
||||
|
||||
switch (this.currentStep)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
stepDesc = Application.getMessage(FacesContext.getCurrentInstance(), STEP1_DESCRIPTION_ID);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
stepDesc = Application.getMessage(FacesContext.getCurrentInstance(), STEP2_DESCRIPTION_ID);
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
stepDesc = Application.getMessage(FacesContext.getCurrentInstance(), STEP3_DESCRIPTION_ID);
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
stepDesc = Application.getMessage(FacesContext.getCurrentInstance(), SUMMARY_DESCRIPTION_ID);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
stepDesc = "";
|
||||
}
|
||||
}
|
||||
|
||||
return stepDesc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.wizard.AbstractWizardBean#getStepInstructions()
|
||||
*/
|
||||
public String getStepInstructions()
|
||||
{
|
||||
String stepInstruction = null;
|
||||
|
||||
switch (this.currentStep)
|
||||
{
|
||||
case 4:
|
||||
{
|
||||
stepInstruction = Application.getMessage(FacesContext.getCurrentInstance(), FINISH_INSTRUCTION_ID);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
stepInstruction = Application.getMessage(FacesContext.getCurrentInstance(), DEFAULT_INSTRUCTION_ID);
|
||||
}
|
||||
}
|
||||
|
||||
return stepInstruction;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.wizard.AbstractWizardBean#getStepTitle()
|
||||
*/
|
||||
public String getStepTitle()
|
||||
{
|
||||
String stepTitle = null;
|
||||
|
||||
switch (this.currentStep)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
stepTitle = Application.getMessage(FacesContext.getCurrentInstance(), STEP1_TITLE_ID);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
stepTitle = Application.getMessage(FacesContext.getCurrentInstance(), STEP2_TITLE_ID);
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
stepTitle = Application.getMessage(FacesContext.getCurrentInstance(), STEP3_TITLE_ID);
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
stepTitle = Application.getMessage(FacesContext.getCurrentInstance(), SUMMARY_TITLE_ID);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
stepTitle = "";
|
||||
}
|
||||
}
|
||||
|
||||
return stepTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the content from the edited form.
|
||||
*/
|
||||
public String getContent()
|
||||
{
|
||||
return this.content;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param content The content to edit (should be clear initially)
|
||||
*/
|
||||
public void setContent(String content)
|
||||
{
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialises the wizard
|
||||
*/
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
|
||||
this.content = null;
|
||||
|
||||
// created content is inline editable by default
|
||||
this.inlineEdit = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the summary data for the wizard.
|
||||
*/
|
||||
public String getSummary()
|
||||
{
|
||||
ResourceBundle bundle = Application.getBundle(FacesContext.getCurrentInstance());
|
||||
|
||||
// TODO: show first few lines of content here?
|
||||
return buildSummary(
|
||||
new String[] {bundle.getString("file_name"), bundle.getString("type"),
|
||||
bundle.getString("content_type"), bundle.getString("title"),
|
||||
bundle.getString("description"), bundle.getString("author")},
|
||||
new String[] {this.fileName, getSummaryObjectType(), getSummaryContentType(),
|
||||
this.title, this.description, this.author});
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.wizard.AbstractWizardBean#determineOutcomeForStep(int)
|
||||
*/
|
||||
protected String determineOutcomeForStep(int step)
|
||||
{
|
||||
String outcome = null;
|
||||
|
||||
switch(step)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
outcome = "select";
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
if (getCreateType().equals(CONTENT_HTML))
|
||||
{
|
||||
outcome = "create-html";
|
||||
}
|
||||
else if (getCreateType().equals(CONTENT_TEXT))
|
||||
{
|
||||
outcome = "create-text";
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
this.fileName = "newfile." + getCreateType();
|
||||
this.contentType = Repository.getMimeTypeForFileName(
|
||||
FacesContext.getCurrentInstance(), this.fileName);
|
||||
this.title = this.fileName;
|
||||
|
||||
outcome = "properties";
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
outcome = "summary";
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
outcome = CANCEL_OUTCOME;
|
||||
}
|
||||
}
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create content type value changed by the user
|
||||
*/
|
||||
public void createContentChanged(ValueChangeEvent event)
|
||||
{
|
||||
// clear the content as HTML is not compatible with the plain text box etc.
|
||||
this.content = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the createType.
|
||||
*/
|
||||
public String getCreateType()
|
||||
{
|
||||
return this.createType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param createType The createType to set.
|
||||
*/
|
||||
public void setCreateType(String createType)
|
||||
{
|
||||
this.createType = createType;
|
||||
}
|
||||
}
|
@@ -1,180 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* Licensed under the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation; either version
|
||||
* 2.1 of the License, or (at your option) any later version.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.gnu.org/licenses/lgpl.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*/
|
||||
package org.alfresco.web.bean.wizard;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.event.ActionEvent;
|
||||
import javax.transaction.UserTransaction;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.model.ForumModel;
|
||||
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.Repository;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
import org.alfresco.web.ui.common.component.UIActionLink;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Backing bean class used to create discussions for documents
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class NewDiscussionWizard extends NewTopicWizard
|
||||
{
|
||||
private static final Log logger = LogFactory.getLog(NewDiscussionWizard.class);
|
||||
|
||||
private NodeRef discussingNodeRef;
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.wizard.AbstractWizardBean#startWizard(javax.faces.event.ActionEvent)
|
||||
*/
|
||||
@Override
|
||||
public void startWizard(ActionEvent event)
|
||||
{
|
||||
UIActionLink link = (UIActionLink)event.getComponent();
|
||||
Map<String, String> params = link.getParameterMap();
|
||||
String id = params.get("id");
|
||||
if (id == null || id.length() == 0)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("startDiscussion called without an id");
|
||||
}
|
||||
|
||||
FacesContext context = FacesContext.getCurrentInstance();
|
||||
UserTransaction tx = null;
|
||||
NodeRef forumNodeRef = null;
|
||||
|
||||
try
|
||||
{
|
||||
tx = Repository.getUserTransaction(context);
|
||||
tx.begin();
|
||||
|
||||
this.discussingNodeRef = new NodeRef(Repository.getStoreRef(), id);
|
||||
|
||||
if (this.nodeService.hasAspect(this.discussingNodeRef, ForumModel.ASPECT_DISCUSSABLE))
|
||||
{
|
||||
throw new AlfrescoRuntimeException("startDiscussion called for an object that already has a discussion!");
|
||||
}
|
||||
|
||||
// add the discussable aspect
|
||||
this.nodeService.addAspect(this.discussingNodeRef, ForumModel.ASPECT_DISCUSSABLE, null);
|
||||
|
||||
// create a child forum space using the child association just introduced by
|
||||
// adding the discussable aspect
|
||||
String name = (String)this.nodeService.getProperty(this.discussingNodeRef,
|
||||
ContentModel.PROP_NAME);
|
||||
String msg = Application.getMessage(FacesContext.getCurrentInstance(), "discussion_for");
|
||||
String forumName = MessageFormat.format(msg, new Object[] {name});
|
||||
|
||||
Map<QName, Serializable> forumProps = new HashMap<QName, Serializable>(1);
|
||||
forumProps.put(ContentModel.PROP_NAME, forumName);
|
||||
ChildAssociationRef childRef = this.nodeService.createNode(this.discussingNodeRef,
|
||||
ForumModel.ASSOC_DISCUSSION,
|
||||
QName.createQName(ForumModel.FORUMS_MODEL_URI, "discussion"),
|
||||
ForumModel.TYPE_FORUM, forumProps);
|
||||
|
||||
forumNodeRef = childRef.getChildRef();
|
||||
|
||||
// apply the uifacets aspect
|
||||
Map<QName, Serializable> uiFacetsProps = new HashMap<QName, Serializable>(5);
|
||||
uiFacetsProps.put(ContentModel.PROP_ICON, "forum");
|
||||
this.nodeService.addAspect(forumNodeRef, ContentModel.ASPECT_UIFACETS, uiFacetsProps);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("created forum for content: " + this.discussingNodeRef.toString());
|
||||
|
||||
// commit the transaction
|
||||
tx.commit();
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
// rollback the transaction
|
||||
try { if (tx != null) {tx.rollback();} } catch (Exception ex) {}
|
||||
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
|
||||
context, Repository.ERROR_GENERIC), e.getMessage()), e);
|
||||
}
|
||||
|
||||
// finally setup the context for the forum we just created
|
||||
if (forumNodeRef != null)
|
||||
{
|
||||
this.browseBean.clickSpace(forumNodeRef);
|
||||
|
||||
// now initialise the wizard and navigate to it
|
||||
super.startWizard(event);
|
||||
context.getApplication().getNavigationHandler().handleNavigation(context, null, "dialog:createDiscussion");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.wizard.AbstractWizardBean#cancel()
|
||||
*/
|
||||
@Override
|
||||
public String cancel()
|
||||
{
|
||||
// if we cancel the creation of a discussion all the setup that was done
|
||||
// when the wizard started needs to be undone i.e. removing the created forum
|
||||
// and the discussable aspect
|
||||
|
||||
FacesContext context = FacesContext.getCurrentInstance();
|
||||
UserTransaction tx = null;
|
||||
|
||||
try
|
||||
{
|
||||
tx = Repository.getUserTransaction(context);
|
||||
tx.begin();
|
||||
|
||||
// remove the discussable aspect from the node we were going to discuss!
|
||||
this.nodeService.removeAspect(this.discussingNodeRef, ForumModel.ASPECT_DISCUSSABLE);
|
||||
|
||||
// delete the forum space created when the wizard started
|
||||
this.browseBean.setActionSpace(this.navigator.getCurrentNode());
|
||||
this.browseBean.deleteSpaceOK();
|
||||
|
||||
// commit the transaction
|
||||
tx.commit();
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
// rollback the transaction
|
||||
try { if (tx != null) {tx.rollback();} } catch (Exception ex) {}
|
||||
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
|
||||
context, Repository.ERROR_GENERIC), e.getMessage()), e);
|
||||
}
|
||||
|
||||
// do cancel processing
|
||||
super.cancel();
|
||||
|
||||
// as we are cancelling the creation of a discussion we know we need to go back
|
||||
// to the browse screen, this also makes sure we don't end up in the forum that
|
||||
// just got deleted!
|
||||
return AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME +
|
||||
AlfrescoNavigationHandler.OUTCOME_SEPARATOR + "browse";
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* Licensed under the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation; either version
|
||||
* 2.1 of the License, or (at your option) any later version.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.gnu.org/licenses/lgpl.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*/
|
||||
package org.alfresco.web.bean.wizard;
|
||||
|
||||
import org.alfresco.model.ForumModel;
|
||||
import org.alfresco.web.app.AlfrescoNavigationHandler;
|
||||
|
||||
/**
|
||||
* Wizard bean used for creating and editing forum spaces
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class NewForumWizard extends NewSpaceWizard
|
||||
{
|
||||
/**
|
||||
* @see org.alfresco.web.bean.wizard.AbstractWizardBean#init()
|
||||
*/
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
|
||||
this.spaceType = ForumModel.TYPE_FORUM.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.wizard.AbstractWizardBean#finish()
|
||||
*/
|
||||
@Override
|
||||
public String finish()
|
||||
{
|
||||
String outcome = super.finish();
|
||||
|
||||
// if we had a successful outcome from the creation close the dialog
|
||||
if (outcome != null);
|
||||
{
|
||||
outcome = AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME;
|
||||
}
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.wizard.AbstractWizardBean#cancel()
|
||||
*/
|
||||
@Override
|
||||
public String cancel()
|
||||
{
|
||||
super.cancel();
|
||||
|
||||
return AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME;
|
||||
}
|
||||
}
|
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* Licensed under the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation; either version
|
||||
* 2.1 of the License, or (at your option) any later version.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.gnu.org/licenses/lgpl.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*/
|
||||
package org.alfresco.web.bean.wizard;
|
||||
|
||||
import org.alfresco.model.ForumModel;
|
||||
import org.alfresco.web.app.AlfrescoNavigationHandler;
|
||||
|
||||
/**
|
||||
* Wizard bean used for creating and editing forums spaces
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class NewForumsWizard extends NewSpaceWizard
|
||||
{
|
||||
/**
|
||||
* @see org.alfresco.web.bean.wizard.AbstractWizardBean#init()
|
||||
*/
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
|
||||
this.spaceType = ForumModel.TYPE_FORUMS.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.wizard.AbstractWizardBean#finish()
|
||||
*/
|
||||
@Override
|
||||
public String finish()
|
||||
{
|
||||
String outcome = super.finish();
|
||||
|
||||
// if we had a successful outcome from the creation close the dialog
|
||||
if (outcome != null);
|
||||
{
|
||||
outcome = AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME;
|
||||
}
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.wizard.AbstractWizardBean#cancel()
|
||||
*/
|
||||
@Override
|
||||
public String cancel()
|
||||
{
|
||||
super.cancel();
|
||||
|
||||
return AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME;
|
||||
}
|
||||
}
|
@@ -1,168 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* Licensed under the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation; either version
|
||||
* 2.1 of the License, or (at your option) any later version.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.gnu.org/licenses/lgpl.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*/
|
||||
package org.alfresco.web.bean.wizard;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.event.ActionEvent;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.model.ForumModel;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.web.app.AlfrescoNavigationHandler;
|
||||
import org.alfresco.web.bean.ForumsBean;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Backing bean for posting forum articles.
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class NewPostWizard extends CreateContentWizard
|
||||
{
|
||||
/**
|
||||
* @see org.alfresco.web.bean.wizard.AbstractWizardBean#init()
|
||||
*/
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
|
||||
// set up for creating a post
|
||||
this.objectType = ForumModel.TYPE_POST.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.wizard.AbstractWizardBean#startWizardForEdit(javax.faces.event.ActionEvent)
|
||||
*/
|
||||
@Override
|
||||
public void startWizardForEdit(ActionEvent event)
|
||||
{
|
||||
// TODO: Allow action link to have multiple action listeners
|
||||
// then we wouldn't need to have this coupling back
|
||||
// to the browse bean in here
|
||||
|
||||
// we need to setup the content in the browse bean first
|
||||
this.browseBean.setupContentAction(event);
|
||||
|
||||
super.startWizardForEdit(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.wizard.AbstractWizardBean#populate()
|
||||
*/
|
||||
@Override
|
||||
public void populate()
|
||||
{
|
||||
super.populate();
|
||||
|
||||
// we need to remove the <br> tags and replace with carriage returns
|
||||
// and then setup the content member variable
|
||||
Node currentDocument = this.browseBean.getDocument();
|
||||
ContentReader reader = this.contentService.getReader(currentDocument.getNodeRef(),
|
||||
ContentModel.PROP_CONTENT);
|
||||
|
||||
if (reader != null)
|
||||
{
|
||||
String htmlContent = reader.getContentString();
|
||||
if (htmlContent != null)
|
||||
{
|
||||
this.content = StringUtils.replace(htmlContent, "<br/>", "\r\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.wizard.AbstractWizardBean#finish()
|
||||
*/
|
||||
@Override
|
||||
public String finish()
|
||||
{
|
||||
if (this.editMode)
|
||||
{
|
||||
// remove the line breaks before the save
|
||||
this.content = Utils.replaceLineBreaks(this.content);
|
||||
}
|
||||
else
|
||||
{
|
||||
// create appropriate values for filename and content type
|
||||
this.fileName = ForumsBean.createPostFileName();
|
||||
this.contentType = Repository.getMimeTypeForFileName(
|
||||
FacesContext.getCurrentInstance(), this.fileName);
|
||||
|
||||
// remove link breaks and replace with <br/>
|
||||
this.content = Utils.replaceLineBreaks(this.content);
|
||||
}
|
||||
|
||||
String outcome = super.finish();
|
||||
|
||||
// if we had a successful outcome from the creation close the dialog
|
||||
if (outcome != null);
|
||||
{
|
||||
outcome = AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME;
|
||||
}
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.wizard.BaseContentWizard#performCustomProcessing()
|
||||
*/
|
||||
@Override
|
||||
protected void performCustomProcessing() throws Exception
|
||||
{
|
||||
if (this.editMode)
|
||||
{
|
||||
// update the content
|
||||
NodeRef postNode = this.browseBean.getDocument().getNodeRef();
|
||||
|
||||
// check that the name of this post does not contain the :
|
||||
// character (used in previous versions), if it does rename
|
||||
// the post.
|
||||
String name = (String)this.nodeService.getProperty(
|
||||
postNode, ContentModel.PROP_NAME);
|
||||
if (name.indexOf(":") != -1)
|
||||
{
|
||||
String newName = name.replace(':', '-');
|
||||
this.fileFolderService.rename(postNode, newName);
|
||||
}
|
||||
|
||||
ContentWriter writer = this.contentService.getWriter(postNode,
|
||||
ContentModel.PROP_CONTENT, true);
|
||||
if (writer != null)
|
||||
{
|
||||
writer.putContent(this.content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.wizard.AbstractWizardBean#cancel()
|
||||
*/
|
||||
@Override
|
||||
public String cancel()
|
||||
{
|
||||
super.cancel();
|
||||
|
||||
return AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME;
|
||||
}
|
||||
}
|
@@ -1,142 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* Licensed under the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation; either version
|
||||
* 2.1 of the License, or (at your option) any later version.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.gnu.org/licenses/lgpl.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*/
|
||||
package org.alfresco.web.bean.wizard;
|
||||
|
||||
import javax.faces.event.ActionEvent;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.web.app.AlfrescoNavigationHandler;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
|
||||
/**
|
||||
* Backing bean for posting replies to forum articles.
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class NewReplyWizard extends NewPostWizard
|
||||
{
|
||||
private static Log logger = LogFactory.getLog(NewReplyWizard.class);
|
||||
|
||||
private String replyContent = null;
|
||||
|
||||
/**
|
||||
* Returns the content of the post we are replying to
|
||||
*
|
||||
* @return The content
|
||||
*/
|
||||
public String getReplyContent()
|
||||
{
|
||||
if (this.replyContent == null)
|
||||
{
|
||||
// get the content reader of the node we are replying to
|
||||
NodeRef replyNode = this.browseBean.getDocument().getNodeRef();
|
||||
if (replyNode != null)
|
||||
{
|
||||
ContentReader reader = this.contentService.getReader(replyNode, ContentModel.PROP_CONTENT);
|
||||
|
||||
if (reader != null)
|
||||
{
|
||||
this.replyContent = reader.getContentString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this.replyContent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.wizard.AbstractWizardBean#init()
|
||||
*/
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
|
||||
this.replyContent = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.wizard.AbstractWizardBean#startWizard(javax.faces.event.ActionEvent)
|
||||
*/
|
||||
@Override
|
||||
public void startWizard(ActionEvent event)
|
||||
{
|
||||
super.startWizard(event);
|
||||
|
||||
// also setup the content in the browse bean
|
||||
this.browseBean.setupContentAction(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.wizard.AbstractWizardBean#finish()
|
||||
*/
|
||||
@Override
|
||||
public String finish()
|
||||
{
|
||||
// remove link breaks and replace with <br/>
|
||||
this.content = Utils.replaceLineBreaks(this.content);
|
||||
|
||||
String outcome = super.finish();
|
||||
|
||||
// if we had a successful outcome from the creation close the dialog
|
||||
if (outcome != null);
|
||||
{
|
||||
outcome = AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME;
|
||||
}
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.wizard.BaseContentWizard#performCustomProcessing()
|
||||
*/
|
||||
@Override
|
||||
protected void performCustomProcessing()
|
||||
{
|
||||
if (this.editMode == false)
|
||||
{
|
||||
// setup the referencing aspect with the references association
|
||||
// between the new post and the one being replied to
|
||||
this.nodeService.addAspect(this.createdNode, ContentModel.ASPECT_REFERENCING, null);
|
||||
this.nodeService.createAssociation(this.createdNode, this.browseBean.getDocument().getNodeRef(),
|
||||
ContentModel.ASSOC_REFERENCES);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("created new node: " + this.createdNode);
|
||||
logger.debug("existing node: " + this.browseBean.getDocument().getNodeRef());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.wizard.AbstractWizardBean#cancel()
|
||||
*/
|
||||
@Override
|
||||
public String cancel()
|
||||
{
|
||||
super.cancel();
|
||||
|
||||
return AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME;
|
||||
}
|
||||
}
|
@@ -1,974 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* Licensed under the Mozilla Public License version 1.1
|
||||
* with a permitted attribution clause. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.alfresco.org/legal/license.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*/
|
||||
package org.alfresco.web.bean.wizard;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import javax.faces.application.FacesMessage;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.model.SelectItem;
|
||||
import javax.transaction.UserTransaction;
|
||||
|
||||
import org.alfresco.config.Config;
|
||||
import org.alfresco.config.ConfigElement;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.dictionary.TypeDefinition;
|
||||
import org.alfresco.service.cmr.model.FileExistsException;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.search.SearchService;
|
||||
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.bean.repository.Node;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.data.IDataContainer;
|
||||
import org.alfresco.web.data.QuickSort;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
import org.alfresco.web.ui.common.component.UIListItem;
|
||||
import org.alfresco.web.ui.common.component.description.UIDescription;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Handler class used by the New Space Wizard
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class NewSpaceWizard extends AbstractWizardBean
|
||||
{
|
||||
public static final String SPACE_ICON_DEFAULT = "space-icon-default";
|
||||
|
||||
private static Log logger = LogFactory.getLog(NewSpaceWizard.class);
|
||||
|
||||
// TODO: retrieve these from the config service
|
||||
private static final String WIZARD_TITLE_ID = "new_space_title";
|
||||
private static final String WIZARD_DESC_ID = "new_space_desc";
|
||||
private static final String STEP1_TITLE_ID = "new_space_step1_title";
|
||||
private static final String STEP1_DESCRIPTION_ID = "new_space_step1_desc";
|
||||
private static final String STEP2_TITLE_ID = "new_space_step2_title";
|
||||
private static final String STEP2_DESCRIPTION_ID = "new_space_step2_desc";
|
||||
private static final String STEP3_TITLE_ID = "new_space_step3_title";
|
||||
private static final String STEP3_DESCRIPTION_ID = "new_space_step3_desc";
|
||||
private static final String FINISH_INSTRUCTION_ID = "new_space_finish_instruction";
|
||||
|
||||
private static final String ERROR = "error_space";
|
||||
private static final String DEFAULT_SPACE_TYPE_ICON = "/images/icons/space.gif";
|
||||
private static final String ICONS_LOOKUP_KEY = " icons";
|
||||
|
||||
// new space wizard specific properties
|
||||
protected SearchService searchService;
|
||||
protected NamespaceService namespaceService;
|
||||
protected DictionaryService dictionaryService;
|
||||
|
||||
protected String spaceType;
|
||||
protected String icon;
|
||||
protected String createFrom;
|
||||
protected NodeRef existingSpaceId;
|
||||
protected String templateSpaceId;
|
||||
protected String copyPolicy;
|
||||
protected String name;
|
||||
protected String description;
|
||||
protected String templateName;
|
||||
protected boolean saveAsTemplate;
|
||||
protected List<SelectItem> templates;
|
||||
protected List<UIListItem> folderTypes;
|
||||
protected List<UIDescription> folderTypeDescriptions;
|
||||
|
||||
// the NodeRef of the node created during finish
|
||||
protected NodeRef createdNode;
|
||||
|
||||
/**
|
||||
* Deals with the finish button being pressed
|
||||
*
|
||||
* @return outcome
|
||||
*/
|
||||
public String finish()
|
||||
{
|
||||
String outcome = FINISH_OUTCOME;
|
||||
|
||||
UserTransaction tx = null;
|
||||
|
||||
try
|
||||
{
|
||||
FacesContext context = FacesContext.getCurrentInstance();
|
||||
tx = Repository.getUserTransaction(FacesContext.getCurrentInstance());
|
||||
tx.begin();
|
||||
|
||||
if (this.editMode)
|
||||
{
|
||||
// update the existing node in the repository
|
||||
Node currentSpace = this.browseBean.getActionSpace();
|
||||
NodeRef nodeRef = currentSpace.getNodeRef();
|
||||
|
||||
// rename if necessary
|
||||
fileFolderService.rename(nodeRef, this.name);
|
||||
|
||||
// update the properties
|
||||
Map<QName, Serializable> properties = this.nodeService.getProperties(nodeRef);
|
||||
properties.put(ContentModel.PROP_NAME, this.name);
|
||||
properties.put(ContentModel.PROP_ICON, this.icon);
|
||||
properties.put(ContentModel.PROP_DESCRIPTION, this.description);
|
||||
|
||||
// apply properties
|
||||
this.nodeService.setProperties(nodeRef, properties);
|
||||
}
|
||||
else
|
||||
{
|
||||
String newSpaceId = null;
|
||||
|
||||
if (this.createFrom.equals("scratch"))
|
||||
{
|
||||
// create the space (just create a folder for now)
|
||||
NodeRef parentNodeRef;
|
||||
String nodeId = getNavigator().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();
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Created folder node with name: " + this.name);
|
||||
|
||||
// apply the uifacets aspect - icon, title and description props
|
||||
Map<QName, Serializable> uiFacetsProps = new HashMap<QName, Serializable>(5);
|
||||
uiFacetsProps.put(ContentModel.PROP_ICON, this.icon);
|
||||
uiFacetsProps.put(ContentModel.PROP_TITLE, this.name);
|
||||
uiFacetsProps.put(ContentModel.PROP_DESCRIPTION, this.description);
|
||||
this.nodeService.addAspect(nodeRef, ContentModel.ASPECT_UIFACETS, uiFacetsProps);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Added uifacets aspect with properties: " + uiFacetsProps);
|
||||
|
||||
// remember the created node
|
||||
this.createdNode = nodeRef;
|
||||
}
|
||||
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(), getNavigator().getCurrentNodeId());
|
||||
|
||||
// copy from existing
|
||||
NodeRef copiedNode = this.fileFolderService.copy(sourceNode, parentSpace, this.name).getNodeRef();
|
||||
|
||||
// also need to set the new description and icon properties
|
||||
this.nodeService.setProperty(copiedNode, ContentModel.PROP_DESCRIPTION, this.description);
|
||||
this.nodeService.setProperty(copiedNode, ContentModel.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;
|
||||
}
|
||||
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(), getNavigator().getCurrentNodeId());
|
||||
// copy from the template
|
||||
NodeRef copiedNode = this.fileFolderService.copy(sourceNode, parentSpace, this.name).getNodeRef();
|
||||
// also need to set the new description and icon properties
|
||||
this.nodeService.setProperty(copiedNode, ContentModel.PROP_DESCRIPTION, this.description);
|
||||
this.nodeService.setProperty(copiedNode, ContentModel.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)
|
||||
{
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// give subclasses a chance to perform custom processing before committing
|
||||
performCustomProcessing(context);
|
||||
|
||||
// commit the transaction
|
||||
tx.commit();
|
||||
|
||||
// now we know the new details are in the repository, reset the
|
||||
// client side node representation so the new details are retrieved
|
||||
String statusMsg = null;
|
||||
if (this.editMode)
|
||||
{
|
||||
this.browseBean.getActionSpace().reset();
|
||||
statusMsg = MessageFormat.format(Application.getMessage(context, "status_space_updated"),
|
||||
new Object[]{this.name});
|
||||
}
|
||||
else
|
||||
{
|
||||
// add a message to inform the user that the creation was OK
|
||||
statusMsg = MessageFormat.format(Application.getMessage(context, "status_space_created"),
|
||||
new Object[]{this.name});
|
||||
}
|
||||
|
||||
// add the status message
|
||||
Utils.addStatusMessage(FacesMessage.SEVERITY_INFO, statusMsg);
|
||||
}
|
||||
catch (FileExistsException e)
|
||||
{
|
||||
// rollback the transaction
|
||||
try { if (tx != null) {tx.rollback();} } catch (Exception ex) {}
|
||||
// print status message
|
||||
String statusMsg = MessageFormat.format(
|
||||
Application.getMessage(
|
||||
FacesContext.getCurrentInstance(), "error_exists"),
|
||||
e.getExisting().getName());
|
||||
Utils.addErrorMessage(statusMsg);
|
||||
// no outcome
|
||||
outcome = null;
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
// rollback the transaction
|
||||
try { if (tx != null) {tx.rollback();} } catch (Exception ex) {}
|
||||
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
|
||||
FacesContext.getCurrentInstance(), ERROR), e.getMessage()), e);
|
||||
outcome = null;
|
||||
}
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.wizard.AbstractWizardBean#getWizardDescription()
|
||||
*/
|
||||
public String getWizardDescription()
|
||||
{
|
||||
return Application.getMessage(FacesContext.getCurrentInstance(), WIZARD_DESC_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.wizard.AbstractWizardBean#getWizardTitle()
|
||||
*/
|
||||
public String getWizardTitle()
|
||||
{
|
||||
return Application.getMessage(FacesContext.getCurrentInstance(), WIZARD_TITLE_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.wizard.AbstractWizardBean#getStepDescription()
|
||||
*/
|
||||
public String getStepDescription()
|
||||
{
|
||||
String stepDesc = null;
|
||||
|
||||
switch (this.currentStep)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
stepDesc = Application.getMessage(FacesContext.getCurrentInstance(), STEP1_DESCRIPTION_ID);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
stepDesc = Application.getMessage(FacesContext.getCurrentInstance(), STEP2_DESCRIPTION_ID);
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
stepDesc = Application.getMessage(FacesContext.getCurrentInstance(), STEP3_DESCRIPTION_ID);
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
stepDesc = Application.getMessage(FacesContext.getCurrentInstance(), SUMMARY_DESCRIPTION_ID);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
stepDesc = "";
|
||||
}
|
||||
}
|
||||
|
||||
return stepDesc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.wizard.AbstractWizardBean#getStepTitle()
|
||||
*/
|
||||
public String getStepTitle()
|
||||
{
|
||||
String stepTitle = null;
|
||||
|
||||
switch (this.currentStep)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
stepTitle = Application.getMessage(FacesContext.getCurrentInstance(), STEP1_TITLE_ID);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
stepTitle = Application.getMessage(FacesContext.getCurrentInstance(), STEP2_TITLE_ID);
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
stepTitle = Application.getMessage(FacesContext.getCurrentInstance(), STEP3_TITLE_ID);
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
stepTitle = Application.getMessage(FacesContext.getCurrentInstance(), SUMMARY_TITLE_ID);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
stepTitle = "";
|
||||
}
|
||||
}
|
||||
|
||||
return stepTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.wizard.AbstractWizardBean#getStepInstructions()
|
||||
*/
|
||||
public String getStepInstructions()
|
||||
{
|
||||
String stepInstruction = null;
|
||||
|
||||
switch (this.currentStep)
|
||||
{
|
||||
case 4:
|
||||
{
|
||||
stepInstruction = Application.getMessage(FacesContext.getCurrentInstance(), FINISH_INSTRUCTION_ID);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
stepInstruction = Application.getMessage(FacesContext.getCurrentInstance(), DEFAULT_INSTRUCTION_ID);
|
||||
}
|
||||
}
|
||||
|
||||
return stepInstruction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialises the wizard
|
||||
*/
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
|
||||
// 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();
|
||||
this.icon = null;
|
||||
this.copyPolicy = "contents";
|
||||
this.existingSpaceId = null;
|
||||
this.templateSpaceId = null;
|
||||
this.name = null;
|
||||
this.description = "";
|
||||
this.templateName = null;
|
||||
this.saveAsTemplate = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.wizard.AbstractWizardBean#populate()
|
||||
*/
|
||||
public void populate()
|
||||
{
|
||||
// get hold of the current node and populate the appropriate values
|
||||
Node currentSpace = browseBean.getActionSpace();
|
||||
Map<String, Object> props = currentSpace.getProperties();
|
||||
|
||||
this.name = (String)props.get("name");
|
||||
this.description = (String)props.get("description");
|
||||
this.icon = (String)props.get("app:icon");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the summary data for the wizard.
|
||||
*/
|
||||
public String getSummary()
|
||||
{
|
||||
String summaryCreateType = null;
|
||||
ResourceBundle bundle = Application.getBundle(FacesContext.getCurrentInstance());
|
||||
|
||||
if (this.createFrom.equals("scratch"))
|
||||
{
|
||||
summaryCreateType = bundle.getString("scratch");
|
||||
}
|
||||
else if (this.createFrom.equals("existing"))
|
||||
{
|
||||
summaryCreateType = bundle.getString("an_existing_space");
|
||||
}
|
||||
else if (this.createFrom.equals("template"))
|
||||
{
|
||||
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())
|
||||
{
|
||||
if (item.getValue().equals(this.spaceType))
|
||||
{
|
||||
spaceTypeLabel = item.getLabel();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return buildSummary(
|
||||
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());
|
||||
NamespaceService resolver = Repository.getServiceRegistry(context).getNamespaceService();
|
||||
List<NodeRef> results = this.searchService.selectNodes(rootNodeRef, xpath, null, resolver, false);
|
||||
|
||||
if (results.size() > 0)
|
||||
{
|
||||
for (NodeRef assocRef : results)
|
||||
{
|
||||
Node childNode = new Node(assocRef);
|
||||
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
|
||||
* and also constructs the list of descriptions for each type
|
||||
*
|
||||
* @return List of UIListItem components
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<UIListItem> getFolderTypes()
|
||||
{
|
||||
if (this.folderTypes == null)
|
||||
{
|
||||
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");
|
||||
defaultItem.setValue(ContentModel.TYPE_FOLDER.toString());
|
||||
defaultItem.setLabel(defaultLabel);
|
||||
defaultItem.setTooltip(defaultLabel);
|
||||
defaultItem.getAttributes().put("image", DEFAULT_SPACE_TYPE_ICON);
|
||||
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");
|
||||
if (wizardCfg != null)
|
||||
{
|
||||
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 &&
|
||||
this.dictionaryService.isSubClass(typeDef.getName(), ContentModel.TYPE_FOLDER))
|
||||
{
|
||||
// try and get the display 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;
|
||||
}
|
||||
|
||||
UIListItem item = new UIListItem();
|
||||
item.getAttributes().put("value", idQName.toString());
|
||||
item.getAttributes().put("label", label);
|
||||
item.getAttributes().put("tooltip", label);
|
||||
item.getAttributes().put("image", icon);
|
||||
this.folderTypes.add(item);
|
||||
|
||||
UIDescription desc = new UIDescription();
|
||||
desc.setControlValue(idQName.toString());
|
||||
desc.setText(description);
|
||||
this.folderTypeDescriptions.add(desc);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.warn("Could not find 'folder-types' configuration element");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
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()
|
||||
{
|
||||
if (this.folderTypeDescriptions == null)
|
||||
{
|
||||
// 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")
|
||||
public List<UIListItem> getIcons()
|
||||
{
|
||||
// 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;
|
||||
|
||||
QName type = QName.createQName(this.spaceType);
|
||||
String typePrefixForm = type.toPrefixString(this.namespaceService);
|
||||
|
||||
Config config = Application.getConfigService(FacesContext.getCurrentInstance()).
|
||||
getConfig(typePrefixForm + ICONS_LOOKUP_KEY);
|
||||
if (config != null)
|
||||
{
|
||||
ConfigElement iconsCfg = config.getConfigElement("icons");
|
||||
if (iconsCfg != null)
|
||||
{
|
||||
boolean first = true;
|
||||
for (ConfigElement icon : iconsCfg.getChildren())
|
||||
{
|
||||
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
|
||||
// the first icon in the list the default
|
||||
|
||||
icons = new ArrayList<UIListItem>(iconsCfg.getChildCount());
|
||||
if (this.icon == null)
|
||||
{
|
||||
// set the default if it is not already
|
||||
this.icon = iconName;
|
||||
}
|
||||
first = false;
|
||||
}
|
||||
|
||||
UIListItem item = new UIListItem();
|
||||
item.setValue(iconName);
|
||||
item.getAttributes().put("image", iconPath);
|
||||
icons.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if we didn't find any icons display one default choice
|
||||
if (icons == null)
|
||||
{
|
||||
icons = new ArrayList<UIListItem>(1);
|
||||
this.icon = SPACE_ICON_DEFAULT;
|
||||
|
||||
UIListItem item = new UIListItem();
|
||||
item.setValue("space-icon-default");
|
||||
item.getAttributes().put("image", "/images/icons/space-icon-default.gif");
|
||||
icons.add(item);
|
||||
}
|
||||
|
||||
return icons;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the searchService.
|
||||
*/
|
||||
public SearchService getSearchService()
|
||||
{
|
||||
return searchService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param searchService The searchService to set.
|
||||
*/
|
||||
public void setSearchService(SearchService searchService)
|
||||
{
|
||||
this.searchService = searchService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param namespaceService The NamespaceService
|
||||
*/
|
||||
public void setNamespaceService(NamespaceService namespaceService)
|
||||
{
|
||||
this.namespaceService = namespaceService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the dictionary service
|
||||
*
|
||||
* @param dictionaryService the dictionary service
|
||||
*/
|
||||
public void setDictionaryService(DictionaryService dictionaryService)
|
||||
{
|
||||
this.dictionaryService = dictionaryService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the copyPolicy.
|
||||
*/
|
||||
public String getCopyPolicy()
|
||||
{
|
||||
return copyPolicy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param copyPolicy The copyPolicy to set.
|
||||
*/
|
||||
public void setCopyPolicy(String copyPolicy)
|
||||
{
|
||||
this.copyPolicy = copyPolicy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the createFrom.
|
||||
*/
|
||||
public String getCreateFrom()
|
||||
{
|
||||
return createFrom;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param createFrom The createFrom to set.
|
||||
*/
|
||||
public void setCreateFrom(String createFrom)
|
||||
{
|
||||
this.createFrom = createFrom;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the description.
|
||||
*/
|
||||
public String getDescription()
|
||||
{
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param description The description to set.
|
||||
*/
|
||||
public void setDescription(String description)
|
||||
{
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the existingSpaceId.
|
||||
*/
|
||||
public NodeRef getExistingSpaceId()
|
||||
{
|
||||
return existingSpaceId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param existingSpaceId The existingSpaceId to set.
|
||||
*/
|
||||
public void setExistingSpaceId(NodeRef existingSpaceId)
|
||||
{
|
||||
this.existingSpaceId = existingSpaceId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the icon.
|
||||
*/
|
||||
public String getIcon()
|
||||
{
|
||||
return icon;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param icon The icon to set.
|
||||
*/
|
||||
public void setIcon(String icon)
|
||||
{
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the name.
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name The name to set.
|
||||
*/
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the saveAsTemplate.
|
||||
*/
|
||||
public boolean isSaveAsTemplate()
|
||||
{
|
||||
return saveAsTemplate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param saveAsTemplate The saveAsTemplate to set.
|
||||
*/
|
||||
public void setSaveAsTemplate(boolean saveAsTemplate)
|
||||
{
|
||||
this.saveAsTemplate = saveAsTemplate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the spaceType.
|
||||
*/
|
||||
public String getSpaceType()
|
||||
{
|
||||
return spaceType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param spaceType The spaceType to set.
|
||||
*/
|
||||
public void setSpaceType(String spaceType)
|
||||
{
|
||||
this.spaceType = spaceType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the templateName.
|
||||
*/
|
||||
public String getTemplateName()
|
||||
{
|
||||
return templateName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param templateName The templateName to set.
|
||||
*/
|
||||
public void setTemplateName(String templateName)
|
||||
{
|
||||
this.templateName = templateName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the templateSpaceId.
|
||||
*/
|
||||
public String getTemplateSpaceId()
|
||||
{
|
||||
return templateSpaceId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param templateSpaceId The templateSpaceId to set.
|
||||
*/
|
||||
public void setTemplateSpaceId(String templateSpaceId)
|
||||
{
|
||||
this.templateSpaceId = templateSpaceId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.wizard.AbstractWizardBean#determineOutcomeForStep(int)
|
||||
*/
|
||||
protected String determineOutcomeForStep(int step)
|
||||
{
|
||||
String outcome = null;
|
||||
|
||||
switch(step)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
outcome = "create-from";
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
if (createFrom.equalsIgnoreCase("scratch"))
|
||||
{
|
||||
outcome = "from-scratch";
|
||||
}
|
||||
else if (createFrom.equalsIgnoreCase("existing"))
|
||||
{
|
||||
outcome = "from-existing";
|
||||
}
|
||||
else if (createFrom.equalsIgnoreCase("template"))
|
||||
{
|
||||
outcome = "from-template";
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
outcome = "details";
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
outcome = "summary";
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
outcome = CANCEL_OUTCOME;
|
||||
}
|
||||
}
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs any processing sub classes may wish to do before commit is called
|
||||
*
|
||||
* @param context Faces context
|
||||
*/
|
||||
protected void performCustomProcessing(FacesContext context) throws Exception
|
||||
{
|
||||
// used by subclasses if necessary
|
||||
}
|
||||
}
|
@@ -1,174 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* Licensed under the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation; either version
|
||||
* 2.1 of the License, or (at your option) any later version.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.gnu.org/licenses/lgpl.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*/
|
||||
package org.alfresco.web.bean.wizard;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.model.ForumModel;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.repository.ContentService;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.web.app.AlfrescoNavigationHandler;
|
||||
import org.alfresco.web.bean.ForumsBean;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Wizard bean used for creating and editing topic spaces
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class NewTopicWizard extends NewSpaceWizard
|
||||
{
|
||||
private static final Log logger = LogFactory.getLog(NewTopicWizard.class);
|
||||
|
||||
protected String message;
|
||||
|
||||
protected ContentService contentService;
|
||||
|
||||
/**
|
||||
* Returns the message entered by the user for the first post
|
||||
*
|
||||
* @return The message for the first post
|
||||
*/
|
||||
public String getMessage()
|
||||
{
|
||||
return this.message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the message
|
||||
*
|
||||
* @param message The message
|
||||
*/
|
||||
public void setMessage(String message)
|
||||
{
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param contentService The contentService to set.
|
||||
*/
|
||||
public void setContentService(ContentService contentService)
|
||||
{
|
||||
this.contentService = contentService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.wizard.AbstractWizardBean#init()
|
||||
*/
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
|
||||
this.spaceType = ForumModel.TYPE_TOPIC.toString();
|
||||
this.message = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.wizard.NewSpaceWizard#performCustomProcessing(javax.faces.context.FacesContext)
|
||||
*/
|
||||
@Override
|
||||
protected void performCustomProcessing(FacesContext context) throws Exception
|
||||
{
|
||||
if (this.editMode == false)
|
||||
{
|
||||
// get the node ref of the node that will contain the content
|
||||
NodeRef containerNodeRef = this.createdNode;
|
||||
|
||||
// create a unique file name for the message content
|
||||
String fileName = ForumsBean.createPostFileName();
|
||||
|
||||
FileInfo fileInfo = this.fileFolderService.create(containerNodeRef,
|
||||
fileName, ForumModel.TYPE_POST);
|
||||
NodeRef postNodeRef = fileInfo.getNodeRef();
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Created post node with filename: " + fileName);
|
||||
|
||||
// apply the titled aspect - title and description
|
||||
Map<QName, Serializable> titledProps = new HashMap<QName, Serializable>(3, 1.0f);
|
||||
titledProps.put(ContentModel.PROP_TITLE, fileName);
|
||||
this.nodeService.addAspect(postNodeRef, ContentModel.ASPECT_TITLED, titledProps);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Added titled aspect with properties: " + titledProps);
|
||||
|
||||
Map<QName, Serializable> editProps = new HashMap<QName, Serializable>(1, 1.0f);
|
||||
editProps.put(ContentModel.PROP_EDITINLINE, true);
|
||||
this.nodeService.addAspect(postNodeRef, ContentModel.ASPECT_INLINEEDITABLE, editProps);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Added inlineeditable aspect with properties: " + editProps);
|
||||
|
||||
// get a writer for the content and put the file
|
||||
ContentWriter writer = contentService.getWriter(postNodeRef, ContentModel.PROP_CONTENT, true);
|
||||
// set the mimetype and encoding
|
||||
writer.setMimetype(Repository.getMimeTypeForFileName(context, fileName));
|
||||
writer.setEncoding("UTF-8");
|
||||
writer.putContent(Utils.replaceLineBreaks(this.message));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.wizard.AbstractWizardBean#finish()
|
||||
*/
|
||||
@Override
|
||||
public String finish()
|
||||
{
|
||||
String outcome = super.finish();
|
||||
|
||||
// if we had a successful outcome work out the outcome to return
|
||||
if (outcome != null)
|
||||
{
|
||||
outcome = AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME;
|
||||
|
||||
if (this.editMode == false)
|
||||
{
|
||||
// if we are successful in creating the topic we need to setup
|
||||
// the browse context for the new topic and pass an override
|
||||
// outcome of 'showTopic'
|
||||
this.browseBean.clickSpace(this.createdNode);
|
||||
|
||||
outcome = outcome + AlfrescoNavigationHandler.OUTCOME_SEPARATOR + "showTopic";
|
||||
}
|
||||
}
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.wizard.AbstractWizardBean#cancel()
|
||||
*/
|
||||
@Override
|
||||
public String cancel()
|
||||
{
|
||||
super.cancel();
|
||||
|
||||
return AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME;
|
||||
}
|
||||
}
|
@@ -45,6 +45,7 @@ import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.app.context.UIContextService;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.bean.spaces.CreateSpaceWizard;
|
||||
import org.alfresco.web.bean.users.UsersBean;
|
||||
import org.alfresco.web.config.ClientConfigElement;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
@@ -98,9 +99,6 @@ public class NewUserWizard extends AbstractWizardBean
|
||||
/** action context */
|
||||
private Node person = null;
|
||||
|
||||
/** ref to system people folder */
|
||||
private NodeRef peopleRef = null;
|
||||
|
||||
/** ref to the company home space folder */
|
||||
private NodeRef companyHomeSpaceRef = null;
|
||||
|
||||
@@ -497,7 +495,6 @@ public class NewUserWizard extends AbstractWizardBean
|
||||
props.put(ContentModel.PROP_ORGID, this.companyId);
|
||||
|
||||
// create the node to represent the Person
|
||||
String assocName = QName.createValidLocalName(this.userName);
|
||||
NodeRef newPerson = this.personService.createPerson(props);
|
||||
|
||||
// ensure the user can access their own Person object
|
||||
@@ -867,7 +864,6 @@ public class NewUserWizard extends AbstractWizardBean
|
||||
*/
|
||||
private NodeRef createHomeSpace(String locationId, String spaceName, boolean error)
|
||||
{
|
||||
String homeSpaceId = locationId;
|
||||
NodeRef homeSpaceNodeRef = null;
|
||||
if (spaceName != null && spaceName.length() != 0)
|
||||
{
|
||||
@@ -908,7 +904,7 @@ public class NewUserWizard extends AbstractWizardBean
|
||||
|
||||
// apply the uifacets aspect - icon, title and description props
|
||||
Map<QName, Serializable> uiFacetsProps = new HashMap<QName, Serializable>(3);
|
||||
uiFacetsProps.put(ContentModel.PROP_ICON, NewSpaceWizard.SPACE_ICON_DEFAULT);
|
||||
uiFacetsProps.put(ContentModel.PROP_ICON, CreateSpaceWizard.DEFAULT_SPACE_ICON_NAME);
|
||||
uiFacetsProps.put(ContentModel.PROP_TITLE, spaceName);
|
||||
this.nodeService.addAspect(nodeRef, ContentModel.ASPECT_UIFACETS, uiFacetsProps);
|
||||
|
||||
@@ -916,7 +912,6 @@ public class NewUserWizard extends AbstractWizardBean
|
||||
|
||||
// return the ID of the created space
|
||||
homeSpaceNodeRef = nodeRef;
|
||||
homeSpaceId = nodeRef.getId();
|
||||
}
|
||||
|
||||
return homeSpaceNodeRef;
|
||||
|
Reference in New Issue
Block a user