[opencms-dev] CmsDefaultFileNameGenerator.getNewFileName
Alexei Shigaeff
shigaeff.alexei at gmail.com
Sat Nov 16 21:16:23 CET 2013
Hi list.
I try to use CmsDefaultFileNameGenerator.getNewFileName(CmsObject cms,
java.lang.String namePattern, int defaultDigits)
this method returns good new name for first folder (i tri to create folders)
but for second new name it returns the same name as first
opencms 8.5.2
jsp code:
<%@ page buffer="none" session="false"%>
<%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@page import="
java.util.*,
java.text.DateFormat,
org.opencms.jsp.*,
org.opencms.file.CmsObject,
org.opencms.jsp.util.CmsJspContentAccessBean,
org.opencms.file.types.CmsResourceTypeFolder,
org.opencms.loader.*,
org.opencms.main.OpenCms,
org.opencms.file.*,
org.opencms.file.types.*,
org.opencms.util.CmsRequestUtil,
org.opencms.main.CmsException
"%>
<%
CmsJspActionElement cmsa = new CmsJspActionElement(pageContext, request,
response);
CmsObject cmso = cmsa.getCmsObject();
String act = cmsa.getRequest().getParameter("fact") == null ? "view" :
cmsa.getRequest().getParameter("fact");
String fText = request.getParameter("fText") == null ? "" :
request.getParameter("fText");
String fPath = request.getParameter("fPath") == null ? "/" :
request.getParameter("fPath");
String backURL = request.getParameter("backURL") == null ? "/" :
request.getParameter("backURL");
if( !cmso.getRequestContext().currentUser().isGuestUser() ){
List properties = new ArrayList();
properties.add(new CmsProperty("Title", fText, null));
properties.add(new CmsProperty("NavText", fText, null));
if( act.equals("new") ){
CmsDefaultFileNameGenerator defaultGenerator = new
CmsDefaultFileNameGenerator();
String fName = defaultGenerator.getNewFileName(cmso, fPath + "f%(number)",
6);
out.println("fName="+fName);
CmsResourceManager res_manager = OpenCms.getResourceManager();
cmso.createResource(fName,
res_manager.getResourceType("folder").getTypeId(), null, properties);
cmso.createResource(fName+"/index.html",
res_manager.getResourceType("IndexHtml").getTypeId(), null, null);
}else if( act.equals("save") ){
cmso.lockResource(fPath);
cmso.writePropertyObjects(fPath, properties);
cmso.unlockResource(fPath);
}
//org.opencms.util.CmsRequestUtil.redirectRequestSecure(cmsa, backURL);
}
%>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20131117/cfb3d3a0/attachment.htm>
More information about the opencms-dev
mailing list