Author: ludovic Date: 2008-02-26 10:08:57 +0100 (Tue, 26 Feb 2008) New Revision: 7949
Modified: xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/api/Document.java Log: XWIKI-2017 NullPointer in addAttachments in Document Modified: xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/api/Document.java =================================================================== --- xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/api/Document.java 2008-02-26 09:07:41 UTC (rev 7948) +++ xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/api/Document.java 2008-02-26 09:08:57 UTC (rev 7949) @@ -1664,6 +1664,8 @@ (FileUploadPlugin) xwiki.getPlugin("fileupload", getXWikiContext()); List fileuploadlist = fileupload.getFileItems(getXWikiContext()); List attachments = new ArrayList(); + // adding attachment list to context so we find the names + context.put("addedAttachments", attachments); int nb = 0; if (fileuploadlist == null) { @@ -1693,7 +1695,8 @@ if ((data != null) && (data.length > 0)) { XWikiAttachment attachment = addAttachment(filename, data); getDoc().saveAttachmentContent(attachment, getXWikiContext()); - getDoc().getAttachmentList().add(attachment); + // commenting because this was already done by addAttachment + // getDoc().getAttachmentList().add(attachment); attachments.add(attachment); nb++; } @@ -1729,7 +1732,8 @@ if (attachment == null) { attachment = new XWikiAttachment(); // TODO: Review this code and understand why it's needed. - getDoc().getOriginalDocument().getAttachmentList().add(attachment); + // Add the attachment in the current doc + getDoc().getAttachmentList().add(attachment); } attachment.setContent(data); _______________________________________________ notifications mailing list notifications@xwiki.org http://lists.xwiki.org/mailman/listinfo/notifications