I don'n know exactly what you're aiming for but you could make that action
that you call idempotent.

This is a snippet of an api that we use to update and create using a single
method:

@Hidden
public class Api extends AbstractFactoryAndRepository {

    ...

    @ActionSemantics(Of.IDEMPOTENT)
    public void putPerson(
            @Named("reference") String reference,
            @Named("initials") @Optional String initials,
            @Named("firstName") String firstName,
            @Named("lastName") String lastName) {
        Person person = (Person) parties.findPartyByReference(reference);
        if (person == null) {
            person = parties.newPerson(initials, firstName, lastName);
            person.setReference(reference);
        }
        person.setFirstName(firstName)
        person.setLastName(lastName);
    }

   ...

    private Parties parties;

public void setPartyRepository(final Parties parties) {

        this.parties = parties;

    }

}


On Sat, Jan 26, 2013 at 6:14 PM, Mark Wood-Patrick
<[email protected]>wrote:

> Are there any plans for the Restful Objects API to support the patch http
> verb (aka upsert) there by saving a round trip?
>
> Mark
>
> -----Original Message-----
> From: Mark Wood-Patrick [mailto:[email protected]]
> Sent: Friday, January 25, 2013 9:57 PM
> To: '[email protected]'
> Cc: 'dev'
> Subject: RE: problem using firefox REST tool with archetype
>
> Many thanks, very much appreciated.
>
> Mark
>
> -----Original Message-----
> From: Dan Haywood [mailto:[email protected]]
> Sent: Friday, January 25, 2013 9:16 AM
> To: [email protected]
> Cc: dev
> Subject: Re: problem using firefox REST tool with archetype
>
> Glad you are now going, Mark.
>
> Nevertheless, I've raised ISIS-318 because this should have returned a 400,
> not a 500.
>
> fyi, although we've put out RO Viewer 1.0.0, do note that it doesn't yet
> implement Restful Objects spec 1.0.0.  And it's new code, so there are
> bound
> to be some rough issues.
>
> Jeroen is probably the expert in terms of using it from a client-side
> perspective; on the project we're working on together, he's using the RO
> API
> as a way to migrate all the data from an old system onto the new app.
>  So it is getting a good workout, but in a fairly narrow way.
>
> To your question about regression tests, there aren't really any.  Which
> isn't good enough, I know; but when I was writing that code I was also
> trying to keep up with Richard and Stef who were doing the .NET impl, as
> well as write the RO spec at the same time... I took some corners.  One or
> two people on the dev mailing list have offered to backfill these tests,
> but
> that was a while ago and there's been no contributions, so I suspect I may
> need to get round to it myself.
>
> In the meantime, if you do hit any showstoppers, I'll certainly do my best
> to resolve them, though you may need to build the code from source for
> expediency's sake.
>
> Cheers
> Dan
>
> On 25 January 2013 16:52, Mark Wood-Patrick <[email protected]>
> wrote:
>
> > Actually that content worked,
> >
> > Many thanks
> >
> > Very much appreciated
> >
> > Mark
> >
> > -----Original Message-----
> > From: Jeroen van der Wal [mailto:[email protected]]
> > Sent: Friday, January 25, 2013 8:01 AM
> > To: [email protected]
> > Subject: Re: problem using firefox REST tool with archetype
> >
> > Hi Mark, perhaps you could share the raw respones body which shows the
> > stacktrace.
> >
> > Futhermore, I've tested with
> >
> > {
> >     "description": "Eat Seaweed",
> >     "category": "Other",
> >     "dueBy": "20130123T000000000"
> > }
> >
> > and that works fine.
> >
> >
> >
> >
> >
> > On Fri, Jan 25, 2013 at 4:46 PM, Mark Wood-Patrick
> > <[email protected]>wrote:
> >
> > > Anyone know what's going on here?
> > >
> > > This is currently blocking for me. Does this work for other folks?
> > >
> > > What regression tests do we have to verify that this should work?
> > >
> > > Mark
> > >
> > > -----Original Message-----
> > > From: Mark Wood-Patrick [mailto:[email protected]]
> > > Sent: Thursday, January 24, 2013 11:53 AM
> > > To: [email protected]
> > > Subject: RE: problem using firefox REST tool with archetype
> > >
> > > No I got a Status Code: 500 Server Error
> > >
> > > Changing the capitalization as you suggested did not help
> > >
> > > Are you able to repro the issue or does it work for you?
> > >
> > > Mark
> > >
> > > -----Original Message-----
> > > From: Dan Haywood [mailto:[email protected]]
> > > Sent: Thursday, January 24, 2013 9:55 AM
> > > To: [email protected]
> > > Subject: Re: problem using firefox REST tool with archetype
> > >
> > > Hi Mark,
> > >
> > > Just looking at the code, the Category enum is defined as:
> > >
> > >     public static enum Category {
> > >         Professional, Domestic, Other;
> > >     }
> > >
> > > So try "Other" instead of "OTHER".
> > >
> > > Did you get a 400 response code (you should have)?
> > >
> > > Let me know...
> > > Dan
> > >
> > > On 24 January 2013 17:16, Mark Wood-Patrick
> > > <[email protected]>
> > > wrote:
> > >
> > > > I was trying to post:
> > > >
> > > > {
> > > >     "description": "Eat Seaweed",
> > > >     "category": "OTHER",
> > > >     "dueBy": "Jan 23, 2013"
> > > > }
> > > >
> > > > To an instance of the archetype using URL:
> > > >
> > > >
> > > > http://l-sim-15-165:8080/restful/objects/objstore.jdo.todo.ToDoIte
> > > > ms
> > > > Jd
> > > > o:1/actions/newToDo/invoke
> > > >
> > > > using the Firefox REST tool with current archetype
> > > >
> > > > And I got:
> > > >
> > > > {
> > > >   "message": "Unknown enum constant 'OTHER'",
> > > >   "stackTrace": [
> > > >
> > > > "org.apache.isis.core.progmodel.facets.object.choices.enums.EnumVa
> > > > lu eS
> > > > emanticsProvider.doParse(EnumValueSemanticsProvider.java:63)",
> > > >
> > > > "org.apache.isis.core.progmodel.facets.object.choices.enums.EnumVa
> > > > lu eS
> > > > emanticsProvider.doRestore(EnumValueSemanticsProvider.java:73)",
> > > >
> > > > "org.apache.isis.core.progmodel.facets.object.choices.enums.EnumVa
> > > > lu eS
> > > > emanticsProvider.doRestore(EnumValueSemanticsProvider.java:32)",
> > > >
> > > > "org.apache.isis.core.progmodel.facets.object.value.ValueSemantics
> > > > Pr
> > > > ov
> > > > iderAndFacetAbstract.fromEncodedString(ValueSemanticsProviderAndFa
> > > > ce
> > > > tA
> > > > bstract.java:261)",
> > > >
> > > > "org.apache.isis.core.progmodel.facets.object.encodeable.Encodable
> > > > Fa
> > > > ce
> > > > tUsingEncoderDecoder.fromEncodedString(EncodableFacetUsingEncoderD
> > > > ec
> > > > od
> > > > er.java:60)",
> > > >
> > > >
> "org.apache.isis.viewer.restfulobjects.viewer.resources.domainobjects.
> > > > JsonValueEncoder.asAdapter(JsonValueEncoder.java:163)",
> > > >
> > > >
> "org.apache.isis.viewer.restfulobjects.viewer.resources.domainobjects.
> > > > DomainResourceHelper.objectAdapterFor(DomainResourceHelper.java:33
> > > > 2)
> > > > ",
> > > >
> > > >
> "org.apache.isis.viewer.restfulobjects.viewer.resources.domainobjects.
> > > > DomainResourceHelper.parseArguments(DomainResourceHelper.java:476)
> > > > ",
> > > >
> > > >
> "org.apache.isis.viewer.restfulobjects.viewer.resources.domainobjects.
> > > > DomainResourceHelper.parseArguments(DomainResourceHelper.java:463)
> > > > ",
> > > >
> > > >
> "org.apache.isis.viewer.restfulobjects.viewer.resources.domainobjects.
> > > > DomainResourceHelper.invokeActionUsingAdapters(DomainResourceHelper.
> > > > ja
> > > > va:270)",
> > > >
> > > >
> "org.apache.isis.viewer.restfulobjects.viewer.resources.domainobjects.
> > > > DomainResourceHelper.invokeAction(DomainResourceHelper.java:265)",
> > > >
> > > >
> > >
> > > "org.apache.isis.viewer.restfulobjects.viewer.resources.domainobjects.
> > > Domain
> > >
> > > ObjectResourceServerside.invokeAction(DomainObjectResourceServerside
> > > .j
> > > ava:40
> > > 7)",
> > > >     "sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)",
> > > >
> > > >
> "sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
> > > > java:57)",
> > > >
> > > >
> > >
> > > "sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcc
> > > es
> > > sorImp
> > > l.java:43)",
> > > >     "java.lang.reflect.Method.invoke(Method.java:601)",
> > > >
> > > >
> "org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.
> > > > java:155)",
> > > >
> > > >
> "org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.
> > > > java:257)",
> > > >
> > > > "org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java
> > > > :2
> > > > 22
> > > > )",
> > > >
> > > > "org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java
> > > > :2
> > > > 11
> > > > )",
> > > >
> > > > "org.jboss.resteasy.core.SynchronousDispatcher.getResponse(Synchro
> > > > no
> > > > us
> > > > Dispatcher.java:525)",
> > > >
> > > > "org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousD
> > > > is
> > > > pa
> > > > tcher.java:502)",
> > > >
> > > > "org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousD
> > > > is
> > > > pa
> > > > tcher.java:119)",
> > > >
> > > >
> "org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.
> > > > service(ServletContainerDispatcher.java:208)",
> > > >
> > > > Anyone know what I'm doing wrong?
> > > >
> > > > Mark Wood-Patrick
> > > > Performance Infrastructure Lead
> > > > e-mail: [email protected]<mailto:[email protected]>
> > > > Building/Cube: SC B31.3084
> > > > Primary Office: please use cell # below (+1 408 486-2757)
> > > > Cell:    408-627-5025
> > > > Fax: 408 486-4757
> > > > Mailstop/Mailbox: MS-10 / B307
> > > >
> > > >  (\__/)
> > > >  (='.'=)
> > > >  (")_(")
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > ------------------------------------------------------------------
> > > > --
> > > > --
> > > > ------------- This email message is for the sole use of the
> > > > intended
> > > > recipient(s) and may contain confidential information.  Any
> > > > unauthorized review, use, disclosure or distribution is prohibited.
> > > > If you are not the intended recipient, please contact the sender
> > > > by reply email and destroy all copies of the original message.
> > > >
> > > > ------------------------------------------------------------------
> > > > --
> > > > --
> > > > -------------
> > > >
> > >
> > >
> > >
> >
> >
>
>

Reply via email to