ofbiz-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pierre Smits <pierre.sm...@gmail.com>
Subject Re: adding a user login to a security group
Date Wed, 01 Oct 2014 12:55:51 GMT
Joel,

Definitions in xml files in the servicedef folder can point to either:

   - simple methods (in xml) in the scripts subdirectories (OFBiz
   development methodology)
   - elaborate functions (in java) in the scr subdirectories (OFBiz
   development methodology
   - others in other directories (NON OFBiz development methodology)

Regards,


Pierre Smits

*ORRTIZ.COM <http://www.orrtiz.com>*
Services & Solutions for Cloud-
Based Manufacturing, Professional
Services and Retail & Trade
http://www.orrtiz.com

On Wed, Oct 1, 2014 at 2:39 PM, joelfradkin@gmail.com <joelfradkin@gmail.com
> wrote:

> I did see that. I appreciate your help and the URL, I guess I don't
> understand.
> I thought the service def folder had xml saying what services are
> available,
> but I do not understand looking at this XML where the actual service is, or
> maybe the xml actually does the work?
> I found that in the service def folder, not the script.
> I do not understand how that bit there adds a record to the table.
>
> I ended up doing my own java function (hard coded to add the group to
> fulladmin):
>
>         public static String addUserLoginToSecurityGroup(HttpServletRequest
> request,String partyId) {
>                 GenericDelegator delegator = (GenericDelegator) request
>                                 .getAttribute("delegator");
>         boolean useEncryption = true;
>         String userLoginId = partyId;
>         String currentPassword = partyId;
>         String groupId = "FULLADMIN";
>         Timestamp now = UtilDateTime.nowTimestamp();
>         GenericValue userLoginSecurityGroupToCreate =
> delegator.makeValue("UserLoginSecurityGroup", UtilMisc.toMap("userLoginId",
> userLoginId,"groupId",groupId, "fromDate",now));
>         try {
>             EntityCondition condition =
> EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("userLoginId"),
> EntityOperator.EQUALS, EntityFunction.UPPER(userLoginId));
>             if
> (UtilValidate.isNotEmpty(delegator.findList("UserLoginSecurityGroup",
> condition, null, null, null, false))) {
>                 Map<String, String> messageMap =
> UtilMisc.toMap("userLoginId", userLoginId);
>               return "found security group for user";
>             }
>         } catch (GenericEntityException e) {
>             return "user login already in security group";
>         }
>         //not there so create security group for userlogin
>         try {
>             userLoginSecurityGroupToCreate.create();
>         } catch (GenericEntityException e) {
>             Debug.logWarning(e, "", module);
>             Map<String, String> messageMap = UtilMisc.toMap("errorMessage",
> e.getMessage());
>               return "error";
>         }
>         return "created security group for login user :"+partyId;
>     }// addUserLoginToSecurityGroup
>
>
>
>
> -----
> Joel Fradkin
> --
> View this message in context:
> http://ofbiz.135035.n4.nabble.com/adding-a-user-login-to-a-security-group-tp4656265p4656310.html
> Sent from the OFBiz - User mailing list archive at Nabble.com.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message