public String renameResourceInternal(CmsUUID structureId, String newName) throws CmsException {

        newName = newName.trim();
        CmsObject rootCms = OpenCms.initCmsObject(getCmsObject());
        rootCms.getRequestContext().setSiteRoot("");
        Locale locale = OpenCms.getWorkplaceManager().getWorkplaceLocale(rootCms);
        try {
            CmsResource.checkResourceName(newName);
        } catch (CmsIllegalArgumentException e) {
            return e.getLocalizedMessage(locale);
        }
        CmsResource resource = rootCms.readResource(structureId, CmsResourceFilter.IGNORE_EXPIRATION);
        String oldPath = resource.getRootPath();
        String parentPath = CmsResource.getParentFolder(oldPath);
        String newPath = CmsStringUtil.joinPaths(parentPath, newName);
        try {
            ensureLock(resource);
            rootCms.moveResource(oldPath, newPath);
            resource = rootCms.readResource(structureId, CmsResourceFilter.IGNORE_EXPIRATION);
        } catch (CmsException e) {
            return e.getLocalizedMessage(OpenCms.getWorkplaceManager().getWorkplaceLocale(rootCms));
        }
        tryUnlock(resource);
        return null;
    }
public String renameResourceInternal ( CmsUUID structureId , String newName ) throws CmsException { newName = newName . trim ( ) ; CmsObject rootCms = OpenCms . initCmsObject ( getCmsObject ( ) ) ; rootCms . getRequestContext ( ) . setSiteRoot ( "" ) ; Locale locale = OpenCms . getWorkplaceManager ( ) . getWorkplaceLocale ( rootCms ) ; try { CmsResource . checkResourceName ( newName ) ; } catch ( CmsIllegalArgumentException e ) { return e . getLocalizedMessage ( locale ) ; } CmsResource resource = rootCms . readResource ( structureId , CmsResourceFilter . IGNORE_EXPIRATION ) ; String oldPath = resource . getRootPath ( ) ; String parentPath = CmsResource . getParentFolder ( oldPath ) ; String newPath = CmsStringUtil . joinPaths ( parentPath , newName ) ; try { ensureLock ( resource ) ; rootCms . moveResource ( oldPath , newPath ) ; resource = rootCms . readResource ( structureId , CmsResourceFilter . IGNORE_EXPIRATION ) ; } catch ( CmsException e ) { return e . getLocalizedMessage ( OpenCms . getWorkplaceManager ( ) . getWorkplaceLocale ( rootCms ) ) ; } tryUnlock ( resource ) ; return null ; }
Internal implementation for renaming a resource.<p>

@param structureId the structure id of the resource to rename
@param newName the new resource name
@return either null if the rename was successful, or an error message

@throws CmsException if something goes wrong