comanage-dev - [comanage-dev] Re: CoPersonRole creation via REST fails
Subject: COmanage Developers List
List archive
- From: Scott Koranda <>
- To: comanage-dev <>
- Subject: [comanage-dev] Re: CoPersonRole creation via REST fails
- Date: Sun, 3 Mar 2013 16:28:26 -0600
- Authentication-results: sfpop-ironport01.merit.edu; dkim=pass (signature verified)
On Sat, Mar 2, 2013 at 3:57 PM, Scott Koranda
<>
wrote:
> On Sat, Mar 2, 2013 at 3:40 PM, Scott Koranda
> <>
> wrote:
>> Hi,
>>
>> When I try to create a CoPersonRole via the REST API it fails
>> with this:
>>
>> 403 CO Does Not Exist
>>
>> This error is being thrown in checkRestPost() in
>> AppController.php in this clause:
>>
>> if($this->requires_co && !isset($this->cur_co)) {
>> // If a CO is required and we didn't find one,
>> // bail
>>
>> $this->restResultHeader(403, "CO Does Not Exist");
>> return(false);
>> }
>>
>> Yes, I am sure it is there in that clause and not the one
>> above it.
>>
>> The CoPersonRole model does have requires_co set, but I have
>> looked through beforeFilter() and add() at all levels in the
>> controllers (CoPersonRoleController, StandardController, and
>> AppController) and I don't see how the CO could be set during
>> a REST call.
>>
>> The API doesn't include a CoId. I tried putting one in just in
>> case but that didn't work.
>>
>> I think the right place to fix this is in checkRestPost(), but
>> I am not sure.
>>
>> Please advise...
>>
>> Scott
>
> Hi,
>
> I changed this clause in checkRestPost()
>
> if(!isset($this->cur_co)) {
> $coid = -1;
>
> if(isset($reqdata['CoId']))
> $coid = $reqdata['CoId'];
>
> to be
>
> if(!isset($this->cur_co)) {
> $coid = -1;
>
> if(isset($reqdata['CoId']))
> $coid = $reqdata['CoId'];
>
> if(isset($reqdata['CouId'])) {
> $this->loadModel('Cou');
> $found = $this->Cou->findById($reqdata['CouId']);
> $coid = $found['Cou']['co_id'];
> }
>
> That is, if there is a CouId in the data sent in to the REST API, use
> it to find the CoId since there is one and only one Co for each Cou
> (right?).
>
> Let me know if this is satisfactory.
>
> For now, it worked...
>
> Thanks,
>
> Scott
I needed to further evolve checkRestPost() to handle the case when
creating a CoPersonRole without a COU Id being passed in because the
role is not bound to a COU, just the CO (Virgo as a CO has no COUs).
checkRestPost() could use a PersonType set to 'CO' and an Id to get
the CO, but it could not use CoPersonId as sent in with the
CoPersonRole add request.
This note is mainly a reminder to me to discuss this on Monday
(tomorrow), submit a JIRA if we agree this is a problem and it is not
"fixed" in the current trunk, and then commit the code.
Thanks,
Scott
- [comanage-dev] CoPersonRole creation via REST fails, Scott Koranda, 03/02/2013
- [comanage-dev] Re: CoPersonRole creation via REST fails, Scott Koranda, 03/02/2013
- [comanage-dev] Re: CoPersonRole creation via REST fails, Scott Koranda, 03/03/2013
- [comanage-dev] Re: CoPersonRole creation via REST fails, Scott Koranda, 03/02/2013
Archive powered by MHonArc 2.6.16.