Users - Unable to Create Forum

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Users - Unable to Create Forum

G.Venkata Phanindra
Hi,...
         I want to Create my own party Id and login programatically using the same and Create a forum later .......
         I have Created a party using the partymanger and did not assing any roles or permission and i was  able to create forum with that party Userlogin Id and password
         But simmilary when i create a Party using the same services i must be able to Create a Forum
         But until and unless i assing the PartyRole and then Security Group as CATALOGMANAGER_ADMIN   i am unable to create a forum the problem with this is i will be giving access to Content Module who ever will be create a forum in my application ... i donnot want that to happen can u guide me how is the Party Creation using the Code bellow is different from using PartyManager. 
//Lines of Code. .......
GenericValue userLogin = null;
        try {
            TransactionUtil.begin();
            try{
                forumRequestWrapper= new InputStreamCachingRequest(request);
            }
            catch(IOException e) {
                Debug.logError(e,module);
                TransactionUtil.rollback();
            }
            LocalDispatcher dispatcher = (LocalDispatcher) forumRequestWrapper.getAttribute("dispatcher");       
            GenericDelegator delegator = (GenericDelegator) forumRequestWrapper.getAttribute("delegator");
           adminLogin = dispatcher.runSync("userLogin", UtilMisc.toMap("login.username", "admin", "login.password","ofbiz"));
            userLogin = (GenericValue)adminLogin.get("userLogin");
            session = forumRequestWrapper.getSession();
            session.setAttribute("userLogin",userLogin);
            firstName = forumRequestWrapper.getParameter("firstName");
            lastName = forumRequestWrapper.getParameter("lastName");
            emailId = forumRequestWrapper.getParameter("email");
            country = forumRequestWrapper.getParameter("countryId");
       Debug.logError("The value of firstName is "+ firstName + "lastName is " + lastName + "email id is  " + emailId,module); //REMOVEME
            existingUser = delegator.findByPrimaryKey("UserLogin", UtilMisc.toMap("userLoginId", emailId));
            Debug.logInfo("The Value of user with" + emailId + "-->>" + existingUser + "will be null when no user exist",module); //REMOVEME           
            GenericValue forumUser = (GenericValue)adminLogin.get("userLogin");
            Debug.logInfo("The generic value of forumUser from adminLogin is " + forumUser, module); //REMOVEME
            if(existingUser == null) {
                Map context1 = new HashMap();
                context1.put("firstName",firstName);
                context1.put("lastName",lastName);
                context1.put("userLoginId",emailId);
                context1.put("currentPassword",emailId);
                context1.put("currentPasswordVerify",emailId);
                context1.put("comments",country); // TODO Make it Assosciated
                context1.put("passwordHint",PASSWORD_HINT);
                context1.put("userLogin",forumUser);
                partyForumMap = dispatcher.runSync("createPersonAndUserLogin", context1);
                Debug.logInfo("The value in result set after creating new User: :: :" + partyForumMap, module);  //REMOVEME                               
                partyRole = dispatcher.runSync("createPartyRole", UtilMisc.toMap("partyId",partyForumMap.get("partyId").toString(), "roleTypeId","BLOG_ADMIN","userLogin",forumUser));
                Map responseMessage = dispatcher.runSync("addUserLoginToSecurityGroup",UtilMisc.toMap("userLoginId",emailId,"groupId","CONTENT_ADMIN","userLogin", userLogin));               
                Debug.logInfo("the value of addUserLoginToSecurityGroup is : "+responseMessage,module);  //REMOVEME       
               
                }
            //Login with the new party created
            forumUserLogin = dispatcher.runSync("userLogin", UtilMisc.toMap("login.username", emailId, "login.password",emailId));
            userLogin = (GenericValue)forumUserLogin.get("userLogin");
            session = forumRequestWrapper.getSession();
            session.setAttribute("userLogin",userLogin);
            Debug.logInfo("The value of UserLogin from session is " + session.getAttribute("userLogin")+"the partyId is :::::::"+ userLogin.get("partyId") ,module);  //REMOVEME
            if(UploadContentAndImage.uploadContentAndImage(forumRequestWrapper, response).equals("success")) {
                Debug.logInfo("Sucessful Forum Creation",module); //REMOVEME
                TransactionUtil.commit();
            }
            else {
                Debug.logInfo("Not Sucessful Forum Creation",module); //REMOVEME
                TransactionUtil.rollback();
                return "error";
            }

--
G.Venkata Phanindra
Mob:: 9849852989
 
_______________________________________________
Users mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Users - Unable to Create Forum

BJ Freeman
I believe the answer is to change the forum code to a new Security role
you create. by code, I mean the FTL and widgets as well as the services.
Something like FORUMUSER_CREATE.

G.Venkata Phanindra sent the following on 6/17/06 7:02 AM:

> Hi,...
>         I want to Create my own party Id and login programatically using
> the same and Create a forum later .......
>         I have Created a party using the partymanger and did not assing any
> roles or permission and i was  able to create forum with that party
> Userlogin Id and password
>         But simmilary when i create a Party using the same services i must
> be able to Create a Forum
>         But until and unless i assing the PartyRole and then Security Group
> as CATALOGMANAGER_ADMIN   i am unable to create a forum the problem with
> this is i will be giving access to Content Module who ever will be create a
> forum in my application ... i donnot want that to happen can u guide me how
> is the Party Creation using the Code bellow is different from using
> PartyManager.
> //Lines of Code. .......
> GenericValue userLogin = null;
>        try {
>            TransactionUtil.begin();
>            try{
>                forumRequestWrapper= new InputStreamCachingRequest(request);
>            }
>            catch(IOException e) {
>                Debug.logError(e,module);
>                TransactionUtil.rollback();
>            }
>            LocalDispatcher dispatcher = (LocalDispatcher)
> forumRequestWrapper.getAttribute("dispatcher");
>            GenericDelegator delegator = (GenericDelegator)
> forumRequestWrapper.getAttribute("delegator");
>           adminLogin = dispatcher.runSync("userLogin", UtilMisc.toMap("
> login.username", "admin", "login.password","ofbiz"));
>            userLogin = (GenericValue)adminLogin.get("userLogin");
>            session = forumRequestWrapper.getSession();
>            session.setAttribute("userLogin",userLogin);
>            firstName = forumRequestWrapper.getParameter("firstName");
>            lastName = forumRequestWrapper.getParameter("lastName");
>            emailId = forumRequestWrapper.getParameter("email");
>            country = forumRequestWrapper.getParameter("countryId");
>       Debug.logError("The value of firstName is "+ firstName + "lastName is
> " + lastName + "email id is  " + emailId,module); //REMOVEME
>            existingUser = delegator.findByPrimaryKey("UserLogin",
> UtilMisc.toMap("userLoginId", emailId));
>            Debug.logInfo("The Value of user with" + emailId + "-->>" +
> existingUser + "will be null when no user exist",module);
> //REMOVEME
>            GenericValue forumUser =
> (GenericValue)adminLogin.get("userLogin");
>            Debug.logInfo("The generic value of forumUser from adminLogin is
> " + forumUser, module); //REMOVEME
>            if(existingUser == null) {
>                Map context1 = new HashMap();
>                context1.put("firstName",firstName);
>                context1.put("lastName",lastName);
>                context1.put("userLoginId",emailId);
>                context1.put("currentPassword",emailId);
>                context1.put("currentPasswordVerify",emailId);
>                context1.put("comments",country); // TODO Make it
> Assosciated
>                context1.put("passwordHint",PASSWORD_HINT);
>                context1.put("userLogin",forumUser);
>                partyForumMap =
> dispatcher.runSync("createPersonAndUserLogin",
> context1);
>                Debug.logInfo("The value in result set after creating new
> User: :: :" + partyForumMap, module);  //REMOVEME
>
>                partyRole = dispatcher.runSync("createPartyRole",
> UtilMisc.toMap("partyId",partyForumMap.get("partyId").toString(),
> "roleTypeId","BLOG_ADMIN","userLogin",forumUser));
>                Map responseMessage = dispatcher.runSync
> ("addUserLoginToSecurityGroup",UtilMisc.toMap("userLoginId",emailId,"groupId","CONTENT_ADMIN","userLogin",
>
> userLogin));
>                Debug.logInfo("the value of addUserLoginToSecurityGroup is :
> "+responseMessage,module);  //REMOVEME
>
>                }
>            //Login with the new party created
>            forumUserLogin = dispatcher.runSync("userLogin", UtilMisc.toMap
> ("login.username", emailId, "login.password",emailId));
>            userLogin = (GenericValue)forumUserLogin.get("userLogin");
>            session = forumRequestWrapper.getSession();
>            session.setAttribute("userLogin",userLogin);
>            Debug.logInfo("The value of UserLogin from session is " +
> session.getAttribute("userLogin")+"the partyId is :::::::"+
> userLogin.get("partyId")
> ,module);  //REMOVEME
>            
> if(UploadContentAndImage.uploadContentAndImage(forumRequestWrapper,
> response).equals("success")) {
>                Debug.logInfo("Sucessful Forum Creation",module); //REMOVEME
>                TransactionUtil.commit();
>            }
>            else {
>                Debug.logInfo("Not Sucessful Forum Creation",module);
> //REMOVEME
>                TransactionUtil.rollback();
>                return "error";
>            }
>
>
> ------------------------------------------------------------------------
>
>  
> _______________________________________________
> Users mailing list
> [hidden email]
> http://lists.ofbiz.org/mailman/listinfo/users
 
_______________________________________________
Users mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/users