Trying to create a new space action, returning a zip file with all attachments from space. I want to put the .../spaces/downloadallattachmentsfromspace.action?key=MYSPACE on a page, clicking on it should return a zip file.
I have extended DownloadAllAttachmentsOnPageAction class.
Updated xworks.xml, spaces package:
<action name="downloadallattachmentsfromspace" class="com.atlassian.confluence.spaces.actions.DownloadAllAttachmentsFromSpaceAction">
<result name="success" type="redirect">${downloadPath}</result>
</action>
Community moderators have prevented the ability to post new answers.
I would use the conveyor plugin to overwrite the default xwork action. Makes updates much more easier.
Do it in your own plugin, use the conveyor. If it's not working, create your own namespace and try it there. And take always a look into the logs
I don't think my code is actually the problem, I don't even enter the method (don't get the "we are here!" log). There must be a mechanism that is needed to make such that link "/spaces/downloadallattachmentsfromspace.action?key=MYSPACE" does call my execute() method.
Any help very welcome.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sure.
I started from confluence-4.3.2-source/confluence-project/confluence-core/confluence/src/java/com/atlassian/confluence/pages/actions/DownloadAllAttachmentsOnPageAction.java
Created from it confluence-4.3.2-source/confluence-project/confluence-core/confluence/src/java/com/atlassian/confluence/spaces/actions/DownloadAllAttachmentsFromSpaceAction.java
basically I just populate the "attachments" list with attachment from the space rather than from the page. The rest of the method is identical.
part of DownloadAllAttachmentsFromSpaceAction.java source code:
-- START --
public class DownloadAllAttachmentsFromSpaceAction extends DownloadAllAttachmentsOnPageAction
{
...
private GateKeeper gateKeeper;
private AbstractSpaceAction abstractSpaceAction;
protected SpaceManager spaceManager;
protected PageManager pageManager;
private static final Logger log = Logger.getLogger(DownloadAllAttachmentsFromSpaceAction.class);
public String execute() throws Exception
{
log.setLevel(Level.INFO);
log.info("we are here!");
// get space
Space space = spaceManager.getSpace(abstractSpaceAction.getSpaceKey());
log.info("space: "+space.getDisplayTitle());
// get pages
List<Page> pages = pageManager.getPages(space, true);
// create attachments list
List<Attachment> attachments = new ArrayList<Attachment>();
// Grab only the latest versions of the attachments
for (Page page : pages)
{
log.info("une page: "+page.getTitle());
attachments.addAll(attachmentManager.getLatestVersionsOfAttachments(page));
}
// Iterate through and write them to the temporary zip directory
for (Attachment attachment : attachments)
{
...
-- END --
Thanks in advance for your help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Could you please provide sources and state where you put them? Would make it easier to reproduce what you did and test locally.
Good luck!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.