Java Code Examples for org.apache.commons.fileupload.disk.DiskFileItem

The following examples show how to use org.apache.commons.fileupload.disk.DiskFileItem. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: ysoserial-modified   Source File: FileUpload1.java    License: MIT License 6 votes vote down vote up
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));
        }
    }
 
Example 2
Source Project: sakai   Source File: PopupForm.java    License: Educational Community License v2.0 6 votes vote down vote up
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);
}
 
Example 3
/**
 * Create an instance of FileItem in a temporary file.
 * 
 * @param fieldName
 * @param fileName
 * @param classPathResource
 * @return
 * @throws IOException
 * @throws URISyntaxException
 */
private FileItem createFileItemFromClassPathResource(String fieldName, String fileName, String classPathResource)
        throws IOException, URISyntaxException {
    InputStream inputStream = getClass().getResourceAsStream(classPathResource);
    Path inputPath = Paths.get(getClass().getResource(classPathResource).toURI());
    int availableBytes = inputStream.available();

    // Write the inputStream to a FileItem
    File outFile = codedefendersHome.createTempFile("ClassUploadManagerTest","");
    outFile.deleteOnExit();
    
    String contentType = null;
    if( classPathResource.endsWith(".zip") ){
        contentType = "application/zip";
    } else {
        contentType = "plain/text";
    }
    FileItem fileItem = new DiskFileItem(fieldName, contentType, false, fileName, availableBytes, outFile);
    Files.copy(inputPath, fileItem.getOutputStream());

    return fileItem;
}
 
Example 4
Source Project: ysoserial   Source File: FileUpload1.java    License: MIT License 6 votes vote down vote up
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));
        }
    }
 
Example 5
Source Project: sakai   Source File: PopupForm.java    License: Educational Community License v2.0 6 votes vote down vote up
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);
}
 
Example 6
Source Project: spring-analysis-note   Source File: CommonsMultipartFile.java    License: MIT License 5 votes vote down vote up
/**
 * 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);
}
 
Example 7
Source Project: spring-analysis-note   Source File: CommonsMultipartFile.java    License: MIT License 5 votes vote down vote up
/**
 * 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";
	}
}
 
Example 8
Source Project: java-technology-stack   Source File: CommonsMultipartFile.java    License: MIT License 5 votes vote down vote up
/**
 * 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);
}
 
Example 9
Source Project: java-technology-stack   Source File: CommonsMultipartFile.java    License: MIT License 5 votes vote down vote up
/**
 * 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";
	}
}
 
Example 10
/**
 * Test delete method.
 *
 * @throws Exception when a serious error occurs.
 */
@Test
public void testDelete() throws Exception {
    File file = new File("delete.me");
    file.createNewFile();
    assertTrue(file.exists());
    FileItem item = new DiskFileItem("fieldName", "text/html", false,
            "delete.me", 0, file);
    ApacheMultiPart part = new ApacheMultiPart(item);
    part.delete();
    file.delete();
}
 
Example 11
/**
 * Test getContentType method.
 * 
 * @throws Exception when a serious error occurs.
 */
@Test
public void testGetContentType() throws Exception {
    File file = new File("delete.me");
    file.createNewFile();
    assertTrue(file.exists());
    FileItem item = new DiskFileItem("fieldName", "text/html", false,
            "delete.me", 0, file);
    ApacheMultiPart part = new ApacheMultiPart(item);
    assertEquals(part.getContentType(), "text/html");
    file.delete();
}
 
Example 12
Source Project: lams   Source File: CommonsMultipartFile.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 13
Source Project: lams   Source File: CommonsMultipartFile.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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";
	}
}
 
Example 14
Source Project: spring-boot   Source File: RotateImgUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 选择图片
 *
 * @param fileName 上传的文件
 */
public static final InputStream rotateImg(MultipartFile fileName) throws TSException {
    if (fileName == null) return null;
    CommonsMultipartFile cf = (CommonsMultipartFile) fileName;
    DiskFileItem fi = (DiskFileItem) cf.getFileItem();
    File file = fi.getStoreLocation();
    //获取旋转角度
    int angle = getRotateAngle(file);
    //选择图片
    return rotatePhonePhoto(file, angle);
}
 
Example 15
Source Project: ysoserial-modified   Source File: FileUpload1.java    License: MIT License 5 votes vote down vote up
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;
}
 
Example 16
Source Project: validator-web   Source File: CommonsMultipartFile.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 17
Source Project: validator-web   Source File: CommonsMultipartFile.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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";
    }
}
 
Example 18
Source Project: AndServer   Source File: StandardMultipartFile.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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 (fileItem.isInMemory()) {
        return true;
    }
    // Check actual existence of temporary file.
    if (fileItem instanceof DiskFileItem) {
        return ((DiskFileItem) fileItem).getStoreLocation().exists();
    }
    // Check whether current file size is different than original one.
    return (fileItem.getSize() == size);
}
 
Example 19
Source Project: carbon-identity-framework   Source File: SecurityUIUtil.java    License: Apache License 2.0 5 votes vote down vote up
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(), StandardCharsets.UTF_8);
    } else {
        textValue = new String(diskFileItem.get(), encoding);
    }
    return textValue;
}
 
Example 20
/**
 * 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);
}
 
Example 21
/**
 * 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";
	}
}
 
Example 22
Source Project: sakai   Source File: PopupForm.java    License: Educational Community License v2.0 5 votes vote down vote up
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;
}
 
Example 23
Source Project: ysoserial   Source File: FileUpload1.java    License: MIT License 5 votes vote down vote up
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;
}
 
Example 24
Source Project: carbon-identity   Source File: SecurityUIUtil.java    License: Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 25
public void testDoImportUsersFromFile( ) throws AccessDeniedException, UserNotSignedException, IOException
{
    AdminUserJspBean bean = new AdminUserJspBean( );
    MockHttpServletRequest request = new MockHttpServletRequest( );
    request.addParameter( SecurityTokenService.PARAMETER_TOKEN, SecurityTokenService.getInstance( ).getToken( request, "jsp/admin/user/ImportUser.jsp" ) );
    AdminUser user = getUserToModify( );
    AdminAuthenticationService.getInstance( ).registerUser( request, user );
    bean.init( request, "CORE_USERS_MANAGEMENT" );
    Map<String, List<FileItem>> multipartFiles = new HashMap<>( );
    List<FileItem> fileItems = new ArrayList<>( );
    FileItem file = new DiskFileItem( "import_file", "application/csv", true, "junit.csv", 1024, new File( System.getProperty( "java.io.tmpdir" ) ) );
    OutputStreamWriter writer = new OutputStreamWriter( file.getOutputStream( ), Charset.forName( "UTF-8" ) );
    writer.write( "test;test;test;[email protected];" + AdminUser.ACTIVE_CODE + ";" + Locale.FRANCE + ";0;false;false;;;" );
    writer.close( );
    fileItems.add( file );
    multipartFiles.put( "import_file", fileItems );
    Map<String, String [ ]> parameters = request.getParameterMap( );
    MultipartHttpServletRequest multipartRequest = new MultipartHttpServletRequest( request, multipartFiles, parameters );
    bean.getImportUsersFromFile( request ); // initialize _importAdminUserService
    AdminUser importedUser = null;
    try
    {
        bean.doImportUsersFromFile( multipartRequest );
        importedUser = AdminUserHome.findUserByLogin( "test" );
        assertNotNull( importedUser );
        assertEquals( "test", importedUser.getAccessCode( ) );
        assertEquals( "test", importedUser.getFirstName( ) );
        assertEquals( "test", importedUser.getLastName( ) );
        assertEquals( "[email protected]", importedUser.getEmail( ) );
        assertEquals( AdminUser.ACTIVE_CODE, importedUser.getStatus( ) );
    }
    finally
    {
        if ( importedUser != null )
        {
            disposeOfUser( importedUser );
        }
        disposeOfUser( user );
    }
}
 
Example 26
public void testDoImportUsersFromFileInvalidToken( ) throws AccessDeniedException, UserNotSignedException, IOException
{
    AdminUserJspBean bean = new AdminUserJspBean( );
    MockHttpServletRequest request = new MockHttpServletRequest( );
    request.addParameter( SecurityTokenService.PARAMETER_TOKEN, SecurityTokenService.getInstance( ).getToken( request, "jsp/admin/user/ImportUser.jsp" )
            + "b" );
    AdminUser user = getUserToModify( );
    AdminAuthenticationService.getInstance( ).registerUser( request, user );
    bean.init( request, "CORE_USERS_MANAGEMENT" );
    Map<String, List<FileItem>> multipartFiles = new HashMap<>( );
    List<FileItem> fileItems = new ArrayList<>( );
    FileItem file = new DiskFileItem( "import_file", "application/csv", true, "junit.csv", 1024, new File( System.getProperty( "java.io.tmpdir" ) ) );
    OutputStreamWriter writer = new OutputStreamWriter( file.getOutputStream( ), Charset.forName( "UTF-8" ) );
    writer.write( "test;test;test;[email protected];" + AdminUser.ACTIVE_CODE + ";" + Locale.FRANCE + ";0;false;false;;;" );
    writer.close( );
    fileItems.add( file );
    multipartFiles.put( "import_file", fileItems );
    Map<String, String [ ]> parameters = request.getParameterMap( );
    MultipartHttpServletRequest multipartRequest = new MultipartHttpServletRequest( request, multipartFiles, parameters );
    bean.getImportUsersFromFile( request ); // initialize _importAdminUserService
    AdminUser importedUser = null;
    try
    {
        bean.doImportUsersFromFile( multipartRequest );
        fail( "Should have thrown" );
    }
    catch( AccessDeniedException e )
    {
        importedUser = AdminUserHome.findUserByLogin( "test" );
        assertNull( importedUser );
    }
    finally
    {
        if ( importedUser != null )
        {
            disposeOfUser( importedUser );
        }
        disposeOfUser( user );
    }
}
 
Example 27
public void testDoImportUsersFromFileNoToken( ) throws AccessDeniedException, UserNotSignedException, IOException
{
    AdminUserJspBean bean = new AdminUserJspBean( );
    MockHttpServletRequest request = new MockHttpServletRequest( );
    AdminUser user = getUserToModify( );
    AdminAuthenticationService.getInstance( ).registerUser( request, user );
    bean.init( request, "CORE_USERS_MANAGEMENT" );
    Map<String, List<FileItem>> multipartFiles = new HashMap<>( );
    List<FileItem> fileItems = new ArrayList<>( );
    FileItem file = new DiskFileItem( "import_file", "application/csv", true, "junit.csv", 1024, new File( System.getProperty( "java.io.tmpdir" ) ) );
    OutputStreamWriter writer = new OutputStreamWriter( file.getOutputStream( ), Charset.forName( "UTF-8" ) );
    writer.write( "test;test;test;[email protected];" + AdminUser.ACTIVE_CODE + ";" + Locale.FRANCE + ";0;false;false;;;" );
    writer.close( );
    fileItems.add( file );
    multipartFiles.put( "import_file", fileItems );
    Map<String, String [ ]> parameters = request.getParameterMap( );
    MultipartHttpServletRequest multipartRequest = new MultipartHttpServletRequest( request, multipartFiles, parameters );
    bean.getImportUsersFromFile( request ); // initialize _importAdminUserService
    AdminUser importedUser = null;
    try
    {
        bean.doImportUsersFromFile( multipartRequest );
        fail( "Should have thrown" );
    }
    catch( AccessDeniedException e )
    {
        importedUser = AdminUserHome.findUserByLogin( "test" );
        assertNull( importedUser );
    }
    finally
    {
        if ( importedUser != null )
        {
            disposeOfUser( importedUser );
        }
        disposeOfUser( user );
    }
}
 
Example 28
Source Project: restcommander   Source File: ApacheMultipartParser.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 29
Source Project: sakai   Source File: PopupForm.java    License: Educational Community License v2.0 5 votes vote down vote up
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;
}
 
Example 30
Source Project: tomee   Source File: CommonsFileUploadPart.java    License: Apache License 2.0 5 votes vote down vote up
@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();
}