当前位置: 首页>>代码示例>>Java>>正文


Java Core.storeFileDocumentContent方法代码示例

本文整理汇总了Java中com.mendix.core.Core.storeFileDocumentContent方法的典型用法代码示例。如果您正苦于以下问题:Java Core.storeFileDocumentContent方法的具体用法?Java Core.storeFileDocumentContent怎么用?Java Core.storeFileDocumentContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.mendix.core.Core的用法示例。


在下文中一共展示了Core.storeFileDocumentContent方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: executeAction

import com.mendix.core.Core; //导入方法依赖的package包/类
@Override
public Boolean executeAction() throws Exception
{
	this.fileDocument = __fileDocument == null ? null : system.proxies.FileDocument.initialize(getContext(), __fileDocument);

	// BEGIN USER CODE
	File myFile = new File(Core.getConfiguration().getResourcesPath() + 
			File.separator + filename);

	FileInputStream fis = new FileInputStream(myFile);
	Core.storeFileDocumentContent(getContext(), fileDocument.getMendixObject(), 
			filename, fis);
	
	return true;
	// END USER CODE
}
 
开发者ID:appronto,项目名称:RedisConnector,代码行数:17,代码来源:GetFileContentsFromResource.java

示例2: Synthesize

import com.mendix.core.Core; //导入方法依赖的package包/类
public static IMendixObject Synthesize(IContext context, String text, VoiceEnum voiceEnumParameter, String username, String password) throws MendixException {
	LOGGER.debug("Executing Synthetize Connector...");

	service.setUsernameAndPassword(username, password);

	final Voice voice = getVoice(voiceEnumParameter);

	InputStream stream;
	try {
		stream = service.synthesize(text, voice, AudioFormat.OGG).execute();
	} catch (Exception e) {
		LOGGER.error("Watson Service Connection - Failed text to speech: " + StringUtils.abbreviate(text, 20), e);
		throw new MendixException(e);
	}

	final IMendixObject speechObject = Core.instantiate(context, Speech.entityName);
	Core.storeFileDocumentContent(context, speechObject, stream);

	return speechObject;
}
 
开发者ID:mendix,项目名称:IBM-Watson-Connector-Suite,代码行数:21,代码来源:TextToSpeechService.java

示例3: duplicateFileDocument

import com.mendix.core.Core; //导入方法依赖的package包/类
public static Boolean duplicateFileDocument(IContext context, IMendixObject toClone, IMendixObject target) throws Exception
{
	if (toClone == null || target == null)
		throw new Exception("No file to clone or to clone into provided");
	
	 MendixBoolean hasContents = (MendixBoolean) toClone.getMember(context, FileDocument.MemberNames.HasContents.toString());
    if (!hasContents.getValue(context))
   	 return false;

	InputStream inputStream = Core.getFileDocumentContent(context, toClone); 

	Core.storeFileDocumentContent(context, target, (String) toClone.getValue(context, system.proxies.FileDocument.MemberNames.Name.toString()),  inputStream); 
	return true;
}
 
开发者ID:appronto,项目名称:RedisConnector,代码行数:15,代码来源:Misc.java

示例4: storeURLToFileDocument

import com.mendix.core.Core; //导入方法依赖的package包/类
public static Boolean storeURLToFileDocument(IContext context, String url, IMendixObject __document, String filename) throws Exception
{
       if (__document == null || url == null || filename == null)
           throw new Exception("No document, filename or URL provided");
       
       final int MAX_REMOTE_FILESIZE = 1024 * 1024 * 200; //maxium of 200 MB
       URL imageUrl = new URL(url);
       URLConnection connection = imageUrl.openConnection();
       //we connect in 20 seconds or not at all
       connection.setConnectTimeout(20000);
       connection.setReadTimeout(20000);
       connection.connect();

       //check on forehand the size of the remote file, we don't want to kill the server by providing a 3 terabyte image. 
       if (connection.getContentLength() > MAX_REMOTE_FILESIZE) { //maximum of 200 mb 
           throw new IllegalArgumentException("MxID: importing image, wrong filesize of remote url: " + connection.getContentLength()+ " (max: " + String.valueOf(MAX_REMOTE_FILESIZE)+ ")");
       } else if (connection.getContentLength() < 0) {
           // connection has not specified content length, wrap stream in a LimitedInputStream
           LimitedInputStream limitStream = new LimitedInputStream(connection.getInputStream(), MAX_REMOTE_FILESIZE) {                
               @Override
               protected void raiseError(long pSizeMax, long pCount) throws IOException {
                   throw new IllegalArgumentException("MxID: importing image, wrong filesize of remote url (max: " + String.valueOf(MAX_REMOTE_FILESIZE)+ ")");                    
               }
           };
           Core.storeFileDocumentContent(context, __document, filename, limitStream);
       } else {
           // connection has specified correct content length, read the stream normally
           //NB; stream is closed by the core
           Core.storeFileDocumentContent(context, __document, filename, connection.getInputStream());
       }
       
       return true;
}
 
开发者ID:appronto,项目名称:RedisConnector,代码行数:34,代码来源:Misc.java

示例5: executeAction

import com.mendix.core.Core; //导入方法依赖的package包/类
@Override
public Boolean executeAction() throws Exception
{
	this.fileDocument = __fileDocument == null ? null : system.proxies.FileDocument.initialize(getContext(), __fileDocument);

	// BEGIN USER CODE
	FileInputStream fis = new FileInputStream(new File(this.file));
	Core.storeFileDocumentContent(getContext(), fileDocument.getMendixObject(), 
			this.file, fis);
	fis.close();
	return true;
	// END USER CODE
}
 
开发者ID:appronto,项目名称:RedisConnector,代码行数:14,代码来源:FileDocumentFromFile.java

示例6: base64DecodeToFile

import com.mendix.core.Core; //导入方法依赖的package包/类
public static void base64DecodeToFile(IContext context, String encoded, FileDocument targetFile) throws Exception
{
	if (targetFile == null)
		throw new IllegalArgumentException("Source file is null");
	if (encoded == null)
		throw new IllegalArgumentException("Source data is null");
	
	byte [] decoded = Base64.decodeBase64(encoded.getBytes());
	Core.storeFileDocumentContent(context, targetFile.getMendixObject(), new ByteArrayInputStream(decoded));
}
 
开发者ID:appronto,项目名称:RedisConnector,代码行数:11,代码来源:StringUtils.java

示例7: stringToFile

import com.mendix.core.Core; //导入方法依赖的package包/类
public static void stringToFile(IContext context, String value, FileDocument destination) 
{
	if (destination == null)
		throw new IllegalArgumentException("Destination file is null");
	if (value == null)
		throw new IllegalArgumentException("Value to write is null");
	Core.storeFileDocumentContent(context, destination.getMendixObject(), IOUtils.toInputStream(value));
}
 
开发者ID:appronto,项目名称:RedisConnector,代码行数:9,代码来源:StringUtils.java

示例8: overlayPdf

import com.mendix.core.Core; //导入方法依赖的package包/类
/**
 * Overlay a generated PDF document with another PDF (containing the company stationary for example)
 * @param context
 * @param generatedDocumentMendixObject The document to overlay
 * @param overlayMendixObject The document containing the overlay
 * @return boolean
 * @throws IOException
 * @throws COSVisitorException
 */
public static boolean overlayPdf(IContext context, IMendixObject generatedDocumentMendixObject, IMendixObject overlayMendixObject) throws IOException, COSVisitorException {
	
	ILogNode logger = Core.getLogger("OverlayPdf"); 
	logger.trace("Overlay PDF start, retrieve overlay PDF");
	PDDocument overlayDoc = PDDocument.load(Core.getFileDocumentContent(context, overlayMendixObject));
	int overlayPageCount = overlayDoc.getNumberOfPages();
	PDPage lastOverlayPage = (PDPage)overlayDoc.getDocumentCatalog().getAllPages().get(overlayPageCount - 1);

	logger.trace("Retrieve generated document");
	PDDocument offerteDoc = PDDocument.load(Core.getFileDocumentContent(context, generatedDocumentMendixObject));

	int pageCount = offerteDoc.getNumberOfPages();
	if (logger.isTraceEnabled()) {
		logger.trace("Number of pages in overlay: " + overlayPageCount + ", in generated document: " + pageCount);						
	}
	if (pageCount > overlayPageCount) {
		logger.trace("Duplicate last overlay page to match number of pages");
		for (int i = overlayPageCount; i < pageCount; i++) {
			overlayDoc.importPage(lastOverlayPage);
		}
	} else if (overlayPageCount > pageCount) {
		logger.trace("Delete unnecessary pages from the overlay to match number of pages");
		for (int i = pageCount; i < overlayPageCount; i++) {
			overlayDoc.removePage(i);
		}
	}
			
	logger.trace("Perform overlay");
	Overlay overlay = new Overlay();
	overlay.overlay(offerteDoc,overlayDoc);
	
	logger.trace("Save result in output stream");
	ByteArrayOutputStream baos = new ByteArrayOutputStream();
	overlayDoc.save(baos);
	
	logger.trace("Duplicate result in input stream");
	InputStream overlayedContent = new ByteArrayInputStream(baos.toByteArray());
	
	logger.trace("Store result in original document");
	Core.storeFileDocumentContent(context, generatedDocumentMendixObject, overlayedContent);
	
	logger.trace("Close PDFs");
	overlayDoc.close();
	offerteDoc.close();
	
	logger.trace("Overlay PDF end");
	return true;
	
}
 
开发者ID:appronto,项目名称:RedisConnector,代码行数:59,代码来源:Misc.java


注:本文中的com.mendix.core.Core.storeFileDocumentContent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。