diff --git a/source/java/org/alfresco/web/bean/coci/CCCheckoutFileDialog.java b/source/java/org/alfresco/web/bean/coci/CCCheckoutFileDialog.java index baeca098d2..07aa3a35f9 100644 --- a/source/java/org/alfresco/web/bean/coci/CCCheckoutFileDialog.java +++ b/source/java/org/alfresco/web/bean/coci/CCCheckoutFileDialog.java @@ -73,7 +73,11 @@ public class CCCheckoutFileDialog extends CheckinCheckoutDialog @Override public String getContainerTitle() { - return Application.getMessage(FacesContext.getCurrentInstance(), LBL_CHECKOUT) + " '" + property.getDocument().getName() + "'"; + final Node document = property.getDocument(); + if (document != null){ + return Application.getMessage(FacesContext.getCurrentInstance(), LBL_CHECKOUT) + " '" + document.getName() + "'"; + } + return null; } /** diff --git a/source/java/org/alfresco/web/bean/coci/CCUpdateFileDialog.java b/source/java/org/alfresco/web/bean/coci/CCUpdateFileDialog.java index 447912954d..49e62d64d7 100644 --- a/source/java/org/alfresco/web/bean/coci/CCUpdateFileDialog.java +++ b/source/java/org/alfresco/web/bean/coci/CCUpdateFileDialog.java @@ -2,6 +2,8 @@ package org.alfresco.web.bean.coci; import javax.faces.context.FacesContext; +import org.alfresco.web.bean.repository.Node; + import org.alfresco.web.app.Application; public class CCUpdateFileDialog extends CheckinCheckoutDialog @@ -19,7 +21,12 @@ public class CCUpdateFileDialog extends CheckinCheckoutDialog @Override public String getContainerTitle() { - return Application.getMessage(FacesContext.getCurrentInstance(), MSG_UPDATE) + " '" + property.getDocument().getName() + "'"; + Node document = property.getDocument(); + if(document != null) + { + return Application.getMessage(FacesContext.getCurrentInstance(), MSG_UPDATE) + " '" + document.getName() + "'"; + } + return null; } @Override diff --git a/source/java/org/alfresco/web/bean/coci/CheckinCheckoutDialog.java b/source/java/org/alfresco/web/bean/coci/CheckinCheckoutDialog.java index 64c19758f9..4f17ed5de3 100644 --- a/source/java/org/alfresco/web/bean/coci/CheckinCheckoutDialog.java +++ b/source/java/org/alfresco/web/bean/coci/CheckinCheckoutDialog.java @@ -311,70 +311,78 @@ public class CheckinCheckoutDialog extends BaseDialogBean UIActionLink link = (UIActionLink)event.getComponent(); Map params = link.getParameterMap(); String id = params.get("id"); - if (id != null && id.length() != 0) + try { - boolean editingInline = false; - Node node = setupContentDocument(id); + if (id != null && id.length() != 0) + { + boolean editingInline = false; + Node node = setupContentDocument(id); - if (node.hasAspect(WCMAppModel.ASPECT_FORM_INSTANCE_DATA)) - { - editingInline = true; + if (node.hasAspect(WCMAppModel.ASPECT_FORM_INSTANCE_DATA)) + { + editingInline = true; - // editable form document - FacesContext fc = FacesContext.getCurrentInstance(); - this.navigator.setupDispatchContext(node); + // editable form document + FacesContext fc = FacesContext.getCurrentInstance(); + this.navigator.setupDispatchContext(node); - // TODO - rename editContent Wizard since it only deals with editing form content - fc.getApplication().getNavigationHandler().handleNavigation(fc, null, "wizard:editContent"); - } + // TODO - rename editContent Wizard since it only deals with editing form content + fc.getApplication().getNavigationHandler().handleNavigation(fc, null, "wizard:editContent"); + } - // detect the inline editing aspect to see which edit mode to use - else if (node.hasAspect(ApplicationModel.ASPECT_INLINEEDITABLE) && - node.getProperties().get(ApplicationModel.PROP_EDITINLINE) != null && - ((Boolean)node.getProperties().get(ApplicationModel.PROP_EDITINLINE)).booleanValue() == true) - { - // retrieve the content reader for this node - ContentReader reader = property.getContentService().getReader(node.getNodeRef(), ContentModel.PROP_CONTENT); - if (reader != null) - { - editingInline = true; - String mimetype = reader.getMimetype(); + // detect the inline editing aspect to see which edit mode to use + else if (node.hasAspect(ApplicationModel.ASPECT_INLINEEDITABLE) && + node.getProperties().get(ApplicationModel.PROP_EDITINLINE) != null && + ((Boolean)node.getProperties().get(ApplicationModel.PROP_EDITINLINE)).booleanValue() == true) + { + // retrieve the content reader for this node + ContentReader reader = property.getContentService().getReader(node.getNodeRef(), ContentModel.PROP_CONTENT); + if (reader != null) + { + editingInline = true; + String mimetype = reader.getMimetype(); - // calculate which editor screen to display - if (MimetypeMap.MIMETYPE_TEXT_PLAIN.equals(mimetype) || - MimetypeMap.MIMETYPE_XML.equals(mimetype) || - MimetypeMap.MIMETYPE_TEXT_CSS.equals(mimetype) || - MimetypeMap.MIMETYPE_JAVASCRIPT.equals(mimetype)) - { - // make content available to the text editing screen - property.setEditorOutput(reader.getContentString()); + // calculate which editor screen to display + if (MimetypeMap.MIMETYPE_TEXT_PLAIN.equals(mimetype) || + MimetypeMap.MIMETYPE_XML.equals(mimetype) || + MimetypeMap.MIMETYPE_TEXT_CSS.equals(mimetype) || + MimetypeMap.MIMETYPE_JAVASCRIPT.equals(mimetype)) + { + // make content available to the text editing screen + property.setEditorOutput(reader.getContentString()); - // navigate to appropriate screen - FacesContext fc = FacesContext.getCurrentInstance(); - this.navigator.setupDispatchContext(node); - fc.getApplication().getNavigationHandler().handleNavigation(fc, null, "dialog:editTextInline"); - } - else - { - // make content available to the html editing screen - property.setDocumentContent(reader.getContentString()); - property.setEditorOutput(null); + // navigate to appropriate screen + FacesContext fc = FacesContext.getCurrentInstance(); + this.navigator.setupDispatchContext(node); + fc.getApplication().getNavigationHandler().handleNavigation(fc, null, "dialog:editTextInline"); + } + else + { + // make content available to the html editing screen + property.setDocumentContent(reader.getContentString()); + property.setEditorOutput(null); - // navigate to appropriate screen - FacesContext fc = FacesContext.getCurrentInstance(); - this.navigator.setupDispatchContext(node); - fc.getApplication().getNavigationHandler().handleNavigation(fc, null, "dialog:editHtmlInline"); - } - } - } + // navigate to appropriate screen + FacesContext fc = FacesContext.getCurrentInstance(); + this.navigator.setupDispatchContext(node); + fc.getApplication().getNavigationHandler().handleNavigation(fc, null, "dialog:editHtmlInline"); + } + } + } - if (editingInline == false) - { - // normal downloadable document - FacesContext fc = FacesContext.getCurrentInstance(); - this.navigator.setupDispatchContext(node); - fc.getApplication().getNavigationHandler().handleNavigation(fc, null, "dialog:editFile"); - } + if (editingInline == false) + { + // normal downloadable document + FacesContext fc = FacesContext.getCurrentInstance(); + this.navigator.setupDispatchContext(node); + fc.getApplication().getNavigationHandler().handleNavigation(fc, null, "dialog:editFile"); + } + } + } + catch (InvalidNodeRefException refErr) + { + Utils.addErrorMessage(MessageFormat.format(Application.getMessage( + FacesContext.getCurrentInstance(), Repository.ERROR_NODEREF), new Object[] {id}) ); } } diff --git a/source/java/org/alfresco/web/bean/content/EditContentPropertiesDialog.java b/source/java/org/alfresco/web/bean/content/EditContentPropertiesDialog.java index cd7f148415..d613aa0620 100644 --- a/source/java/org/alfresco/web/bean/content/EditContentPropertiesDialog.java +++ b/source/java/org/alfresco/web/bean/content/EditContentPropertiesDialog.java @@ -46,6 +46,7 @@ import org.alfresco.web.app.Application; import org.alfresco.web.bean.dialog.BaseDialogBean; import org.alfresco.web.bean.repository.Node; import org.alfresco.web.bean.repository.Repository; +import org.alfresco.web.ui.common.Utils; /** * Bean implementation of the "Edit Content Properties" dialog. @@ -72,14 +73,18 @@ public class EditContentPropertiesDialog extends BaseDialogBean // setup the editable node this.editableNode = initEditableNode(); - // special case for Mimetype - since this is a sub-property of the ContentData object - // we must extract it so it can be edited in the client, then we check for it later - // and create a new ContentData object to wrap it and it's associated URL - ContentData content = (ContentData)this.editableNode.getProperties().get(ContentModel.PROP_CONTENT); - if (content != null) + if(editableNode != null) { - this.editableNode.getProperties().put(TEMP_PROP_MIMETYPE, content.getMimetype()); - this.editableNode.getProperties().put(TEMP_PROP_ENCODING, content.getEncoding()); + + // special case for Mimetype - since this is a sub-property of the ContentData object + // we must extract it so it can be edited in the client, then we check for it later + // and create a new ContentData object to wrap it and it's associated URL + ContentData content = (ContentData)this.editableNode.getProperties().get(ContentModel.PROP_CONTENT); + if (content != null) + { + this.editableNode.getProperties().put(TEMP_PROP_MIMETYPE, content.getMimetype()); + this.editableNode.getProperties().put(TEMP_PROP_ENCODING, content.getEncoding()); + } } } @@ -88,7 +93,12 @@ public class EditContentPropertiesDialog extends BaseDialogBean */ protected Node initEditableNode() { - return new Node(this.browseBean.getDocument().getNodeRef()); + final Node document = this.browseBean.getDocument(); + if (document != null) + { + return new Node(document.getNodeRef()); + } + return null; } @Override diff --git a/source/java/org/alfresco/web/bean/content/ViewContentPropertiesDialog.java b/source/java/org/alfresco/web/bean/content/ViewContentPropertiesDialog.java index d20c21e11d..e926cf9b51 100644 --- a/source/java/org/alfresco/web/bean/content/ViewContentPropertiesDialog.java +++ b/source/java/org/alfresco/web/bean/content/ViewContentPropertiesDialog.java @@ -24,6 +24,7 @@ */ package org.alfresco.web.bean.content; +import java.text.MessageFormat; import java.util.Map; import javax.faces.context.FacesContext; @@ -33,6 +34,8 @@ import org.alfresco.service.cmr.repository.ContentData; import org.alfresco.web.app.Application; import org.alfresco.web.bean.dialog.BaseDialogBean; import org.alfresco.web.bean.repository.Node; +import org.alfresco.web.bean.repository.Repository; +import org.alfresco.web.ui.common.Utils; /** * Bean implementation of the "View Content Properties" dialog. @@ -56,21 +59,27 @@ public class ViewContentPropertiesDialog extends BaseDialogBean { super.init(parameters); - // setup the editable node - this.viewingNode = new Node(this.browseBean.getDocument().getNodeRef()); - - // special case for Mimetype - since this is a sub-property of the ContentData object - // we must extract it so it can be edited in the client, then we check for it later - // and create a new ContentData object to wrap it and it's associated URL - ContentData content = (ContentData)this.viewingNode.getProperties().get(ContentModel.PROP_CONTENT); - if (content != null) + Node document = this.browseBean.getDocument(); + if(document != null) { - this.viewingNode.getProperties().put(TEMP_PROP_MIMETYPE, content.getMimetype()); - this.viewingNode.getProperties().put(TEMP_PROP_ENCODING, content.getEncoding()); - } - // add the specially handled 'size' property - this.viewingNode.addPropertyResolver("size", this.browseBean.resolverSize); + // setup the editable node + this.viewingNode = new Node(document.getNodeRef()); + + + // special case for Mimetype - since this is a sub-property of the ContentData object + // we must extract it so it can be edited in the client, then we check for it later + // and create a new ContentData object to wrap it and it's associated URL + ContentData content = (ContentData)this.viewingNode.getProperties().get(ContentModel.PROP_CONTENT); + if (content != null) + { + this.viewingNode.getProperties().put(TEMP_PROP_MIMETYPE, content.getMimetype()); + this.viewingNode.getProperties().put(TEMP_PROP_ENCODING, content.getEncoding()); + } + + // add the specially handled 'size' property + this.viewingNode.addPropertyResolver("size", this.browseBean.resolverSize); + } } @Override diff --git a/source/web/scripts/ajax/xforms.js b/source/web/scripts/ajax/xforms.js index 679334f4b7..678a4131cd 100644 --- a/source/web/scripts/ajax/xforms.js +++ b/source/web/scripts/ajax/xforms.js @@ -1163,12 +1163,12 @@ alfresco.xforms.AbstractSelectWidget = alfresco.xforms.Widget.extend({ alfresco.xforms.constants.XFORMS_NS, alfresco.xforms.constants.XFORMS_PREFIX, "label")[0]; - label = label.firstChild.nodeValue; + label = label.firstChild === null ? "" : label.firstChild.nodeValue; var value = _getElementsByTagNameNS(values[i], alfresco.xforms.constants.XFORMS_NS, alfresco.xforms.constants.XFORMS_PREFIX, "value")[0]; - var valueText = value.firstChild.nodeValue; + var valueText = value.firstChild === null ? "" : value.firstChild.nodeValue; var itemId = value.getAttribute("id"); var valid = true; if (binding.constraint)