public CommandRequestInterface doNukeCheck(CommandRequest request) { String path = VirtualFileSystem.fixPath(request.getArgument()); if (!path.startsWith(VirtualFileSystem.separator)) { // Create full path if (request.getCurrentDirectory().isRoot()) { path = VirtualFileSystem.separator + path; } else { path = request.getCurrentDirectory().getPath() + VirtualFileSystem.separator + path; } } NukeData nd = NukeBeans.getNukeBeans().findPath(path); if (nd != null) { // This path exist in nukelog request.setAllowed(false); request.setDeniedResponse( new CommandResponse( 530, "Access denied - " + nd.getPath() + " already nuked for '" + nd.getReason() + "'")); } return request; }
public CommandResponse doSITE_NUKESCLEAN(CommandRequest request) { CommandResponse response = StandardCommandManager.genericResponse("RESPONSE_200_COMMAND_OK"); if (NukeBeans.getNukeBeans().getAll().isEmpty()) { response.addComment("Nukelog empty."); } ArrayList<String> entriesToRemove = new ArrayList<String>(); for (NukeData nd : NukeBeans.getNukeBeans().getAll()) { // Construct new path with [NUKED]- String newPath = VirtualFileSystem.fixPath(nd.getPath()); String fixedName = "[NUKED]-" + newPath.substring(newPath.lastIndexOf(VirtualFileSystem.separator) + 1); newPath = newPath.substring(0, newPath.lastIndexOf(VirtualFileSystem.separator) + 1) + fixedName; try { request.getCurrentDirectory().getDirectoryUnchecked(newPath); // Still here? .. all ok then, just continue with next item in nukelog } catch (FileNotFoundException e) { // Dir was deleted/wiped, lets remove it from nukelog. // Add path to list so we can delete it after going through entire nukelog entriesToRemove.add(nd.getPath()); } catch (ObjectNotValidException e) { return new CommandResponse(550, newPath + " is not a directory"); } } if (entriesToRemove.isEmpty()) { response.addComment("No entries to delete from nukelog."); } else { int deleted = 0; for (String path : entriesToRemove) { try { NukeBeans.getNukeBeans().remove(path); deleted++; } catch (ObjectNotFoundException e) { response.addComment("Error removing nukelog entry: " + path); } } response.addComment("Removed " + deleted + " invalid entries from the nukelog."); } return response; }
public CommandResponse doSITE_NUKES(CommandRequest request) { CommandResponse response = StandardCommandManager.genericResponse("RESPONSE_200_COMMAND_OK"); ReplacerEnvironment env = new ReplacerEnvironment(); SectionInterface section = GlobalContext.getGlobalContext().getSectionManager().getSection(request.getArgument()); if (request.hasArgument() && section.getName().equalsIgnoreCase("")) { return new CommandResponse(501, "Invalid section!"); } if (NukeBeans.getNukeBeans().getAll().isEmpty()) { response.addComment( request .getSession() .jprintf(_bundle, _keyPrefix + "nukes.empty", env, request.getUser())); } for (NukeData nd : NukeBeans.getNukeBeans().getAll()) { if (nd.getPath().startsWith(request.getArgument(), 1)) { env.add("path", nd.getPath()); env.add("multiplier", nd.getMultiplier()); env.add("usersnuked", nd.getNukees().size()); env.add("size", nd.getSize()); env.add("reason", nd.getReason()); env.add("amount", nd.getAmount()); env.add("nuker", nd.getUser()); response.addComment( request.getSession().jprintf(_bundle, _keyPrefix + "nukes", env, request.getUser())); } } if (response.getComment().isEmpty()) { env.add("section", section.getName()); response.addComment( request .getSession() .jprintf(_bundle, _keyPrefix + "nukes.empty.section", env, request.getUser())); } return response; }