@Override public void execute(final OutputStream out) throws ConnectorException { try { response.setHeader("X-CKFinder-Error", String.valueOf(e.getErrorCode())); switch (e.getErrorCode()) { case Constants.Errors.CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST: case Constants.Errors.CKFINDER_CONNECTOR_ERROR_INVALID_NAME: case Constants.Errors.CKFINDER_CONNECTOR_ERROR_THUMBNAILS_DISABLED: case Constants.Errors.CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED: response.sendError(HttpServletResponse.SC_FORBIDDEN); break; case Constants.Errors.CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED: response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); break; default: response.sendError(HttpServletResponse.SC_NOT_FOUND); break; } } catch (IOException e) { throw new ConnectorException(e); } }
@Override protected int getDataForXml() { try { checkParam(newFolderName); } catch (ConnectorException e) { return e.getErrorCode(); } if (!checkIfTypeExists(this.type)) { this.type = null; return Constants.Errors.CKFINDER_CONNECTOR_ERROR_INVALID_TYPE; } if (!AccessControlUtil.getInstance(configuration) .checkFolderACL( this.type, this.currentFolder, this.userRole, AccessControlUtil.CKFINDER_CONNECTOR_ACL_FOLDER_RENAME)) { return Constants.Errors.CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED; } if (configuration.forceASCII()) { this.newFolderName = FileUtils.convertToASCII(this.newFolderName); } if (FileUtils.checkIfDirIsHidden(this.newFolderName, configuration) || !FileUtils.checkFolderName(this.newFolderName, configuration)) { return Constants.Errors.CKFINDER_CONNECTOR_ERROR_INVALID_NAME; } if (this.currentFolder.equals("/")) { return Constants.Errors.CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST; } File dir = new File(configuration.getTypes().get(this.type).getPath() + this.currentFolder); try { if (!dir.isDirectory()) { return Constants.Errors.CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST; } setNewFolder(); File newDir = new File(configuration.getTypes().get(this.type).getPath() + this.newFolderPath); if (newDir.exists()) { return Constants.Errors.CKFINDER_CONNECTOR_ERROR_ALREADY_EXIST; } if (dir.renameTo(newDir)) { renameThumb(); } else { return Constants.Errors.CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED; } } catch (SecurityException e) { if (configuration.isDebugMode()) { throw e; } else { return Constants.Errors.CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED; } } return Constants.Errors.CKFINDER_CONNECTOR_ERROR_NONE; }