Okay, I'm trying to extend AbstractSlingPostOperation:

@Component(immediate = true, metatype = false)
@Service(value=SlingPostOperation.class)
@Property(name="sling.post.operation", value="myUpload")
public class MyUploadOperation extends AbstractSlingPostOperation {
    protected void doRun(SlingHttpServletRequest request, HtmlResponse
response, List<Modification> changes) {
        // I WANT TO CALL:  ModifyOperation.doRun()
        final  Session session =
request.getResourceResolver().adaptTo(Session.class);
        final String path = response.getPath();
        final Node node = session.getNode(path);
        node.addMixin("my:mixin");
    }
}


when I do POST with :operation=myUpload, it does come to
MyUploadOperation.doRun() method.
But, I need to do file creation myself.
Is there a way to get ModifyOperation (from SlingPostServlet) and execute
that object first?
Then, I'll get the node and add mixin.

Or, should I extend some other class?

I am using sling.servlets.post 2.0.5 (proprietary CMS I'm using has that
version shipped).
Maybe newer version already fixed adding mixins for nt:file.

I also tried:
./filename....@typehint=my:mixin
but that failed.
(from comments on:
http://svn.apache.org/repos/asf/sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/helper/SlingFileUploadHandler.java
)

Thanks.
Sam

On Fri, Sep 17, 2010 at 3:04 PM, sam lee <[email protected]> wrote:

> Thanks.. But it does not add jcr:mixinTypes.
> I deleted the nt:file node and retried a few times since I found a bug
> report saying that setting jcr:mixinTypes only works for node creation, not
> modification..
>
> I'm gonna create a servlet that handles file upload :P
>
>
>
> On Thu, Sep 16, 2010 at 2:48 PM, Justin Edelson 
> <[email protected]>wrote:
>
>> This should be
>> <form method="POST" action="/path/to" enctype="multipart/form-data" >
>> <input type="file" name="./filename.jpg" />
>> <input type="submit" value="upload" />
>> <input type="hidden" name="./filename....@typehint" value="nt:file" />
>> <input type="hidden" name="./filename.jpg/jcr:mixinTypes"
>> value="my:mixin" />
>> </form>
>>
>> As it is below, you are setting the type of /path/to to nt:file, not
>> /path/to/filename.jpg. Same thing with the mixin declaration.
>>
>> HTH,
>> Justin
>>
>> On 9/16/10 11:24 AM, sam lee wrote:
>> > Hey,
>> >
>> > I am trying to upload a file to /path/to/filename.jpg
>> > /path/to/filename.jpg should be nt:file and have jcr:mixinTypes set to
>> > my:mixin.
>> >
>> > I am trying:
>> > <form method="POST" action="/path/to" enctype="multipart/form-data" >
>> >     <input type="file" name="./filename.jpg" />
>> >     <input type="submit" value="upload" />
>> >     <input type="hidden" name="*...@typehint" value="nt:file" />
>> >     <input type="hidden" name="./jcr:mixinTypes" value="my:mixin" />
>> > </form>
>> >
>> >
>> > This is what I get:
>> > javax.jcr.nodetype.ConstraintViolationException: /path/to: mandatory
>> child
>> > node 
>> > {http://www.jcp.org/jcr/1.0}content<http://www.jcp.org/jcr/1.0%7Dcontent>does
>> >  not exist
>> >
>> > What am I doing wrong?
>> >
>> > Should I create my own servlet to handle file uploading that should be
>> > mixin?
>> > If so, is there example of file uploading servlet?
>> >
>> > Thanks.
>> > Sam
>> >
>>
>>
>

Reply via email to