/** * Cuts all the leading path portion and get just the file name. */ @Nonnull public static String getFileName(@Nonnull String filePath) { int idx = filePath.lastIndexOf('\\'); if(idx>=0) return getFileName(filePath.substring(idx+1)); idx = filePath.lastIndexOf('/'); if(idx>=0) return getFileName(filePath.substring(idx+1)); return filePath; }
String fileName = Util.getFileName(fileItem.getName()); if("".equals(fileName)){ return new HttpRedirect("advanced");
String target = readSymlink(f); if (target!=null) { int n = Integer.parseInt(Util.getFileName(target)); if (n==RESOLVES_TO_NONE) return null;
/** * Cuts all the leading path portion and get just the file name. */ public static String getFileName(String filePath) { int idx = filePath.lastIndexOf('\\'); if(idx>=0) return getFileName(filePath.substring(idx+1)); idx = filePath.lastIndexOf('/'); if(idx>=0) return getFileName(filePath.substring(idx+1)); return filePath; }
/** * Cuts all the leading path portion and get just the file name. */ public static String getFileName(String filePath) { int idx = filePath.lastIndexOf('\\'); if(idx>=0) return getFileName(filePath.substring(idx+1)); idx = filePath.lastIndexOf('/'); if(idx>=0) return getFileName(filePath.substring(idx+1)); return filePath; }
/** * Cuts all the leading path portion and get just the file name. */ public static String getFileName(String filePath) { int idx = filePath.lastIndexOf('\\'); if (idx >= 0) { return getFileName(filePath.substring(idx + 1)); } idx = filePath.lastIndexOf('/'); if (idx >= 0) { return getFileName(filePath.substring(idx + 1)); } return filePath; }
/** * Cuts all the leading path portion and get just the file name. */ public static String getFileName(String filePath) { int idx = filePath.lastIndexOf('\\'); if (idx >= 0) { return getFileName(filePath.substring(idx + 1)); } idx = filePath.lastIndexOf('/'); if (idx >= 0) { return getFileName(filePath.substring(idx + 1)); } return filePath; }
/** * Cuts all the leading path portion and get just the file name. */ @Nonnull public static String getFileName(@Nonnull String filePath) { int idx = filePath.lastIndexOf('\\'); if(idx>=0) return getFileName(filePath.substring(idx+1)); idx = filePath.lastIndexOf('/'); if(idx>=0) return getFileName(filePath.substring(idx+1)); return filePath; }
/** * Uploads a plugin. */ public HttpResponse doUploadPlugin(StaplerRequest req) throws IOException, ServletException { try { Hudson.getInstance().checkPermission(Hudson.ADMINISTER); ServletFileUpload upload = new ServletFileUpload(new DiskFileItemFactory()); // Parse the request FileItem fileItem = (FileItem) upload.parseRequest(req).get(0); String fileName = Util.getFileName(fileItem.getName()); if("".equals(fileName)) return new HttpRedirect("advanced"); if(!fileName.endsWith(".hpi")) throw new Failure(hudson.model.Messages.Hudson_NotAPlugin(fileName)); fileItem.write(new File(rootDir, fileName)); fileItem.delete(); pluginUploaded = true; return new HttpRedirect("."); } catch (IOException e) { throw e; } catch (Exception e) {// grrr. fileItem.write throws this throw new ServletException(e); } }
/** * Uploads a plugin. */ public HttpResponse doUploadPlugin(StaplerRequest req) throws IOException, ServletException { try { Hudson.getInstance().checkPermission(Hudson.ADMINISTER); ServletFileUpload upload = new ServletFileUpload(new DiskFileItemFactory()); // Parse the request FileItem fileItem = (FileItem) upload.parseRequest(req).get(0); String fileName = Util.getFileName(fileItem.getName()); if("".equals(fileName)) return new HttpRedirect("advanced"); if(!fileName.endsWith(".hpi")) throw new Failure(hudson.model.Messages.Hudson_NotAPlugin(fileName)); fileItem.write(new File(rootDir, fileName)); fileItem.delete(); pluginUploaded = true; return new HttpRedirect("."); } catch (IOException e) { throw e; } catch (Exception e) {// grrr. fileItem.write throws this throw new ServletException(e); } }
/** * Uploads a plugin. */ public HttpResponse doUploadPlugin(StaplerRequest req) throws IOException, ServletException { try { Hudson.getInstance().checkPermission(Hudson.ADMINISTER); ServletFileUpload upload = new ServletFileUpload(new DiskFileItemFactory()); // Parse the request FileItem fileItem = (FileItem) upload.parseRequest(req).get(0); String fileName = Util.getFileName(fileItem.getName()); if("".equals(fileName)) return new HttpRedirect("advanced"); if(!fileName.endsWith(".hpi")) throw new Failure(hudson.model.Messages.Hudson_NotAPlugin(fileName)); fileItem.write(new File(rootDir, fileName)); fileItem.delete(); pluginUploaded = true; return new HttpRedirect("."); } catch (IOException e) { throw e; } catch (Exception e) {// grrr. fileItem.write throws this throw new ServletException(e); } }
/** * Uploads a plugin. */ public HttpResponse doUploadPlugin(StaplerRequest req) throws IOException, ServletException { try { Hudson.getInstance().checkPermission(Hudson.ADMINISTER); ServletFileUpload upload = new ServletFileUpload(new DiskFileItemFactory()); // Parse the request FileItem fileItem = (FileItem) upload.parseRequest(req).get(0); String fileName = Util.getFileName(fileItem.getName()); if ("".equals(fileName)) { return new HttpRedirect("advanced"); } if (!fileName.endsWith(".hpi")) { throw new Failure(hudson.model.Messages.Hudson_NotAPlugin(fileName)); } fileItem.write(new File(rootDir, fileName)); fileItem.delete(); pluginUploaded = true; return new HttpRedirect("."); } catch (IOException e) { throw e; } catch (Exception e) {// grrr. fileItem.write throws this throw new ServletException(e); } }
/** * Uploads a script and stores it with the given filename to the configuration. It will be stored on the filessytem. * * @param req * request * @return forward to index page. * @throws IOException * @throws ServletException */ public HttpResponse doUploadScript(StaplerRequest req) throws IOException, ServletException { checkPermission(Hudson.ADMINISTER); try { FileItem fileItem = req.getFileItem("file"); boolean nonAdministerUsing = req.getSubmittedForm().getBoolean("nonAdministerUsing"); String fileName = Util.getFileName(fileItem.getName()); if (StringUtils.isEmpty(fileName)) { return new HttpRedirect("."); } saveScript(fileItem, nonAdministerUsing, fileName); return new HttpRedirect("index"); } catch (IOException e) { throw e; } catch (Exception e) { throw new ServletException(e); } }
String fileName = Util.getFileName(fileItem.getName()); if("".equals(fileName)){ return new HttpRedirect("advanced");
String target = readSymlink(f); if (target!=null) { int n = Integer.parseInt(Util.getFileName(target)); if (n==RESOLVES_TO_NONE) return null;