Change to the way we apply 'versionable' aspect by default to uploaded documents. Aspect is still applied but "autoversion" and "create initial version" features are off by default. First version is instead explicitly created during checkout process.

Fix to apply 'versionable' aspect to documents that are being updated via the Share client but were initially uploaded via another route i.e. FTP or JSF Client.
Minor fix to doclist json to handle documents that have 'versionable' aspect applied but do not have any version history.
Code cleanup to ML document details.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@10370 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2008-08-14 14:54:25 +00:00
parent 1824fcc35d
commit 3379d0bc9b
2 changed files with 159 additions and 173 deletions

View File

@@ -91,7 +91,6 @@ public class DocumentDetailsDialog extends BaseDetailsBean implements Navigatio
private static final String MSG_DETAILS_OF = "details_of"; private static final String MSG_DETAILS_OF = "details_of";
private static final String MSG_LOCATION = "location"; private static final String MSG_LOCATION = "location";
private final static String MSG_CLOSE = "close"; private final static String MSG_CLOSE = "close";
private static final String ML_VERSION_PANEL_ID = "ml-versions-panel"; private static final String ML_VERSION_PANEL_ID = "ml-versions-panel";
@@ -103,9 +102,14 @@ public class DocumentDetailsDialog extends BaseDetailsBean implements Navigatio
transient protected EditionService editionService; transient protected EditionService editionService;
private Node translationDocument; private Node translationDocument;
/** List of client light weight edition histories */
private List<SingleEditionBean> editionHistory = null;
/** For the client side iteration on the edition hitories list, it represents the index of the list */
private int currentEditionCursorPosition;
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// Construction // Construction
@@ -114,8 +118,6 @@ public class DocumentDetailsDialog extends BaseDetailsBean implements Navigatio
*/ */
public DocumentDetailsDialog() public DocumentDetailsDialog()
{ {
super();
// initial state of some panels that don't use the default // initial state of some panels that don't use the default
panels.put("version-history-panel", false); panels.put("version-history-panel", false);
panels.put("ml-info-panel", false); panels.put("ml-info-panel", false);
@@ -145,13 +147,24 @@ public class DocumentDetailsDialog extends BaseDetailsBean implements Navigatio
return (String)getDocument().getProperties().get("url"); return (String)getDocument().getProperties().get("url");
} }
/**
* @return the translation document for this node
*/
public Node getTranslationDocument() public Node getTranslationDocument()
{ {
return translationDocument; return translationDocument;
} }
/**
* Before opening the ml container details, remeber the translation
* from which the action comes.
*
* @param node
*/
public void setTranslationDocument(Node node)
{
this.translationDocument = node;
}
/** /**
* Returns the URL to the content for the current document * Returns the URL to the content for the current document
@@ -238,7 +251,7 @@ public class DocumentDetailsDialog extends BaseDetailsBean implements Navigatio
if(id.startsWith(ML_VERSION_PANEL_ID)) if(id.startsWith(ML_VERSION_PANEL_ID))
{ {
this.currentEditionCursorPosition = Integer.parseInt(id.substring("ml-versions-panel".length())) - 1; this.currentEditionCursorPosition = Integer.parseInt(id.substring("ml-versions-panel".length())) - 1;
} }
} }
@@ -269,12 +282,12 @@ public class DocumentDetailsDialog extends BaseDetailsBean implements Navigatio
if(getDocument().hasAspect(ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION)) if(getDocument().hasAspect(ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION))
{ {
clientVersion.put("url", null); clientVersion.put("url", null);
} }
else else
{ {
clientVersion.put("url", DownloadContentServlet.generateBrowserURL(version.getFrozenStateNodeRef(), clientVersion.put("url", DownloadContentServlet.generateBrowserURL(version.getFrozenStateNodeRef(),
clientVersion.getName())); clientVersion.getName()));
} }
@@ -287,16 +300,6 @@ public class DocumentDetailsDialog extends BaseDetailsBean implements Navigatio
return versions; return versions;
} }
/** List of client light weight edition histories */
private List<SingleEditionBean> editionHistory = null;
/** For the client side iteration on the edition hitories list, it represents the index of the list */
private int currentEditionCursorPosition;
/** /**
* For the client side iteration on the edition hitories list, * For the client side iteration on the edition hitories list,
* return the next edition history. * return the next edition history.
@@ -305,23 +308,22 @@ public class DocumentDetailsDialog extends BaseDetailsBean implements Navigatio
*/ */
public SingleEditionBean getNextSingleEditionBean() public SingleEditionBean getNextSingleEditionBean()
{ {
currentEditionCursorPosition++; currentEditionCursorPosition++;
return getCurrentSingleEditionBean(); return getCurrentSingleEditionBean();
} }
/** /**
* For the client side iteration on the edition hitories list, * For the client side iteration on the edition hitories list,
* return the current edition history. * return the current edition history.
* *
* @return a light weight representation of an edition history * @return a light weight representation of an edition history
*/ */
public SingleEditionBean getCurrentSingleEditionBean() public SingleEditionBean getCurrentSingleEditionBean()
{ {
return editionHistory.get(currentEditionCursorPosition); return editionHistory.get(currentEditionCursorPosition);
} }
/** /**
* Constructs a list of objects representing the editions of the * Constructs a list of objects representing the editions of the
* logical document * logical document
@@ -331,103 +333,103 @@ public class DocumentDetailsDialog extends BaseDetailsBean implements Navigatio
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private List<SingleEditionBean> initEditionHistory() private List<SingleEditionBean> initEditionHistory()
{ {
// get the mlContainer // get the mlContainer
NodeRef mlContainer = getDocumentMlContainer().getNodeRef(); NodeRef mlContainer = getDocumentMlContainer().getNodeRef();
// get all editions and sort them ascending according their version label // get all editions and sort them ascending according their version label
List<Version> orderedEditionList = new ArrayList<Version>(getEditionService().getEditions(mlContainer).getAllVersions()); List<Version> orderedEditionList = new ArrayList<Version>(getEditionService().getEditions(mlContainer).getAllVersions());
Collections.sort(orderedEditionList, new VersionLabelComparator()); Collections.sort(orderedEditionList, new VersionLabelComparator());
// the list of Single Edition Bean to return // the list of Single Edition Bean to return
editionHistory = new ArrayList<SingleEditionBean>(orderedEditionList.size()); editionHistory = new ArrayList<SingleEditionBean>(orderedEditionList.size());
boolean firstEdition = true; boolean firstEdition = true;
// for each edition, init a SingleEditionBean // for each edition, init a SingleEditionBean
for (Version edition : orderedEditionList) for (Version edition : orderedEditionList)
{ {
SingleEditionBean editionBean = new SingleEditionBean(); SingleEditionBean editionBean = new SingleEditionBean();
MapNode clientEdition = new MapNode(edition.getFrozenStateNodeRef()); MapNode clientEdition = new MapNode(edition.getFrozenStateNodeRef());
String editionLabel = edition.getVersionLabel(); String editionLabel = edition.getVersionLabel();
if (firstEdition) if (firstEdition)
{ {
editionLabel += " (" + Application.getMessage(FacesContext.getCurrentInstance(), MSG_CURRENT) + ")"; editionLabel += " (" + Application.getMessage(FacesContext.getCurrentInstance(), MSG_CURRENT) + ")";
} }
clientEdition.put("editionLabel", editionLabel); clientEdition.put("editionLabel", editionLabel);
clientEdition.put("editionNotes", edition.getDescription()); clientEdition.put("editionNotes", edition.getDescription());
clientEdition.put("editionAuthor", edition.getCreator()); clientEdition.put("editionAuthor", edition.getCreator());
clientEdition.put("editionDate", edition.getCreatedDate()); clientEdition.put("editionDate", edition.getCreatedDate());
// Set the edition of the edition bean // Set the edition of the edition bean
editionBean.setEdition(clientEdition); editionBean.setEdition(clientEdition);
// get translations // get translations
List<VersionHistory> translationHistories = null; List<VersionHistory> translationHistories = null;
if (firstEdition) if (firstEdition)
{ {
// Get the translations because the current edition doesn't content link with its // Get the translations because the current edition doesn't content link with its
// translation in the version store. // translation in the version store.
Map<Locale, NodeRef> translations = getMultilingualContentService().getTranslations(mlContainer); Map<Locale, NodeRef> translations = getMultilingualContentService().getTranslations(mlContainer);
translationHistories = new ArrayList<VersionHistory>(translations.size()); translationHistories = new ArrayList<VersionHistory>(translations.size());
for (NodeRef translation : translations.values()) for (NodeRef translation : translations.values())
{ {
translationHistories.add(getVersionService().getVersionHistory(translation)); translationHistories.add(getVersionService().getVersionHistory(translation));
} }
} }
else else
{ {
translationHistories = getEditionService().getVersionedTranslations(edition); translationHistories = getEditionService().getVersionedTranslations(edition);
} }
// add each translation in the SingleEditionBean // add each translation in the SingleEditionBean
for (VersionHistory versionHistory : translationHistories) for (VersionHistory versionHistory : translationHistories)
{ {
// get the list of versions and sort them ascending according their version label // get the list of versions and sort them ascending according their version label
List<Version> orderedVersions = new ArrayList<Version>(versionHistory.getAllVersions()); List<Version> orderedVersions = new ArrayList<Version>(versionHistory.getAllVersions());
Collections.sort(orderedVersions, new VersionLabelComparator()); Collections.sort(orderedVersions, new VersionLabelComparator());
// the last version is the first version of the list // the last version is the first version of the list
Version lastVersion = orderedVersions.get(0); Version lastVersion = orderedVersions.get(0);
// get the properties of the lastVersion // get the properties of the lastVersion
Map<QName, Serializable> lastVersionProperties = getEditionService().getVersionedMetadatas(lastVersion); Map<QName, Serializable> lastVersionProperties = getEditionService().getVersionedMetadatas(lastVersion);
Locale language = (Locale) lastVersionProperties.get(ContentModel.PROP_LOCALE); Locale language = (Locale) lastVersionProperties.get(ContentModel.PROP_LOCALE);
// create a map node representation of the last version // create a map node representation of the last version
MapNode clientLastVersion = new MapNode(lastVersion.getFrozenStateNodeRef()); MapNode clientLastVersion = new MapNode(lastVersion.getFrozenStateNodeRef());
clientLastVersion.put("versionName", lastVersionProperties.get(ContentModel.PROP_NAME)); clientLastVersion.put("versionName", lastVersionProperties.get(ContentModel.PROP_NAME));
// use the node service for the description to ensure that the returned value is a text and not a MLText // use the node service for the description to ensure that the returned value is a text and not a MLText
clientLastVersion.put("versionDescription", getNodeService().getProperty(lastVersion.getFrozenStateNodeRef(), ContentModel.PROP_DESCRIPTION)); clientLastVersion.put("versionDescription", getNodeService().getProperty(lastVersion.getFrozenStateNodeRef(), ContentModel.PROP_DESCRIPTION));
clientLastVersion.put("versionAuthor", lastVersionProperties.get(ContentModel.PROP_AUTHOR)); clientLastVersion.put("versionAuthor", lastVersionProperties.get(ContentModel.PROP_AUTHOR));
clientLastVersion.put("versionCreatedDate", lastVersionProperties.get(ContentModel.PROP_CREATED)); clientLastVersion.put("versionCreatedDate", lastVersionProperties.get(ContentModel.PROP_CREATED));
clientLastVersion.put("versionModifiedDate", lastVersionProperties.get(ContentModel.PROP_MODIFIED)); clientLastVersion.put("versionModifiedDate", lastVersionProperties.get(ContentModel.PROP_MODIFIED));
clientLastVersion.put("versionLanguage", this.getContentFilterLanguagesService().convertToNewISOCode(language.getLanguage()).toUpperCase()); clientLastVersion.put("versionLanguage", this.getContentFilterLanguagesService().convertToNewISOCode(language.getLanguage()).toUpperCase());
if(getNodeService().hasAspect(lastVersion.getFrozenStateNodeRef(), ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION)) if(getNodeService().hasAspect(lastVersion.getFrozenStateNodeRef(), ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION))
{ {
clientLastVersion.put("versionUrl", null); clientLastVersion.put("versionUrl", null);
} }
else else
{ {
clientLastVersion.put("versionUrl", DownloadContentServlet.generateBrowserURL(lastVersion.getFrozenStateNodeRef(), clientLastVersion.getName())); clientLastVersion.put("versionUrl", DownloadContentServlet.generateBrowserURL(lastVersion.getFrozenStateNodeRef(), clientLastVersion.getName()));
} }
// add a translation of the editionBean // add a translation of the editionBean
editionBean.addTranslations(clientLastVersion); editionBean.addTranslations(clientLastVersion);
} }
editionHistory.add(editionBean); editionHistory.add(editionBean);
firstEdition = false; firstEdition = false;
} }
return editionHistory; return editionHistory;
} }
/** /**
* Determines whether the current document has any categories applied * Determines whether the current document has any categories applied
* *
@@ -453,7 +455,7 @@ public class DocumentDetailsDialog extends BaseDetailsBean implements Navigatio
// we know for now that the general classifiable aspect only will be // we know for now that the general classifiable aspect only will be
// applied so we can retrive the categories property direclty // applied so we can retrive the categories property direclty
Collection<NodeRef> categories = (Collection<NodeRef>)this.getNodeService().getProperty( Collection<NodeRef> categories = (Collection<NodeRef>)this.getNodeService().getProperty(
getDocument().getNodeRef(), ContentModel.PROP_CATEGORIES); getDocument().getNodeRef(), ContentModel.PROP_CATEGORIES);
if (categories == null || categories.size() == 0) if (categories == null || categories.size() == 0)
{ {
@@ -534,7 +536,7 @@ public class DocumentDetailsDialog extends BaseDetailsBean implements Navigatio
// reset the state of the current document // reset the state of the current document
getDocument().reset(); getDocument().reset();
// get hold of the main property sheet on the page and remove the children to force a refresh // get hold of the main property sheet on the page and remove the children to force a refresh
UIComponent comp = context.getViewRoot().findComponent("dialog:dialog-body:document-props"); UIComponent comp = context.getViewRoot().findComponent("dialog:dialog-body:document-props");
if (comp != null) if (comp != null)
@@ -565,12 +567,12 @@ public class DocumentDetailsDialog extends BaseDetailsBean implements Navigatio
{ {
getLockService().unlock(getNode().getNodeRef()); getLockService().unlock(getNode().getNodeRef());
String msg = Application.getMessage(fc, MSG_SUCCESS_UNLOCK); String msg = Application.getMessage(fc, MSG_SUCCESS_UNLOCK);
FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_INFO, msg, msg); FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_INFO, msg, msg);
String formId = Utils.getParentForm(fc, event.getComponent()).getClientId(fc); String formId = Utils.getParentForm(fc, event.getComponent()).getClientId(fc);
fc.addMessage(formId + ':' + getPropertiesPanelId(), facesMsg); fc.addMessage(formId + ':' + getPropertiesPanelId(), facesMsg);
getNode().reset(); getNode().reset();
return null; return null;
} }
}; };
@@ -595,26 +597,26 @@ public class DocumentDetailsDialog extends BaseDetailsBean implements Navigatio
{ {
public Object execute() throws Throwable public Object execute() throws Throwable
{ {
// add the inlineeditable aspect to the node // add the inlineeditable aspect to the node
Map<QName, Serializable> props = new HashMap<QName, Serializable>(1, 1.0f); Map<QName, Serializable> props = new HashMap<QName, Serializable>(1, 1.0f);
String contentType = null; String contentType = null;
ContentData contentData = (ContentData)getDocument().getProperties().get(ContentModel.PROP_CONTENT); ContentData contentData = (ContentData)getDocument().getProperties().get(ContentModel.PROP_CONTENT);
if (contentData != null) if (contentData != null)
{ {
contentType = contentData.getMimetype(); contentType = contentData.getMimetype();
} }
if (contentType != null) if (contentType != null)
{ {
// set the property to true by default if the filetype is a known content type // set the property to true by default if the filetype is a known content type
if (MimetypeMap.MIMETYPE_HTML.equals(contentType) || if (MimetypeMap.MIMETYPE_HTML.equals(contentType) ||
MimetypeMap.MIMETYPE_TEXT_PLAIN.equals(contentType) || MimetypeMap.MIMETYPE_TEXT_PLAIN.equals(contentType) ||
MimetypeMap.MIMETYPE_XML.equals(contentType) || MimetypeMap.MIMETYPE_XML.equals(contentType) ||
MimetypeMap.MIMETYPE_TEXT_CSS.equals(contentType) || MimetypeMap.MIMETYPE_TEXT_CSS.equals(contentType) ||
MimetypeMap.MIMETYPE_JAVASCRIPT.equals(contentType)) MimetypeMap.MIMETYPE_JAVASCRIPT.equals(contentType))
{ {
props.put(ApplicationModel.PROP_EDITINLINE, true); props.put(ApplicationModel.PROP_EDITINLINE, true);
} }
} }
getNodeService().addAspect(getDocument().getNodeRef(), ApplicationModel.ASPECT_INLINEEDITABLE, props); getNodeService().addAspect(getDocument().getNodeRef(), ApplicationModel.ASPECT_INLINEEDITABLE, props);
return null; return null;
@@ -817,19 +819,6 @@ public class DocumentDetailsDialog extends BaseDetailsBean implements Navigatio
return this.getNode(); return this.getNode();
} }
/**
* Before opening the ml container details, remeber the translation
* from which the action comes.
*
* @param node
*/
public void setTranslationDocument(Node node)
{
this.translationDocument = node;
}
/** /**
* Returns the ml container of the document this bean is currently representing * Returns the ml container of the document this bean is currently representing
* *
@@ -837,18 +826,18 @@ public class DocumentDetailsDialog extends BaseDetailsBean implements Navigatio
*/ */
public Node getDocumentMlContainer() public Node getDocumentMlContainer()
{ {
Node currentNode = getNode(); Node currentNode = getNode();
if(ContentModel.TYPE_MULTILINGUAL_CONTAINER.equals(currentNode.getType())) if(ContentModel.TYPE_MULTILINGUAL_CONTAINER.equals(currentNode.getType()))
{ {
return currentNode; return currentNode;
} }
else else
{ {
NodeRef nodeRef = getNode().getNodeRef(); NodeRef nodeRef = getNode().getNodeRef();
return new Node(getMultilingualContentService().getTranslationContainer(nodeRef)); return new Node(getMultilingualContentService().getTranslationContainer(nodeRef));
} }
} }
/** /**
* Sets the lock service instance the bean should use * Sets the lock service instance the bean should use
@@ -859,7 +848,7 @@ public class DocumentDetailsDialog extends BaseDetailsBean implements Navigatio
{ {
this.lockService = lockService; this.lockService = lockService;
} }
protected LockService getLockService() protected LockService getLockService()
{ {
if (lockService == null) if (lockService == null)
@@ -878,7 +867,7 @@ public class DocumentDetailsDialog extends BaseDetailsBean implements Navigatio
{ {
this.versionService = versionService; this.versionService = versionService;
} }
protected VersionService getVersionService() protected VersionService getVersionService()
{ {
if (versionService == null) if (versionService == null)
@@ -897,7 +886,7 @@ public class DocumentDetailsDialog extends BaseDetailsBean implements Navigatio
{ {
this.cociService = cociService; this.cociService = cociService;
} }
protected CheckOutCheckInService getCheckOutCheckInService() protected CheckOutCheckInService getCheckOutCheckInService()
{ {
if (cociService == null) if (cociService == null)
@@ -914,7 +903,7 @@ public class DocumentDetailsDialog extends BaseDetailsBean implements Navigatio
{ {
this.multilingualContentService = multilingualContentService; this.multilingualContentService = multilingualContentService;
} }
protected MultilingualContentService getMultilingualContentService() protected MultilingualContentService getMultilingualContentService()
{ {
if (multilingualContentService == null) if (multilingualContentService == null)
@@ -931,7 +920,7 @@ public class DocumentDetailsDialog extends BaseDetailsBean implements Navigatio
{ {
this.contentFilterLanguagesService = contentFilterLanguagesService; this.contentFilterLanguagesService = contentFilterLanguagesService;
} }
protected ContentFilterLanguagesService getContentFilterLanguagesService() protected ContentFilterLanguagesService getContentFilterLanguagesService()
{ {
if (contentFilterLanguagesService == null) if (contentFilterLanguagesService == null)
@@ -948,7 +937,7 @@ public class DocumentDetailsDialog extends BaseDetailsBean implements Navigatio
{ {
this.editionService = editionService; this.editionService = editionService;
} }
protected EditionService getEditionService() protected EditionService getEditionService()
{ {
if (editionService == null) if (editionService == null)
@@ -966,7 +955,7 @@ public class DocumentDetailsDialog extends BaseDetailsBean implements Navigatio
public String getContainerSubTitle() public String getContainerSubTitle()
{ {
return Application.getMessage(FacesContext.getCurrentInstance(), MSG_LOCATION) + ": " + return Application.getMessage(FacesContext.getCurrentInstance(), MSG_LOCATION) + ": " +
getDocument().getNodePath().toDisplayPath(getNodeService(), getPermissionService()); getDocument().getNodePath().toDisplayPath(getNodeService(), getPermissionService());
} }
public String getContainerTitle() public String getContainerTitle()
@@ -984,7 +973,6 @@ public class DocumentDetailsDialog extends BaseDetailsBean implements Navigatio
return null; return null;
} }
public String getOutcome() public String getOutcome()
{ {
return "dialog:close:dialog:showDocDetails"; return "dialog:close:dialog:showDocDetails";

View File

@@ -13,9 +13,9 @@ import org.alfresco.web.bean.repository.MapNode;
*/ */
public class SingleEditionBean implements Serializable public class SingleEditionBean implements Serializable
{ {
private static final long serialVersionUID = 9145202732094403340L; private static final long serialVersionUID = 9145202732094403340L;
/** The edition in a list */ /** The edition in a list */
private List<MapNode> edition = null; private List<MapNode> edition = null;
/** The translation list of the edition */ /** The translation list of the edition */
@@ -61,13 +61,11 @@ public class SingleEditionBean implements Serializable
*/ */
public void addTranslations(MapNode translation) public void addTranslations(MapNode translation)
{ {
if(this.translations == null) if (this.translations == null)
{ {
this.translations = new ArrayList<MapNode>(); this.translations = new ArrayList<MapNode>();
} }
this.translations.add(translation); this.translations.add(translation);
} }
} }