Revision 0336eab9

b/gss/src/gr/ebs/gss/client/commands/PasteCommand.java
55 55
	public void execute() {
56 56
		containerPanel.hide();
57 57
		Object selection = GSS.get().getCurrentSelection();
58
		if (GSS.get().getCurrentSelection() instanceof FolderResource) {
58
		if(selection != null && selection instanceof GroupResource){
59
			final ClipboardItem citem = GSS.get().getClipboard().getItem();
60
			GroupResource group = (GroupResource) GSS.get().getCurrentSelection();
61
			if(citem.getUser() != null){
62
				ExecutePost cg = new ExecutePost(group.getPath()+"?name="+citem.getUser().getUsername(), "", 201){
63

  
64
					public void onComplete() {
65
						GSS.get().getGroups().updateGroups();
66
						GSS.get().showUserList();
67
					}
68
					public void onError(Throwable t) {
69
						GWT.log("", t);
70
						if(t instanceof RestException){
71
							int statusCode = ((RestException)t).getHttpStatusCode();
72
							if(statusCode == 405)
73
								GSS.get().displayError("You don't have the necessary permissions");
74
							else if(statusCode == 404)
75
								GSS.get().displayError("User does not exist");
76
							else if(statusCode == 409)
77
								GSS.get().displayError("A user with the same name already exists");
78
							else if(statusCode == 413)
79
								GSS.get().displayError("Your quota has been exceeded");
80
							else
81
								GSS.get().displayError("Unable to add user:"+((RestException)t).getHttpStatusText());
82
						}
83
						else
84
							GSS.get().displayError("System error adding user:"+t.getMessage());
85
					}
86
				};
87
				DeferredCommand.addCommand(cg);
88
				return;
89
			}
90
		}
91
		FolderResource selectedFolder = null;
92
		if(selection != null && selection instanceof FolderResource)
93
			selectedFolder = (FolderResource)selection;
94
		else if(GSS.get().getFolders().getCurrent() != null && ((DnDTreeItem)GSS.get().getFolders().getCurrent()).getFolderResource() != null)
95
			selectedFolder = ((DnDTreeItem)GSS.get().getFolders().getCurrent()).getFolderResource();
96
		if (selectedFolder != null) {
59 97
			final ClipboardItem citem = GSS.get().getClipboard().getItem();
60 98
			if (citem != null && citem.getFolderResource() != null) {
61 99

  
62
				String target = ((FolderResource) GSS.get().getCurrentSelection()).getPath();
100
				String target = selectedFolder.getPath();
63 101
				target = target.endsWith("/") ? target : target + '/';
64 102
				target = target + URL.encodeComponent(citem.getFolderResource().getName());
65 103
				if (citem.getOperation() == Clipboard.COPY) {
......
121 159
				}
122 160
				return;
123 161
			} else if (citem != null && citem.getFile() != null) {
124
				String target = ((FolderResource) GSS.get().getCurrentSelection()).getPath();
162
				String target = selectedFolder.getPath();
125 163
				target = target.endsWith("/") ? target : target + '/';
126 164
				target = target + URL.encodeComponent(citem.getFile().getName());
127 165
				if (citem.getOperation() == Clipboard.COPY) {
......
183 221
			} else if (citem != null && citem.getFiles() != null) {
184 222
				List<FileResource> res = citem.getFiles();
185 223
				List<String> fileIds = new ArrayList<String>();
186
				String target = ((FolderResource) GSS.get().getCurrentSelection()).getPath();
224
				String target = selectedFolder.getPath();
187 225
				target = target.endsWith("/") ? target : target + '/';
188 226

  
189 227
				if (citem.getOperation() == Clipboard.COPY) {
......
207 245
			}
208 246

  
209 247
		}
210
		else if(GSS.get().getCurrentSelection() instanceof GroupResource){
211
			final ClipboardItem citem = GSS.get().getClipboard().getItem();
212
			GroupResource group = (GroupResource) GSS.get().getCurrentSelection();
213
			if(citem.getUser() != null){
214
				ExecutePost cg = new ExecutePost(group.getPath()+"?name="+citem.getUser().getUsername(), "", 201){
215

  
216
					public void onComplete() {
217
						GSS.get().getGroups().updateGroups();
218
						GSS.get().showUserList();
219
					}
220
					public void onError(Throwable t) {
221
						GWT.log("", t);
222
						if(t instanceof RestException){
223
							int statusCode = ((RestException)t).getHttpStatusCode();
224
							if(statusCode == 405)
225
								GSS.get().displayError("You don't have the necessary permissions");
226
							else if(statusCode == 404)
227
								GSS.get().displayError("User does not exist");
228
							else if(statusCode == 409)
229
								GSS.get().displayError("A user with the same name already exists");
230
							else if(statusCode == 413)
231
								GSS.get().displayError("Your quota has been exceeded");
232
							else
233
								GSS.get().displayError("Unable to add user:"+((RestException)t).getHttpStatusText());
234
						}
235
						else
236
							GSS.get().displayError("System error adding user:"+t.getMessage());
237
					}
238
				};
239
				DeferredCommand.addCommand(cg);
240
			}
241
		}
242 248

  
243 249
	}
244 250

  
251

  
245 252
	private void executeCopyOrMove(final int index, final List<String> paths){
246 253
		if(index >= paths.size()){
247 254
			GSS.get().showFileList(true);

Also available in: Unified diff