<fim-prefix>slator.Translator;
import org.olat.core.util.Util;
import org.olat.core.util.vfs.VFSConstants;
import org.olat.core.util.vfs.VFSContainer;
import org.olat.core.util.vfs.VFSItem;
import org.olat.core.util.vfs.VFSLeaf;
import org.olat.core.util.vfs.VFSLockApplicationType;
import org.olat.core.util.vfs.VFSLockManager;
import org.olat.core.util.vfs.VFSManager;
import org.olat.core.util.vfs.VFSStatus;
import org.olat.core.util.vfs.callbacks.VFSSecurityCallback;
import org.olat.core.util.vfs.filters.VFSItemFilter;
import org.springframework.beans.factory.annotation.Autowired;

public class CmdMoveCopy extends DefaultController implements FolderCommand {

	private static final String VELOCITY_ROOT = Util.getPackageVelocityRoot(CmdMoveCopy.class);
	private static int status = FolderCommandStatus.STATUS_SUCCESS;

	private Translator translator;

	private MenuTree selTree;
	private FileSelection fileSelection;
	private Link selectButton, cancelButton;
	private FolderComponent folderComponent;
	private final boolean move;
	
	@Autowired
	private VFSLockManager vfsLockManager;
	@Autowired
	private VFSRepositoryService vfsRepositoryService;
	@Autowired
	private NotificationsManager notificationsManager;

	protected CmdMoveCopy(WindowControl wControl, boolean move) {
		super(wControl);
		this.move = move;
	}
	
	@Override
	public Controller execute(FolderComponent fc, UserRequest ureq, WindowControl windowControl, Translator trans) {
		this.folderComponent = fc;
		this.translator = trans;
		// BUG: CWE-22 Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
		// this.fileSelection = new FileSelection(ureq, fc.getCurrentContainerPath());
		// FIXED: 
<fim-middle>		this.fileSelection = new FileSelection(ureq, fc.getCurrentContainer(), fc.getCurrentContainerPath());
				
		VelocityContainer main = new VelocityContainer("mc", VELOCITY_ROOT + "/movecopy.html", tra<fix-suffix>nslator, this);
		main.contextPut("fileselection", fileSelection);
		
		//check if command is executed on a file list containing invalid filenames or paths
		if(!fileSelection.getInvalidFileNames().isEmpty()) {		
			main.contextPut("invalidFileNames", fileSelection.getInvalidFileNames());
		}		

		selTree = new MenuTree(null, "seltree", this);
		FolderTreeModel ftm = new FolderTreeModel(ureq.getLocale(), fc.getRootContainer(),
				true, false, true, fc.getRootContainer().canWrite() == VFSConstants.YES, new EditableFilter());
		selTree.setTreeModel(ftm);
		selectButton = LinkFactory.createButton(move ? "move" : "copy", main, this);
		cancelButton = LinkFactory.createButton("cancel", main, this);

		main.put("seltree", selTree);
		if (move) {
			main.contextPut("move", Boolean.TRUE);
		}

		setInitialComponent(main);
		return this;
	}
	
	public boolean isMoved() {
		return move;
	}
	
	public FileSelection getFileSelection() {
		return fileSelection;
	}

	@Override
	public int getStatus()<|endoftext|>