cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From step...@apache.org
Subject cvs commit: xml-cocoon2/src/scratchpad/src/org/apache/cocoon/acting SourceMultiAction.java
Date Mon, 19 Aug 2002 08:01:50 GMT
stephan     2002/08/19 01:01:50

  Modified:    src/scratchpad/src/org/apache/cocoon/acting
                        SourceMultiAction.java
  Log:
  Complete the doDeleteSource methods.
  Add new doCreateCollection method.
  
  Revision  Changes    Path
  1.8       +52 -6     xml-cocoon2/src/scratchpad/src/org/apache/cocoon/acting/SourceMultiAction.java
  
  Index: SourceMultiAction.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/scratchpad/src/org/apache/cocoon/acting/SourceMultiAction.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- SourceMultiAction.java	16 Aug 2002 12:42:56 -0000	1.7
  +++ SourceMultiAction.java	19 Aug 2002 08:01:50 -0000	1.8
  @@ -63,6 +63,7 @@
   import org.apache.cocoon.acting.AbstractAction;
   import org.apache.cocoon.components.request.multipart.FilePartFile;
   import org.apache.cocoon.components.source.InspectableSource;
  +import org.apache.cocoon.components.source.ModifiableTraversableSource;
   import org.apache.cocoon.components.source.RestrictableSource;
   import org.apache.cocoon.components.source.WriteableSource;
   import org.apache.cocoon.components.source.helpers.GroupSourcePermission;
  @@ -105,7 +106,7 @@
       public final static String PRINCIPAL = "cocoon-principal";
       public final static String PASSWORD = "cocoon-password";
       public final static String UPLOAD_FILE = "cocoon-upload-file";
  -    public final static String SOURCE_FILENAME = "cocoon-source-filename";
  +    public final static String SOURCE_NAME = "cocoon-source-name";
   
       File uploadDir = null;
   
  @@ -125,7 +126,7 @@
           Request request = ObjectModelHelper.getRequest(objectModel);
   
           String uri = parameters.getParameter(SOURCE_URI, request.getParameter(SOURCE_URI));
  -        String filename = parameters.getParameter(SOURCE_FILENAME, request.getParameter(SOURCE_FILENAME));
  +        String filename = parameters.getParameter(SOURCE_NAME, request.getParameter(SOURCE_NAME));
           String principal = parameters.getParameter(PRINCIPAL,
                                 request.getParameter(PRINCIPAL));
           String password = parameters.getParameter(PASSWORD,
  @@ -180,6 +181,46 @@
           return EMPTY_MAP;
       }
   
  +    public Map doCreateCollection(Redirector redirector,
  +                   SourceResolver resolver,
  +                   Map objectModel,
  +                   String src,
  +                   Parameters parameters) throws Exception {
  +
  +        getLogger().debug("create collection called");
  +
  +        Request request = ObjectModelHelper.getRequest(objectModel);
  +
  +        String uri = parameters.getParameter(SOURCE_URI, request.getParameter(SOURCE_URI));
  +        String collectionname = parameters.getParameter(SOURCE_NAME, request.getParameter(SOURCE_NAME));
  +        String principal = parameters.getParameter(PRINCIPAL,
  +                              request.getParameter(PRINCIPAL));
  +        String password = parameters.getParameter(PASSWORD,
  +                              request.getParameter(PASSWORD));
  +
  +        try {
  +            Source source = resolver.resolveURI(uri);
  +
  +            if (source instanceof RestrictableSource)
  +                ((RestrictableSource)source).setSourceCredential(new SourceCredential(principal,
password));
  +
  +            if (source instanceof ModifiableTraversableSource) {
  +                ModifiableTraversableSource modifiabletraversablesource = (ModifiableTraversableSource)source;
  +
  +                modifiabletraversablesource.createCollection(collectionname);
  +
  +            } else
  +                throw new ProcessingException("Source isn't writeable");
  +
  +        } catch (SourceException se) {
  +            if (getLogger().isDebugEnabled())
  +                getLogger().debug("Exception occurs while creation of a collection", se);
  +            throw new ProcessingException("Exception occurs while creation of a collection",
se);
  +        }
  +
  +        return EMPTY_MAP;
  +    }
  +
       public Map doDeleteSource(Redirector redirector,
                      SourceResolver resolver,
                      Map objectModel,
  @@ -191,16 +232,21 @@
           Request request = ObjectModelHelper.getRequest(objectModel);
   
           String uri = parameters.getParameter(SOURCE_URI, request.getParameter(SOURCE_URI));
  -        //String filename = parameters.getParameter("filename", request.getParameter("filename"));
  +        String principal = parameters.getParameter(PRINCIPAL,
  +                              request.getParameter(PRINCIPAL));
  +        String password = parameters.getParameter(PASSWORD,
  +                              request.getParameter(PASSWORD));
   
           try {
               Source source = resolver.resolveURI(uri);
   
  +            if (source instanceof RestrictableSource)
  +                ((RestrictableSource)source).setSourceCredential(new SourceCredential(principal,
password));
  +
               if (source instanceof WriteableSource) {
                   WriteableSource writeablesource = (WriteableSource)source;
   
  -                //FIXME : evaluate a interface for a delete method
  -                //writeablesource.delete();
  +                writeablesource.delete();
   
               } else
                   throw new ProcessingException("Source isn't writeable");
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org


Mime
View raw message