[opencms-dev] Problem publishing a specific list of
Jasper Roel
jroel at salesforce.com
Fri Sep 18 21:04:45 CEST 2009
Hi Paul,
Thanks for getting back to me on this one and my apologies for letting it linger so long.
My specific problem is that I want some resources deep inside the structure to be published, and some changed ones have to remain UNpublished. The current (OpenCms 7.0.5) functionality does not allow for this out of the box. It's either a) only the root folders or b) all changed resources contained within the root folders (including the root folders). This is essentially the 'Publish Directly' functionality.
And the way OpenCms handles it ends up having the Get* functions in PublishList 'ignore' a lot of my resources and returns the empty Lists you're referring to.
The function that does it 'right' (for my purpose) within OpenCms is the addAll() function in PublishList. Since this is protected we can't officially reach it from the outside (ie: my code).
I created a workaround by creating a new class in my project within the org.opencms.db package, and having a small function act as a proxy for my code.
This way I get exactly what I want, without any side-effects (so far anyway...)
The class consists of this one function:
public static CmsPublishList convert(CmsPublishList cmsPublishList, java.util.Collection<org.opencms.file.CmsResource> resources, boolean check) {
cmsPublishList.addAll(resources, check);
return cmsPublishList;
}
Thanks for the feedback, I appreciate it!
Regards,
Jasper
----------------------------------------------------------------------
Message: 1
Date: Fri, 4 Sep 2009 14:05:18 +0200
From: Paul-Inge Flakstad <flakstad at npolar.no>
Subject: Re: [opencms-dev] Problem publishing a specific list of
resources
To: The OpenCms mailing list <opencms-dev at opencms.org>
Message-ID: <4D405B4872E4E54A95966E6CF909E7F325C674FB4B at anton>
Content-Type: text/plain; charset="us-ascii"
Hi Jasper
I've just finished some event listener code that publishes a custom-made list of resources. After checking some other approaches, I actually ended up with more or less the exact same code you posted here. My resources get published.
Looks like something's happening in your getPublishList call - from your screenshot it looks like the method returns an empty list?
------------------------------
Message: 2
Message-ID: <mailman.2.1252144801.16650.opencms-dev at opencms.org>
1.) the user trying to perform the publish operation on the resource(s) doe=
s not have publish permissions, or
2.) the resource(s) are not lockable by the user trying to perform the publ=
ish operation.
There may be other possible reasons (of which I'm unaware), but I'd check t=
hese two at least: make sure your resources are lockable, and perform the p=
ublish operation using an Admin account.
HTH
Cheers,
Paul
________________________________
From: opencms-dev-bounces at opencms.org [mailto:opencms-dev-bounces at opencms.o=
rg] On Behalf Of Jasper Roel
Sent: 1. september 2009 20:03
To: opencms-dev at opencms.org
Subject: [opencms-dev] Problem publishing a specific list of resources
I've been trying to get OpenCms to publish only a specific subset of resour=
ces in OpenCms. This is a mix of new folders, new files, modified resources=
and deleted resources.
This code is run via the Administration panel through a newly created Modul=
e.
The code extract looks something like this;
// This list gets populated before creating the CmsPublishList
List<CmsResource> resourcesToPublish =3D new ArrayList<CmsResource>();
// Only publish what we actually touched
boolean publishSiblings =3D false;
boolean publishSubResources =3D false;
CmsPublishList publishList =3D OpenCms.getPublishManager().getPublishList(c=
ms, resourcesToPublish, publishSiblings, publishSubResources);
OpenCms.getPublishManager().publishProject(cms, report, publishList);
OpenCms.getPublishManager().waitWhileRunning();
A short example of the result of this code is attached. All the resources w=
ith status N & U (New and Updated) are added to the resourcesToPublish List=
, but the publishProject publishes none of them (see ImportLog.htm for the =
result).
Any idea why OpenCms decides not to publish my resources, or is there a bet=
ter way to publish these specific resources programmaticly?
Thanks,
Jasper Roel
More information about the opencms-dev
mailing list