[opencms-dev] login

bub habub japorami at yahoo.com
Wed Jul 13 09:23:58 CEST 2005


hi,

i want to create a file in the opencms vfs when a
someone who acceses an internet page and makes some
entries on a form. 
therefore i wrote some code. my problem is that now
when i execute it, i'm asked for name and password
even though i'm using 

cmsobject.loginUser("name", "password");
this shouldn't happen, right?

here my full code. searched already a lot but couldn't
find an answer.

<%@ page import="org.opencms.file.*,
org.opencms.file.collectors.*, java.util.*,
org.opencms.jsp.*, org.opencms.flex.*,
org.opencms.util.CmsUUID" %>
<%@ taglib prefix="cms"
uri="http://www.opencms.org/taglib/cms" %>
<%

CmsJspActionElement cms = new
CmsJspActionElement(pageContext, request, response);
CmsObject cmsobject =
CmsFlexController.getCmsObject(request);
String uname = request.getParameter("uname");
out.println(uname);
CmsUser user  = cmsobject.readUser(uname);
CmsUUID userid = user.getId();
//outprintln(userid);


String destination = "www/new_projects/";
String title = request.getParameter("title");
out.println(title);
String internalfilename = destination + title; 
out.println(internalfilename);
int filetype = 1 ;    //request.getParameter("type");






	boolean exists; 
	CmsUUID uid = userid;

	if(cmsobject.existsResource(internalfilename))
	{
		//????, redirect to page with error explanation 
		out.println(title);
	}
	
	else
	{	
		//cmsobject.loginUser("name", "password");
		CmsResource resource =
cmsobject.createResource(internalfilename, filetype); 
//filename must be full path
		
		String source = resource.getRootPath();
		out.println(source);
		
		//cmsobject.writePropertyObjects(resource,
properties);
		cmsobject.lockResource(source);
		
		
		CmsFile myfile = CmsFile.upgrade(resource,
cmsobject);
		
		//myfile.moveResource(source, filepath);	
		//String name = myfile.getRootPath();

		CmsResource contentresource =
cmsobject.readResource("/system/modules/com.authentication/elements/registration_form.html");
 		CmsFile contentfile = new CmsFile(contentresource);
		byte[] content = contentfile.getContents();		
		myfile.setContents(content);
		myfile.setUserLastModified(uid);
		cmsobject.writeFile(myfile);
		cmsobject.unlockResource(source);
		cmsobject.publishResource(source);

	}



%>

actually one time it worked but then somehow not
anymore, was able to create one file.
now it also throws an error that says that i cannot
find a specific resource.

thanks for help

jap 

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the opencms-dev mailing list