Seems to deploy fine..

29.01.2010 14:06:52.747 *INFO* [FelixDispatchQueue]
com.daisytechnologies.spike.website-spike BundleEvent STOPPED
29.01.2010 14:06:52.762 *INFO* [FelixDispatchQueue]
com.daisytechnologies.spike.website-spike BundleEvent UNRESOLVED
29.01.2010 14:06:52.762 *INFO* [FelixDispatchQueue]
com.daisytechnologies.spike.website-spike BundleEvent UPDATED
29.01.2010 14:06:52.762 *INFO* [FelixDispatchQueue]
org.apache.felix.framework FrameworkEvent PACKAGES REFRESHED
29.01.2010 14:06:52.762 *INFO* [FelixDispatchQueue]
com.daisytechnologies.spike.website-spike BundleEvent RESOLVED
29.01.2010 14:06:52.856 *INFO* [Background Update
com.daisytechnologies.spike.website-spike (52)]
org.apache.sling.jcr.contentloader.internal.ContentLoaderService createFile:
Cannot find content type
for GET.jsp, using application/octet-stream
29.01.2010 14:06:52.856 *INFO* [Background Update
com.daisytechnologies.spike.website-spike (52)]
org.apache.sling.jcr.contentloader.internal.ContentLoaderService createFile:
Cannot find content type
for xml.jsp, using application/octet-stream
29.01.2010 14:06:52.856 *INFO* [Background Update
com.daisytechnologies.spike.website-spike (52)]
org.apache.sling.jcr.contentloader.internal.ContentLoaderService createFile:
Cannot find content type
for GET.jsp, using application/octet-stream
29.01.2010 14:06:53.012 *INFO* [FelixDispatchQueue]
com.daisytechnologies.spike.website-spike BundleEvent STARTED

And the logging when I perform the post

29.01.2010 14:08:16.419 *INFO* [127.0.0.1 [1264774096419] POST
/mollycupcakes/baskets HTTP/1.1] logs/request.log 29/Jan/2010:14:08:16 +0000
[102] -> POST /mollycupcakes/baskets HTTP/1.1
29.01.2010 14:08:16.434 *INFO* [127.0.0.1 [1264774096419] POST
/mollycupcakes/baskets HTTP/1.1] logs/request.log 29/Jan/2010:14:08:16 +0000
[102] <- 500 text/html 15ms
29.01.2010 14:08:16.434 *INFO* [127.0.0.1 [1264774096419] POST
/mollycupcakes/baskets HTTP/1.1] logs/access.log 127.0.0.1 - anonymous
29/Jan/2010:14:08:16 +0000 "POST /mollycupcakes/baskets HTTP/1.1"
500 1992 "-" "curl/7.19.5 (i586-pc-mingw32msvc) libcurl/7.19.5
OpenSSL/0.9.8j zlib/1.2.3"

2010/1/29 Vidar Ramdal <[email protected]>

> On Fri, Jan 29, 2010 at 2:51 PM, Ben Short <[email protected]> wrote:
> > Thank you for the response.
> >
> > I have the following rough class.
> >
> > package com.daisytechnologies.basket;
> >
> > import org.apache.sling.api.SlingHttpServletRequest;
> > import org.apache.sling.api.servlets.HtmlResponse;
> > import org.apache.sling.servlets.post.SlingPostOperation;
> > import org.apache.sling.servlets.post.SlingPostProcessor;
> >
> > import javax.jcr.Node;
> > import javax.jcr.RepositoryException;
> > import javax.jcr.Session;
> > import javax.jcr.SimpleCredentials;
> >
> > /**
> >  *
> >  * @scr.component metatype="no" immediate="true"
> >  * @scr.service
> > interface="org.apache.sling.servlets.post.SlingPostOperation"
> >  * @scr.property name="sling.post.operation" value="createBasket"
> >  */
> > public class CreateBasketPostOperation implements SlingPostOperation {
> >    public void run(SlingHttpServletRequest request, HtmlResponse
> > htmlResponse, SlingPostProcessor[] slingPostProcessors) {
> >
> >        Session session =
> > request.getResourceResolver().adaptTo(Session.class);
> >
> >        try {
> >            Session superSession = session.getRepository().login(new
> > SimpleCredentials("admin", "admin".toCharArray()));
> >
> >            final String path = request.getResource().getPath();
> >
> >            Node basketsNode = (Node)superSession.getItem(path);
> >
> >            Node basketNode =
> > basketsNode.addNode(Long.toString(System.currentTimeMillis()));
> >
> >            htmlResponse.onCreated(basketNode.getPath());
> >
> >            superSession.save();
> >            superSession.logout();
> >        } catch (RepositoryException e) {
> >            e.printStackTrace();
> >        }
> >
> >    }
> > }
> >
> > And the following in my pom
> >
> > <plugin>
> >                <groupId>org.apache.felix</groupId>
> >                <artifactId>maven-bundle-plugin</artifactId>
> >                <extensions>true</extensions>
> >                <configuration>
> >                    <instructions>
> >
> >
>  
> <Sling-Initial-Content>initial-content;overwrite:=true;uninstall=true</Sling-Initial-Content>
> >                        <Private-Package>>
> >                            com.daisytechnologies.basket
> >                        </Private-Package>>
> >                    </instructions>
> >                </configuration>
> >            </plugin>
> >
> > the bundle deploys ok but when I execute the following command
> >
> > curl -F":operation=addBasket"
> http://127.0.0.1:8080/mollycupcakes/baskets
> >
> > I get the following error..
> >
> > Status
> > 500
> > Message
> > Invalid operation specified for POST request
> > Location <http://127.0.0.1:8080/mollycupcakes/baskets>Parent
> > Location<http://127.0.0.1:8080/mollycupcakes/baskets>
> > Path
> > Refererhttp://127.0.0.1:8080/mollycupcakesChangeLog
> >
> >
> > any ideas where im going wrong?
>
> Check the Felix web console
> (http://localhost:8080/system/console/bundles) and see that your
> bundle is listed there, and is "active". If it is not, click to expand
> it and check if any of the imports are listed in red.
> You can also tail your sling.log, and see what is output when you
> start your bundle.
>
> > Also how do i inject the SlingRepository into the post operation?
>
> You just declare it with a /** @scr.reference */ annotation:
>
> /** @scr.reference */
> private SlingRepository repository;
>
> --
> Vidar S. Ramdal <[email protected]> - http://www.idium.no
> Sommerrogata 13-15, N-0255 Oslo, Norway
> + 47 22 00 84 00 / +47 21 531941, ext 2070
>

Reply via email to