<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi Yves<div><br></div><div>we do it with the following code. Works for us in 8.0.3</div><div><br></div><div>Regards</div><div>Christoph</div><div><br></div><div>--------------------------------------------------------------------------</div><div>    /**<br>     * publishes the resource.<br>     * <br>     * @param cms cms object<br>     * @param resourcePath pfad zur resource<br>     * @param stealLockIfNecessary ob das Lock gestohlen werden soll, wenn das nötig ist<br>     * @return uuid der Ressource<br>     * @throws Exception<br>     */<br>    public static CmsUUID publishResource(CmsObject cms, String resourcePath, boolean stealLockIfNecessary) throws Exception {<br><br>        String resPathModified = cms.getRequestContext().removeSiteRoot(resourcePath);<br>        if (stealLockIfNecessary) {<br>            CmsUtils.stealLocks(cms, resPathModified);<br>        }<br>        return OpenCms.getPublishManager().publishResource(cms, resPathModified);<br><br>    }<br><br>    /**<br>     * publishes the resource and includes related resources.<br>     * <br>     * @param cms cms object<br>     * @param resourcePath pfad zur resource<br>     * @param stealLockIfNecessary ob das Lock gestohlen werden soll, wenn das nötig ist<br>     * @return uuid der Ressource<br>     * @throws Exception<br>     */<br>    public static CmsUUID publishResourceIncludingRelated(CmsObject cms, String resourcePath, boolean stealLockIfNecessary)<br>            throws Exception {<br><br>        String resPathModified = cms.getRequestContext().removeSiteRoot(resourcePath);<br>        CmsResource resource = cms.readResource(resPathModified);<br>        if (stealLockIfNecessary) {<br>            CmsUtils.stealLocks(cms, resource);<br>        }<br>        List<CmsResource> toPublish = new ArrayList<CmsResource>();<br>        toPublish.add(resource);<br>        CmsPublishList pubList = OpenCms.getPublishManager().getPublishList(cms, toPublish, false);<br>        CmsPublishList relatedList = OpenCms.getPublishManager().getRelatedResourcesToPublish(cms, pubList);<br>        pubList = OpenCms.getPublishManager().mergePublishLists(cms, pubList, relatedList);<br>        CmsLogReport report = new CmsLogReport(ModuleConstants.DEFAULT_LOCALE, null);<br>        return OpenCms.getPublishManager().publishProject(cms, report, pubList);<br><br>    }</div><div><br></div><div>   public static void stealLocks(CmsObject cmso, String resource) throws CmsException {<br>        List<String> locked = cmso.getLockedResources(resource, CmsLockFilter.FILTER_INHERITED);<br>        if (locked != null && locked.size() > 0) {<br>            for (String lock : locked) {<br>                if (F3Logger.log.isDebugEnabled()) {<br>                    F3Logger.log.debug("Stealing lock of " + lock);<br>                }<br>                cmso.changeLock(lock);<br>            }<br>        } else {<br>            CmsLock lock = cmso.getLock(resource);<br>            if (lock == null || lock.isUnlocked()) {<br>                cmso.lockResource(resource);<br>                return;<br>            } else {<br>                cmso.changeLock(resource);<br>            }<br>        }<br><br>    }<br><div><div>Am 19.09.2012 um 10:59 schrieb Yves Glodt:</div><br class="Apple-interchange-newline"><blockquote type="cite">Hello,<br><br>In OpenCms 8 there is no longer CmsObject.publishResource(). So I tried to use the CmsPublishManager, but it does not work as expected.<br><br>Here is my code:<br><br><span style="font-family:courier new,monospace">CmsObject cms = OpenCms.initCmsObject("Guest");<br>

cms.loginUser("user", "password");<br>CmsProject project = cms.readProject("Offline");<br>cms.getRequestContext().setCurrentProject(project);<br>cms.getRequestContext().setSiteRoot("/sites/<a href="http://mysite.lu/">mysite.lu/</a>");<br>

<br>CmsPublishManager cmsPublish = new CmsPublishManager();<br>cmsPublish.initialize(cms);<br>cmsPublish.publishResource(cms,"/images/articles/"+no_article);<br></span><br>What's wrong with it?<br><br>Best regards,<br>

Yves<br><br>
_______________________________________________<br>This mail is sent to you from the opencms-dev mailing list<br>To change your list options, or to unsubscribe from the list, please visit<br><a href="http://lists.opencms.org/cgi-bin/mailman/listinfo/opencms-dev">http://lists.opencms.org/cgi-bin/mailman/listinfo/opencms-dev</a><br><br><br><br></blockquote></div><br></div></body></html>