Java 类org.apache.commons.fileupload.disk.DiskFileItem 实例源码

项目:APacheSynapseSimplePOC    文件:FileUpload1.java   
public DiskFileItem getObject ( String command ) throws Exception {

        String[] parts = command.split(";");

        if ( parts.length == 3 && "copyAndDelete".equals(parts[ 0 ]) ) {
            return copyAndDelete(parts[ 1 ], parts[ 2 ]);
        }
        else if ( parts.length == 3 && "write".equals(parts[ 0 ]) ) {
            return write(parts[ 1 ], parts[ 2 ].getBytes("US-ASCII"));
        }
        else if ( parts.length == 3 && "writeB64".equals(parts[ 0 ]) ) {
            return write(parts[ 1 ], Base64.decodeBase64(parts[ 2 ]));
        }
        else if ( parts.length == 3 && "writeOld".equals(parts[ 0 ]) ) {
            return writePre131(parts[ 1 ], parts[ 2 ].getBytes("US-ASCII"));
        }
        else if ( parts.length == 3 && "writeOldB64".equals(parts[ 0 ]) ) {
            return writePre131(parts[ 1 ], Base64.decodeBase64(parts[ 2 ]));
        }
        else {
            throw new IllegalArgumentException("Unsupported command " + command + " " + Arrays.toString(parts));
        }
    }
项目:ysoserial-modified    文件:FileUpload1.java   
public DiskFileItem getObject ( CmdExecuteHelper cmdHelper ) throws Exception {

        String[] parts = cmdHelper.getCommand().split(";");

        if ( parts.length == 3 && "copyAndDelete".equals(parts[ 0 ]) ) {
            return copyAndDelete(parts[ 1 ], parts[ 2 ]);
        }
        else if ( parts.length == 3 && "write".equals(parts[ 0 ]) ) {
            return write(parts[ 1 ], parts[ 2 ].getBytes("US-ASCII"));
        }
        else if ( parts.length == 3 && "writeB64".equals(parts[ 0 ]) ) {
            return write(parts[ 1 ], Base64.decodeBase64(parts[ 2 ]));
        }
        else if ( parts.length == 3 && "writeOld".equals(parts[ 0 ]) ) {
            return writePre131(parts[ 1 ], parts[ 2 ].getBytes("US-ASCII"));
        }
        else if ( parts.length == 3 && "writeOldB64".equals(parts[ 0 ]) ) {
            return writePre131(parts[ 1 ], Base64.decodeBase64(parts[ 2 ]));
        }
        else {
            throw new IllegalArgumentException("Unsupported command " + cmdHelper.getCommand() + " " + Arrays.toString(parts));
        }
    }
项目:ysoserial-plus    文件:FileUpload1.java   
public DiskFileItem getObject ( String command ) throws Exception {

        String[] parts = command.split(";");

        if ( parts.length == 3 && "copyAndDelete".equals(parts[ 0 ]) ) {
            return copyAndDelete(parts[ 1 ], parts[ 2 ]);
        }
        else if ( parts.length == 3 && "write".equals(parts[ 0 ]) ) {
            return write(parts[ 1 ], parts[ 2 ].getBytes("US-ASCII"));
        }
        else if ( parts.length == 3 && "writeB64".equals(parts[ 0 ]) ) {
            return write(parts[ 1 ], Base64.decodeBase64(parts[ 2 ]));
        }
        else if ( parts.length == 3 && "writeOld".equals(parts[ 0 ]) ) {
            return writePre131(parts[ 1 ], parts[ 2 ].getBytes("US-ASCII"));
        }
        else if ( parts.length == 3 && "writeOldB64".equals(parts[ 0 ]) ) {
            return writePre131(parts[ 1 ], Base64.decodeBase64(parts[ 2 ]));
        }
        else {
            throw new IllegalArgumentException("Unsupported command " + command + " " + Arrays.toString(parts));
        }
    }
项目:struts2    文件:JakartaMultiPartRequest.java   
public File[] getFile(String fieldName) {
    List<FileItem> items = files.get(fieldName);

    if (items == null) {
        return null;
    }

    List<File> fileList = new ArrayList<>(items.size());
    for (FileItem fileItem : items) {
        File storeLocation = ((DiskFileItem) fileItem).getStoreLocation();
        if (fileItem.isInMemory() && storeLocation != null && !storeLocation.exists()) {
            try {
                storeLocation.createNewFile();
            } catch (IOException e) {
                LOG.error("Cannot write uploaded empty file to disk: {}", storeLocation.getAbsolutePath(), e);
            }
        }
        fileList.add(storeLocation);
    }

    return fileList.toArray(new File[fileList.size()]);
}
项目:sakai    文件:PopupForm.java   
public static PopupForm fromRequest(String uuid, HttpServletRequest request) {
    String descriptor = request.getParameter("descriptor");
    boolean isOpenCampaign = "open-campaign".equals(request.getParameter("open-campaign"));

    long startTime = "".equals(request.getParameter("start_time")) ? 0 : parseTime(request.getParameter("start_time_selected_datetime"));
    long endTime = "".equals(request.getParameter("end_time")) ? 0 : parseTime(request.getParameter("end_time_selected_datetime"));

    List<String> assignToEids = new ArrayList<String>();
    if (request.getParameter("distribution") != null) {
        for (String user : request.getParameter("distribution").split("[\r\n]+")) {
            if (!user.isEmpty()) {
                assignToEids.add(user);
            }
        }
    }

    Optional<DiskFileItem> templateItem = Optional.empty();
    DiskFileItem dfi = (DiskFileItem) request.getAttribute("template");
    if (dfi != null && dfi.getSize() > 0) {
        templateItem = Optional.of(dfi);
    }

    return new PopupForm(uuid, descriptor, startTime, endTime, isOpenCampaign, assignToEids, templateItem);
}
项目:ysoserial    文件:FileUpload1.java   
public DiskFileItem getObject ( String command ) throws Exception {

        String[] parts = command.split(";");

        if ( parts.length == 3 && "copyAndDelete".equals(parts[ 0 ]) ) {
            return copyAndDelete(parts[ 1 ], parts[ 2 ]);
        }
        else if ( parts.length == 3 && "write".equals(parts[ 0 ]) ) {
            return write(parts[ 1 ], parts[ 2 ].getBytes("US-ASCII"));
        }
        else if ( parts.length == 3 && "writeB64".equals(parts[ 0 ]) ) {
            return write(parts[ 1 ], Base64.decodeBase64(parts[ 2 ]));
        }
        else if ( parts.length == 3 && "writeOld".equals(parts[ 0 ]) ) {
            return writePre131(parts[ 1 ], parts[ 2 ].getBytes("US-ASCII"));
        }
        else if ( parts.length == 3 && "writeOldB64".equals(parts[ 0 ]) ) {
            return writePre131(parts[ 1 ], Base64.decodeBase64(parts[ 2 ]));
        }
        else {
            throw new IllegalArgumentException("Unsupported command " + command + " " + Arrays.toString(parts));
        }
    }
项目:wso2-axis2    文件:MultipartFormDataBuilder.java   
private String getTextParameter(DiskFileItem diskFileItem,
                                String characterEncoding) throws Exception {

    String encoding = diskFileItem.getCharSet();

    if (encoding == null) {
        encoding = characterEncoding;
    }

    String textValue;
    if (encoding == null) {
        textValue = new String(diskFileItem.get());
    } else {
        textValue = new String(diskFileItem.get(), encoding);
    }

    return textValue;
}
项目:sakai    文件:PopupForm.java   
public static PopupForm fromRequest(String uuid, HttpServletRequest request) {
    String descriptor = request.getParameter("descriptor");
    boolean isOpenCampaign = "open-campaign".equals(request.getParameter("open-campaign"));

    long startTime = "".equals(request.getParameter("start_time")) ? 0 : parseTime(request.getParameter("start_time_selected_datetime"));
    long endTime = "".equals(request.getParameter("end_time")) ? 0 : parseTime(request.getParameter("end_time_selected_datetime"));

    List<String> assignToEids = new ArrayList<String>();
    if (request.getParameter("distribution") != null) {
        for (String user : request.getParameter("distribution").split("[\r\n]+")) {
            if (!user.isEmpty()) {
                assignToEids.add(user);
            }
        }
    }

    Optional<DiskFileItem> templateItem = Optional.empty();
    DiskFileItem dfi = (DiskFileItem) request.getAttribute("template");
    if (dfi != null && dfi.getSize() > 0) {
        templateItem = Optional.of(dfi);
    }

    return new PopupForm(uuid, descriptor, startTime, endTime, isOpenCampaign, assignToEids, templateItem);
}
项目:gen-server-http-listener    文件:TestRequestFileHandlingUtilities.java   
@Override
public void handle(final HttpRequest request,
        final HttpResponse response, final HttpContext context) {

    try {
        final List<FileItem> files = RequestFileHandlingUtilities
                .handleFileUpload(request);
        final HashMap<String, String> fileMap = new HashMap<String, String>();
        for (final FileItem fileItem : files) {
            fileMap.put(fileItem.getName(), Files
                    .getCanonicalPath(((DiskFileItem) fileItem)
                            .getStoreLocation()));
        }

        response.setEntity(new SerializableEntity(fileMap, false));
        fileItems.addAll(files);
    } catch (Exception e) {
        response.setEntity(new StringEntity("ERROR",
                ContentType.DEFAULT_TEXT));
    }
}
项目:Runway-SDK    文件:MultipartFileParameter.java   
/**
 * Determine whether the multipart content is still available. If a temporary
 * file has been moved, the content is no longer available.
 */
protected boolean isAvailable()
{
  // If in memory, it's available.
  if (this.fileItem.isInMemory())
  {
    return true;
  }

  // Check actual existence of temporary file.
  if (this.fileItem instanceof DiskFileItem)
  {
    return ( (DiskFileItem) this.fileItem ).getStoreLocation().exists();
  }

  // Check whether current file size is different than original one.
  return ( this.fileItem.getSize() == this.size );
}
项目:orbeon-forms    文件:RequestGenerator.java   
public static String urlForFileItem(FileItem fileItem) throws SAXException {
    // Only a reference to the file is output (xs:anyURI)
    final DiskFileItem diskFileItem = (DiskFileItem) fileItem;
    final String uriExpiringWithRequest;
    if (!fileItem.isInMemory()) {
        // File must exist on disk since isInMemory() returns false
        final File file = diskFileItem.getStoreLocation();
        uriExpiringWithRequest = file.toURI().toString();
    } else {
        // File does not exist on disk, must convert
        // NOTE: Conversion occurs every time this method is called. Not optimal.
        try {
            uriExpiringWithRequest = NetUtils.inputStreamToAnyURI(fileItem.getInputStream(), NetUtils.REQUEST_SCOPE);
        } catch (IOException e) {
            throw new OXFException(e);
        }
    }

    return uriExpiringWithRequest;
}
项目:APacheSynapseSimplePOC    文件:FileUpload1.java   
private static DiskFileItem makePayload ( int thresh, String repoPath, String filePath, byte[] data ) throws IOException, Exception {
    // if thresh < written length, delete outputFile after copying to repository temp file
    // otherwise write the contents to repository temp file
    File repository = new File(repoPath);
    DiskFileItem diskFileItem = new DiskFileItem("test", "application/octet-stream", false, "test", 100000, repository);
    File outputFile = new File(filePath);
    DeferredFileOutputStream dfos = new DeferredFileOutputStream(thresh, outputFile);
    OutputStream os = (OutputStream) Reflections.getFieldValue(dfos, "memoryOutputStream");
    os.write(data);
    Reflections.getField(ThresholdingOutputStream.class, "written").set(dfos, data.length);
    Reflections.setFieldValue(diskFileItem, "dfos", dfos);
    Reflections.setFieldValue(diskFileItem, "sizeThreshold", 0);
    return diskFileItem;
}
项目:lams    文件:CommonsMultipartFile.java   
/**
 * Determine whether the multipart content is still available.
 * If a temporary file has been moved, the content is no longer available.
 */
protected boolean isAvailable() {
    // If in memory, it's available.
    if (this.fileItem.isInMemory()) {
        return true;
    }
    // Check actual existence of temporary file.
    if (this.fileItem instanceof DiskFileItem) {
        return ((DiskFileItem) this.fileItem).getStoreLocation().exists();
    }
    // Check whether current file size is different than original one.
    return (this.fileItem.getSize() == this.size);
}
项目:lams    文件:CommonsMultipartFile.java   
/**
 * Return a description for the storage location of the multipart content.
 * Tries to be as specific as possible: mentions the file location in case
 * of a temporary file.
 */
public String getStorageDescription() {
    if (this.fileItem.isInMemory()) {
        return "in memory";
    }
    else if (this.fileItem instanceof DiskFileItem) {
        return "at [" + ((DiskFileItem) this.fileItem).getStoreLocation().getAbsolutePath() + "]";
    }
    else {
        return "on disk";
    }
}
项目:ysoserial-modified    文件:FileUpload1.java   
private static DiskFileItem makePayload ( int thresh, String repoPath, String filePath, byte[] data ) throws IOException, Exception {
    // if thresh < written length, delete outputFile after copying to repository temp file
    // otherwise write the contents to repository temp file
    File repository = new File(repoPath);
    DiskFileItem diskFileItem = new DiskFileItem("test", "application/octet-stream", false, "test", 100000, repository);
    File outputFile = new File(filePath);
    DeferredFileOutputStream dfos = new DeferredFileOutputStream(thresh, outputFile);
    OutputStream os = (OutputStream) Reflections.getFieldValue(dfos, "memoryOutputStream");
    os.write(data);
    Reflections.getField(ThresholdingOutputStream.class, "written").set(dfos, data.length);
    Reflections.setFieldValue(diskFileItem, "dfos", dfos);
    Reflections.setFieldValue(diskFileItem, "sizeThreshold", 0);
    return diskFileItem;
}
项目:ysoserial-plus    文件:FileUpload1.java   
private static DiskFileItem makePayload ( int thresh, String repoPath, String filePath, byte[] data ) throws IOException, Exception {
    // if thresh < written length, delete outputFile after copying to repository temp file
    // otherwise write the contents to repository temp file
    File repository = new File(repoPath);
    DiskFileItem diskFileItem = new DiskFileItem("test", "application/octet-stream", false, "test", 100000, repository);
    File outputFile = new File(filePath);
    DeferredFileOutputStream dfos = new DeferredFileOutputStream(thresh, outputFile);
    OutputStream os = (OutputStream) Reflections.getFieldValue(dfos, "memoryOutputStream");
    os.write(data);
    Reflections.getField(ThresholdingOutputStream.class, "written").set(dfos, data.length);
    Reflections.setFieldValue(diskFileItem, "dfos", dfos);
    Reflections.setFieldValue(diskFileItem, "sizeThreshold", 0);
    return diskFileItem;
}
项目:validator-web    文件:CommonsMultipartFile.java   
/**
 * Determine whether the multipart content is still available.
 * If a temporary file has been moved, the content is no longer available.
 */
protected boolean isAvailable() {
    // If in memory, it's available.
    if (this.fileItem.isInMemory()) {
        return true;
    }
    // Check actual existence of temporary file.
    if (this.fileItem instanceof DiskFileItem) {
        return ((DiskFileItem) this.fileItem).getStoreLocation().exists();
    }
    // Check whether current file size is different than original one.
    return (this.fileItem.getSize() == this.size);
}
项目:validator-web    文件:CommonsMultipartFile.java   
/**
 * Return a description for the storage location of the multipart content.
 * Tries to be as specific as possible: mentions the file location in case
 * of a temporary file.
 */
public String getStorageDescription() {
    if (this.fileItem.isInMemory()) {
        return "in memory";
    }
    else if (this.fileItem instanceof DiskFileItem) {
        return "at [" + ((DiskFileItem) this.fileItem).getStoreLocation().getAbsolutePath() + "]";
    }
    else {
        return "on disk";
    }
}
项目:carbon-identity-framework    文件:SecurityUIUtil.java   
public static String getTextParameter(DiskFileItem diskFileItem, String characterEncoding)
        throws Exception {
    String encoding = diskFileItem.getCharSet();
    if (encoding == null) {
        encoding = characterEncoding;
    }
    String textValue;
    if (encoding == null) {
        textValue = new String(diskFileItem.get());
    } else {
        textValue = new String(diskFileItem.get(), encoding);
    }
    return textValue;
}
项目:spring4-understanding    文件:CommonsMultipartFile.java   
/**
 * Determine whether the multipart content is still available.
 * If a temporary file has been moved, the content is no longer available.
 */
protected boolean isAvailable() {
    // If in memory, it's available.
    if (this.fileItem.isInMemory()) {
        return true;
    }
    // Check actual existence of temporary file.
    if (this.fileItem instanceof DiskFileItem) {
        return ((DiskFileItem) this.fileItem).getStoreLocation().exists();
    }
    // Check whether current file size is different than original one.
    return (this.fileItem.getSize() == this.size);
}
项目:spring4-understanding    文件:CommonsMultipartFile.java   
/**
 * Return a description for the storage location of the multipart content.
 * Tries to be as specific as possible: mentions the file location in case
 * of a temporary file.
 */
public String getStorageDescription() {
    if (this.fileItem.isInMemory()) {
        return "in memory";
    }
    else if (this.fileItem instanceof DiskFileItem) {
        return "at [" + ((DiskFileItem) this.fileItem).getStoreLocation().getAbsolutePath() + "]";
    }
    else {
        return "on disk";
    }
}
项目:struts2    文件:JakartaMultiPartRequest.java   
public String[] getFilesystemName(String fieldName) {
    List<FileItem> items = files.get(fieldName);

    if (items == null) {
        return null;
    }

    List<String> fileNames = new ArrayList<>(items.size());
    for (FileItem fileItem : items) {
        fileNames.add(((DiskFileItem) fileItem).getStoreLocation().getName());
    }

    return fileNames.toArray(new String[fileNames.size()]);
}
项目:prudence    文件:LazyInitializationFile.java   
/**
 * Creates a PHP-style item in the $_FILE map.
 * 
 * @param fileItem
 *        The file itme
 * @return A PHP-style $_FILE item
 */
private static Map<String, Object> createFileItemMap( FileItem fileItem )
{
    Map<String, Object> exposedFileItem = new HashMap<String, Object>();
    exposedFileItem.put( "name", fileItem.getName() );
    exposedFileItem.put( "type", fileItem.getContentType() );
    exposedFileItem.put( "size", fileItem.getSize() );
    if( fileItem instanceof DiskFileItem )
    {
        DiskFileItem diskFileItem = (DiskFileItem) fileItem;
        exposedFileItem.put( "tmp_name", diskFileItem.getStoreLocation().getAbsolutePath() );
    }
    // exposedFileItem.put("error", );
    return exposedFileItem;
}
项目:aspectran    文件:CommonsMultipartFileParameter.java   
/**
 * Determine whether the multipart content is still available.
 * If a temporary file has been moved, the content is no longer available.
 *
 * @return true, if the multipart content is still available
 */
private boolean isAvailable() {
    // If in memory, it's available.
    if (this.fileItem.isInMemory()) {
        return true;
    }
    // Check actual existence of temporary file.
    if (this.fileItem instanceof DiskFileItem) {
        return ((DiskFileItem)this.fileItem).getStoreLocation().exists();
    }
    // Check whether current file size is different than original one.
    return (this.fileItem.getSize() == this.fileSize);
}
项目:aspectran    文件:CommonsMultipartFileParameter.java   
/**
 * Return a description for the storage location of the multipart content.
 * Tries to be as specific as possible: mentions the file location in case
 * of a temporary file.
 *
 * @return a description for the storage location of the multipart content
 */
public String getStorageDescription() {
    if (this.fileItem.isInMemory()) {
        return "in memory";
    } else if (this.fileItem instanceof DiskFileItem) {
        return "at [" + ((DiskFileItem)this.fileItem).getStoreLocation().getAbsolutePath() + "]";
    } else {
        return "on disk";
    }
}
项目:imageweb    文件:FileUtil.java   
public static File multipartFile2File(MultipartFile file) {
    CommonsMultipartFile commonsMultipartFile = (CommonsMultipartFile) file;
    DiskFileItem fileItem = (DiskFileItem) commonsMultipartFile.getFileItem();

    File _file = fileItem.getStoreLocation();
    return _file;
}
项目:sakai    文件:PopupForm.java   
private PopupForm(String uuid,
                  String descriptor,
                  long startTime, long endTime,
                  boolean isOpenCampaign,
                  List<String> assignToEids,
                  Optional<DiskFileItem> templateItem) {
    this.uuid = uuid;
    this.descriptor = descriptor;
    this.startTime = startTime;
    this.endTime = endTime;
    this.isOpenCampaign = isOpenCampaign;
    this.assignToEids = assignToEids;
    this.templateItem = templateItem;
}
项目:ysoserial    文件:FileUpload1.java   
private static DiskFileItem makePayload ( int thresh, String repoPath, String filePath, byte[] data ) throws IOException, Exception {
    // if thresh < written length, delete outputFile after copying to repository temp file
    // otherwise write the contents to repository temp file
    File repository = new File(repoPath);
    DiskFileItem diskFileItem = new DiskFileItem("test", "application/octet-stream", false, "test", 100000, repository);
    File outputFile = new File(filePath);
    DeferredFileOutputStream dfos = new DeferredFileOutputStream(thresh, outputFile);
    OutputStream os = (OutputStream) Reflections.getFieldValue(dfos, "memoryOutputStream");
    os.write(data);
    Reflections.getField(ThresholdingOutputStream.class, "written").set(dfos, data.length);
    Reflections.setFieldValue(diskFileItem, "dfos", dfos);
    Reflections.setFieldValue(diskFileItem, "sizeThreshold", 0);
    return diskFileItem;
}
项目:carbon-identity    文件:SecurityUIUtil.java   
public static String getTextParameter(DiskFileItem diskFileItem, String characterEncoding)
        throws Exception {
    String encoding = diskFileItem.getCharSet();
    if (encoding == null) {
        encoding = characterEncoding;
    }
    String textValue;
    if (encoding == null) {
        textValue = new String(diskFileItem.get());
    } else {
        textValue = new String(diskFileItem.get(), encoding);
    }
    return textValue;
}
项目:taulukko-commons-util    文件:EWebTools.java   
private Iterator<DiskFileItem> getItems() throws FileUploadException
{
    if (list == null)
    {
        ServletFileUpload upload = new ServletFileUpload();
        upload.setFileItemFactory(new DiskFileItemFactory());
        upload.setSizeMax(100 * EFile.TP_KILO);
        // Processa os itens do upload
        list = upload.parseRequest(request);
    }
    return list.iterator();
}
项目:class-guard    文件:CommonsMultipartFile.java   
/**
 * Determine whether the multipart content is still available.
 * If a temporary file has been moved, the content is no longer available.
 */
protected boolean isAvailable() {
    // If in memory, it's available.
    if (this.fileItem.isInMemory()) {
        return true;
    }
    // Check actual existence of temporary file.
    if (this.fileItem instanceof DiskFileItem) {
        return ((DiskFileItem) this.fileItem).getStoreLocation().exists();
    }
    // Check whether current file size is different than original one.
    return (this.fileItem.getSize() == this.size);
}
项目:class-guard    文件:CommonsMultipartFile.java   
/**
 * Return a description for the storage location of the multipart content.
 * Tries to be as specific as possible: mentions the file location in case
 * of a temporary file.
 */
public String getStorageDescription() {
    if (this.fileItem.isInMemory()) {
        return "in memory";
    }
    else if (this.fileItem instanceof DiskFileItem) {
        return "at [" + ((DiskFileItem) this.fileItem).getStoreLocation().getAbsolutePath() + "]";
    }
    else {
        return "on disk";
    }
}
项目:wso2-axis2    文件:MultipartFormDataBuilder.java   
private MultipleEntryHashMap getParameterMap(RequestContext request,
                                             String charSetEncoding)
        throws FileUploadException {

    MultipleEntryHashMap parameterMap = new MultipleEntryHashMap();

    List items = parseRequest(request);
    Iterator iter = items.iterator();
    while (iter.hasNext()) {
        DiskFileItem diskFileItem = (DiskFileItem)iter.next();

        boolean isFormField = diskFileItem.isFormField();

        Object value;
        try {
            if (isFormField) {
                value = getTextParameter(diskFileItem, charSetEncoding);
            } else {
                value = getFileParameter(diskFileItem);
            }
        } catch (Exception ex) {
            throw new FileUploadException(ex.getMessage());
        }
        parameterMap.put(diskFileItem.getFieldName(), value);
    }

    return parameterMap;
}
项目:wso2-axis2    文件:MultipartFormDataBuilder.java   
private DataHandler getFileParameter(DiskFileItem diskFileItem)
        throws Exception {

    DataSource dataSource = new DiskFileDataSource(diskFileItem);
    DataHandler dataHandler = new DataHandler(dataSource);

    return dataHandler;
}
项目:restcommander    文件:ApacheMultipartParser.java   
/**
 * Returns an identifier that is unique within the class loader used to
 * load this class, but does not have random-like apearance.
 *
 * @return A String with the non-random looking instance identifier.
 */
private static String getUniqueId() {
    int current;
    synchronized (DiskFileItem.class) {
        current = counter++;
    }
    String id = Integer.toString(current);

    // If you manage to get more than 100 million of ids, you'll
    // start getting ids longer than 8 characters.
    if (current < 100000000) {
        id = ("00000000" + id).substring(id.length());
    }
    return id;
}
项目:sakai    文件:PopupForm.java   
private PopupForm(String uuid,
                  String descriptor,
                  long startTime, long endTime,
                  boolean isOpenCampaign,
                  List<String> assignToEids,
                  Optional<DiskFileItem> templateItem) {
    this.uuid = uuid;
    this.descriptor = descriptor;
    this.startTime = startTime;
    this.endTime = endTime;
    this.isOpenCampaign = isOpenCampaign;
    this.assignToEids = assignToEids;
    this.templateItem = templateItem;
}
项目:tomee    文件:CommonsFileUploadPart.java   
@Override
public Collection<String> getHeaderNames() {
    if (fileItem instanceof DiskFileItem) {
        final Set<String> headerNames = new LinkedHashSet<>();
        final Iterator<String> iter = fileItem.getHeaders().getHeaderNames();
        while (iter.hasNext()) {
            headerNames.add(iter.next());
        }
        return headerNames;
    }
    return Collections.emptyList();
}