comanage-dev - Re: [comanage-dev] Re: CoPersonRole creation via REST fails
Subject: COmanage Developers List
List archive
- From: Benn Oshrin <>
- To:
- Subject: Re: [comanage-dev] Re: CoPersonRole creation via REST fails
- Date: Sun, 18 Aug 2013 21:53:47 -0400
To somewhat belatedly reply to this...
I agree that depending on the COU isn't right. CoPersonRole should actually not requires_co, but fixing that is going to take a significant effort, up to (and possibly including) the refactoring of co id out the various URLs in which it is present (CO-620).
I don't understand why you can't use CoPersonId to infer CO ID? It must always be present (you can't have a CO Person Role without a CO Person) and must always be attached to a CO. I bet that was the original design intent.
We should capture this in JIRA if we're not going to do anything with it in the immediate future.
-Benn-
On 3/3/13 5:28 PM, Scott Koranda wrote:
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
- Re: [comanage-dev] Re: CoPersonRole creation via REST fails, Benn Oshrin, 08/18/2013
Archive powered by MHonArc 2.6.16.