package gr.ebs.gss.server.webdav.milton;
import static gr.ebs.gss.server.configuration.GSSConfigurationFactory.getConfiguration;
-import gr.ebs.gss.client.exceptions.ObjectNotFoundException;
-import gr.ebs.gss.client.exceptions.RpcException;
+import gr.ebs.gss.common.exceptions.ObjectNotFoundException;
+import gr.ebs.gss.common.exceptions.RpcException;
+import gr.ebs.gss.server.domain.FileHeader;
+import gr.ebs.gss.server.domain.Folder;
import gr.ebs.gss.server.domain.User;
-import gr.ebs.gss.server.domain.dto.FileHeaderDTO;
-import gr.ebs.gss.server.domain.dto.FolderDTO;
-import gr.ebs.gss.server.domain.dto.UserDTO;
import gr.ebs.gss.server.ejb.ExternalAPI;
import gr.ebs.gss.server.ejb.TransactionHelper;
import com.bradmcevoy.http.Resource;
import com.bradmcevoy.http.ResourceFactory;
import com.bradmcevoy.http.SecurityManager;
-import com.bradmcevoy.http.Request.Method;
import com.ettrema.http.fs.LockManager;
url = stripContext(url);
if(url==null||url.trim().equals("")||url.equals("/")){
url="/";
- return new GssRootFolderResource(host, this, null,"/");
}
/*//log.info("URL:"+url);
if(url.equals("/OthersShared")||url.equals("/OthersShared/")){
}*/
try {
- UserDTO user =null;
+ User user =null;
if(HttpManager.request().getAuthorization()!=null && HttpManager.request().getAuthorization().getTag()==null){
String username = HttpManager.request().getAuthorization().getUser();
- //log.info("username is:"+username);
if(username !=null)
user = getService().getUserByUserName(username);
}
else if(HttpManager.request().getAuthorization()!=null&&HttpManager.request().getAuthorization().getTag()!=null){
- //log.info(HttpManager.request().getAuthorization().getUser());
- user =(UserDTO) HttpManager.request().getAuthorization().getTag();//getService().getUserByUserName("past@ebs.gr");
+ user =(User) HttpManager.request().getAuthorization().getTag();
}
if(user==null){
- //if(HttpManager.request().getMethod().equals(Method.PROPFIND)){
- ////log.info("[PROP FIND RETURNING ROOT FOR:]"+url);
- return new GssRootFolderResource(host, this, null,url);
- //}
- ////log.info("[RETURNING NULL FOR:]"+url+" "+HttpManager.request().getMethod());
- //return null;
+ //create a resource based on path if no resource exists at this path it will be handled by subsequent webdav method calls
+ return new GssRootFolderResource(host, this, null,url);
}
Object r = getResourceGss(url,user);
return null;
}
- if(r instanceof FolderDTO)
+ if(r instanceof Folder){
+
return new GssFolderResource(host, this,r ,user);
+ }
else
return new GssFileResource(host, this,r,user);
} catch (RpcException e) {
public Long maxAgeSeconds(GssResource resource) {
return maxAgeSeconds;
}
- protected Object getResourceGss(String path, UserDTO user) throws RpcException{
- //log.info(path+" <--> "+HttpManager.request().getAuthorization() + HttpManager.request().getHeaders());
+ protected Object getResourceGss(String path, User user) throws RpcException{
+
if(user ==null){
if(HttpManager.request().getAuthorization()!=null && HttpManager.request().getAuthorization().getTag()==null){
String username = HttpManager.request().getAuthorization().getUser();
- //log.info("username is:"+username);
if(username !=null)
user = getService().getUserByUserName(username);
}
else if(HttpManager.request().getAuthorization()!=null&&HttpManager.request().getAuthorization().getTag()!=null){
- //log.info(HttpManager.request().getAuthorization().getUser());
- user =(UserDTO) HttpManager.request().getAuthorization().getTag();//getService().getUserByUserName("past@ebs.gr");
+ user =(User) HttpManager.request().getAuthorization().getTag();
}
}
if(user==null){
- //log.info("---------------->"+path);
return null;
}
-
- //UserDTO user =getService().getUserByUserName("past@ebs.gr");
- /*String username = HttpManager.request().getHeaders().get("authorization");
-
- if(username!=null){
-
- username=getUsernameFromAuthHeader(username);
- try {
- user= getService().getUserByUserName(username);
- } catch (RpcException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- return null;
- }
- }*/
boolean exists = true;
Object resource = null;
- FileHeaderDTO file = null;
- FolderDTO folder = null;
try {
resource = getService().getResourceAtPath(user.getId(), path, true);
} catch (ObjectNotFoundException e) {
return null;
}
-
+ if(resource instanceof Folder){
+ try {
+ resource = getService().expandFolder((Folder) resource);
+ } catch (ObjectNotFoundException e) {
+ // TODO Auto-generated catch block
+ return null;
+ }
+ }
+ else if(resource instanceof FileHeader){
+ try {
+ resource = getService().expandFile((FileHeader) resource);
+ } catch (ObjectNotFoundException e) {
+ // TODO Auto-generated catch block
+ return null;
+ }
+ }
return resource;
}