Fwd: svn commit: r781752 - in /ofbiz/trunk/applications/party: data/PartyTypeData.xml src/org/ofbiz/party/party/PartyServices.java

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

Fwd: svn commit: r781752 - in /ofbiz/trunk/applications/party: data/PartyTypeData.xml src/org/ofbiz/party/party/PartyServices.java

Anil Patel-3
Hans,
Mods in this commit are causing checkout process to break. I am  
getting following error.

2009-06-08 00:48:37,975 (http-0.0.0.0-8443-3)  
[        CallService.java:247:ERROR]
---- exception report  
----------------------------------------------------------
Exception: org.ofbiz.service.GenericServiceException
Message: Service [updatePerson] target threw an unexpected exception  
(null)
---- cause  
---------------------------------------------------------------------
Exception: java.lang.NullPointerException
Message: null
---- stack trace  
---------------------------------------------------------------
java.lang.NullPointerException
org.ofbiz.party.party.PartyServices.updatePerson(PartyServices.java:306)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun
.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)

Its because null value for statusId field is passed to service. Please  
look into it and suggest the fix.

Regards
Anil Patel


Begin forwarded message:

> From: [hidden email]
> Date: June 4, 2009 10:33:08 AM EDT
> To: [hidden email]
> Subject: svn commit: r781752 - in /ofbiz/trunk/applications/party:  
> data/PartyTypeData.xml src/org/ofbiz/party/party/PartyServices.java
> Reply-To: [hidden email]
>
> Author: hansbak
> Date: Thu Jun  4 14:33:07 2009
> New Revision: 781752
>
> URL: http://svn.apache.org/viewvc?rev=781752&view=rev
> Log:
> disable related userlogins when a party is disabled, status changes  
> makes now use of separate service, als make re-activate party possible
>
> Modified:
>    ofbiz/trunk/applications/party/data/PartyTypeData.xml
>    ofbiz/trunk/applications/party/src/org/ofbiz/party/party/
> PartyServices.java
>
> Modified: ofbiz/trunk/applications/party/data/PartyTypeData.xml
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/data/PartyTypeData.xml?rev=781752&r1=781751&r2=781752&view=diff
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- ofbiz/trunk/applications/party/data/PartyTypeData.xml (original)
> +++ ofbiz/trunk/applications/party/data/PartyTypeData.xml Thu Jun  4  
> 14:33:07 2009
> @@ -297,7 +297,8 @@
>     <StatusItem description="Enabled" sequenceId="01"  
> statusCode="ENABLED" statusId="PARTY_ENABLED"  
> statusTypeId="PARTY_STATUS"/>
>     <StatusItem description="Disabled" sequenceId="99"  
> statusCode="DISABLED" statusId="PARTY_DISABLED"  
> statusTypeId="PARTY_STATUS"/>
>     <StatusValidChange condition="" statusId="PARTY_ENABLED"  
> statusIdTo="PARTY_DISABLED" transitionName="Disable"/>
> -
> +    <StatusValidChange condition="" statusId="PARTY_DISABLED"  
> statusIdTo="PARTY_ENABLED" transitionName="Re-Enable"/>
> +
>     <StatusType description="Case" hasTable="N" parentTypeId=""  
> statusTypeId="CASE_STATUS"/>
>
>     <StatusType description="Communication Event" hasTable="N"  
> parentTypeId="" statusTypeId="COM_EVENT_STATUS"/>
>
> Modified: ofbiz/trunk/applications/party/src/org/ofbiz/party/party/
> PartyServices.java
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/src/org/ofbiz/party/party/PartyServices.java?rev=781752&r1=781751&r2=781752&view=diff
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- ofbiz/trunk/applications/party/src/org/ofbiz/party/party/
> PartyServices.java (original)
> +++ ofbiz/trunk/applications/party/src/org/ofbiz/party/party/
> PartyServices.java Thu Jun  4 14:33:07 2009
> @@ -211,22 +211,40 @@
>         try {
>             GenericValue party = delegator.findByPrimaryKey("Party",  
> UtilMisc.toMap("partyId", partyId));
>
> -            // check that status is defined as a valid change
> -            GenericValue statusValidChange =  
> delegator.findByPrimaryKey("StatusValidChange",  
> UtilMisc.toMap("statusId", party.getString("statusId"),  
> "statusIdTo", statusId));
> -            if (statusValidChange == null) {
> -                String errorMsg = "Cannot change party status from  
> " + party.getString("statusId") + " to " + statusId;
> -                Debug.logWarning(errorMsg, module);
> -                return ServiceUtil.returnError(errorMsg);
> +            if (party.get("statusId") == null) { // old records
> +             party.set("statusId", "PARTY_ENABLED");
>             }
>
> -            // record the oldStatusId and change the party status
> -            String oldStatusId = party.getString("statusId");
> -            party.set("statusId", statusId);
> -            party.store();
> +         String oldStatusId = party.getString("statusId");
> +            if (!party.getString("statusId").equals(statusId)) {
>
> -            // record this status change in PartyStatus table
> -            GenericValue partyStatus =  
> delegator.makeValue("PartyStatus", UtilMisc.toMap("partyId",  
> partyId, "statusId", statusId, "statusDate", statusDate));
> -            partyStatus.create();
> +             // check that status is defined as a valid change
> +             GenericValue statusValidChange =  
> delegator.findByPrimaryKey("StatusValidChange",  
> UtilMisc.toMap("statusId", party.getString("statusId"),  
> "statusIdTo", statusId));
> +             if (statusValidChange == null) {
> +             String errorMsg = "Cannot change party status from "  
> + party.getString("statusId") + " to " + statusId;
> +             Debug.logWarning(errorMsg, module);
> +             return ServiceUtil.returnError(errorMsg);
> +             }
> +
> +             party.set("statusId", statusId);
> +             party.store();
> +
> +             // record this status change in PartyStatus table
> +             GenericValue partyStatus =  
> delegator.makeValue("PartyStatus", UtilMisc.toMap("partyId",  
> partyId, "statusId", statusId, "statusDate", statusDate));
> +             partyStatus.create();
> +
> +             // disable all userlogins for this user when the new  
> status is disabled
> +             if (("PARTY_DISABLED").equals(statusId)) {
> +             List <GenericValue> userLogins =  
> delegator.findByAnd("UserLogin", UtilMisc.toMap("partyId", partyId));
> +             for(GenericValue userLogin : userLogins) {
> +             if (!"N".equals(userLogin.getString("enabled"))) {
> +             userLogin.set("enabled", "N");
> +             userLogin.set("disabledDateTime",  
> UtilDateTime.nowTimestamp());
> +             userLogin.store();
> +             }
> +             }
> +             }
> +            }
>
>             Map<String, Object> results = ServiceUtil.returnSuccess();
>             results.put("oldStatusId", oldStatusId);
> @@ -246,6 +264,7 @@
>     public static Map<String, Object> updatePerson(DispatchContext  
> ctx, Map<String, ? extends Object> context) {
>         Map<String, Object> result = FastMap.newInstance();
>         GenericDelegator delegator = ctx.getDelegator();
> +        LocalDispatcher dispatcher = ctx.getDispatcher();
>         Locale locale = (Locale) context.get("locale");
>
>         String partyId = getPartyId(context);
> @@ -267,10 +286,15 @@
>         if (person == null || party == null) {
>             return  
> ServiceUtil.returnError(UtilProperties.getMessage(resource,  
> "person.update.not_found", locale));
>         }
> +
> +        // update status by separate service
> +        String oldStatusId = party.getString("statusId");
>
>         person.setNonPKFields(context);
>         party.setNonPKFields(context);
>
> +        party.set("statusId", oldStatusId);
> +
>         try {
>             person.store();
>             party.store();
> @@ -278,6 +302,15 @@
>             Debug.logWarning(e.getMessage(), module);
>             return  
> ServiceUtil.returnError(UtilProperties.getMessage(resource,  
> "person.update.write_failure", new Object[] { e.getMessage() },  
> locale));
>         }
> +
> +        if (!context.get("statusId").equals(oldStatusId)) {
> +            try {
> +                dispatcher.runSync("setPartyStatus",  
> UtilMisc.toMap("partyId", partyId, "statusId",  
> context.get("statusId"), "userLogin", context.get("userLogin")));
> +            } catch (GenericServiceException e) {
> +                Debug.logWarning(e.getMessage(), module);
> +                return  
> ServiceUtil.returnError(UtilProperties.getMessage(resource,  
> "person.update.write_failure", new Object[] { e.getMessage() },  
> locale));
> +            }
> +        }
>
>         result.put(ModelService.RESPONSE_MESSAGE,  
> ModelService.RESPOND_SUCCESS);
>         result.put(ModelService.SUCCESS_MESSAGE,  
> UtilProperties.getMessage(resource, "person.update.success", locale));
> @@ -399,6 +432,7 @@
>     public static Map<String, Object>  
> updatePartyGroup(DispatchContext ctx, Map<String, ? extends Object>  
> context) {
>         Map<String, Object> result = FastMap.newInstance();
>         GenericDelegator delegator = ctx.getDelegator();
> +        LocalDispatcher dispatcher = ctx.getDispatcher();
>         Locale locale = (Locale) context.get("locale");
>
>         String partyId = getPartyId(context);
> @@ -425,8 +459,12 @@
>             return ServiceUtil.returnError(errMsg);
>         }
>
> +
> +        // update status by separate service
> +        String oldStatusId = party.getString("statusId");
>         partyGroup.setNonPKFields(context);
>         party.setNonPKFields(context);
> +        party.set("statusId", oldStatusId);
>
>         try {
>             partyGroup.store();
> @@ -438,6 +476,15 @@
>             return ServiceUtil.returnError(errMsg);
>         }
>
> +        if (!context.get("statusId").equals(oldStatusId)) {
> +            try {
> +                dispatcher.runSync("setPartyStatus",  
> UtilMisc.toMap("partyId", partyId, "statusId",  
> context.get("statusId"), "userLogin", context.get("userLogin")));
> +            } catch (GenericServiceException e) {
> +                Debug.logWarning(e.getMessage(), module);
> +                return  
> ServiceUtil.returnError(UtilProperties.getMessage(resource,  
> "person.update.write_failure", new Object[] { e.getMessage() },  
> locale));
> +            }
> +        }
> +
>         result.put(ModelService.RESPONSE_MESSAGE,  
> ModelService.RESPOND_SUCCESS);
>         return result;
>     }
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Fwd: svn commit: r781752 - in /ofbiz/trunk/applications/party: data/PartyTypeData.xml src/org/ofbiz/party/party/PartyServices.java

hans_bakker
Hi Anil,

the problem should be solved with revision 782529, if not, let me know.
Thanks for reporting,

Regards,
Hans

On Mon, 2009-06-08 at 01:07 -0400, Anil Patel wrote:

> Hans,
> Mods in this commit are causing checkout process to break. I am  
> getting following error.
>
> 2009-06-08 00:48:37,975 (http-0.0.0.0-8443-3)  
> [        CallService.java:247:ERROR]
> ---- exception report  
> ----------------------------------------------------------
> Exception: org.ofbiz.service.GenericServiceException
> Message: Service [updatePerson] target threw an unexpected exception  
> (null)
> ---- cause  
> ---------------------------------------------------------------------
> Exception: java.lang.NullPointerException
> Message: null
> ---- stack trace  
> ---------------------------------------------------------------
> java.lang.NullPointerException
> org.ofbiz.party.party.PartyServices.updatePerson(PartyServices.java:306)
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> sun
> .reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
> 39)
>
> Its because null value for statusId field is passed to service. Please  
> look into it and suggest the fix.
>
> Regards
> Anil Patel
>
>
> Begin forwarded message:
>
> > From: [hidden email]
> > Date: June 4, 2009 10:33:08 AM EDT
> > To: [hidden email]
> > Subject: svn commit: r781752 - in /ofbiz/trunk/applications/party:  
> > data/PartyTypeData.xml src/org/ofbiz/party/party/PartyServices.java
> > Reply-To: [hidden email]
> >
> > Author: hansbak
> > Date: Thu Jun  4 14:33:07 2009
> > New Revision: 781752
> >
> > URL: http://svn.apache.org/viewvc?rev=781752&view=rev
> > Log:
> > disable related userlogins when a party is disabled, status changes  
> > makes now use of separate service, als make re-activate party possible
> >
> > Modified:
> >    ofbiz/trunk/applications/party/data/PartyTypeData.xml
> >    ofbiz/trunk/applications/party/src/org/ofbiz/party/party/
> > PartyServices.java
> >
> > Modified: ofbiz/trunk/applications/party/data/PartyTypeData.xml
> > URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/data/PartyTypeData.xml?rev=781752&r1=781751&r2=781752&view=diff
> > =
> > =
> > =
> > =
> > =
> > =
> > =
> > =
> > ======================================================================
> > --- ofbiz/trunk/applications/party/data/PartyTypeData.xml (original)
> > +++ ofbiz/trunk/applications/party/data/PartyTypeData.xml Thu Jun  4  
> > 14:33:07 2009
> > @@ -297,7 +297,8 @@
> >     <StatusItem description="Enabled" sequenceId="01"  
> > statusCode="ENABLED" statusId="PARTY_ENABLED"  
> > statusTypeId="PARTY_STATUS"/>
> >     <StatusItem description="Disabled" sequenceId="99"  
> > statusCode="DISABLED" statusId="PARTY_DISABLED"  
> > statusTypeId="PARTY_STATUS"/>
> >     <StatusValidChange condition="" statusId="PARTY_ENABLED"  
> > statusIdTo="PARTY_DISABLED" transitionName="Disable"/>
> > -
> > +    <StatusValidChange condition="" statusId="PARTY_DISABLED"  
> > statusIdTo="PARTY_ENABLED" transitionName="Re-Enable"/>
> > +
> >     <StatusType description="Case" hasTable="N" parentTypeId=""  
> > statusTypeId="CASE_STATUS"/>
> >
> >     <StatusType description="Communication Event" hasTable="N"  
> > parentTypeId="" statusTypeId="COM_EVENT_STATUS"/>
> >
> > Modified: ofbiz/trunk/applications/party/src/org/ofbiz/party/party/
> > PartyServices.java
> > URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/src/org/ofbiz/party/party/PartyServices.java?rev=781752&r1=781751&r2=781752&view=diff
> > =
> > =
> > =
> > =
> > =
> > =
> > =
> > =
> > ======================================================================
> > --- ofbiz/trunk/applications/party/src/org/ofbiz/party/party/
> > PartyServices.java (original)
> > +++ ofbiz/trunk/applications/party/src/org/ofbiz/party/party/
> > PartyServices.java Thu Jun  4 14:33:07 2009
> > @@ -211,22 +211,40 @@
> >         try {
> >             GenericValue party = delegator.findByPrimaryKey("Party",  
> > UtilMisc.toMap("partyId", partyId));
> >
> > -            // check that status is defined as a valid change
> > -            GenericValue statusValidChange =  
> > delegator.findByPrimaryKey("StatusValidChange",  
> > UtilMisc.toMap("statusId", party.getString("statusId"),  
> > "statusIdTo", statusId));
> > -            if (statusValidChange == null) {
> > -                String errorMsg = "Cannot change party status from  
> > " + party.getString("statusId") + " to " + statusId;
> > -                Debug.logWarning(errorMsg, module);
> > -                return ServiceUtil.returnError(errorMsg);
> > +            if (party.get("statusId") == null) { // old records
> > +             party.set("statusId", "PARTY_ENABLED");
> >             }
> >
> > -            // record the oldStatusId and change the party status
> > -            String oldStatusId = party.getString("statusId");
> > -            party.set("statusId", statusId);
> > -            party.store();
> > +         String oldStatusId = party.getString("statusId");
> > +            if (!party.getString("statusId").equals(statusId)) {
> >
> > -            // record this status change in PartyStatus table
> > -            GenericValue partyStatus =  
> > delegator.makeValue("PartyStatus", UtilMisc.toMap("partyId",  
> > partyId, "statusId", statusId, "statusDate", statusDate));
> > -            partyStatus.create();
> > +             // check that status is defined as a valid change
> > +             GenericValue statusValidChange =  
> > delegator.findByPrimaryKey("StatusValidChange",  
> > UtilMisc.toMap("statusId", party.getString("statusId"),  
> > "statusIdTo", statusId));
> > +             if (statusValidChange == null) {
> > +             String errorMsg = "Cannot change party status from "  
> > + party.getString("statusId") + " to " + statusId;
> > +             Debug.logWarning(errorMsg, module);
> > +             return ServiceUtil.returnError(errorMsg);
> > +             }
> > +
> > +             party.set("statusId", statusId);
> > +             party.store();
> > +
> > +             // record this status change in PartyStatus table
> > +             GenericValue partyStatus =  
> > delegator.makeValue("PartyStatus", UtilMisc.toMap("partyId",  
> > partyId, "statusId", statusId, "statusDate", statusDate));
> > +             partyStatus.create();
> > +
> > +             // disable all userlogins for this user when the new  
> > status is disabled
> > +             if (("PARTY_DISABLED").equals(statusId)) {
> > +             List <GenericValue> userLogins =  
> > delegator.findByAnd("UserLogin", UtilMisc.toMap("partyId", partyId));
> > +             for(GenericValue userLogin : userLogins) {
> > +             if (!"N".equals(userLogin.getString("enabled"))) {
> > +             userLogin.set("enabled", "N");
> > +             userLogin.set("disabledDateTime",  
> > UtilDateTime.nowTimestamp());
> > +             userLogin.store();
> > +             }
> > +             }
> > +             }
> > +            }
> >
> >             Map<String, Object> results = ServiceUtil.returnSuccess();
> >             results.put("oldStatusId", oldStatusId);
> > @@ -246,6 +264,7 @@
> >     public static Map<String, Object> updatePerson(DispatchContext  
> > ctx, Map<String, ? extends Object> context) {
> >         Map<String, Object> result = FastMap.newInstance();
> >         GenericDelegator delegator = ctx.getDelegator();
> > +        LocalDispatcher dispatcher = ctx.getDispatcher();
> >         Locale locale = (Locale) context.get("locale");
> >
> >         String partyId = getPartyId(context);
> > @@ -267,10 +286,15 @@
> >         if (person == null || party == null) {
> >             return  
> > ServiceUtil.returnError(UtilProperties.getMessage(resource,  
> > "person.update.not_found", locale));
> >         }
> > +
> > +        // update status by separate service
> > +        String oldStatusId = party.getString("statusId");
> >
> >         person.setNonPKFields(context);
> >         party.setNonPKFields(context);
> >
> > +        party.set("statusId", oldStatusId);
> > +
> >         try {
> >             person.store();
> >             party.store();
> > @@ -278,6 +302,15 @@
> >             Debug.logWarning(e.getMessage(), module);
> >             return  
> > ServiceUtil.returnError(UtilProperties.getMessage(resource,  
> > "person.update.write_failure", new Object[] { e.getMessage() },  
> > locale));
> >         }
> > +
> > +        if (!context.get("statusId").equals(oldStatusId)) {
> > +            try {
> > +                dispatcher.runSync("setPartyStatus",  
> > UtilMisc.toMap("partyId", partyId, "statusId",  
> > context.get("statusId"), "userLogin", context.get("userLogin")));
> > +            } catch (GenericServiceException e) {
> > +                Debug.logWarning(e.getMessage(), module);
> > +                return  
> > ServiceUtil.returnError(UtilProperties.getMessage(resource,  
> > "person.update.write_failure", new Object[] { e.getMessage() },  
> > locale));
> > +            }
> > +        }
> >
> >         result.put(ModelService.RESPONSE_MESSAGE,  
> > ModelService.RESPOND_SUCCESS);
> >         result.put(ModelService.SUCCESS_MESSAGE,  
> > UtilProperties.getMessage(resource, "person.update.success", locale));
> > @@ -399,6 +432,7 @@
> >     public static Map<String, Object>  
> > updatePartyGroup(DispatchContext ctx, Map<String, ? extends Object>  
> > context) {
> >         Map<String, Object> result = FastMap.newInstance();
> >         GenericDelegator delegator = ctx.getDelegator();
> > +        LocalDispatcher dispatcher = ctx.getDispatcher();
> >         Locale locale = (Locale) context.get("locale");
> >
> >         String partyId = getPartyId(context);
> > @@ -425,8 +459,12 @@
> >             return ServiceUtil.returnError(errMsg);
> >         }
> >
> > +
> > +        // update status by separate service
> > +        String oldStatusId = party.getString("statusId");
> >         partyGroup.setNonPKFields(context);
> >         party.setNonPKFields(context);
> > +        party.set("statusId", oldStatusId);
> >
> >         try {
> >             partyGroup.store();
> > @@ -438,6 +476,15 @@
> >             return ServiceUtil.returnError(errMsg);
> >         }
> >
> > +        if (!context.get("statusId").equals(oldStatusId)) {
> > +            try {
> > +                dispatcher.runSync("setPartyStatus",  
> > UtilMisc.toMap("partyId", partyId, "statusId",  
> > context.get("statusId"), "userLogin", context.get("userLogin")));
> > +            } catch (GenericServiceException e) {
> > +                Debug.logWarning(e.getMessage(), module);
> > +                return  
> > ServiceUtil.returnError(UtilProperties.getMessage(resource,  
> > "person.update.write_failure", new Object[] { e.getMessage() },  
> > locale));
> > +            }
> > +        }
> > +
> >         result.put(ModelService.RESPONSE_MESSAGE,  
> > ModelService.RESPOND_SUCCESS);
> >         return result;
> >     }
> >
> >
>
--
Antwebsystems.com: Quality OFBiz services for competitive rates