本文整理汇总了Java中org.wso2.carbon.application.upload.xsd.UploadedFileItem类的典型用法代码示例。如果您正苦于以下问题:Java UploadedFileItem类的具体用法?Java UploadedFileItem怎么用?Java UploadedFileItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UploadedFileItem类属于org.wso2.carbon.application.upload.xsd包,在下文中一共展示了UploadedFileItem类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deploy
import org.wso2.carbon.application.upload.xsd.UploadedFileItem; //导入依赖的package包/类
public void deploy(CarbonApplication deployable) throws WSO2AdminServicesException
{
logUpload(deployable.getFile());
try
{
CarbonAppUploaderStub carbonAppUploaderStub =
new CarbonAppUploaderStub(new URL(getUrl() + SERVICES_CARBON_APP_UPLOADER).toString());
prepareStub(carbonAppUploaderStub);
UploadedFileItem[] carbonAppArray = new UploadedFileItem[1];
UploadedFileItem carbonApp = new UploadedFileItem();
DataHandler dh = new DataHandler(new File(deployable.getFile()).toURI().toURL());
carbonApp.setFileName(new File(deployable.getFile()).getName());
carbonApp.setDataHandler(dh);
carbonApp.setFileType("jar");
carbonAppArray[0] = carbonApp;
carbonAppUploaderStub.uploadApp(carbonAppArray);
}
catch (Exception e)
{
throw new WSO2AdminServicesException("error uploading carbon application", e);
}
}
示例2: uploadCAR
import org.wso2.carbon.application.upload.xsd.UploadedFileItem; //导入依赖的package包/类
/**
* Upload carbon abb artifact to WSO2 ESB or other WSO2 Server via WSO2 SOAP
* service
*
* @param appType
* @param artifactFileName
* Filename for CAR artifact to upload to WSO2 Server
* @return true, if upload is OK
*/
public boolean uploadCAR ( File artifact, String targetFileName, String appType ) {
log.info( "[WSO2 CAR Deployer] Start CAR upload" );
boolean result = true;
try {
InputStream fin = new FileInputStream( artifact );
UploadedFileItem fileItem = new UploadedFileItem();
org.wso2.carbon.application.upload.xsd.ObjectFactory fieldFactory = new org.wso2.carbon.application.upload.xsd.ObjectFactory();
// byte[] fileContent = readFile( fin );
final byte fileContent[] = readFully( fin );
final int cnt = fileContent.length;
log.info( "[WSO2 CAR Deployer] Read CAR with " + cnt + " bytes" );
fileItem.setDataHandler( fieldFactory.createUploadedFileItemDataHandler( fileContent ) );
fileItem.setFileName( fieldFactory.createUploadedFileItemFileName( targetFileName ) );
fileItem.setFileType( fieldFactory.createUploadedFileItemFileType( appType ) );
UploadApp req = new UploadApp();
req.getFileItems().add( fileItem );
log.info( "[WSO2 CAR Deployer] Invoking uploadService for " + targetFileName + " ..." );
uploadSvc.uploadApp( req );
} catch ( Exception e ) {
if ( e.getMessage().indexOf( "uploadAppResponse was not recognized" ) > 0 ) {
// TODO: Why is the response empty in WSDL?
log.info( "[WSO2 CAR Deployer] WARNING: response ignored ;-)" );
} else {
log.error( "[WSO2 CAR Deployer] ERROR: " + e.getMessage() );
result = false;
log.error( e );
}
}
return result;
}
示例3: uploadCAR
import org.wso2.carbon.application.upload.xsd.UploadedFileItem; //导入依赖的package包/类
/**
* Upload carbon abb artifact to WSO2 ESB or other WSO2 Server via WSO2 SOAP service
* @param appType
* @param artifactFileName Filename for CAR artifact to upload to WSO2 Server
* @return true, if upload is OK
*/
public boolean uploadCAR( InputStream fin, String targetFileName, String appType ) {
boolean result = true;
try {
UploadedFileItem fileItem = new UploadedFileItem();
org.wso2.carbon.application.upload.xsd.ObjectFactory fieldFactory = new org.wso2.carbon.application.upload.xsd.ObjectFactory();
//byte[] fileContent = readFile( fin );
final byte fileContent[] = readFully(fin);
final int cnt = fileContent.length;
listener.getLogger().println( "[WSO2 CAR Deployer] Read CAR with "+cnt+" bytes" );
fileItem.setDataHandler( fieldFactory.createUploadedFileItemDataHandler( fileContent ) );
fileItem.setFileName( fieldFactory.createUploadedFileItemFileName( targetFileName ) );
fileItem.setFileType( fieldFactory.createUploadedFileItemFileType( appType ) );
UploadApp req = new UploadApp();
req.getFileItems().add( fileItem );
listener.getLogger().println( "[WSO2 CAR Deployer] Invoking uploadService for "+targetFileName+" ...");
uploadSvc.uploadApp( req );
} catch ( Exception e) {
if ( e.getMessage().indexOf("uploadAppResponse was not recognized") > 0 ) {
// TODO: Why is the response empty in WSDL?
listener.getLogger().println( "[WSO2 CAR Deployer] WARNING: response ignored ;-)" );
} else {
listener.getLogger().println( "[WSO2 CAR Deployer] ERROR: "+e.getMessage() );
result = false;
e.printStackTrace();
}
}
return result ;
}
示例4: getFileItems
import org.wso2.carbon.application.upload.xsd.UploadedFileItem; //导入依赖的package包/类
/**
* Gets the value of the fileItems property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the fileItems property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getFileItems().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link UploadedFileItem }
*
*
*/
public List<UploadedFileItem> getFileItems() {
if (fileItems == null) {
fileItems = new ArrayList<UploadedFileItem>();
}
return this.fileItems;
}