Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright (C) 2009 eXo Platform SAS.
   *
   * This is free software; you can redistribute it and/or modify it
   * under the terms of the GNU Lesser General Public License as
   * published by the Free Software Foundation; either version 2.1 of
   * the License, or (at your option) any later version.
   *
   * This software is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
 package org.exoplatform.services.jcr.webdav.command;
 
 
 import java.util.List;
 
 import javax.jcr.Node;
Created by The eXo Platform SAS Author : Vitaly Guly.

Version:
$Id: $
 
 
 public class MkColCommand
 {

   
Logger.
 
    private static Log log = ExoLogger.getLogger("exo.jcr.component.webdav.MkColCommand");

   
resource locks.
 
    private final NullResourceLocksHolder nullResourceLocks;

   
Provides URI information needed for 'location' header in 'CREATED' response
 
    private final UriBuilder uriBuilder;

   
Constructor.

Parameters:
nullResourceLocks resource locks.
 
    public MkColCommand(final NullResourceLocksHolder nullResourceLocks)
    {
       this. = nullResourceLocks;
       this. = null;
    }

   
Constructor.

Parameters:
nullResourceLocks resource locks.
uriBuilder - provide data used in 'location' header
 
    public MkColCommand(final NullResourceLocksHolder nullResourceLocksUriBuilder uriBuilder)
    {
       this. = nullResourceLocks;
       this. = uriBuilder;
    }

   
Webdav Mkcol method implementation.

Parameters:
session current session
path resource path
nodeType folder node type
mixinTypes mixin types
tokens tokens
Returns:
the instance of javax.ws.rs.core.Response
 
    public Response mkCol(Session sessionString pathString nodeTypeList<StringmixinTypesList<Stringtokens)
    {
 
      Node node;
      try
      {
         .checkLock(sessionpathtokens);
         node = session.getRootNode().addNode(TextUtil.relativizePath(path), nodeType);
         if (mixinTypes != null)
         {
            addMixins(nodemixinTypes);
         }
         session.save();
      }
      catch (ItemExistsException exc)
      {
         return Response.status(.).entity(exc.getMessage()).build();
      }
      catch (PathNotFoundException exc)
      {
         return Response.status(.).entity(exc.getMessage()).build();
      }
      catch (AccessDeniedException exc)
      {
         return Response.status(.).entity(exc.getMessage()).build();
      }
      catch (LockException exc)
      {
         return Response.status(.).entity(exc.getMessage()).build();
      }
      catch (RepositoryException exc)
      {
         .error(exc.getMessage(), exc);
         return Response.serverError().entity(exc.getMessage()).build();
      }
      if ( != null)
      {
         return Response.created(.path(session.getWorkspace().getName()).path(path).build()).build();
      }
      // to save compatibility if uriBuilder is not provided
      return Response.status(.).build();
   }

   
Adds mixins to node.

Parameters:
node node.
mixinTypes mixin types.
   private void addMixins(Node nodeList<StringmixinTypes)
   {
      for (int i = 0; i < mixinTypes.size(); i++)
      {
         String curMixinType = mixinTypes.get(i);
         try
         {
            node.addMixin(curMixinType);
         }
         catch (Exception exc)
         {
            .error("Can't add mixin [" + curMixinType + "]"exc);
         }
      }
   }
New to GrepCode? Check out our FAQ X