You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@roller.apache.org by Tatsuya Noyori <no...@gmail.com> on 2007/10/17 18:13:35 UTC

Is it possible to post to resources/subdir directory?

Hello

I am using roller4.0RC8 and rome propono0.6.
I can post GIF files to resouces directory with below code, but I
can't post to resources/subdir directory.
The subdir on Roller can be made by anyone using web browser and the
subdir is very useful to preserve categorized files. So I would like
to ask the following question.

Q1. Is it possible to post to resources/subdir directory?

I would be grateful if someone answer me.

import java.util.List;
import com.sun.syndication.propono.atom.client.AtomClientFactory;
import com.sun.syndication.propono.atom.client.ClientAtomService;
import com.sun.syndication.propono.atom.client.ClientCollection;
import com.sun.syndication.propono.atom.client.ClientMediaEntry;
import com.sun.syndication.propono.atom.client.ClientWorkspace;
import java.io.FileInputStream;

public class AtomMediaEntryPoster {

    public static void main(String[] args) throws Exception {
        String username = "User1";
        String password = "User1Password";
        String title    = "Test";
        String slug     = "Uploaded";
        String filepath = "local.gif";
        String uri      = "http://localhost:8080/roller/roller-services/app";

        ClientAtomService service =
            AtomClientFactory.getAtomService(uri, username, password);
        ClientWorkspace workspace = null;
        List workspaces = service.getWorkspaces();
        if (workspaces.size() > 0) {
            workspace = (ClientWorkspace)workspaces.get(0);
        } else {
            System.out.println("No workspaces found");
            System.exit(-1);
        }
        ClientCollection collection = (ClientCollection)
            workspace.findCollection(null, "entry");

        if (collection != null) {
            ClientMediaEntry entry = collection.createMediaEntry(
                title, slug, "image/gif", new FileInputStream(filepath));

            collection.addEntry(entry);
        } else {
            System.out.println("No collection found that accepts entries");
            System.exit(-1);
        }
    }
}

Best regards,

-- 
Tatsuya Noyori (^o^)/

Re: Is it possible to post to resources/subdir directory?

Posted by Dave <sn...@gmail.com>.
Looks like you do not have a collection that accepts images.

Go to your Server Admin page and make sure that you have "images/*" or
"images/gif" in your list of valid extensions for file upload.

- Dave




On 10/19/07, Tatsuya Noyori <no...@gmail.com> wrote:
> Dear Dave,
>
> Thank you for your reply.
>
> > Wrong. You should not post an "image/gif" to a collection that accepts
> > only entries.
> >
> > You should call workspace.findCollection(null, "image/gif") to find a
> > collection that will accept GIF images.
>
> I have called workspace.findCollection(null, "image/gif"), but the
> collection was null.
> And I have checked below app:service.xml on roller4.0rc8. I am not
> sure, but It seems like <accept>image/gif</accept> was missing. I
> would appreciate it if you confirm my suggestion.
>
> <?xml version="1.0" encoding="UTF-8"?>
> <app:service xmlns:app="http://www.w3.org/2007/app">
>   <app:workspace>
>     <atom:title xmlns:atom="http://www.w3.org/2005/Atom"
> type="text">Nojorin</atom:title>
>     <app:collection
> href="http://localhost:8080/roller/roller-services/app/Nojorin/entries"
> type="text">
>       <atom:title xmlns:atom="http://www.w3.org/2005/Atom">Weblog
> Entries</atom:title>
>       <app:categories fixed="yes"
> scheme="http://localhost:8080/roller/Nojorin/">
>         <atom:category xmlns:atom="http://www.w3.org/2005/Atom"
> term="TEST" label="TEST"/>
>       </app:categories>
>       <app:categories fixed="no"/>
>       <app:accept>application/atom+xml;type=entry</app:accept>
>     </app:collection>
>     <app:collection
> href="http://localhost:8080/roller/roller-services/app/Nojorin/resources/"
> type="text">
>       <atom:title xmlns:atom="http://www.w3.org/2005/Atom">Media
> Files</atom:title>
>     </app:collection>
>     <app:collection
> href="http://localhost:8080/roller/roller-services/app/Nojorin/resources/image"
> type="text">
>       <atom:title xmlns:atom="http://www.w3.org/2005/Atom">Media
> Files: image</atom:title>
>     </app:collection>
>   </app:workspace>
> </app:service>
>
> --
> Tatsuya Noyori (^o^)/
>

Re: Is it possible to post to resources/subdir directory?

Posted by Tatsuya Noyori <no...@gmail.com>.
Dear Dave,

Thank you for your reply.

> Wrong. You should not post an "image/gif" to a collection that accepts
> only entries.
>
> You should call workspace.findCollection(null, "image/gif") to find a
> collection that will accept GIF images.

I have called workspace.findCollection(null, "image/gif"), but the
collection was null.
And I have checked below app:service.xml on roller4.0rc8. I am not
sure, but It seems like <accept>image/gif</accept> was missing. I
would appreciate it if you confirm my suggestion.

<?xml version="1.0" encoding="UTF-8"?>
<app:service xmlns:app="http://www.w3.org/2007/app">
  <app:workspace>
    <atom:title xmlns:atom="http://www.w3.org/2005/Atom"
type="text">Nojorin</atom:title>
    <app:collection
href="http://localhost:8080/roller/roller-services/app/Nojorin/entries"
type="text">
      <atom:title xmlns:atom="http://www.w3.org/2005/Atom">Weblog
Entries</atom:title>
      <app:categories fixed="yes"
scheme="http://localhost:8080/roller/Nojorin/">
        <atom:category xmlns:atom="http://www.w3.org/2005/Atom"
term="TEST" label="TEST"/>
      </app:categories>
      <app:categories fixed="no"/>
      <app:accept>application/atom+xml;type=entry</app:accept>
    </app:collection>
    <app:collection
href="http://localhost:8080/roller/roller-services/app/Nojorin/resources/"
type="text">
      <atom:title xmlns:atom="http://www.w3.org/2005/Atom">Media
Files</atom:title>
    </app:collection>
    <app:collection
href="http://localhost:8080/roller/roller-services/app/Nojorin/resources/image"
type="text">
      <atom:title xmlns:atom="http://www.w3.org/2005/Atom">Media
Files: image</atom:title>
    </app:collection>
  </app:workspace>
</app:service>

-- 
Tatsuya Noyori (^o^)/

Re: Is it possible to post to resources/subdir directory?

Posted by Dave <sn...@gmail.com>.
On 10/17/07, Tatsuya Noyori <no...@gmail.com> wrote:
> I am using roller4.0RC8 and rome propono0.6.
> I can post GIF files to resouces directory with below code, but I
> can't post to resources/subdir directory.
> The subdir on Roller can be made by anyone using web browser and the
> subdir is very useful to preserve categorized files. So I would like
> to ask the following question.
>
> Q1. Is it possible to post to resources/subdir directory?
> I would be grateful if someone answer me.

Yes. But 1) the sub-directory must exist and 2) you must post to the
collection that represents the sub-directory.


>         ClientCollection collection = (ClientCollection)
>             workspace.findCollection(null, "entry");

OK, now you have found a collection that can accept an entry.

>         if (collection != null) {
>             ClientMediaEntry entry = collection.createMediaEntry(
>                 title, slug, "image/gif", new FileInputStream(filepath));

Wrong. You should not post an "image/gif" to a collection that accepts
only entries.

You should call workspace.findCollection(null, "image/gif") to find a
collection that will accept GIF images. The resource directory and
each of it's sub-directories is represented as a collection, so you'll
have to iterate through the collections to find the one you want.

- Dave