Java Code Examples for org.apache.commons.fileupload.FileItem#isInMemory()

The following examples show how to use org.apache.commons.fileupload.FileItem#isInMemory() . 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 File: JobUploadService.java    From Knowage-Server with GNU Affero General Public License v3.0 5 votes vote down vote up
private String[] processUploadedFile(FileItem item, JobDeploymentDescriptor jobDeploymentDescriptor) throws ZipException, IOException, SpagoBIEngineException {
	String fieldName = item.getFieldName();
    String fileName = item.getName();
    String contentType = item.getContentType();
    boolean isInMemory = item.isInMemory();
    long sizeInBytes = item.getSize();
    
    if(fieldName.equalsIgnoreCase("deploymentDescriptor")) return null;
    
    RuntimeRepository runtimeRepository = TalendEngine.getRuntimeRepository();
    File jobsDir = new File(runtimeRepository.getRootDir(), jobDeploymentDescriptor.getLanguage().toLowerCase());
	File projectDir = new File(jobsDir, jobDeploymentDescriptor.getProject());
	File tmpDir = new File(projectDir, "tmp");
	if(!tmpDir.exists()) tmpDir.mkdirs();	   
     File uploadedFile = new File(tmpDir, fileName);
    
    try {
		item.write(uploadedFile);
	} catch (Exception e) {
		e.printStackTrace();
	}	
	
	String[] dirNames = ZipUtils.getDirectoryNameByLevel(new ZipFile(uploadedFile), 2);
	List dirNameList = new ArrayList();
	for(int i = 0; i < dirNames.length; i++) {
		if(!dirNames[i].equalsIgnoreCase("lib")) dirNameList.add(dirNames[i]);
	}
	String[] jobNames = (String[])dirNameList.toArray(new String[0]);
	
    runtimeRepository.deployJob(jobDeploymentDescriptor, new ZipFile(uploadedFile));
    uploadedFile.delete();	
    tmpDir.delete();
    
    return jobNames;
}
 
Example 2
Source File: JobUploadService.java    From Knowage-Server with GNU Affero General Public License v3.0 4 votes vote down vote up
private void publishOnSpagoBI(FileItem item, JobDeploymentDescriptor jobDeploymentDescriptor) throws ZipException, IOException, SpagoBIEngineException {
	String fieldName = item.getFieldName();
    String fileName = item.getName();
    String contentType = item.getContentType();
    boolean isInMemory = item.isInMemory();
    long sizeInBytes = item.getSize();
    
    if(fieldName.equalsIgnoreCase("deploymentDescriptor")) return;
    
    
    
    RuntimeRepository runtimeRepository = TalendEngine.getRuntimeRepository();
    
    String projectName = jobDeploymentDescriptor.getProject();
    String projectLanguage = jobDeploymentDescriptor.getLanguage().toLowerCase();
    String jobName = "JOB_NAME";
    String contextName = "Default";
    String template = "";
    template += "<etl>\n";
    template += "\t<job project=\"" + projectName + "\" ";
    template += "jobName=\"" + projectName + "\" ";
    template += "context=\"" + projectName + "\" ";
    template += "language=\"" + contextName + "\" />\n";
    template += "</etl>";
    
    BASE64Encoder encoder = new BASE64Encoder();
    String templateBase64Coded = encoder.encode(template.getBytes());		
    
    TalendEngineConfig config = TalendEngineConfig.getInstance();
    
    String user = "biadmin";
	String password = "biadmin";
	String label = "ETL_JOB";
	String name = "EtlJob";
	String description = "Etl Job";
	boolean encrypt = false;
	boolean visible = true;
	String functionalitiyCode = config.getSpagobiTargetFunctionalityLabel();	
	String type = "ETL";
	String state = "DEV";
    
    try {

    	//PublishAccessUtils.publish(spagobiurl, user, password, label, name, description, encrypt, visible, type, state, functionalitiyCode, templateBase64Coded);
	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
    
}