Index: plugins/asset/src/main/java/org/curriki/xwiki/plugin/asset/Asset.java =================================================================== --- plugins/asset/src/main/java/org/curriki/xwiki/plugin/asset/Asset.java (revision 29807) +++ plugins/asset/src/main/java/org/curriki/xwiki/plugin/asset/Asset.java (working copy) @@ -1015,19 +1015,16 @@ // Let's choose a nice name for the page String prettyName = context.getWiki().clearName(name, true, true, context); assetDoc.rename(space + "." + context.getWiki().getUniquePageName(space, prettyName.trim(), context), new ArrayList(), context); + // CURRIKI-5174 + // update the doc reference after the rename + this.doc = assetDoc; applyRightsPolicy(); List params = new ArrayList(); params.add(assetDoc.getStringValue(Constants.ASSET_CLASS_CATEGORY)); - try { - save(context.getMessageTool().get("curriki.comment.finishcreatingsubasset", params)); - } catch (Exception e) { - // THIS IS A HACK to fix creating an attachment based asset with core 2.x - // we need to find the real issue - // retry the saving as a temp workaround - save(context.getMessageTool().get("curriki.comment.finishcreatingsubasset", params)); - } + save(context.getMessageTool().get("curriki.comment.finishcreatingsubasset", params)); + if (isCollection()) { RootCollectionCompositeAsset root = CollectionSpace.getRootCollection(space, context); root.addSubasset(this.getFullName());