Revision ff32989e

b/src/gr/grnet/pithos/web/client/Pithos.java
999 999
    }
1000 1000

  
1001 1001
    public void copyFolder(final Folder f, final String targetUsername, final String targetUri, final Command callback) {
1002
        String path = targetUri + "/" + f.getName();
1003
        PutRequest createFolder = new PutRequest(getApiPath(), targetUsername, path) {
1002
        String path = targetUri + "/" + f.getName() + "?delimiter=/";
1003
        PutRequest copyFolder = new PutRequest(getApiPath(), targetUsername, path) {
1004 1004
            @Override
1005 1005
            public void onSuccess(Resource result) {
1006
            	GetRequest<Folder> getFolder = new GetRequest<Folder>(Folder.class, getApiPath(), f.getOwner(), "/" + f.getContainer() + "?format=json&delimiter=/&prefix=" + URL.encodeQueryString(f.getPrefix()), f) {
1007

  
1008
					@Override
1009
					public void onSuccess(final Folder _f) {
1010
		                Iterator<File> iter = _f.getFiles().iterator();
1011
		                copyFiles(iter, targetUsername, targetUri + "/" + _f.getName(), new Command() {
1012
		                    @Override
1013
		                    public void execute() {
1014
		                        Iterator<Folder> iterf = _f.getSubfolders().iterator();
1015
		                        copySubfolders(iterf, targetUsername, targetUri + "/" + _f.getName(), callback);
1016
		                    }
1017
		                });
1018
					}
1019

  
1020
					@Override
1021
					public void onError(Throwable t) {
1022
		                GWT.log("", t);
1023
						setError(t);
1024
		                if (t instanceof RestException) {
1025
		                    displayError("Unable to get folder: " + ((RestException) t).getHttpStatusText());
1026
		                }
1027
		                else
1028
		                    displayError("System error getting folder: " + t.getMessage());
1029
					}
1030

  
1031
					@Override
1032
					protected void onUnauthorized(Response response) {
1033
						sessionExpired();
1034
					}
1035
				};
1036
				getFolder.setHeader("X-Auth-Token", getToken());
1037
				Scheduler.get().scheduleDeferred(getFolder);
1006
            	if (callback != null)
1007
            		callback.execute();
1038 1008
            }
1039 1009

  
1040 1010
            @Override
......
1042 1012
                GWT.log("", t);
1043 1013
				setError(t);
1044 1014
               if (t instanceof RestException) {
1045
                    displayError("Unable to create folder: " + ((RestException) t).getHttpStatusText());
1015
                    displayError("Unable to copy folder: " + ((RestException) t).getHttpStatusText());
1046 1016
                }
1047 1017
                else
1048
                    displayError("System error creating folder: " + t.getMessage());
1018
                    displayError("System error copying folder: " + t.getMessage());
1049 1019
            }
1050 1020

  
1051 1021
			@Override
......
1053 1023
				sessionExpired();
1054 1024
			}
1055 1025
        };
1056
        createFolder.setHeader("X-Auth-Token", getToken());
1057
        createFolder.setHeader("Accept", "*/*");
1058
        createFolder.setHeader("Content-Length", "0");
1059
        createFolder.setHeader("Content-Type", "application/folder");
1060
        Scheduler.get().scheduleDeferred(createFolder);
1026
        copyFolder.setHeader("X-Auth-Token", getToken());
1027
        copyFolder.setHeader("Accept", "*/*");
1028
        copyFolder.setHeader("Content-Length", "0");
1029
        copyFolder.setHeader("Content-Type", "application/directory");
1030
        if (!f.getOwner().equals(targetUsername))
1031
        	copyFolder.setHeader("X-Source-Account", f.getOwner());
1032
        copyFolder.setHeader("X-Copy-From", URL.encodePathSegment(f.getUri()));
1033
        Scheduler.get().scheduleDeferred(copyFolder);
1061 1034
    }
1062 1035
    
1063 1036
    public void addSelectionModel(@SuppressWarnings("rawtypes") SingleSelectionModel model) {

Also available in: Unified diff