Merge with 2ad3c504ee5d73982c0ef23336276dc1fc9e165f
authorkoutsoub <devnull@localhost>
Mon, 28 Feb 2011 13:02:57 +0000 (15:02 +0200)
committerkoutsoub <devnull@localhost>
Mon, 28 Feb 2011 13:02:57 +0000 (15:02 +0200)
1  2 
.classpath
build.xml
src/gr/ebs/gss/client/FileContextMenu.java
src/gr/ebs/gss/server/ejb/ExternalAPI.java
src/gr/ebs/gss/server/ejb/ExternalAPIBean.java
src/gr/ebs/gss/server/ejb/GSSDAOBean.java

diff --combined .classpath
@@@ -26,7 -26,7 +26,7 @@@
                        <attribute name="javadoc_location" value="http://commons.apache.org/codec/api-release/"/>
                </attributes>
        </classpathentry>
-       <classpathentry kind="lib" path="dependencies/gwt-2.1.1/gwt-user.jar" sourcepath="/home/kman/.m2/repository/com/google/gwt/gwt-user/2.1.0/gwt-user-2.1.0-sources.jar"/>
 -      <classpathentry kind="lib" path="dependencies/gwt-2.0.4/gwt-user.jar"/>
++      <classpathentry kind="lib" path="dependencies/gwt-2.1.1/gwt-user.jar" />
        <classpathentry kind="lib" path="dependencies/junit4.8.1/junit-4.8.1.jar"/>
        <classpathentry kind="lib" path="dependencies/jboss-5.1.0.GA/lib/concurrent.jar"/>
        <classpathentry kind="lib" path="dependencies/jboss-5.1.0.GA/lib/dom4j.jar"/>
        <classpathentry kind="lib" path="dependencies/jboss-5.1.0.GA/common/lib/slf4j-jboss-logging.jar"/>
        <classpathentry kind="lib" path="dependencies/jboss-5.1.0.GA/common/lib/xnio-api.jar"/>
        <classpathentry kind="lib" path="dependencies/gwt-dnd-3.0.1.jar"/>
 -      <classpathentry kind="lib" path="dependencies/gwt-incubator-20100204-r1747.jar"/>
++      <classpathentry kind="lib" path="dependencies/gwt-incubator-20101117-r1766.jar"/>
        <classpathentry kind="lib" path="dependencies/gwt-gears-1.3.0/gwt-gears.jar"/>
        <classpathentry kind="lib" path="dependencies/gwt-visualization-1.1.0/gwt-visualization.jar"/>
        <classpathentry kind="lib" path="dependencies/apache-solr-1.4.1/dist/apache-solr-solrj-1.4.1.jar"/>
        <classpathentry kind="lib" path="dependencies/apache-solr-1.4.1/lib/lucene-analyzers-2.9.3.jar"/>
        <classpathentry kind="lib" path="dependencies/apache-solr-1.4.1/lib/lucene-core-2.9.3.jar"/>
        <classpathentry kind="lib" path="dependencies/apache-solr-1.4.1/dist/apache-solr-core-1.4.1.jar"/>
 +      <classpathentry kind="lib" path="lib/draggable-plugin-1.0.2.jar"/>
 +      <classpathentry kind="lib" path="lib/droppable-plugin-1.0.2.jar"/>
 +      <classpathentry kind="lib" path="lib/gwtquery-1.0.0-20110116.074055-7.jar"/>
        <classpathentry kind="lib" path="dependencies/selenium-server-standalone-2.0b1.jar"/>
-       <classpathentry kind="lib" path="dependencies/gwt-incubator-20101117-r1766.jar"/>
+       <classpathentry kind="lib" path="webdav/WEB-INF/lib/commons-fileupload-1.2.1.jar"/>
+       <classpathentry kind="lib" path="ear/lib/commons-io-1.1.jar"/>
+       <classpathentry kind="lib" path="ear/lib/jdom-1.1.jar"/>
+       <classpathentry kind="lib" path="ear/lib/milton-api-1.5.7-SNAPSHOT.jar"/>
+       <classpathentry kind="lib" path="webdav/WEB-INF/lib/milton-console-1.5.7-SNAPSHOT.jar"/>
+       <classpathentry kind="lib" path="webdav/WEB-INF/lib/milton-servlet-1.5.7-SNAPSHOT.jar"/>
+       <classpathentry kind="lib" path="ear/lib/mime-util-2.1.3.jar"/>
        <classpathentry kind="output" path="bin"/>
  </classpath>
diff --combined build.xml
+++ b/build.xml
        <property name="solr.download.url" value="http://apache.ntua.gr/lucene/solr/${solr.version}/${solr.filename}"/>
        <property name="solrj.version" value="1.4.1"/>
        <property name="solrj.jar" value="apache-solr-solrj-${solrj.version}.jar"/>
 -    <property name="gwt.path" value="${deps.dir}/gwt-2.0.4"/>
 -    <property name="gwt.filename" value="gwt-2.0.4.zip"/>
 -      <property name="gwt.download.url" value="http://google-web-toolkit.googlecode.com/files/gwt-2.0.4.zip"/>
 +      <!--
 +      <property name="gwt.path" value="${deps.dir}/gwt-2.2-M1"/>
 +      <property name="gwt.filename" value="gwt-2.2-M1.zip"/>
 +      <property name="gwt.download.url" value="http://google-web-toolkit.googlecode.com/files/gwt-2.2-M1.zip"/>
 +      -->
 +       
 +      <property name="gwt.path" value="${deps.dir}/gwt-2.1.1"/>
 +    <property name="gwt.filename" value="gwt-2.1.1.zip"/>
 +    <property name="gwt.download.url" value="http://google-web-toolkit.googlecode.com/files/gwt-2.1.1.zip"/>
 +    
 +      
 +      
      <property name="hornetq.path" value="${deps.dir}/hornetq-2.0.0.GA" />
      <property name="hornetq.filename" value="hornetq-2.0.0.GA.zip/"/>
      <property name="hornetq.download.url" value="http://sourceforge.net/projects/hornetq/files/2.0.0.GA/hornetq-2.0.0.GA.zip/download"/>
 -    <property name="junit.path" value="${deps.dir}/junit4.8.1" />
 -    <property name="junit.filename" value="junit4.8.1.zip"/>
 -    <property name="junit.download.url" value="http://sourceforge.net/projects/junit/files/junit/4.8.1/junit4.8.1.zip/download"/>
 +      <property name="junit.path" value="${deps.dir}/junit4.8.1"/>
 +      <property name="junit.filename" value="junit4.8.1.zip"/>
 +      <property name="junit.download.url" value="http://sourceforge.net/projects/junit/files/junit/4.8.1/junit4.8.1.zip/download"/>    
      <property name="gwt-dnd.filename" value="gwt-dnd-3.0.1.jar"/>
      <property name="gwt-dnd.download.url" value="http://gwt-dnd.googlecode.com/files/gwt-dnd-3.0.1.jar"/>
      <property name="gwt-gears.path" value="${deps.dir}/gwt-gears-1.3.0" />
      <property name="gwt-visualization.path" value="${deps.dir}/gwt-visualization-1.1.0" />
      <property name="gwt-visualization.filename" value="gwt-visualization-1.1.0.zip"/>
      <property name="gwt-visualization.download.url" value="http://gwt-google-apis.googlecode.com/files/gwt-visualization-1.1.0.zip"/>
 -    <property name="gwt-incubator.filename" value="gwt-incubator-20100204-r1747.jar"/>
 -    <property name="gwt-incubator.download.url" value="http://google-web-toolkit-incubator.googlecode.com/files/gwt-incubator-20100204-r1747.jar"/>   
 +    <property name="gwt-incubator.filename" value="gwt-incubator-20101117-r1766.jar"/>
 +    <property name="gwt-incubator.download.url" value="http://google-web-toolkit-incubator.googlecode.com/files/gwt-incubator-20101117-r1766.jar"/>
        <property name="selenium-server.filename" value="selenium-server-standalone-2.0b1.jar"/>
        <property name="selenium-server.download.url" value="http://selenium.googlecode.com/files/selenium-server-standalone-2.0b1.jar"/>
 +      
 +      <!-- DND SUPPORT -->
 +              <property name="gquery.filename" value="gwtquery-1.0.0-SNAPSHOT.jar"/>
 +              <property name="gquery-dnd-bundle.filename" value="gquery-dnd-bundle-1.0.2.jar"/>
 +              <property name="gquery-dnd-bundle.download.url" value="http://gwtquery-plugins.googlecode.com/files/gquery-dnd-bundle-1.0.2.jar"/>
 +              
 +      
        <!-- Source and runtime layout configuration -->
        <property name="jboss_run_configuration" value="default" />
      <property name="root.context" value="gss" />
@@@ -94,7 -78,7 +94,7 @@@
  
        <!-- JUnit dirs -->
        <property name="test.dir" value="${basedir}/test" />
 -      
 +
        <!-- Build dirs -->
      <property  name="src.dir" value="${basedir}/src}"/>
      <property  name="solr.src.dir" value="${solr-spec.dir}/src"/>
        <property name="ear.dir" value="${basedir}/ear" />
        <property name="ear.lib.dir" value="${ear.dir}/lib" />
        <property name="mbeans.dist.file" value="${ant.project.name}-mbeans.sar"/>
 +      <property name="lib.dir" value="${basedir}/lib" />
 +      
        <!-- set classpath -->
        <path id="project.class.path">
                <pathelement path="${java.class.path}/" />
 +              <!-- DO NOT MOVE THESE JARS BELOW MUST BE FIRST ON CLASSPATH -->
 +              <pathelement location="${lib.dir}/gwtquery-1.0.0-20110116.074055-7.jar"/>
 +              <pathelement location="${lib.dir}/droppable-plugin-1.0.2.jar"/> 
 +              <pathelement location="${lib.dir}/draggable-plugin-1.0.2.jar"/>
 +              <pathelement location="${lib.dir}/commonui-plugin-1.0.3.jar"/>
 +              <!-- END OF DO NOT MOVE THESE JARS BELOW MUST BE FIRST ON CLASSPATH -->
                <pathelement path="${gwt.path}/gwt-user.jar" />
                <pathelement location="${jboss.common.lib.dir}/commons-logging.jar"/>
                <pathelement location="${jboss.common.lib.dir}/ejb3-persistence.jar"/>
                <pathelement location="${jboss.common.lib.dir}/jbosssx.jar"/>
                <pathelement location="${jboss.common.lib.dir}/hibernate-core.jar"/>
          <pathelement location="${jboss.common.lib.dir}/hibernate-annotations.jar"/>
 -              <pathelement location="${jboss.common.lib.dir}/jboss-remoting.jar"/>
++        <pathelement location="${jboss.common.lib.dir}/jboss-remoting.jar"/>
+         <pathelement location="${jboss.common.lib.dir}/slf4j-api.jar"/>
                <pathelement location="${jboss.lib.dir}/jboss-j2se.jar"/>
                <pathelement location="${jboss.lib.dir}/jboss-kernel.jar"/>
                <pathelement location="${jboss.lib.dir}/jboss-system-jmx.jar"/>
          <pathelement location="${ear.lib.dir}/commons-httpclient-3.1.jar"/>
                <pathelement location="${ear.lib.dir}/commons-lang.jar"/>
                <pathelement location="${ear.lib.dir}/ldap.jar"/>
 -        <pathelement location="${ear.lib.dir}/milton-api-1.5.7-SNAPSHOT.jar"/>
++              <pathelement location="${ear.lib.dir}/milton-api-1.5.7-SNAPSHOT.jar"/>
+         <pathelement location="${ear.lib.dir}/commons-io-1.1.jar"/>
                <pathelement location="${junit.path}/junit.jar"/>
                <pathelement location="${deps.dir}/${gwt-dnd.filename}"/>
                <pathelement location="${gwt-gears.path}/gwt-gears.jar"/>
                <pathelement location="${solr.dist}/${solrj.jar}"/>
          <pathelement location="${solr.dist}/apache-solr-core-1.4.1.jar"/>
          <pathelement location="${solr.lib}/lucene-core-2.9.3.jar"/>
 -        <pathelement location="${solr.lib}/lucene-analyzers-2.9.3.jar"/>      
 -              <pathelement location="${deps.dir}/${selenium-server.filename}"/>
 -        <pathelement location="${webdav.war.lib.dir}/milton-servlet-1.5.7-SNAPSHOT.jar"/>
 +        <pathelement location="${solr.lib}/lucene-analyzers-2.9.3.jar"/>
 +              <pathelement location="${deps.dir}/${selenium-server.filename}"/>               
++              <pathelement location="${webdav.war.lib.dir}/milton-servlet-1.5.7-SNAPSHOT.jar"/>
+         <pathelement location="${webdav.war.lib.dir}/milton-console-1.5.7-SNAPSHOT.jar"/>
        </path>
  
        <target name="check-jboss">
                <available file="${jboss.home}" type="dir" property="jboss.home.present"/>
        </target>
  
 -    <target name="fetch-dependencies" description="Fetch the dpendencies" unless="jboss.home.present" depends="check-jboss">
 +    <target name="fetch-dependencies" description="Fetch the dpendencies" depends="check-jboss">
        <mkdir dir="${deps.dir}"/>
 -        <get src="${gwt.download.url}" dest="${deps.dir}/${gwt.filename}" usetimestamp="true"/>
 -        <get src="${gwt-dnd.download.url}" dest="${deps.dir}/${gwt-dnd.filename}" usetimestamp="true"/>
 +      <!--
 +      <get src="${gwt-dnd.download.url}" dest="${deps.dir}/${gwt-dnd.filename}" usetimestamp="true"/>
          <get src="${gwt-gears.download.url}" dest="${deps.dir}/${gwt-gears.filename}" usetimestamp="true"/>
 -        <get src="${gwt-visualization.download.url}" dest="${deps.dir}/${gwt-visualization.filename}" usetimestamp="true"/>
 -        <get src="${gwt-incubator.download.url}" dest="${deps.dir}/${gwt-incubator.filename}" usetimestamp="true"/>
 -        <get src="${hornetq.download.url}" dest="${deps.dir}/${hornetq.filename}" usetimestamp="true"/>
 -        <get src="${junit.download.url}" dest="${deps.dir}/${junit.filename}" usetimestamp="true"/>
 +        <get src="${gwt-visualization.download.url}" dest="${deps.dir}/${gwt-visualization.filename}" usetimestamp="true"/>       
 +        <get src="${hornetq.download.url}" dest="${deps.dir}/${hornetq.filename}" usetimestamp="true"/>        
          <get src="${jboss.download.url}" dest="${deps.dir}/${jboss.filename}" usetimestamp="true"/>
 -      <get src="${selenium-server.download.url}" dest="${deps.dir}/${selenium-server.filename}" usetimestamp="true"/>
 +        -->           
 +      
 +      <get src="${gwt.download.url}" dest="${deps.dir}/${gwt.filename}" usetimestamp="true"/>
 +      
 +      
 +      <get src="${gwt-incubator.download.url}" dest="${deps.dir}/${gwt-incubator.filename}" usetimestamp="true"/>
 +      <get src="${junit.download.url}" dest="${deps.dir}/${junit.filename}" usetimestamp="true"/>
 +      <get src="${selenium-server.download.url}" dest="${deps.dir}/${selenium-server.filename}" usetimestamp="true"/>         
        <unzip src="${deps.dir}/${gwt.filename}" dest="${deps.dir}"/>
 -        <unzip src="${deps.dir}/${gwt-gears.filename}" dest="${deps.dir}"/>
 +      <unzip src="${deps.dir}/${junit.filename}" dest="${deps.dir}"/>         
 +      <!--
 +      <unzip src="${deps.dir}/${gwt-gears.filename}" dest="${deps.dir}"/>
          <unzip src="${deps.dir}/${gwt-visualization.filename}" dest="${deps.dir}"/>
 -        <unzip src="${deps.dir}/${hornetq.filename}" dest="${deps.dir}"/>
 -        <unzip src="${deps.dir}/${junit.filename}" dest="${deps.dir}"/>
 +        <unzip src="${deps.dir}/${hornetq.filename}" dest="${deps.dir}"/>        
          <unzip src="${deps.dir}/${jboss.filename}" dest="${jboss.home}/.."/>
 +        -->
      </target>
  
        <target name="install" depends="fetch-dependencies, install-solr" description="Installs the configuration files of the application server">
                        <arg value="-war"/>
                        <arg value="${gwt.www.admin.dir}"/>
                        <arg value="${gwt.admin.module}"/>
 -            <jvmarg value="-Xmx128m"/>                                                
 +            <jvmarg value="-Xmx256m"/>                                                
                    <classpath>
                        <pathelement path="${gwt-dev-lib}"/>
                                <path refid="project.class.path" />
                </jar>
        </target>
        
 -      <target name="package-ear" depends="package-admin-war, package-war, package-webdav-war, package-ejb, package-mbeans" description="Package up the project as an ear">
 +      <target name="package-ear" depends=" package-war,package-admin-war,package-webdav-war, package-ejb, package-mbeans" description="Package up the project as an ear">
                <jar destfile="${build.dir}/${dist.ear}">
                        <zipfileset dir="${ear.dir}" />
                        <zipfileset dir="${build.dir}" >
                                <include name="ejbs.jar" />
                                <include name="${dist.war}" />
                                <include name="${webdav.war}" />
 -                <include name="${dist.admin.war}" />
 +                              <include name="${dist.admin.war}" />
                                <include name="${mbeans.dist.file}"/>
                        </zipfileset>
                <zipfileset dir="${solr.dist}" prefix="lib">
@@@ -27,11 -27,9 +27,11 @@@ import gr.ebs.gss.client.commands.Refre
  import gr.ebs.gss.client.commands.RestoreTrashCommand;
  import gr.ebs.gss.client.commands.ToTrashCommand;
  import gr.ebs.gss.client.commands.UploadFileCommand;
 -import gr.ebs.gss.client.dnd.DnDTreeItem;
  import gr.ebs.gss.client.rest.resource.FileResource;
  import gr.ebs.gss.client.rest.resource.FolderResource;
 +import gr.ebs.gss.client.rest.resource.RestResource;
 +import gr.ebs.gss.client.rest.resource.RestResourceWrapper;
 +import gr.ebs.gss.client.rest.resource.TrashFolderResource;
  
  import java.util.List;
  
@@@ -46,6 -44,7 +46,6 @@@ import com.google.gwt.user.client.ui.Ab
  import com.google.gwt.user.client.ui.MenuBar;
  import com.google.gwt.user.client.ui.MenuItem;
  import com.google.gwt.user.client.ui.PopupPanel;
 -import com.google.gwt.user.client.ui.TreeItem;
  
  /**
   * The 'File Context' menu implementation.
@@@ -129,40 -128,40 +129,40 @@@ public class FileContextMenu extends Po
                };
  
                pasteItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.paste()).getHTML() + "&nbsp;Paste</span>", true, new PasteCommand(this));
 -              pasteItem.getElement().setId("fileContextMenu.paste");
 -
 +              pasteItem.getElement().setId("FileContextMenu.paste");
 +              RestResource sel = GSS.get().getTreeView().getSelection();
                MenuBar contextMenu = new MenuBar(true);
                if (isEmpty) {
                        contextMenu.addItem(pasteItem);
 -                      if (GSS.get().getFolders().getCurrent() != null)
 -                              if (GSS.get().getFolders().isFileItem(GSS.get().getFolders().getCurrent())){
 -                                      MenuItem uploadItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.fileUpdate()).getHTML() + "&nbsp;Upload</span>", true, new UploadFileCommand(this));
 -                                      uploadItem.getElement().setId("fileContextMenu.upload");
 -                                      contextMenu.addItem(uploadItem);
 -                              }
 -                              else if (GSS.get().getFolders().isMySharedItem(GSS.get().getFolders().getCurrent()) || GSS      .get()
 -                                                                                                                                                                                                                      .getFolders()
 +                      if (sel != null)
 +                              /*TODO:CELLTREE
 +                              if (GSS.get().getTreeView().isFileItem(GSS.get().getTreeView().getCurrent()))
 +                                      contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.fileUpdate()).getHTML() + "&nbsp;Upload</span>", true, new UploadFileCommand(this));
 +                              else if (GSS.get().getTreeView().isMySharedItem(GSS.get().getTreeView().getCurrent()) || GSS    .get()
 +                                                                                                                                                                                                                      .getTreeView()
                                                                                                                                                                                                                        .isOthersSharedItem(GSS .get()
 -                                                                                                                                                                                                                                                                      .getFolders()
 +                                                                                                                                                                                                                                                                      .getTreeView()
                                                                                                                                                                                                                                                                        .getCurrent()))
 -                                      if(GSS.get().getFolders().getCurrent().getUserObject() instanceof FolderResource){
 -                                              MenuItem uploadItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.fileUpdate()).getHTML() + "&nbsp;Upload</span>", true, new UploadFileCommand(this));
 -                                              uploadItem.getElement().setId("fileContextMenu.upload");
 -                                              contextMenu.addItem(uploadItem);
 -                                      }
 +                                      if(sel instanceof FolderResource)
 +                                              contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.fileUpdate()).getHTML() + "&nbsp;Upload</span>", true, new UploadFileCommand(this));
 +                      */
 +                      if(sel instanceof RestResourceWrapper && !(sel instanceof TrashFolderResource)){
 +                              MenuItem upload = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.fileUpdate()).getHTML() + "&nbsp;Upload</span>", true, new UploadFileCommand(this));
 +                              upload.getElement().setId("fileContextMenu.upload");
 +                              contextMenu.addItem(upload);
 +                      }
 +                      MenuItem refresh = new MenuItem("<span>" + AbstractImagePrototype.create(images.refresh()).getHTML() + "&nbsp;Refresh</span>", true, new RefreshCommand(this, images));
 +                      refresh.getElement().setId("fileContextMenu.refresh");
 +                      contextMenu.addItem(refresh);
                        
 -                      MenuItem refreshItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.refresh()).getHTML() + "&nbsp;Refresh</span>", true, new RefreshCommand(this, images));
 -                      refreshItem.getElement().setId("fileContextItem.refresh");
 -                      contextMenu.addItem(refreshItem);
                } else if (isTrash) {
 -                      MenuItem restoreItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.versions()).getHTML() + "&nbsp;Restore</span>", true, new RestoreTrashCommand(this));
 -                      restoreItem.getElement().setId("fileContextMenu.restore");
 -                      
 -                      MenuItem deleteItem2 = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + "&nbsp;Delete</span>", true, new DeleteCommand(this, images));
 -                      deleteItem2.getElement().setId("fileContextMenu.delete");
 +                      MenuItem restore = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.versions()).getHTML() + "&nbsp;Restore</span>", true, new RestoreTrashCommand(this));
 +                      restore.getElement().setId("fileContextMenu.restore");
 +                      contextMenu.addItem(restore);
                        
 -                      contextMenu.addItem(restoreItem);
 -                      contextMenu.addItem(deleteItem2);
 +                      MenuItem delete = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + "&nbsp;Delete</span>", true, new DeleteCommand(this, images));
 +                      delete.getElement().setId("fileContextMenu.delete");
 +                      contextMenu.addItem(delete);
                } else {
                        final Command unselectAllCommand = new Command() {
  
                                                GSS.get().getSearchResults().clearSelectedRows();
                                }
                        };
 -                      cutItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.cut()).getHTML() + "&nbsp;Cut</span>", true, new CutCommand(this));
 +                      cutItem = new MenuItem("<span id='fileContextMenu.cut'>" + AbstractImagePrototype.create(newImages.cut()).getHTML() + "&nbsp;Cut</span>", true, new CutCommand(this));
                        cutItem.getElement().setId("fileContextMenu.cut");
                        
                        copyItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.copy()).getHTML() + "&nbsp;Copy</span>", true, new CopyCommand(this));
                        
                        updateItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.fileUpdate()).getHTML() + "&nbsp;Upload</span>", true, new UploadFileCommand(this));
                        updateItem.getElement().setId("fileContextMenu.upload");
 -                      
 +
                        trashItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.emptyTrash()).getHTML() + "&nbsp;Move to Trash</span>", true, new ToTrashCommand(this));
                        trashItem.getElement().setId("fileContextMenu.moveToTrash");
                        
                        propItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + "&nbsp;Properties</span>", true, new PropertiesCommand(this, images, 0));
                        propItem.getElement().setId("fileContextMenu.properties");
  
 -                      TreeItem currentFolder = gss.getFolders().getCurrent();
 -                      if(currentFolder!=null && currentFolder.getUserObject() instanceof FolderResource)
 +                      
 +                      if(sel!=null && sel instanceof FolderResource)
                                contextMenu.addItem(updateItem);
                        String[] link = {"", ""};
                        gss.getTopPanel().getFileMenu().createDownloadLink(link, false);
                        contextMenu.addItem(downloadItem);
                        
                        gss.getTopPanel().getFileMenu().createDownloadLink(link, true);
 -                      
                        saveAsItem = new MenuItem("<span>" + link[0] + AbstractImagePrototype.create(newImages.download()).getHTML() + " Save As" + link[1] + "</span>", true, downloadCmd);
                        saveAsItem.getElement().setId("fileContextMenu.saveAs");
                        contextMenu.addItem(saveAsItem);
                        contextMenu.addItem(cutItem);
                        contextMenu.addItem(copyItem);
 -                      
 -                      if(currentFolder!=null && currentFolder.getUserObject() instanceof FolderResource)
 +                      if(sel!=null && sel instanceof FolderResource)
                                contextMenu.addItem(pasteItem);
 +                      MenuItem unSelect = new MenuItem("<span>" + AbstractImagePrototype.create(images.unselectAll()).getHTML() + "&nbsp;Unselect</span>", true, unselectAllCommand);
 +                      unSelect.getElement().setId("fileContextMenu.unSelect");
 +                      contextMenu.addItem(unSelect);
                        
                        contextMenu.addItem(trashItem);
                        contextMenu.addItem(deleteItem);
                        
 -                      MenuItem refreshItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.refresh()).getHTML() + "&nbsp;Refresh</span>", true, new RefreshCommand(this, images));
 -                      refreshItem.getElement().setId("fileContextMenu.refresh");
 +                      MenuItem refresh = new MenuItem("<span id='fileContextMenu.refresh'>" + AbstractImagePrototype.create(images.refresh()).getHTML() + "&nbsp;Refresh</span>", true, new RefreshCommand(this, images));
- //                    refresh.getElement().setId("fileContextMenu.refresh");
++                      refresh.getElement().setId("fileContextMenu.refresh");
 +                      contextMenu.addItem(refresh);
                        
 -                      contextMenu.addItem(refreshItem);
                        contextMenu.addItem(sharingItem);
                        contextMenu.addItem(propItem);
                }
                                menu.show();
                        } else if (GSS.get().getCurrentSelection() instanceof List) {
                                FileContextMenu menu;
 -                              if (GSS.get().getFolders().isTrashItem(GSS.get().getFolders().getCurrent()))
 +                              /*TODO: CELLTREE
 +                              if (GSS.get().getTreeView().isTrashItem(GSS.get().getTreeView().getCurrent()))
                                        menu = new FileContextMenu(images, true, false);
                                else {
                                        menu = new FileContextMenu(images, false, false);
                                        menu.onMultipleSelection();
                                }
 +                              */
 +                              menu = new FileContextMenu(images, false, false);
 +                              menu.onMultipleSelection();
                                int left = event.getRelativeElement().getAbsoluteLeft();
                                int top = event.getRelativeElement().getAbsoluteTop() + event.getRelativeElement().getOffsetHeight();
                                menu.setPopupPosition(left, top);
  
                        } else if (GSS.get().getCurrentSelection() instanceof List) {
                                FileContextMenu menu;
 -                              if (GSS.get().getFolders().isTrashItem(GSS.get().getFolders().getCurrent()))
 +                              /*TODO: CELLTREE
 +                              if (GSS.get().getTreeView().isTrashItem(GSS.get().getTreeView().getCurrent()))
                                        menu = new FileContextMenu(images, true, false);
                                else {
                                        menu = new FileContextMenu(images, false, false);
                                        menu.onMultipleSelection();
                                }
 +                              */
                                int left = event.getNativeEvent().getClientX();
                                int top = event.getNativeEvent().getClientY();
 -                              menu.setPopupPosition(left, top);
 -                              menu.show();
 +                              //menu.setPopupPosition(left, top);
 +                              //menu.show();
                        }
        }
  
                                menu.setPopupPosition(left, top);
                                menu.show();
                        } else if (GSS.get().getCurrentSelection() instanceof List) {
 -
 -                              if (GSS.get().getFolders().isTrashItem(GSS.get().getFolders().getCurrent()))
 +                              /*TODO: CELLTREE
 +                              if (GSS.get().getTreeView().isTrashItem(GSS.get().getTreeView().getSelection()))
                                        menu = new FileContextMenu(images, true, false);
                                else {
                                        menu = new FileContextMenu(images, false, false);
                                        menu.onMultipleSelection();
 -                              }
 +                              }*/
 +                              menu = new FileContextMenu(images, false, false);
 +                              menu.onMultipleSelection();
                                int left = event.getClientX();
                                int top = event.getClientY();
                                menu.setPopupPosition(left, top);
  
        public FileContextMenu onEmptyEvent(Event event) {
                FileContextMenu menu=null;
 -              if (GSS.get().getFolders().isTrashItem(GSS.get().getFolders().getCurrent()))
 +              /*TODO: CELLTREE
 +              if (GSS.get().getTreeView().isTrashItem(GSS.get().getTreeView().getCurrent()))
                        menu = new FileContextMenu(images, true, true);
 -              else if(((DnDTreeItem)GSS.get().getFolders().getCurrent()).getFolderResource() != null)
 +              else if(((DnDTreeItem)GSS.get().getTreeView().getCurrent()).getFolderResource() != null)
                        menu = new FileContextMenu(images, false, true);
                else return menu;
 +              */
 +              menu = new FileContextMenu(images, false, true);
                int left = event.getClientX();
                int top = event.getClientY();
                menu.setPopupPosition(left, top);
@@@ -24,20 -24,18 +24,18 @@@ import gr.ebs.gss.client.exceptions.Ins
  import gr.ebs.gss.client.exceptions.InvitationUsedException;
  import gr.ebs.gss.client.exceptions.ObjectNotFoundException;
  import gr.ebs.gss.client.exceptions.QuotaExceededException;
+ import gr.ebs.gss.server.domain.FileBody;
  import gr.ebs.gss.server.domain.FileHeader;
+ import gr.ebs.gss.server.domain.FileLock;
  import gr.ebs.gss.server.domain.FileUploadStatus;
+ import gr.ebs.gss.server.domain.Folder;
+ import gr.ebs.gss.server.domain.Group;
  import gr.ebs.gss.server.domain.Invitation;
  import gr.ebs.gss.server.domain.Nonce;
+ import gr.ebs.gss.server.domain.Permission;
  import gr.ebs.gss.server.domain.User;
  import gr.ebs.gss.server.domain.UserClass;
  import gr.ebs.gss.server.domain.UserLogin;
- import gr.ebs.gss.server.domain.dto.FileBodyDTO;
- import gr.ebs.gss.server.domain.dto.FileHeaderDTO;
- import gr.ebs.gss.server.domain.dto.FolderDTO;
- import gr.ebs.gss.server.domain.dto.GroupDTO;
- import gr.ebs.gss.server.domain.dto.PermissionDTO;
- import gr.ebs.gss.server.domain.dto.StatsDTO;
- import gr.ebs.gss.server.domain.dto.UserDTO;
  
  import java.io.File;
  import java.io.IOException;
@@@ -50,6 -48,10 +48,10 @@@ import javax.ejb.Local
  import javax.ejb.TransactionAttribute;
  import javax.ejb.TransactionAttributeType;
  
+ import gr.ebs.gss.server.domain.WebDavNonce;
+ import gr.ebs.gss.server.domain.dto.FileHeaderDTO;
+ import gr.ebs.gss.server.domain.dto.StatsDTO;
+ import gr.ebs.gss.server.domain.dto.UserDTO;
  import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
  
  /**
@@@ -68,7 -70,7 +70,7 @@@ public interface ExternalAPI 
         * @return Folder
         * @throws ObjectNotFoundException if no Folder or user was found
         */
-       public FolderDTO getRootFolder(Long userId) throws ObjectNotFoundException;
+       public Folder getRootFolder(Long userId) throws ObjectNotFoundException;
  
        /**
         * Retrieve the folder with the specified ID.
@@@ -79,7 -81,7 +81,7 @@@
         * @throws ObjectNotFoundException if the folder or the user was not found
         * @throws InsufficientPermissionsException if ther user does not have read permissions for folder
         */
-       public FolderDTO getFolder(Long userId, Long folderId) throws ObjectNotFoundException,
+       public Folder getFolder(Long userId, Long folderId) throws ObjectNotFoundException,
                        InsufficientPermissionsException;
  
        /**
         * @return The Group object
         * @throws ObjectNotFoundException if the group cannot be found
         */
-       public GroupDTO getGroup(Long groupId) throws ObjectNotFoundException;
+       public Group getGroup(Long groupId) throws ObjectNotFoundException;
  
        /**
         * Returns the group with the specified name that belongs to the
         * @return The Group object
         * @throws ObjectNotFoundException if the group cannot be found
         */
-       public GroupDTO getGroup(Long userId, String name) throws ObjectNotFoundException;
+       public Group getGroup(Long userId, String name) throws ObjectNotFoundException;
  
        /**
         * Retrieve the list of groups for a particular user.
         * @return a List of Groups that belong to the specified User
         * @throws ObjectNotFoundException if the user was not found
         */
-       public List<GroupDTO> getGroups(Long userId) throws ObjectNotFoundException;
+       public List<Group> getGroups(Long userId) throws ObjectNotFoundException;
  
        /**
         * Returns a list of files contained in the folder specified by its id.
         * @throws ObjectNotFoundException if the user or the folder cannot be found
         * @throws InsufficientPermissionsException
         */
-       public List<FileHeaderDTO> getFiles(Long userId, Long folderId, boolean ignoreDeleted) throws ObjectNotFoundException,
+       public List<FileHeader> getFiles(Long userId, Long folderId, boolean ignoreDeleted) throws ObjectNotFoundException,
                        InsufficientPermissionsException;
  
        /**
         *
         * @param userId the ID of the User
         * @param groupId the ID of the requested group
-        * @return List<UserDTO>
+        * @return List<User>
         * @throws ObjectNotFoundException if the user or group was not found, with
         *             the exception message mentioning the precise problem
         */
-       public List<UserDTO> getUsers(Long userId, Long groupId) throws ObjectNotFoundException;
+       public List<User> getUsers(Long userId, Long groupId) throws ObjectNotFoundException;
  
        /**
         * Returns a list of users matching the specified username
         *
         * @param username the username of the User
-        * @return List<UserDTO>
+        * @return List<User>
         */
-       public List<UserDTO> getUsersByUserNameLike(String username);
+       public List<User> getUsersByUserNameLike(String username);
  
        /**
         * Creates a new folder with the specified owner, parent folder and name.
         *             problem
         * @throws InsufficientPermissionsException
         */
-       public FolderDTO createFolder(Long userId, Long parentId, String name) throws DuplicateNameException,
+       public Folder createFolder(Long userId, Long parentId, String name) throws DuplicateNameException,
                        ObjectNotFoundException, InsufficientPermissionsException;
  
        /**
         * @throws ObjectNotFoundException if the folder or user was not found
         * @throws InsufficientPermissionsException
         */
-       public List<FolderDTO> getSubfolders(Long userId, Long folderId)
-                       throws ObjectNotFoundException, InsufficientPermissionsException;
-       /**
-        * Retrieve the folder with the specified ID with subfolders.
-        *
-        * @param userId the ID of the current user
-        * @param folderId the ID of the folder to retrieve
-        * @return the folder found
-        * @throws ObjectNotFoundException if the folder or the user was not found
-        * @throws InsufficientPermissionsException if ther user does not have read permissions for folder
-        */
-       public FolderDTO getFolderWithSubfolders(Long userId, Long folderId)
+       public List<Folder> getSubfolders(Long userId, Long folderId)
                        throws ObjectNotFoundException, InsufficientPermissionsException;
  
        /**
-        * Retrieve the folder with the specified ID with subfolders.
-        *
-        * @param userId the ID of the current user
-        * @param callingUserId the ID of the user requesting this operation
-        * @param folderId the ID of the folder to retrieve
-        * @return the folder found
-        * @throws ObjectNotFoundException if the folder or the user was not found
-        * @throws InsufficientPermissionsException if ther user does not have read permissions for folder
-        */
-       public FolderDTO getFolderWithSubfolders(Long userId, Long callingUserId, Long folderId)
-                       throws ObjectNotFoundException, InsufficientPermissionsException;
-       /**
         * Retrieve the subfolders of the specified folder that are shared to others.
         *
         * @param userId the ID of the current user
         * @return the list of subfolders found
         * @throws ObjectNotFoundException if the folder or user was not found
         */
-       public List<FolderDTO> getSharedSubfolders(Long userId, Long folderId) throws ObjectNotFoundException;
+       public List<Folder> getSharedSubfolders(Long userId, Long folderId) throws ObjectNotFoundException;
  
        /**
         * Retrieve the subfolders of the specified folder that are shared to others.
         * @return the list of subfolders found
         * @throws ObjectNotFoundException if the folder or user was not found
         */
-       public List<FolderDTO> getSharedSubfolders(Long userId, Long callingUserId, Long folderId) throws ObjectNotFoundException;
+       public List<Folder> getSharedSubfolders(Long userId, Long callingUserId, Long folderId) throws ObjectNotFoundException;
        /**
         * Modifies the specified folder if the specified user has the appropriate
         * permission.
         * @throws DuplicateNameException if the specified name already exists in
         *             the parent folder, as either a folder or file
         */
-       public FolderDTO updateFolder(Long userId, Long folderId, String folderName,
+       public Folder updateFolder(Long userId, Long folderId, String folderName,
                                Boolean readForAll,
-                               Set<PermissionDTO> permissions)
+                               Set<Permission> permissions)
                        throws InsufficientPermissionsException, ObjectNotFoundException, DuplicateNameException;
  
        /**
         * @param name the name of the new file
         * @param mimeType the MIME type of the file
         * @param stream the input stream with the file contents
-        * @return The FileHeaderDTO created
+        * @return The FileHeader created
         * @throws DuplicateNameException if the specified name already exists in
         *             the parent folder, as either a folder or file
         * @throws ObjectNotFoundException if the user or parent folder was not
         * @throws InsufficientPermissionsException
         * @throws QuotaExceededException
         */
-       public FileHeaderDTO createFile(Long userId, Long folderId, String name, String mimeType,
+       public FileHeader createFile(Long userId, Long folderId, String name, String mimeType,
                                InputStream stream) throws DuplicateNameException, ObjectNotFoundException,
                                GSSIOException, InsufficientPermissionsException, QuotaExceededException;
  
        public void deleteFile(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
  
        /**
-        * Deletes the specified file in the specified user's namespace.
-        *
-        * @param userId the ID of the current user
-        * @param fileIds the IDs of the files to delete
-        * @throws ObjectNotFoundException if the user or file was not found, with
-        *             the exception message mentioning the precise problem
-        * @throws InsufficientPermissionsException if the user does not have the
-        *             appropriate privileges
-        */
-       public void deleteFiles(Long userId, List<Long> fileIds)
-                       throws ObjectNotFoundException, InsufficientPermissionsException;
-       /**
         * Creates a new tag for the specified user and file.
         *
         * @param userId the creator of the tag
         */
        public void updateFile(Long userId, Long fileId, String name, String tagSet,
                        Date modificationDate, Boolean versioned, Boolean readForAll,
-                       Set<PermissionDTO> permissions)
+                       Set<Permission> permissions)
                        throws DuplicateNameException, ObjectNotFoundException, InsufficientPermissionsException;
  
        /**
         *                      the exception message mentioning the precise problem
         * @throws InsufficientPermissionsException
         */
-       public FileHeaderDTO getFile(Long userId, Long fileId) throws ObjectNotFoundException,
+       public FileHeader getFile(Long userId, Long fileId) throws ObjectNotFoundException,
                        InsufficientPermissionsException;
  
        /**
         *                      the exception message mentioning the precise problem
         * @throws InsufficientPermissionsException
         */
-       public FileBodyDTO getFileBody(Long userId, Long fileId, Long bodyId)
+       public FileBody getFileBody(Long userId, Long fileId, Long bodyId)
                        throws ObjectNotFoundException, InsufficientPermissionsException;
  
        /**
         * Get the resource (file or folder) at the specified path in
         * the specified user's namespace. The returned object will be of type
-        * FileHeaderDTO or FolderDTO.<p><strong>Note:</strong> this method does not
+        * FileHeader or Folder.<p><strong>Note:</strong> this method does not
         * receive the current user as a parameter, therefore it is unable to perform
         * the necessary permission checks and should <strong>NOT</strong> be directly
         * exposed to remote clients. It is the caller's responsibility to verify that
        public void removeFileFromTrash(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
  
        /**
-        * Marks  the specified files as deleted in the specified user's namespace.
-        *
-        * @param userId the ID of the current user
-        * @param fileIds the IDs of the file to delete
-        * @throws ObjectNotFoundException if the user or file was not found, with
-        *             the exception message mentioning the precise problem
-        * @throws InsufficientPermissionsException if the user does not have the
-        *             appropriate privileges
-        */
-       public void moveFilesToTrash(Long userId, List<Long> fileIds)
-                       throws ObjectNotFoundException, InsufficientPermissionsException;
-       /**
-        * Marks  the specified deleted files as undeleted in the specified user's namespace.
-        *
-        * @param userId the ID of the current user
-        * @param fileIds the IDs of the file to undelete
-        * @throws ObjectNotFoundException if the user or file was not found, with
-        *             the exception message mentioning the precise problem
-        * @throws InsufficientPermissionsException if the user does not have the
-        *             appropriate privileges
-        */
-       public void removeFilesFromTrash(Long userId, List<Long> fileIds) throws ObjectNotFoundException, InsufficientPermissionsException;
-       /**
         * Marks  the specified folder as deleted in the specified user's namespace.
         *
         * @param userId the ID of the current user
         *       * @return the list of deleted file header objects
         * @throws ObjectNotFoundException if the user cannot be found
         */
-       public List<FileHeaderDTO> getDeletedFiles(Long userId) throws ObjectNotFoundException;
+       public List<FileHeader> getDeletedFiles(Long userId) throws ObjectNotFoundException;
  
        /**
         * Returns a list of All deleted root folders of a user.
         *       * @return the list of deleted file header objects
         * @throws ObjectNotFoundException if the user cannot be found
         */
-       public List<FolderDTO> getDeletedRootFolders(Long userId) throws ObjectNotFoundException;
+       public List<Folder> getDeletedRootFolders(Long userId) throws ObjectNotFoundException;
  
        /**
         * Empty Trash by deleting all marked as deleted files and folders
         * @throws ObjectNotFoundException if the user or folder could not be found
         * @throws InsufficientPermissionsException
         */
-       public Set<PermissionDTO> getFolderPermissions(Long userId, Long folderId)
+       public Set<Permission> getFolderPermissions(Long userId, Long folderId)
                        throws ObjectNotFoundException, InsufficientPermissionsException;
  
        /**
         * @throws ObjectNotFoundException if the user or folder could not be found
         * @throws InsufficientPermissionsException
         */
-       public Set<PermissionDTO> getFilePermissions(Long userId, Long fileId)
+       public Set<Permission> getFilePermissions(Long userId, Long fileId)
                        throws ObjectNotFoundException, InsufficientPermissionsException;
  
        /**
         * @return the list of shared root folders
         * @throws ObjectNotFoundException if the user cannot be found
         */
-       public List<FolderDTO> getSharedRootFolders(Long userId) throws ObjectNotFoundException;
+       public List<Folder> getSharedRootFolders(Long userId) throws ObjectNotFoundException;
  
        /**
         * Returns a list of all shared files of a user that are not
         * @return the list of shared files
         * @throws ObjectNotFoundException if the user cannot be found
         */
-       public List<FileHeaderDTO> getSharedFilesNotInSharedFolders(Long userId) throws ObjectNotFoundException;
+       public List<FileHeader> getSharedFilesNotInSharedFolders(Long userId) throws ObjectNotFoundException;
  
        /**
         * Returns a list of all shared files of a user.
         * @return the list of shared files
         * @throws ObjectNotFoundException if the user cannot be found
         */
-       public List<FileHeaderDTO> getSharedFiles(Long userId) throws ObjectNotFoundException;
+       public List<FileHeader> getSharedFiles(Long userId) throws ObjectNotFoundException;
  
        /**
         * Returns a list of all shared folders of a user.
         * @return the list of shared folders
         * @throws ObjectNotFoundException if the user cannot be found
         */
-       public List<FolderDTO> getSharedFolders(Long userId) throws ObjectNotFoundException;
+       public List<Folder> getSharedFolders(Long userId) throws ObjectNotFoundException;
  
        /**
         * Returns a list of all shared root folders of a user that calling
         *
         * @throws ObjectNotFoundException if the user cannot be found
         */
-       public List<FolderDTO> getSharedRootFolders(Long ownerId, Long callingUserId)
+       public List<Folder> getSharedRootFolders(Long ownerId, Long callingUserId)
                        throws ObjectNotFoundException;
  
        /**
         * @param callingUserId
         * @throws ObjectNotFoundException if the user cannot be found
         */
-       public List<FileHeaderDTO> getSharedFiles(Long ownerId, Long callingUserId)
+       public List<FileHeader> getSharedFiles(Long ownerId, Long callingUserId)
                        throws ObjectNotFoundException;
  
        /**
         * @return the List of users sharing files to user
         * @throws ObjectNotFoundException
         */
-       public List<UserDTO> getUsersSharingFoldersForUser(Long userId) throws ObjectNotFoundException;
+       public List<User> getUsersSharingFoldersForUser(Long userId) throws ObjectNotFoundException;
  
        /**
         * Search Files
        public StatsDTO getUserStatistics(Long userId) throws ObjectNotFoundException;
  
        /**
-        * Retrieves file versions
-        *
-        * @param userId the ID of the user
-        * @param fileId the ID of the file
-        * @return the list of filebodies
-        * @throws ObjectNotFoundException
-        * @throws InsufficientPermissionsException
-        *
-        */
-       public List<FileBodyDTO> getVersions(Long userId, Long fileId)
-                       throws ObjectNotFoundException, InsufficientPermissionsException;
-       /**
         * Restore the file contents to the specified version.
         *
         * @param userId the ID of the user
                        throws ObjectNotFoundException, InsufficientPermissionsException,  GSSIOException, QuotaExceededException;
  
        /**
-        * Remove file version identified by bodyId
-        *
-        * @param userId the ID of the user
-        * @param fileId the ID of the file
-        * @param bodyId the ID of the body
-        *
-        * @throws ObjectNotFoundException
-        * @throws InsufficientPermissionsException
-        *
-        */
-       public void removeVersion(Long userId, Long fileId, Long bodyId)
-                       throws ObjectNotFoundException, InsufficientPermissionsException;
-       /**
         * Removes all old file versions for specified file keeping only the current revision
         *
         * @param userId the ID of the user
         * @param mimeType the MIME type of the file
         * @param fileSize the uploaded file size
         * @param filePath the uploaded file full path
-        * @return The FileHeaderDTO created
+        * @return The FileHeader created
         * @throws DuplicateNameException if the specified name already exists in
         *             the parent folder, as either a folder or file
         * @throws ObjectNotFoundException if the user or parent folder was not
         * @throws InsufficientPermissionsException
         * @throws QuotaExceededException
         */
-       public FileHeaderDTO createFile(Long userId, Long folderId, String name, String mimeType, long fileSize, String filePath)
+       public FileHeader createFile(Long userId, Long folderId, String name, String mimeType, long fileSize, String filePath)
                        throws DuplicateNameException, ObjectNotFoundException, GSSIOException,
                        InsufficientPermissionsException, QuotaExceededException;
  
         * @param mimeType the content type of the file
         * @param fileSize the uploaded file size
         * @param filePath the uploaded file full path
-        * @return The FileHeaderDTO updated
+        * @return The FileHeader updated
         * @throws ObjectNotFoundException if the user or file was not found, with
         *                      the exception message mentioning the precise problem
         * @throws GSSIOException when an IO exception occurs
         * @throws InsufficientPermissionsException
         * @throws QuotaExceededException
         */
-       public FileHeaderDTO updateFileContents(Long userId, Long fileId, String mimeType,
+       public FileHeader updateFileContents(Long userId, Long fileId, String mimeType,
                                long fileSize, String filePath) throws ObjectNotFoundException, GSSIOException,
                                InsufficientPermissionsException, QuotaExceededException;
  
         * @throws InsufficientPermissionsException if the user does not
         *                      have enough privileges for reading this file
         */
-       public FileBodyDTO getFileVersion(Long userId, Long fileId, int version) throws ObjectNotFoundException, InsufficientPermissionsException;
+       public FileBody getFileVersion(Long userId, Long fileId, int version) throws ObjectNotFoundException, InsufficientPermissionsException;
  
        /**
         * Search the system for a user with the specified email address.
        public void postFileToSolr(CommonsHttpSolrServer solr, Long id);
        
        /**
+        * @param folder
+        * @throws ObjectNotFoundException 
+        */
+       public Folder expandFolder(Folder folder) throws ObjectNotFoundException;
+       /**
+        * @param folder
+        * @return
+        * @throws ObjectNotFoundException
+        */
+       FileHeader expandFile(FileHeader folder) throws ObjectNotFoundException;
+       /**
+        * @param folder
+        * @return
+        * @throws ObjectNotFoundException
+        */
+       Group expandGroup(Group folder) throws ObjectNotFoundException;
+       /**
+        * @param username
+        * @return
+        */
+       User getUserByUserName(String username);
+       /**
+        * @param lock
+        * @return
+        */
+       FileLock saveOrUpdateLock(FileLock lock);
+       /**
+        * @param lock
+        */
+       void removeLock(FileLock lock);
+       /**
+        * @param tokenId
+        * @return
+        */
+       FileLock getLockByToken(String tokenId);
+       /**
+        * @param id
+        * @return
+        */
+       FileLock getLockById(String id);
+       /**
+        * @param userId
+        * @param folderId
+        * @param name
+        * @return
+        * @throws DuplicateNameException
+        * @throws ObjectNotFoundException
+        * @throws GSSIOException
+        * @throws InsufficientPermissionsException
+        * @throws QuotaExceededException
+        */
+       FileHeader createEmptyFile(Long userId, Long folderId, String name) throws DuplicateNameException, ObjectNotFoundException, GSSIOException, InsufficientPermissionsException, QuotaExceededException;
+       /**
+        * @param nonce
+        * @return
+        */
+       WebDavNonce saveOrUpdateWebDavNonce(WebDavNonce nonce);
+       /**
+        * @param nonce
+        */
+       void removeWebDavNonce(WebDavNonce nonce);
+       /**
+        * @param tokenId
+        * @return
+        */
+       WebDavNonce getWebDavNonce(String tokenId);
++              
++      /**
 +       * Returns a user that matches the given full username 
 +       *
 +       * @param username the username of the User
 +       * @return UserDTO
 +       */
 +      public UserDTO getUserByUserName(String username);
 +
  }
@@@ -19,6 -19,8 +19,8 @@@
  package gr.ebs.gss.server.ejb;
  
  import static gr.ebs.gss.server.configuration.GSSConfigurationFactory.getConfiguration;
+ import gr.ebs.gss.admin.client.ui.UsersTable;
  import gr.ebs.gss.client.exceptions.DuplicateNameException;
  import gr.ebs.gss.client.exceptions.GSSIOException;
  import gr.ebs.gss.client.exceptions.InsufficientPermissionsException;
@@@ -32,17 -34,14 +34,14 @@@ import gr.ebs.gss.server.domain.FileTag
  import gr.ebs.gss.server.domain.FileUploadStatus;
  import gr.ebs.gss.server.domain.Folder;
  import gr.ebs.gss.server.domain.Group;
+ import gr.ebs.gss.server.domain.FileLock;
  import gr.ebs.gss.server.domain.Invitation;
  import gr.ebs.gss.server.domain.Nonce;
  import gr.ebs.gss.server.domain.Permission;
  import gr.ebs.gss.server.domain.User;
  import gr.ebs.gss.server.domain.UserClass;
  import gr.ebs.gss.server.domain.UserLogin;
- import gr.ebs.gss.server.domain.dto.FileBodyDTO;
- import gr.ebs.gss.server.domain.dto.FileHeaderDTO;
- import gr.ebs.gss.server.domain.dto.FolderDTO;
- import gr.ebs.gss.server.domain.dto.GroupDTO;
- import gr.ebs.gss.server.domain.dto.PermissionDTO;
+ import gr.ebs.gss.server.domain.WebDavNonce;
  import gr.ebs.gss.server.domain.dto.StatsDTO;
  import gr.ebs.gss.server.domain.dto.UserDTO;
  
@@@ -58,7 -57,6 +57,6 @@@ import java.util.ArrayList
  import java.util.Date;
  import java.util.Iterator;
  import java.util.LinkedHashSet;
- import java.util.LinkedList;
  import java.util.List;
  import java.util.Locale;
  import java.util.Random;
@@@ -160,15 -158,15 +158,15 @@@ public class ExternalAPIBean implement
        }
        
        @Override
-       public FolderDTO getRootFolder(Long userId) throws ObjectNotFoundException {
+       public Folder getRootFolder(Long userId) throws ObjectNotFoundException {
                if (userId == null)
                        throw new ObjectNotFoundException("No user specified");
                Folder folder = dao.getRootFolder(userId);
-               return folder.getDTO();
+               return folder;
        }
  
        @Override
-       public FolderDTO getFolder(final Long userId, final Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException {
+       public Folder getFolder(final Long userId, final Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException {
                if (userId == null)
                        throw new ObjectNotFoundException("No user specified");
                if (folderId == null)
                // Check permissions
                if (!folder.hasReadPermission(user))
                        throw new InsufficientPermissionsException("You don't have the permissions to read this folder");
-               return folder.getDTO();
+               return expandFolder(folder);
        }
  
        @Override
        }
  
        @Override
-       public GroupDTO getGroup(final Long groupId) throws ObjectNotFoundException {
+       public Group getGroup(final Long groupId) throws ObjectNotFoundException {
                if (groupId == null)
                        throw new ObjectNotFoundException("No group specified");
                final Group group = dao.getEntityById(Group.class, groupId);
-               return group.getDTO();
+               return group;
        }
  
        @Override
-       public GroupDTO getGroup(Long userId, String name) throws ObjectNotFoundException {
+       public Group getGroup(Long userId, String name) throws ObjectNotFoundException {
                if (userId == null)
                        throw new ObjectNotFoundException("No user specified");
                if (name == null)
                List<Group> groups = user.getGroupsSpecified();
                for (Group group: groups)
                        if (group.getName().equals(name))
-                               return group.getDTO();
+                               return group;
                throw new ObjectNotFoundException("Group " + name + " not found");
        }
  
        @Override
-       public List<GroupDTO> getGroups(final Long userId) throws ObjectNotFoundException {
+       public List<Group> getGroups(final Long userId) throws ObjectNotFoundException {
                if (userId == null)
                        throw new ObjectNotFoundException("No user specified");
                final List<Group> groups = dao.getGroups(userId);
-               final List<GroupDTO> result = new ArrayList<GroupDTO>();
-               for (final Group g : groups)
-                       result.add(g.getDTO());
-               return result;
+               return groups;
        }
  
        @Override
-       public List<FileHeaderDTO> getFiles(Long userId, Long folderId, boolean ignoreDeleted)
+       public List<FileHeader> getFiles(Long userId, Long folderId, boolean ignoreDeleted)
                        throws ObjectNotFoundException, InsufficientPermissionsException {
                // Validate.
                if (userId == null)
                Folder folder = dao.getEntityById(Folder.class, folderId);
                if (!folder.hasReadPermission(user))
                        throw new InsufficientPermissionsException("You don't have the permissions to read this folder");
-               // Do the actual work.
-               List<FileHeaderDTO> result = new ArrayList<FileHeaderDTO>();
                List<FileHeader> files = dao.getFiles(folderId, userId, ignoreDeleted);
-               for (FileHeader f : files)
-                       result.add(f.getDTO());
-               return result;
+               return files;
        }
  
        @Override
-       public List<UserDTO> getUsers(final Long userId, final Long groupId) throws ObjectNotFoundException {
+       public List<User> getUsers(final Long userId, final Long groupId) throws ObjectNotFoundException {
                // Validate.
                if (userId == null)
                        throw new ObjectNotFoundException("No user specified");
  
                // Do the actual work.
                final List<User> users = dao.getUsers(groupId);
-               final List<UserDTO> result = new ArrayList<UserDTO>();
-               for (final User u : users)
-                       result.add(u.getDTO());
-               return result;
+               return users;
        }
  
        @Override
-       public FolderDTO createFolder(Long userId, Long parentId, String name)
+       public Folder createFolder(Long userId, Long parentId, String name)
                        throws DuplicateNameException, ObjectNotFoundException, InsufficientPermissionsException {
                // Validate.
                if (userId == null)
         * @param creator
         * @return the new folder
         */
-       private FolderDTO createFolder(String name, Folder parent, User creator) {
+       private Folder createFolder(String name, Folder parent, User creator) {
                Folder folder = new Folder();
                folder.setName(name);
                if (parent != null) {
                        folder.setReadForAll(parent.isReadForAll());
  
                dao.create(folder);
-               return folder.getDTO();
+               return folder;
        }
  
        @Override
  
        @Override
        @SuppressWarnings("unchecked")
-       public List<FolderDTO> getSubfolders(Long userId, Long folderId)
+       public List<Folder> getSubfolders(Long userId, Long folderId)
                        throws ObjectNotFoundException, InsufficientPermissionsException {
                if (userId == null)
                        throw new ObjectNotFoundException("No user specified");
                Folder folder = dao.getEntityById(Folder.class, folderId);
                if (!folder.hasReadPermission(user))
                        throw new InsufficientPermissionsException("You don't have the permissions to read this folder");
-               List<FolderDTO> result = new ArrayList<FolderDTO>();
+               List<Folder> result = new ArrayList<Folder>();
                if (folder.hasReadPermission(user))
                        for (Folder f : folder.getSubfolders())
                                if (f.hasReadPermission(user) && !f.isDeleted())
-                                       result.add(f.getDTO());
+                                       result.add(f);
                return result;
        }
  
        @Override
-       public FolderDTO updateFolder(Long userId, Long folderId, String folderName,
+       public Folder updateFolder(Long userId, Long folderId, String folderName,
                                Boolean readForAll,
-                               Set<PermissionDTO> permissions)
+                               Set<Permission> permissions)
                        throws InsufficientPermissionsException, ObjectNotFoundException,
                        DuplicateNameException {
  
                folder.getAuditInfo().setModifiedBy(user);
                dao.update(folder);
                touchParentFolders(folder, user, new Date());
-               return folder.getDTO();
+               // Re-index the folder contents if it was modified.
+               if ((permissions != null && !permissions.isEmpty()) || readForAll != null) {
+             indexFolder(folder);
+         }
+               return folder;
        }
  
+     private void indexFolder(Folder folder) {
+         for (FileHeader fh : folder.getFiles())
+             indexFile(fh.getId(), false);
+         for (Folder f : folder.getSubfolders())
+             indexFolder(f);
+     }
        @Override
        public void createGroup(final Long userId, final String name) throws ObjectNotFoundException, DuplicateNameException {
                // Validate.
                        List<Folder> folders = dao.getFoldersPermittedForGroup(userId, groupId);
                        for (Folder f : folders){
                                f.getPermissions().removeAll(group.getPermissions());
-                               touchFolder(f, owner, now);
                                for(FileHeader file : f.getFiles()){
                                        file.getPermissions().removeAll(group.getPermissions());
-                                       touchFile(file, owner, now);
                                }
                        }
                        List<FileHeader> files = dao.getFilesPermittedForGroup(userId, groupId);
                        for(FileHeader h : files){
                                h.getPermissions().removeAll(group.getPermissions());
-                               touchFile(h, owner, now);
                        }
                        owner.removeSpecifiedGroup(group);
                        dao.delete(group);
        }
  
        @Override
-       public FileHeaderDTO createFile(Long userId, Long folderId, String name, String mimeType, InputStream stream)
+       public FileHeader createFile(Long userId, Long folderId, String name, String mimeType, InputStream stream)
                        throws DuplicateNameException, ObjectNotFoundException, GSSIOException,
                        InsufficientPermissionsException, QuotaExceededException {
                File file = null;
        @Override
        public void updateFile(Long userId, Long fileId, String name,
                                String tagSet, Date modificationDate, Boolean versioned,
-                               Boolean readForAll,     Set<PermissionDTO> permissions)
+                               Boolean readForAll,     Set<Permission> permissions)
                        throws DuplicateNameException, ObjectNotFoundException, InsufficientPermissionsException {
                if (userId == null)
                        throw new ObjectNotFoundException("No user specified");
        }
  
        @Override
-       public FileHeaderDTO getFile(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException {
+       public FileHeader getFile(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException {
                if (userId == null)
                        throw new ObjectNotFoundException("No user specified");
                if (fileId == null)
                final FileHeader file = dao.getEntityById(FileHeader.class, fileId);
                if (!file.hasReadPermission(user) && !file.getFolder().hasReadPermission(user))
                        throw new InsufficientPermissionsException("You don't have the necessary permissions");
-               return file.getDTO();
+               return file;
        }
  
        @Override
-       public FileBodyDTO getFileBody(Long userId, Long fileId, Long bodyId) throws ObjectNotFoundException, InsufficientPermissionsException {
+       public FileBody getFileBody(Long userId, Long fileId, Long bodyId) throws ObjectNotFoundException, InsufficientPermissionsException {
                if (userId == null)
                        throw new ObjectNotFoundException("No user specified");
                if (fileId == null)
                if (!file.hasReadPermission(user) && !file.getFolder().hasReadPermission(user))
                        throw new InsufficientPermissionsException("You don't have the necessary permissions");
                FileBody body = dao.getEntityById(FileBody.class, bodyId);
-               return body.getDTO();
+               return body;
        }
  
        @Override
                // Use the lastElement to retrieve the actual resource.
                Object resource = null;
                try {
-                       FileHeaderDTO file = getFile(cursor==null ? rootFolderId : cursor.getId(), lastElement);
+                       FileHeader file = getFile(cursor==null ? rootFolderId : cursor.getId(), lastElement);
                        if (ignoreDeleted && file.isDeleted())
                                throw new ObjectNotFoundException("Resource not found");
                        resource = file;
                } catch (ObjectNotFoundException e) {
                        // Perhaps the requested resource is not a file, so
                        // check for folders as well.
-                       FolderDTO folder = getFolder(cursor==null ? rootFolderId : cursor.getId(), lastElement).getDTO();
+                       Folder folder = getFolder(cursor==null ? rootFolderId : cursor.getId(), lastElement);
                        if (ignoreDeleted && folder.isDeleted())
                                throw new ObjectNotFoundException("Resource not found");
                        resource = folder;
         *             found, with the exception message mentioning the precise
         *             problem
         */
-       private FileHeaderDTO getFile(Long folderId, String name) throws ObjectNotFoundException {
+       private FileHeader getFile(Long folderId, String name) throws ObjectNotFoundException {
                if (folderId == null)
                        throw new ObjectNotFoundException("No parent folder specified");
                if (StringUtils.isEmpty(name))
                        throw new ObjectNotFoundException("No file specified");
  
                FileHeader file = dao.getFile(folderId, name);
-               return file.getDTO();
+               return file;
        }
  
        /**
                return folder;
        }
  
-       private FileHeaderDTO updateFileContents(Long userId, Long fileId, String mimeType, InputStream resourceInputStream) throws ObjectNotFoundException, GSSIOException, InsufficientPermissionsException, QuotaExceededException {
+       private FileHeader updateFileContents(Long userId, Long fileId, String mimeType, InputStream resourceInputStream) throws ObjectNotFoundException, GSSIOException, InsufficientPermissionsException, QuotaExceededException {
                File file = null;
                try {
                        file = uploadFile(resourceInputStream, userId);
                        throw new ObjectNotFoundException("No destination specified");
  
                Object destination = getResourceAtPath(userId, getParentPath(dest), true);
-               if (!(destination instanceof FolderDTO))
+               if (!(destination instanceof Folder))
                        throw new ObjectNotFoundException("Destination parent folder not found");
-               FolderDTO parent = (FolderDTO) destination;
+               Folder parent = (Folder) destination;
                copyFile(userId, fileId, parent.getId(), getLastElement(dest));
        }
  
                        throw new ObjectNotFoundException("No destination specified");
  
                Object destination = getResourceAtPath(ownerId, getParentPath(dest), true);
-               if (!(destination instanceof FolderDTO))
+               if (!(destination instanceof Folder))
                        throw new ObjectNotFoundException("Destination parent folder not found");
-               FolderDTO parent = (FolderDTO) destination;
+               Folder parent = (Folder) destination;
                copyFile(userId, fileId, parent.getId(), getLastElement(dest));
        }
  
                        throw new ObjectNotFoundException("No destination specified");
  
                Object destination = getResourceAtPath(userId, getParentPath(dest), true);
-               if (!(destination instanceof FolderDTO))
+               if (!(destination instanceof Folder))
                        throw new ObjectNotFoundException("Destination folder not found");
-               FolderDTO parent = (FolderDTO) destination;
+               Folder parent = (Folder) destination;
                copyFolder(userId, folderId, parent.getId(), getLastElement(dest));
        }
  
                        throw new ObjectNotFoundException("No destination specified");
  
                Object destination = getResourceAtPath(ownerId, getParentPath(dest), true);
-               if (!(destination instanceof FolderDTO))
+               if (!(destination instanceof Folder))
                        throw new ObjectNotFoundException("Destination folder not found");
-               FolderDTO parent = (FolderDTO) destination;
+               Folder parent = (Folder) destination;
                copyFolderStructure(userId, folderId, parent.getId(), getLastElement(dest));
        }
  
                if (parent == null)
                        throw new ObjectNotFoundException("The specified file has no parent folder");
                User user = dao.getEntityById(User.class, userId);
-               if (!file.hasDeletePermission(user))
-                       throw new InsufficientPermissionsException("User " + user.getId() + " cannot delete file " + file.getName() + "(" + file.getId() + ")");
-               file.setDeleted(true);
-               dao.update(file);
-               touchParentFolders(parent, user, new Date());
+         trashFile(user, file);
+         touchParentFolders(parent, user, new Date());
        }
  
+     private void trashFile(User user, FileHeader file) throws InsufficientPermissionsException {
+         if (!file.hasDeletePermission(user))
+             throw new InsufficientPermissionsException("User " + user.getId() + " cannot delete file " + file.getName() + "(" + file.getId() + ")");
+         file.setDeleted(true);
+     }
        @Override
        public void moveFileToPath(Long userId, Long ownerId, Long fileId, String dest) throws ObjectNotFoundException, InsufficientPermissionsException, QuotaExceededException {
                if (userId == null)
                        throw new ObjectNotFoundException("No destination specified");
  
                Object destination = getResourceAtPath(ownerId, getParentPath(dest), true);
-               if (!(destination instanceof FolderDTO))
+               if (!(destination instanceof Folder))
                        throw new ObjectNotFoundException("Destination parent folder not found");
-               FolderDTO parent = (FolderDTO) destination;
+               Folder parent = (Folder) destination;
                moveFile(userId, fileId, parent.getId(), getLastElement(dest));
        }
  
                        throw new ObjectNotFoundException("No destination specified");
  
                Object destination = getResourceAtPath(ownerId, getParentPath(dest), true);
-               if (!(destination instanceof FolderDTO))
+               if (!(destination instanceof Folder))
                        throw new ObjectNotFoundException("Destination parent folder not found");
-               FolderDTO parent = (FolderDTO) destination;
+               Folder parent = (Folder) destination;
                moveFolder(userId, folderId, parent.getId(), getLastElement(dest));
        }
  
        }
  
        @Override
-       public List<FileHeaderDTO> getDeletedFiles(Long userId) throws ObjectNotFoundException {
+       public List<FileHeader> getDeletedFiles(Long userId) throws ObjectNotFoundException {
                // Validate.
                if (userId == null)
                        throw new ObjectNotFoundException("No user specified");
  
                // Do the actual work.
-               final List<FileHeaderDTO> result = new ArrayList<FileHeaderDTO>();
                final List<FileHeader> files = dao.getDeletedFiles(userId);
-               for (final FileHeader f : files)
-                       result.add(f.getDTO());
-               return result;
+               return files;
        }
  
        @Override
                if (parent == null)
                        throw new ObjectNotFoundException("The specified file has no parent folder");
                User user = dao.getEntityById(User.class, userId);
-               if (!file.hasDeletePermission(user))
-                       throw new InsufficientPermissionsException("User " + user.getUsername() +
-                                               " cannot restore file " + file.getName());
-               file.setDeleted(false);
-               dao.update(file);
+         untrashFile(user, file);
                touchParentFolders(parent, user, new Date());
        }
  
+     private void untrashFile(User user, FileHeader file) throws InsufficientPermissionsException {
+         if (!file.hasDeletePermission(user))
+             throw new InsufficientPermissionsException("User " + user.getUsername() +
+                         " cannot restore file " + file.getName());
+         file.setDeleted(false);
+     }
        @Override
        public void moveFolderToTrash(Long userId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException {
-               if (userId == null)
-                       throw new ObjectNotFoundException("No user specified");
-               if (folderId == null)
-                       throw new ObjectNotFoundException("No folder specified");
-               Folder folder = dao.getEntityById(Folder.class, folderId);
-               User user = dao.getEntityById(User.class, userId);
-               if (!folder.hasDeletePermission(user))
-                       throw new InsufficientPermissionsException("You don't have the necessary permissions");
-               folder.setDeleted(true);
-               dao.update(folder);
-               touchParentFolders(folder, user, new Date());
-               for (FileHeader file : folder.getFiles())
-                       moveFileToTrash(userId, file.getId());
-               for (Folder subFolder : folder.getSubfolders())
-                       moveFolderToTrash(userId, subFolder.getId());
-       }
+         if (userId == null)
+             throw new ObjectNotFoundException("No user specified");
+         if (folderId == null)
+             throw new ObjectNotFoundException("No folder specified");
+         Folder folder = dao.getEntityById(Folder.class, folderId);
+         User user = dao.getEntityById(User.class, userId);
+         trashFolder(user, folder);
+         touchParentFolders(folder, user, new Date());
+       }
+     private void trashFolder(User user, Folder folder) throws ObjectNotFoundException, InsufficientPermissionsException {
+         if (!folder.hasDeletePermission(user))
+             throw new InsufficientPermissionsException("You don't have the necessary permissions");
+         folder.setDeleted(true);
+         for (FileHeader file : folder.getFiles())
+             trashFile(user, file);
+         for (Folder subFolder : folder.getSubfolders())
+             trashFolder(user, subFolder);
+     }
  
        @Override
        public void removeFolderFromTrash(Long userId, Long folderId)
                        throw new ObjectNotFoundException("No folder specified");
                Folder folder = dao.getEntityById(Folder.class, folderId);
                User user = dao.getEntityById(User.class, userId);
-               if (!folder.hasDeletePermission(user))
-                       throw new InsufficientPermissionsException("User " + user.getUsername() +
-                                               " cannot restore folder " + folder.getName());
-               folder.setDeleted(false);
-               for (FileHeader file : folder.getFiles())
-                       removeFileFromTrash(userId, file.getId());
-               for (Folder subFolder : folder.getSubfolders())
-                       removeFolderFromTrash(userId, subFolder.getId());
-               dao.update(folder);
+         untrashFolder(user, folder);
                touchParentFolders(folder, user, new Date());
        }
  
+     private void untrashFolder(User user, Folder folder) throws ObjectNotFoundException, InsufficientPermissionsException {
+         if (!folder.hasDeletePermission(user))
+             throw new InsufficientPermissionsException("User " + user.getUsername() +
+                         " cannot restore folder " + folder.getName());
+         folder.setDeleted(false);
+         for (FileHeader file : folder.getFiles())
+             untrashFile(user, file);
+         for (Folder subFolder : folder.getSubfolders())
+             untrashFolder(user, subFolder);
+     }
        @Override
-       public List<FolderDTO> getDeletedRootFolders(Long userId) throws ObjectNotFoundException {
+       public List<Folder> getDeletedRootFolders(Long userId) throws ObjectNotFoundException {
                List<Folder> folders = dao.getDeletedRootFolders(userId);
-               List<FolderDTO> result = new ArrayList<FolderDTO>();
-               for (Folder folder : folders)
-                       result.add(folder.getDTO());
-               return result;
+               return folders;
        }
  
        @Override
        public void emptyTrash(Long userId) throws ObjectNotFoundException, InsufficientPermissionsException {
-               List<FolderDTO> deletedRootFolders = getDeletedRootFolders(userId);
-               for (FolderDTO fdto : deletedRootFolders)
-                       deleteFolder(userId, fdto.getId());
-               List<FileHeaderDTO> deletedFiles = getDeletedFiles(userId);
-               for (FileHeaderDTO filedto : deletedFiles)
-                       deleteFile(userId, filedto.getId());
+               List<Folder> deletedRootFolders = getDeletedRootFolders(userId);
+               for (Folder folder : deletedRootFolders)
+                       deleteFolder(userId, folder.getId());
+               List<FileHeader> deletedFiles = getDeletedFiles(userId);
+               for (FileHeader file : deletedFiles)
+                       deleteFile(userId, file.getId());
        }
  
        @Override
        public void restoreTrash(Long userId) throws ObjectNotFoundException, InsufficientPermissionsException {
-               List<FolderDTO> deletedRootFolders = getDeletedRootFolders(userId);
-               for (FolderDTO fdto : deletedRootFolders)
-                       removeFolderFromTrash(userId, fdto.getId());
-               List<FileHeaderDTO> deletedFiles = getDeletedFiles(userId);
-               for (FileHeaderDTO filedto : deletedFiles)
-                       removeFileFromTrash(userId, filedto.getId());
+               List<Folder> deletedRootFolders = getDeletedRootFolders(userId);
+               for (Folder folder : deletedRootFolders)
+                       removeFolderFromTrash(userId, folder.getId());
+               List<FileHeader> deletedFiles = getDeletedFiles(userId);
+               for (FileHeader file : deletedFiles)
+                       removeFileFromTrash(userId, file.getId());
        }
  
        @Override
        }
  
        @Override
-       public Set<PermissionDTO> getFolderPermissions(Long userId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException {
+       public Set<Permission> getFolderPermissions(Long userId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException {
                if (userId == null)
                        throw new ObjectNotFoundException("No user specified");
                if (folderId == null)
                if(!folder.hasReadPermission(user))
                        throw new InsufficientPermissionsException("You don't have the necessary permissions");
                Set<Permission> perms = folder.getPermissions();
-               Set<PermissionDTO> result = new LinkedHashSet<PermissionDTO>();
+               Set<Permission> result = new LinkedHashSet<Permission>();
                for (Permission perm : perms)
                        if (perm.getUser() != null && perm.getUser().getId().equals(folder.getOwner().getId()))
-                               result.add(perm.getDTO());
+                               result.add(perm);
                for (Permission perm : perms)
                        if (perm.getUser() != null && perm.getUser().getId().equals(folder.getOwner().getId())) {
                        } else
-                               result.add(perm.getDTO());
+                               result.add(perm);
                return result;
  
        }
         * @throws ObjectNotFoundException
         * @throws InsufficientPermissionsException
         */
-       private void setFolderPermissions(User user, Folder folder, Set<PermissionDTO> permissions) throws ObjectNotFoundException, InsufficientPermissionsException {
+       private void setFolderPermissions(User user, Folder folder, Set<Permission> permissions) throws ObjectNotFoundException, InsufficientPermissionsException {
                if (permissions != null && !permissions.isEmpty()) {
                        User owner = folder.getOwner();
-                       PermissionDTO ownerPerm = null;
-                       for (PermissionDTO dto : permissions)
-                               if (dto.getUser() != null && dto.getUser().getId().equals(owner.getId())) {
-                                       ownerPerm = dto;
+                       Permission ownerPerm = null;
+                       for (Permission perm : permissions)
+                               if (perm.getUser() != null && perm.getUser().getId().equals(owner.getId())) {
+                                       ownerPerm = perm;
                                        break;
                                }
                        if (ownerPerm == null || !ownerPerm.hasRead() || !ownerPerm.hasWrite() || !ownerPerm.hasModifyACL())
                        for (Permission perm: folder.getPermissions())
                                dao.delete(perm);
                        folder.getPermissions().clear();
-                       for (PermissionDTO dto : permissions) {
+                       for (Permission p : permissions) {
                                // Skip 'empty' permission entries.
-                               if (!dto.getRead() && !dto.getWrite() && !dto.getModifyACL()) continue;
-                               folder.addPermission(getPermission(dto));
+                               if (!p.getRead() && !p.getWrite() && !p.getModifyACL()) continue;
+                               folder.addPermission(getPermission(p));
                        }
                        dao.update(folder);
                        for (FileHeader file : folder.getFiles()) {
                }
        }
  
-       private Permission getPermission(PermissionDTO dto) throws ObjectNotFoundException {
+       private Permission getPermission(Permission perm) throws ObjectNotFoundException {
                Permission res = new Permission();
-               if (dto.getGroup() != null)
-                       res.setGroup(dao.getEntityById(Group.class, dto.getGroup().getId()));
-               else if (dto.getUser() != null)
-                       if (dto.getUser().getId() == null)
-                               res.setUser(dao.getUser(dto.getUser().getUsername()));
+               if (perm.getGroup() != null)
+                       res.setGroup(dao.getEntityById(Group.class, perm.getGroup().getId()));
+               else if (perm.getUser() != null)
+                       if (perm.getUser().getId() == null)
+                               res.setUser(dao.getUser(perm.getUser().getUsername()));
                        else
-                               res.setUser(dao.getEntityById(User.class, dto.getUser().getId()));
-               res.setRead(dto.hasRead());
-               res.setWrite(dto.hasWrite());
-               res.setModifyACL(dto.hasModifyACL());
+                               res.setUser(dao.getEntityById(User.class, perm.getUser().getId()));
+               res.setRead(perm.hasRead());
+               res.setWrite(perm.hasWrite());
+               res.setModifyACL(perm.hasModifyACL());
                return res;
        }
  
         * @see gr.ebs.gss.server.ejb.ExternalAPI#getUsersByUserNameLike(java.lang.String)
         */
        @Override
-       public List<UserDTO> getUsersByUserNameLike(String username) {
+       public List<User> getUsersByUserNameLike(String username) {
                List<User> users = dao.getUsersByUserNameLike(username);
-               List<UserDTO> result = new ArrayList<UserDTO>();
-               for (User u : users)
-                       result.add(u.getDTO());
-               return result;
+               return users;
  
        }
  
        }
  
        @Override
-       public List<FolderDTO> getSharedRootFolders(Long userId) throws ObjectNotFoundException {
+       public List<Folder> getSharedRootFolders(Long userId) throws ObjectNotFoundException {
                if (userId == null)
                        throw new ObjectNotFoundException("No user specified");
                List<Folder> folders = dao.getSharedRootFolders(userId);
-               List<FolderDTO> result = new ArrayList<FolderDTO>();
+               List<Folder> result = new ArrayList<Folder>();
                for (Folder f : folders) {
-                       FolderDTO dto = f.getDTO();
-                       dto.setSubfolders(getSharedSubfolders(userId, f.getId()));
-                       result.add(dto);
+                       Folder lf = f;
+                       lf.setSubfolders(getSharedSubfolders(userId, f.getId()));
+                       result.add(lf);
                }
                return result;
        }
        }
  
        @Override
-       public List<UserDTO> getUsersSharingFoldersForUser(Long userId) throws ObjectNotFoundException {
+       public List<User> getUsersSharingFoldersForUser(Long userId) throws ObjectNotFoundException {
                List<User> users = dao.getUsersSharingFoldersForUser(userId);
                List<User> usersFiles = dao.getUsersSharingFilesForUser(userId);
-               List<UserDTO> res = new ArrayList<UserDTO>();
+               List<User> result = new ArrayList<User>();
                for (User u : users)
-                       res.add(u.getDTO());
+                       result.add(u);
                for(User fu : usersFiles)
                        if(!users.contains(fu))
-                               res.add(fu.getDTO());
-               return res;
+                               result.add(fu);
+               return result;
        }
  
        @Override
-       public Set<PermissionDTO> getFilePermissions(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException {
+       public Set<Permission> getFilePermissions(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException {
                if (userId == null)
                        throw new ObjectNotFoundException("No user specified");
                if (fileId == null)
                if(!folder.hasReadPermission(user))
                        throw new InsufficientPermissionsException("You don't have the necessary permissions");
                Set<Permission> perms = folder.getPermissions();
-               Set<PermissionDTO> result = new LinkedHashSet<PermissionDTO>();
+               Set<Permission> result = new LinkedHashSet<Permission>();
                for (Permission perm : perms)
                        if (perm.getUser() != null && perm.getUser().getId().equals(folder.getOwner().getId()))
-                               result.add(perm.getDTO());
+                               result.add(perm);
                for (Permission perm : perms)
                        if (perm.getUser() != null && perm.getUser().getId().equals(folder.getOwner().getId())) {
                        } else
-                               result.add(perm.getDTO());
+                               result.add(perm);
                return result;
        }
  
         * @throws InsufficientPermissionsException
         */
        private void setFilePermissions(FileHeader file,
-                               Set<PermissionDTO> permissions)
+                               Set<Permission> permissions)
                        throws ObjectNotFoundException, InsufficientPermissionsException {
                if (permissions != null && !permissions.isEmpty()) {
-                       PermissionDTO ownerPerm = null;
-                       for (PermissionDTO dto : permissions)
-                               if (dto.getUser() != null && dto.getUser().getId().equals(file.getOwner().getId())) {
-                                       ownerPerm = dto;
+                       Permission ownerPerm = null;
+                       for (Permission perm : permissions)
+                               if (perm.getUser() != null && perm.getUser().getId().equals(file.getOwner().getId())) {
+                                       ownerPerm = perm;
                                        break;
                                }
                        if (ownerPerm == null || !ownerPerm.hasRead() || !ownerPerm.hasWrite() || !ownerPerm.hasModifyACL())
                        for (Permission perm: file.getPermissions())
                                dao.delete(perm);
                        file.getPermissions().clear();
-                       for (PermissionDTO dto : permissions) {
+                       for (Permission perm : permissions) {
                                // Skip 'empty' permission entries.
-                               if (!dto.getRead() && !dto.getWrite() && !dto.getModifyACL()) continue;
-                               file.addPermission(getPermission(dto));
+                               if (!perm.getRead() && !perm.getWrite() && !perm.getModifyACL()) continue;
+                               file.addPermission(getPermission(perm));
                        }
                        dao.flush();
                }
        }
  
        @Override
-       public List<FileHeaderDTO> getSharedFilesNotInSharedFolders(Long userId) throws ObjectNotFoundException {
+       public List<FileHeader> getSharedFilesNotInSharedFolders(Long userId) throws ObjectNotFoundException {
                if (userId == null)
                        throw new ObjectNotFoundException("No user specified");
                List<FileHeader> files = dao.getSharedFilesNotInSharedFolders(userId);
-               List<FileHeaderDTO> result = new ArrayList<FileHeaderDTO>();
-               for (FileHeader f : files)
-                       result.add(f.getDTO());
-               return result;
+               return files;
        }
  
        @Override
-       public List<FileHeaderDTO> getSharedFiles(Long userId) throws ObjectNotFoundException {
+       public List<FileHeader> getSharedFiles(Long userId) throws ObjectNotFoundException {
                if (userId == null)
                        throw new ObjectNotFoundException("No user specified");
                List<FileHeader> files = dao.getSharedFiles(userId);
-               List<FileHeaderDTO> result = new ArrayList<FileHeaderDTO>();
-               for (FileHeader f : files)
-                       result.add(f.getDTO());
-               return result;
+               return files;
        }
  
        @Override
-       public List<FolderDTO> getSharedFolders(Long userId) throws ObjectNotFoundException {
+       public List<Folder> getSharedFolders(Long userId) throws ObjectNotFoundException {
                if (userId == null)
                        throw new ObjectNotFoundException("No user specified");
                List<Folder> folders = dao.getSharedFolders(userId);
-               List<FolderDTO> result = new ArrayList<FolderDTO>();
-               for (Folder f : folders)
-                       result.add(f.getDTO());
-               return result;
+               return folders;
        }
  
        @Override
-       public List<FileHeaderDTO> getSharedFiles(Long ownerId, Long callingUserId) throws ObjectNotFoundException {
+       public List<FileHeader> getSharedFiles(Long ownerId, Long callingUserId) throws ObjectNotFoundException {
                if (ownerId == null)
                        throw new ObjectNotFoundException("No owner specified");
                if (callingUserId == null)
                        throw new ObjectNotFoundException("No calling user specified");
                List<FileHeader> folders = dao.getSharedFiles(ownerId, callingUserId);
-               List<FileHeaderDTO> result = new ArrayList<FileHeaderDTO>();
-               for (FileHeader f : folders)
-                       result.add(f.getDTO());
-               return result;
+               return folders;
        }
  
        @Override
-       public List<FolderDTO> getSharedRootFolders(Long ownerId, Long callingUserId) throws ObjectNotFoundException {
+       public List<Folder> getSharedRootFolders(Long ownerId, Long callingUserId) throws ObjectNotFoundException {
                if (ownerId == null)
                        throw new ObjectNotFoundException("No owner specified");
                if (callingUserId == null)
                        throw new ObjectNotFoundException("No calling user specified");
                List<Folder> folders = dao.getSharedRootFolders(ownerId, callingUserId);
-               List<FolderDTO> result = new ArrayList<FolderDTO>();
+               List<Folder> result = new ArrayList<Folder>();
                for (Folder f : folders) {
-                       FolderDTO dto = f.getDTO();
-                       dto.setSubfolders(getSharedSubfolders(ownerId, callingUserId, f.getId()));
-                       result.add(dto);
+                       Folder lf = f;
+                       lf.setSubfolders(getSharedSubfolders(ownerId, callingUserId, f.getId()));
+                       result.add(lf);
                }
                return result;
  
        }
  
        @Override
-       public List<FolderDTO> getSharedSubfolders(Long userId, Long folderId) throws ObjectNotFoundException {
+       public List<Folder> getSharedSubfolders(Long userId, Long folderId) throws ObjectNotFoundException {
                if (userId == null)
                        throw new ObjectNotFoundException("No user specified");
                if (folderId == null)
                        throw new ObjectNotFoundException("No folder specified");
                User user = dao.getEntityById(User.class, userId);
                Folder folder = dao.getEntityById(Folder.class, folderId);
-               List<FolderDTO> result = new ArrayList<FolderDTO>();
+               List<Folder> result = new ArrayList<Folder>();
                if (folder.isShared(user) || folder.isReadForAll())
                        for (Folder f : folder.getSubfolders())
                                if ((f.isShared(user) || f.isReadForAll()) && !f.isDeleted())
-                                       result.add(f.getDTO());
+                                       result.add(f);
                return result;
        }
  
        @Override
-       public List<FolderDTO> getSharedSubfolders(Long userId, Long callingUserId, Long folderId) throws ObjectNotFoundException {
+       public List<Folder> getSharedSubfolders(Long userId, Long callingUserId, Long folderId) throws ObjectNotFoundException {
                if (userId == null)
                        throw new ObjectNotFoundException("No user specified");
                if (callingUserId == null)
                        throw new ObjectNotFoundException("No folder specified");
                User user = dao.getEntityById(User.class, callingUserId);
                Folder folder = dao.getEntityById(Folder.class, folderId);
-               List<FolderDTO> result = new ArrayList<FolderDTO>();
+               List<Folder> result = new ArrayList<Folder>();
                if (folder.isSharedForOtherUser(user))
                        for (Folder f : folder.getSubfolders())
                                if (f.isSharedForOtherUser(user) && !f.isDeleted()){
-                                       FolderDTO dto = f.getDTO();
-                                       dto.setSubfolders(getSharedSubfolders(userId, callingUserId, dto.getId()));
-                                       result.add(dto);
+                                       Folder lf = f;
+                                       lf.setSubfolders(getSharedSubfolders(userId, callingUserId, lf.getId()));
+                                       result.add(lf);
                                }
                return result;
  
        }
  
        @Override
-       public void deleteFiles(Long userId, List<Long> fileIds) throws ObjectNotFoundException, InsufficientPermissionsException {
-               if (userId == null)
-                       throw new ObjectNotFoundException("No user specified");
-               final User user = dao.getEntityById(User.class, userId);
-               List<String> filesToRemove = new ArrayList<String>();
-               //first delete database objects
-               for(Long fileId : fileIds){
-                       if (fileId == null)
-                               throw new ObjectNotFoundException("No file specified");
-                       final FileHeader file = dao.getEntityById(FileHeader.class, fileId);
-                       final Folder parent = file.getFolder();
-                       if (parent == null)
-                               throw new ObjectNotFoundException("The specified file has no parent folder");
-                       if (!file.hasDeletePermission(user))
-                               throw new InsufficientPermissionsException("User " + user.getId() + " cannot delete file " + file.getName() + "(" + file.getId() + ")");
-                       parent.removeFile(file);
-                       for (final FileBody body : file.getBodies())
-                               filesToRemove.add(body.getStoredFilePath());
-                       dao.delete(file);
-                       touchParentFolders(parent, user, new Date());
-               }
-               //then remove physical files if everything is ok
-               for(String physicalFileName : filesToRemove)
-                       deleteActualFile(physicalFileName);
-               //then unindex deleted files
-               for(Long fileId : fileIds)
-                       indexFile(fileId, true);
-       }
-       @Override
-       public void moveFilesToTrash(Long userId, List<Long> fileIds) throws ObjectNotFoundException, InsufficientPermissionsException {
-               for(Long l : fileIds)
-                       moveFileToTrash(userId, l);
-       }
-       @Override
-       public void removeFilesFromTrash(Long userId, List<Long> fileIds) throws ObjectNotFoundException, InsufficientPermissionsException {
-               for(Long l : fileIds)
-                       removeFileFromTrash(userId, l);
-       }
-       @Override
        public Nonce createNonce(Long userId) throws ObjectNotFoundException {
                if (userId == null)
                        throw new ObjectNotFoundException("No user specified");
        }
  
        @Override
-       public List<FileBodyDTO> getVersions(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException {
-               if (userId == null)
-                       throw new ObjectNotFoundException("No user specified");
-               if (fileId == null)
-                       throw new ObjectNotFoundException("No file specified");
-               User user = dao.getEntityById(User.class, userId);
-               FileHeader header = dao.getEntityById(FileHeader.class, fileId);
-               if(!header.hasReadPermission(user))
-                       throw new InsufficientPermissionsException("You don't have the necessary permissions");
-               List<FileBodyDTO> result = new LinkedList<FileBodyDTO>();
-               for(int i = header.getBodies().size()-1 ; i>=0; i--)
-                       result.add(header.getBodies().get(i).getDTO());
-               return result;
-       }
-       @Override
-       public void removeVersion(Long userId, Long fileId, Long bodyId) throws ObjectNotFoundException, InsufficientPermissionsException {
-               if (userId == null)
-                       throw new ObjectNotFoundException("No user specified");
-               if (fileId == null)
-                       throw new ObjectNotFoundException("No file specified");
-               if (bodyId == null)
-                       throw new ObjectNotFoundException("No body specified");
-               User user = dao.getEntityById(User.class, userId);
-               FileHeader header = dao.getEntityById(FileHeader.class, fileId);
-               if(!header.hasWritePermission(user))
-                       throw new InsufficientPermissionsException("You don't have the necessary permissions");
-               FileBody body = dao.getEntityById(FileBody.class, bodyId);
-               if(body.equals(header.getCurrentBody())){
-                       if(header.getBodies().size() == 1)
-                               throw new InsufficientPermissionsException("You cant delete this version, Delete file instead!");
-                       for(FileBody b : header.getBodies())
-                               if(b.getVersion() == body.getVersion()-1)
-                                       header.setCurrentBody(b);
-               }
-               deleteActualFile(body.getStoredFilePath());
-               header.getBodies().remove(body);
-               Folder parent = header.getFolder();
-               touchParentFolders(parent, user, new Date());
-       }
-       @Override
        public void restoreVersion(Long userId, Long fileId, int version) throws ObjectNotFoundException, InsufficientPermissionsException,  GSSIOException, QuotaExceededException {
                if (userId == null)
                        throw new ObjectNotFoundException("No user specified");
        }
  
        @Override
-       public FileHeaderDTO createFile(Long userId, Long folderId, String name, String mimeType, long fileSize, String filePath)
+       public FileHeader createFile(Long userId, Long folderId, String name, String mimeType, long fileSize, String filePath)
                        throws DuplicateNameException, ObjectNotFoundException, GSSIOException,
                        InsufficientPermissionsException, QuotaExceededException {
                // Validate.
                dao.flush();
                indexFile(file.getId(), false);
  
-               return file.getDTO();
+               return file;
        }
  
        @Override
-       public FileHeaderDTO updateFileContents(Long userId, Long fileId, String mimeType, long fileSize, String filePath) throws ObjectNotFoundException, GSSIOException, InsufficientPermissionsException, QuotaExceededException {
+       public FileHeader updateFileContents(Long userId, Long fileId, String mimeType, long fileSize, String filePath) throws ObjectNotFoundException, GSSIOException, InsufficientPermissionsException, QuotaExceededException {
                if (userId == null)
                        throw new ObjectNotFoundException("No user specified");
                if (fileId == null)
                touchParentFolders(parent, owner, new Date());
  
                indexFile(fileId, false);
-               return file.getDTO();
+               return file;
        }
  
        /**
        }
  
        @Override
-       public FolderDTO getFolderWithSubfolders(Long userId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException {
-               if (userId == null)
-                       throw new ObjectNotFoundException("No user specified");
-               if (folderId == null)
-                       throw new ObjectNotFoundException("No folder specified");
-               final User user = dao.getEntityById(User.class, userId);
-               final Folder folder = dao.getEntityById(Folder.class, folderId);
-               // Check permissions
-               if (!folder.hasReadPermission(user))
-                       throw new InsufficientPermissionsException("You don't have the permissions to read this folder");
-               List<FolderDTO> subfolders = new ArrayList<FolderDTO>();
-               if (folder.hasReadPermission(user))
-                       for (Folder f : folder.getSubfolders())
-                               if (f.hasReadPermission(user) && !f.isDeleted())
-                                       subfolders.add(f.getDTO());
-               FolderDTO result = folder.getDTO();
-               result.setSubfolders(subfolders);
-               return folder.getDTO();
-       }
-       @Override
-       public FolderDTO getFolderWithSubfolders(Long userId, Long callingUserId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException {
-               if (userId == null)
-                       throw new ObjectNotFoundException("No user specified");
-               if (folderId == null)
-                       throw new ObjectNotFoundException("No folder specified");
-               User user = dao.getEntityById(User.class, callingUserId);
-               Folder folder = dao.getEntityById(Folder.class, folderId);
-               // Check permissions
-               if (!folder.hasReadPermission(user))
-                       throw new InsufficientPermissionsException("You don't have the permissions to read this folder");
-               FolderDTO result = folder.getDTO();
-               result.setSubfolders(getSharedSubfolders(userId, callingUserId, folder.getId()));
-               return result;
-       }
-       @Override
-       public FileBodyDTO getFileVersion(Long userId, Long fileId, int version)
+       public FileBody getFileVersion(Long userId, Long fileId, int version)
                        throws ObjectNotFoundException, InsufficientPermissionsException {
                if (userId == null)
                        throw new ObjectNotFoundException("No user specified");
                if (!file.hasReadPermission(user) && !file.getFolder().hasReadPermission(user))
                        throw new InsufficientPermissionsException("You don't have the necessary permissions");
                FileBody body = dao.getFileVersion(fileId, version);
-               return body.getDTO();
+               return body;
        }
  
        @Override
        }
  
        /**
-        * Mark the folder as modified from the specified user and change it's modification date.
-        */
-       private void touchFolder(Folder f, User _user, Date now){
-               final AuditInfo auditInfo = f.getAuditInfo();
-               auditInfo.setModificationDate(now);
-               auditInfo.setModifiedBy(_user);
-               f.setAuditInfo(auditInfo);
-       }
-       /**
-        * Mark the file as modified from the specified user and change it's modification date.
-        */
-       private void touchFile(FileHeader f, User _user, Date now){
-               final AuditInfo auditInfo = f.getAuditInfo();
-               auditInfo.setModificationDate(now);
-               auditInfo.setModifiedBy(_user);
-               f.setAuditInfo(auditInfo);
-       }
-       /**
         * Set the provided readForAll as the new readforAll value of the specified
         * folder and sub-folders.
         *
                  for (Permission p : file.getPermissions()) {
                      if (p.getRead()) {
                          if (p.getUser() != null)
-                             solrRequest.setParam("literal.ureaders", p.getUser().getId().toString());
+                             solrRequest.getParams().add("literal.ureaders", p.getUser().getId().toString());
                          else if (p.getGroup() != null)
-                             solrRequest.setParam("literal.greaders", p.getGroup().getId().toString());
+                             solrRequest.getParams().add("literal.greaders", p.getGroup().getId().toString());
                      }
                  }
                  solrRequest.setParam("literal.owner", file.getOwner().getId().toString());
                return text.replaceAll(":", "\\\\:");
        }
        
+       /*** NEW METHODS IN ORDER TO AVOID LAZY loading exception in json render 
+        ****/
+       @Override
+       public Folder expandFolder(Folder folder) throws ObjectNotFoundException{
+               Folder result = dao.getEntityById(Folder.class, folder.getId());
+               result.getSubfolders().size();
+               result.getFiles().size();
+               result.getPermissions().size();
+               return result;
+ }
+       @Override
+       public FileHeader expandFile(FileHeader folder) throws ObjectNotFoundException{
+               FileHeader result = dao.getEntityById(FileHeader.class, folder.getId());
+               result.getFolder();
+               result.getPermissions().size();
+               result.getFileTags().size();
+               return result;
+       }
+       
+       @Override
+       public Group expandGroup(Group folder) throws ObjectNotFoundException{
+               Group result = dao.getEntityById(Group.class, folder.getId());
+               result.getMembers().size();
+               return result;
+       }
+       /* (non-Javadoc)
+        * @see gr.ebs.gss.server.ejb.ExternalAPI#getUsersByUserNameLike(java.lang.String)
+        */
+       @Override
+       public User getUserByUserName(String username) {
+               User result = dao.getUserByUserName(username);
+               return result;
+       }
+       
+       /*WEBDAV CREATE EMPTY FILE*/
+       @Override
+       public FileHeader createEmptyFile(Long userId, Long folderId, String name)
+                       throws DuplicateNameException, ObjectNotFoundException, GSSIOException,
+                       InsufficientPermissionsException, QuotaExceededException {
+               // Validate.
+               if (userId == null)
+                       throw new ObjectNotFoundException("No user specified");
+               if (folderId == null)
+                       throw new ObjectNotFoundException("No folder specified");
+               String contentType = DEFAULT_MIME_TYPE;
+               if (StringUtils.isEmpty(name))
+                       throw new ObjectNotFoundException("No file name specified");
+               if (dao.existsFolderOrFile(folderId, name))
+                       throw new DuplicateNameException("A folder or file with the name '" + name +
+                                               "' already exists at this level");
+               // Do the actual work.
+               Folder parent = null;
+               try {
+                       parent = dao.getEntityById(Folder.class, folderId);
+               } catch (final ObjectNotFoundException onfe) {
+                       // Supply a more accurate problem description.
+                       throw new ObjectNotFoundException("Parent folder not found");
+               }
+               final User owner = dao.getEntityById(User.class, userId);
+               if (!parent.hasWritePermission(owner))
+                       throw new InsufficientPermissionsException("You don't have the permissions to write to this folder");
+               final FileHeader file = new FileHeader();
+               file.setName(name);
+               parent.addFile(file);
+               // set file owner to folder owner
+               file.setOwner(parent.getOwner());
+               //set file's readForAll value according to parent folder readForAll value
+               file.setReadForAll(parent.isReadForAll());
+               final Date now = new Date();
+               final AuditInfo auditInfo = new AuditInfo();
+               auditInfo.setCreatedBy(owner);
+               auditInfo.setCreationDate(now);
+               auditInfo.setModifiedBy(owner);
+               auditInfo.setModificationDate(now);
+               file.setAuditInfo(auditInfo);
+               // TODO set the proper versioning flag on creation
+               file.setVersioned(false);
+               for (final Permission p : parent.getPermissions()) {
+                       final Permission permission = new Permission();
+                       permission.setGroup(p.getGroup());
+                       permission.setUser(p.getUser());
+                       permission.setRead(p.getRead());
+                       permission.setWrite(p.getWrite());
+                       permission.setModifyACL(p.getModifyACL());
+                       file.addPermission(permission);
+               }
+               // Create the file body.
+               try {
+                       createEmptyFileBody(name, contentType, 0,  file, auditInfo);
+               } catch (FileNotFoundException e) {
+                       throw new GSSIOException(e);
+               }
+               touchParentFolders(parent, owner, new Date());
+               dao.flush();
+               return file;
+       }
+       
+       private void createEmptyFileBody(String name, String mimeType, long fileSize, 
+                               FileHeader header, AuditInfo auditInfo)
+                       throws FileNotFoundException, QuotaExceededException, ObjectNotFoundException {
+               long currentTotalSize = 0;
+               if (!header.isVersioned() && header.getCurrentBody() != null && header.getBodies() != null)
+                       currentTotalSize = header.getTotalSize();
+               Long quotaLeft = getQuotaLeft(header.getOwner().getId());
+               
+               FileBody body = new FileBody();
+               // if no mime type or the generic mime type is defined by the client, then try to identify it from the filename extension
+               if (StringUtils.isEmpty(mimeType) || "application/octet-stream".equals(mimeType)
+                                       || "application/download".equals(mimeType) || "application/force-download".equals(mimeType)
+                                       || "octet/stream".equals(mimeType) || "application/unknown".equals(mimeType))
+                       body.setMimeType(identifyMimeType(name));
+               else
+                       body.setMimeType(mimeType);
+               body.setAuditInfo(auditInfo);
+               body.setFileSize(fileSize);
+               body.setOriginalFilename(name);
+               body.setStoredFilePath(generateRepositoryFilePath());
+               //CLEAR OLD VERSION IF FILE IS NOT VERSIONED AND GETS UPDATED
+               if(!header.isVersioned() && header.getCurrentBody() != null){
+                       header.setCurrentBody(null);
+                       if (header.getBodies() != null) {
+                               Iterator<FileBody> it = header.getBodies().iterator();
+                               while(it.hasNext()){
+                                       FileBody bo = it.next();
+                                       deleteActualFile(bo.getStoredFilePath());
+                                       it.remove();
+                                       dao.delete(bo);
+                               }
+                       }
+               }
+               dao.flush();
+               header.addBody(body);
+               header.setAuditInfo(auditInfo);
+               dao.create(body);
+       }
+       /*** WEBDAV LOCK **/
+       @Override
+       public FileLock getLockById(String id) {
+               return dao.getLockById(id);
+       }
+       @Override
+       public FileLock getLockByToken(String tokenId) {
+               return dao.getLockByToken(tokenId);
+       }
+       @Override
+       public void removeLock(FileLock lock) {
+               dao.removeLock(lock);           
+       }
+       @Override
+       public FileLock saveOrUpdateLock(FileLock lock) {
+               return dao.saveOrUpdateLock(lock);
+       }
+       
+       @Override
+       public WebDavNonce getWebDavNonce(String tokenId) {
+               return dao.getWebDavNonce(tokenId);
+       }
+       @Override
+       public void removeWebDavNonce(WebDavNonce nonce) {
+               dao.removeWebDavNonce(nonce);           
+       }
+       @Override
+       public WebDavNonce saveOrUpdateWebDavNonce(WebDavNonce nonce) {
+               return dao.saveOrUpdateWebDavNonce(nonce);
+       }
++      
 +      /* (non-Javadoc)
 +       * @see gr.ebs.gss.server.ejb.ExternalAPI#getUsersByUserNameLike(java.lang.String)
 +       */
 +      @Override
 +      public UserDTO getUserByUserName(String username) {
 +              User result = dao.getUserByUserName(username);
 +              return result.getDTO();
 +      }
 +      
  }
@@@ -26,11 -26,13 +26,13 @@@ import gr.ebs.gss.server.domain.FileHea
  import gr.ebs.gss.server.domain.FileUploadStatus;
  import gr.ebs.gss.server.domain.Folder;
  import gr.ebs.gss.server.domain.Group;
+ import gr.ebs.gss.server.domain.FileLock;
  import gr.ebs.gss.server.domain.Invitation;
  import gr.ebs.gss.server.domain.Nonce;
  import gr.ebs.gss.server.domain.User;
  import gr.ebs.gss.server.domain.UserClass;
  import gr.ebs.gss.server.domain.UserLogin;
+ import gr.ebs.gss.server.domain.WebDavNonce;
  
  import java.math.BigInteger;
  import java.util.ArrayList;
@@@ -797,11 -799,62 +799,69 @@@ public class GSSDAOBean implements GSSD
                                                                .getResultList();
                return res;                                                                     
        }
+       
+       @Override
+       public User getUserByUserName(String username) {
+               return (User) manager.createQuery("select u from User u where u.username=:username").
+               setParameter("username", username).getSingleResult();
+               
+       }
+       
+       
+       /** WEBDAV LOCK API **/
+       @Override
+       public FileLock getLockById(String id) {
+               return manager.find(FileLock.class, id);
+       }
+       @Override
+       public FileLock getLockByToken(String tokenId) {
+               return (FileLock) manager.createQuery("select c from FileLock c where c.tokenId=:tokenId").setParameter("tokenId", tokenId).getSingleResult();
+       }
+       @Override
+       public void removeLock(FileLock lock) {
+               lock =getLockById(lock.getId());
+               if(lock!=null)
+                       manager.remove(lock);           
+       }
+       @Override
+       public FileLock saveOrUpdateLock(FileLock lock) {
+               if(getLockById(lock.getId())!=null)
+                       manager.merge(lock);
+               else
+                       manager.persist(lock);
+               manager.flush();
+               return lock;
+       }
+       
+       @Override
+       public WebDavNonce getWebDavNonce(String tokenId) {
+               return manager.find(WebDavNonce.class, tokenId);
+       }
+       @Override
+       public void removeWebDavNonce(WebDavNonce nonce) {
+               nonce =getWebDavNonce(nonce.getId());
+               if(nonce!=null)
+                       manager.remove(nonce);          
+       }
+       @Override
+       public WebDavNonce saveOrUpdateWebDavNonce(WebDavNonce nonce) {
+               if(getWebDavNonce(nonce.getId())!=null)
+                       manager.merge(nonce);
+               else
+                       manager.persist(nonce);
+               manager.flush();
+               return nonce;
+       }
 +
 +      @Override
 +      public User getUserByUserName(String username) {
 +              return (User) manager.createQuery("select u from User u where u.username=:username").
 +              setParameter("username", username).getSingleResult();
 +              
 +      }
  }