Hi Mirko,
Inspecting the URL in a create event is not supported, mainly due to the
fact that beforeCreate and afterCreate events can be called outside the
context of a user request.
As a workaround you can try deleting the just-deployed artifact in
afterCreate() and throwing an exception that will cause the client to fail
- not very elegant, though.
I have created an issue
<https://issues.jfrog.org/jira/browse/RTFACT-4897>to add support for
working directly with client requests in a generic way,
which is targeted for the release after the upcoming one. But if other
ideas come to mind we'll post them here.
To use external classes in plugins you can either add them your server's
shared classpath folder (or to the war classpath directly). Another option
that is commonly used and is often easier to set up is to resolve 3rd party
classes using Grapes with a couple of @Grab annotations on the top of your
plugin script.
The artifactory-papi jar should be in the JFrog public repository, so we'll
make sure it is available there - thanks for bringing this up.
Yoav
On Sun, Apr 29, 2012 at 10:31 PM, Mirko Friedenhagen <
[email protected]> wrote:
> Hello Noam,
>
> I had a look into:
>
> backend/core/src/main/java/org/artifactory/repo/interceptor/storage/StorageInterceptorsImpl.java
>
> While in the 'before*' methods CancelException is catched and the
> status is set appropriately, the 'after*' methods do not deal at all
> with this.
>
> Just setting the message and status instead of throwing an Exception
> does not work, however. The artifacts will get deployed thought status
> was set to 400.
>
> Is it maybe possible to inspect the used upload-URL?
>
> Regards Mirko
>
> On Sun, Apr 29, 2012 at 20:45, Mirko Friedenhagen
> <[email protected]> wrote:
> > Hello Noam,
> >
> > I now tried the approach with afterCreate and throwing a
> > CancelException will return a HTTP-500 instead of the desired
> > HTTP-400.
> >
> > BTW: Is there a way to write a Java class whose implementation is used
> > in plugins? I did not find artifactory-papi.jar in any public
> > repository (including the jfrog ones).
> >
> > Regards Mirko
> > --
> > http://illegalstateexception.blogspot.com/
> > https://github.com/mfriedenhagen/
> > https://bitbucket.org/mfriedenhagen/
> >
> >
> > On Sun, Apr 29, 2012 at 11:20, Noam Y. Tenne <[email protected]> wrote:
> >> Yes, metadata is removed together with the artifact.
> >> Checksums are actually virtual resources and not real files, so this
> >> information is discarded with the artifact.
> >>
> >> On Sun, Apr 29, 2012 at 11:24 AM, Mirko Friedenhagen
> >> <[email protected]> wrote:
> >>>
> >>> No apology needed :-D. I should have told my requirement in the first
> >>> place instead of presenting a solution of my own ;-) . Thanks for your
> >>> answer.
> >>>
> >>> So throwing CancelException will remove the artifact from staging
> again.
> >>> What about checksums and metadata? Are they removed as well?
> >>>
> >>> Regards Mirko
> >>> --
> >>> Sent from my phone
> >>> http://illegalstateexception.blogspot.com
> >>> http://github.com/mfriedenhagen/
> >>> https://bitbucket.org/mfriedenhagen/
> >>>
> >>> On Apr 29, 2012 10:13 AM, "Noam Y. Tenne" <[email protected]> wrote:
> >>>>
> >>>> Apologies, I misunderstood your intent.
> >>>> In this case, within afterCreate you could use
> >>>> org.artifactory.repo.Repositories#getProperties to check if the
> >>>> properties exist on the artifact and throw
> >>>> a org.artifactory.exception.CancelException if they don't; throwing
> the
> >>>> exception will rollback the deployment.
> >>>>
> >>>> Cheers,
> >>>> Noam
> >>>>
> >>>> On Sun, Apr 29, 2012 at 11:00 AM, Mirko Friedenhagen
> >>>> <[email protected]> wrote:
> >>>>>
> >>>>> Hello Noam,
> >>>>>
> >>>>> my goal is to enforce a policy that all deployments to a staging
> >>>>> repository must have a property (set via matrix parameter) qa-ticket
> and I
> >>>>> hoped I could disallow deployment without this property completely
> in this
> >>>>> event hook.
> >>>>>
> >>>>> Regards Mirko
> >>>>> --
> >>>>> Sent from my phone
> >>>>>
> >>>>> On Apr 29, 2012 8:10 AM, "Noam Y. Tenne" <[email protected]> wrote:
> >>>>>>
> >>>>>> Hi Mirko,
> >>>>>>
> >>>>>> beforeCreate won't be appropriate in this situation since the item
> was
> >>>>>> not created yet, hence there's no artifact to annotate with
> properties.
> >>>>>> If you hook into the afterCreate event, you can
> >>>>>> org.artifactory.repo.Repositories#setProperty or
> >>>>>> org.artifactory.repo.Repositories#setPropertyRecursively to
> annotate.
> >>>>>>
> >>>>>> HTH,
> >>>>>> Noam
> >>>>>>
> >>>>>> On Fri, Apr 27, 2012 at 12:26 AM, Mirko Friedenhagen
> >>>>>> <[email protected]> wrote:
> >>>>>>>
> >>>>>>> Hello,
> >>>>>>>
> >>>>>>> say I want to enforce a policy that every upload into a staging
> >>>>>>> repository called libs-staging-local has a value for a property
> called
> >>>>>>> "qaticket", which will be used during procurement. While I may
> check
> >>>>>>> easily that the given file does not exist in libs-releases-local, I
> >>>>>>> seem to have no access to properties given as matrix parameters in
> >>>>>>> beforeCreate.
> >>>>>>>
> >>>>>>> Regards Mirko
> >>>>>>>
> >>>>>>>
> >>>>>>>
> ------------------------------------------------------------------------------
> >>>>>>> Live Security Virtual Conference
> >>>>>>> Exclusive live event will cover all the ways today's security and
> >>>>>>> threat landscape has changed and how IT managers can respond.
> >>>>>>> Discussions
> >>>>>>> will include endpoint security, mobile security and the latest in
> >>>>>>> malware
> >>>>>>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> >>>>>>> _______________________________________________
> >>>>>>> Artifactory-users mailing list
> >>>>>>> [email protected]
> >>>>>>> https://lists.sourceforge.net/lists/listinfo/artifactory-users
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> ------------------------------------------------------------------------------
> >>>>>> Live Security Virtual Conference
> >>>>>> Exclusive live event will cover all the ways today's security and
> >>>>>> threat landscape has changed and how IT managers can respond.
> >>>>>> Discussions
> >>>>>> will include endpoint security, mobile security and the latest in
> >>>>>> malware
> >>>>>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> >>>>>> _______________________________________________
> >>>>>> Artifactory-users mailing list
> >>>>>> [email protected]
> >>>>>> https://lists.sourceforge.net/lists/listinfo/artifactory-users
> >>>>>>
> >>>>>
> >>>>>
> >>>>>
> ------------------------------------------------------------------------------
> >>>>> Live Security Virtual Conference
> >>>>> Exclusive live event will cover all the ways today's security and
> >>>>> threat landscape has changed and how IT managers can respond.
> >>>>> Discussions
> >>>>> will include endpoint security, mobile security and the latest in
> >>>>> malware
> >>>>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> >>>>> _______________________________________________
> >>>>> Artifactory-users mailing list
> >>>>> [email protected]
> >>>>> https://lists.sourceforge.net/lists/listinfo/artifactory-users
> >>>>>
> >>>>
> >>>>
> >>>>
> >>>>
> ------------------------------------------------------------------------------
> >>>> Live Security Virtual Conference
> >>>> Exclusive live event will cover all the ways today's security and
> >>>> threat landscape has changed and how IT managers can respond.
> Discussions
> >>>> will include endpoint security, mobile security and the latest in
> malware
> >>>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> >>>> _______________________________________________
> >>>> Artifactory-users mailing list
> >>>> [email protected]
> >>>> https://lists.sourceforge.net/lists/listinfo/artifactory-users
> >>>>
> >>>
> >>>
> >>>
> ------------------------------------------------------------------------------
> >>> Live Security Virtual Conference
> >>> Exclusive live event will cover all the ways today's security and
> >>> threat landscape has changed and how IT managers can respond.
> Discussions
> >>> will include endpoint security, mobile security and the latest in
> malware
> >>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> >>> _______________________________________________
> >>> Artifactory-users mailing list
> >>> [email protected]
> >>> https://lists.sourceforge.net/lists/listinfo/artifactory-users
> >>>
> >>
> >>
> >>
> ------------------------------------------------------------------------------
> >> Live Security Virtual Conference
> >> Exclusive live event will cover all the ways today's security and
> >> threat landscape has changed and how IT managers can respond.
> Discussions
> >> will include endpoint security, mobile security and the latest in
> malware
> >> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> >> _______________________________________________
> >> Artifactory-users mailing list
> >> [email protected]
> >> https://lists.sourceforge.net/lists/listinfo/artifactory-users
> >>
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Artifactory-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/artifactory-users
>
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Artifactory-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/artifactory-users