<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Dear Victor <br>
<br>
when a resource is published then opencms locks it with a special
type of lock until the publishing is completed. It would be
dangerous to change this kind of mechanism because it is necessary
to make sure that the opencms file system continues to be
consistent. So if you cannot make a change to the file then you
need to implement some kind of queue system that accepts as many
changes as you need and writes them into the file system
asynchronously whenever it is possible to get a hold of the file
again. Of course this means that all your changes to this file
must be made through this queue and that the changes must be
written and published in the same order like they were meant to be
made.<br>
<br>
However, I am a bit concerned that you are trying to change the
same files so quickly again and again.<br>
<br>
All the best<br>
Christian Steinert<br>
<br>
<br>
<br>
</div>
<blockquote
cite="mid:CACrioDqRPMSsFDCL+cePvb9w2a_adcS0gyOSzEOv+7Gif2ogjg@mail.gmail.com"
type="cite">
<div dir="ltr">
<div>
<div>Hello,<br>
<br>
We are building an application in opencms 7.5.4 to let
change and publish several resources together.</div>
<div><br>
The first time an user changes and publishes a group of
resources seems to work fine. But if the same resources are
change and publish moments later, the changes takes place,
but the resources don't publish.<br>
<br>
We saw that the second time no resources are inside the
publish list.<br>
</div>
<div>Further analysis shows a problem with permissions.
Something related to lock for publishing. Is any way that we
could change or "cheat" this opencms behaviour?<br>
<br>
</div>
Any idea what's going on?<br>
<div><br>
here a jsp to execute twice to replicate the problem:<br>
<br>
------------<br>
<br>
</div>
<div><%@ page import="<br>
org.opencms.jsp.*,<br>
org.opencms.main.*,<br>
org.opencms.relations.*,<br>
org.opencms.db.*,<br>
org.opencms.file.*,<br>
org.opencms.lock.*,<br>
org.opencms.xml.content.*,<br>
java.util.*,<br>
org.opencms.loader.*,<br>
org.opencms.report.*,<br>
org.opencms.workplace.explorer.*,<br>
org.opencms.util.*<br>
" <br>
%><br>
<%<br>
<br>
CmsJspActionElement cmsAction = new
CmsJspActionElement(pageContext, request, response);<br>
CmsObject cms = cmsAction.getCmsObject();<br>
<br>
<br>
List<CmsResource> resources = new
ArrayList<CmsResource>();<br>
<br>
Boolean publish = true;<br>
<br>
<br>
int resourcesCount = 2;<br>
<br>
String[] paths =
{"/contenidos/2011/12/20/noticia_0007.html","/contenidos/2011/12/20/noticia_0017.html"};<br>
<br>
for (int idx=0;idx<resourcesCount;idx++) {<br>
Random rand = new Random();<br>
int randomNum = rand.nextInt(1000) + 1;<br>
<br>
String path = paths[idx];<br>
String title = "new title " + randomNum;<br>
String copete = "new upertitle " + randomNum;<br>
String body = "new body " + randomNum;<br>
<br>
CmsFile file = cms.readFile(path);<br>
<br>
CmsLock cachedlock =
OpenCms.getMemoryMonitor().getCachedLock(cms.getRequestContext().addSiteRoot(path));<br>
if (cachedlock == null)<br>
cachedlock = CmsLock.getNullLock();<br>
<br>
if (!cachedlock.getSystemLock().isUnlocked())<br>
OpenCms.getMemoryMonitor().uncacheLock(cms.getRequestContext().addSiteRoot(path));<br>
<br>
<br>
<br>
CmsLock lock = cms.getLock(path);<br>
<br>
//if(publish && lock.isNullLock() &&
lock.isOwnedBy(cms.getRequestContext().currentUser()) )<br>
// cms.changeLock(path);<br>
<br>
if (lock.isUnlocked())<br>
cms.lockResource(path);<br>
else if
(!lock.getUserId().equals(cms.getRequestContext().currentUser().getId()))<br>
cms.changeLock(path);<br>
<br>
<br>
<br>
CmsXmlContent content =
CmsXmlContentFactory.unmarshal(cms, file);<br>
<br>
content.setAutoCorrectionEnabled(true);<br>
content.correctXmlStructure(cms);<br>
<br>
<br>
content.getValue("titulo",
Locale.ENGLISH).setStringValue(cms, title);<br>
content.getValue("copete",
Locale.ENGLISH).setStringValue(cms, copete);<br>
content.getValue("cuerpo",
Locale.ENGLISH).setStringValue(cms, body); <br>
<br>
file.setContents(content.marshal());<br>
cms.writeFile(file); <br>
<br>
cms.unlockResource(path);<br>
<br>
resources.add(file);<br>
<br>
}<br>
<br>
if(publish) {<br>
<br>
CmsPublishList pList =
OpenCms.getPublishManager().getPublishList(cms, resources,
true);<br>
CmsPublishList pRelated =
OpenCms.getPublishManager().getRelatedResourcesToPublish(cms,pList);<br>
CmsPublishList pall =
OpenCms.getPublishManager().mergePublishLists(<br>
cms,<br>
pList ,<br>
pRelated );<br>
%>file to publish:<br><%<br>
for (Object lockRes : pList.getAllResources() )
{<br>
%><%=cms.getSitePath((CmsResource)lockRes)%> -
<%=cms.readPropertyObject((CmsResource)lockRes, "Title",
false).getValue("")%><br/><%<br>
}<br>
%>related files to publish:<br><%<br>
for (Object lockRes : pRelated.getAllResources()
) {<br>
%><%=cms.getSitePath((CmsResource)lockRes)%> -
<%=cms.readPropertyObject((CmsResource)lockRes, "Title",
false).getValue("")%><br/><%<br>
}<br>
CmsStringBufferReport report = new
CmsStringBufferReport(Locale.ENGLISH);<br>
OpenCms.getPublishManager().publishProject(cms, report,
pall);<br>
%>end<br>:<br>
<%=report.toString() %><%<br>
}<br>
%><br>
</div>
<div><br>
----------------<br>
<br>
</div>
Thanks you,<br>
</div>
Víctor Podberezski<br>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
This mail is sent to you from the opencms-dev mailing list
To change your list options, or to unsubscribe from the list, please visit
<a class="moz-txt-link-freetext" href="http://lists.opencms.org/cgi-bin/mailman/listinfo/opencms-dev">http://lists.opencms.org/cgi-bin/mailman/listinfo/opencms-dev</a>
</pre>
</blockquote>
<br>
</body>
</html>