本文整理了Java中com.ebmwebsourcing.petalsbpm.utils.server.ZipHelper
类的一些代码示例,展示了ZipHelper
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipHelper
类的具体详情如下:
包路径:com.ebmwebsourcing.petalsbpm.utils.server.ZipHelper
类名称:ZipHelper
[英]Zip Helper For handling zip files
[中]处理Zip文件的Zip助手
代码示例来源:origin: com.ebmwebsourcing.petalsbpm/bpmn-plugins
private File getXPDLFromBPMN2(File projectInstanceFile, File temporaryOutputDirectory) throws Exception{
XPDLAdapter adapter = new XPDLAdapter();
if(ZipHelper.getInstance().isZipFile(projectInstanceFile)) {
ZipHelper.getInstance().unzipFile(projectInstanceFile, temporaryOutputDirectory);
return adapter.getXPDL2FromBPMN2(BPMNFileHelper.getBPMNFileInFolder(temporaryOutputDirectory).getAbsolutePath());
}
else {
return adapter.getXPDL2FromBPMN2(projectInstanceFile.getAbsolutePath());
}
}
代码示例来源:origin: com.ebmwebsourcing.petalsbpm/petalsbpm-utils
public static ZipHelper getInstance() {
if (instance == null) {
instance = new ZipHelper();
}
return instance;
}
代码示例来源:origin: com.ebmwebsourcing.petalsbpm/petalsbpm-utils
public File createZipFromFolder(String folderLocation, String zipName) throws IOException{
try {
File zip = new File(zipName);
ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zip));
zipDir(folderLocation, zos, folderLocation);
zos.close();
return zip;
} catch (Exception e) {
e.printStackTrace();
throw new IOException("Couldn't create Zip file:" + zipName + " from folder "
+ folderLocation);
}
}
代码示例来源:origin: com.ebmwebsourcing.petalsbpm/bpmn-plugins
protected void readFile(File file) throws Exception {
if(ZipHelper.getInstance().isZipFile(file)) {
readZipFile(file);
}
else {
readBPMNFiles(new File[]{file});
}
}
代码示例来源:origin: com.ebmwebsourcing.petalsbpm/bpmn-plugins
private File getBPELZipFromBPMN(File projectInstanceFile, IProjectInstanceMetaData exportData, File directory) throws Exception{
FileHelper.cleanDirectory(directory);
//first retrieve the bpmn defintions form the given project instance file
if(ZipHelper.getInstance().isZipFile(projectInstanceFile)) {
ZipHelper.getInstance().unzipFile(projectInstanceFile,directory);
}
else {
FileHelper.copyFile(projectInstanceFile, directory);
}
File bpmnFile = BPMNFileHelper.getBPMNFileInFolder(directory);
URL url = bpmnFile.toURI().toURL();
Definitions defs = new XmlContextFactory().newContext().createReader().readDocument(url, Definitions.class);
//get or create a temp dir and generate bpel and wsdl files in it
String bpelZipPath = directory.getAbsolutePath()+File.separator+"zip";
File bpelZipDir = new File(bpelZipPath);
if(!bpelZipDir.exists()) {
bpelZipDir.mkdir();
}
FileHelper.cleanDirectory(bpelZipDir);
new BPELGenerator().generate(defs, bpelZipPath);
//make a zip out of this temporary directory
return ZipHelper.getInstance().createZipFromFolder(bpelZipPath, directory.getAbsolutePath()+File.separator+"BPEL"+defs.getId()+".zip");
}
代码示例来源:origin: com.ebmwebsourcing.petalsbpm/bpmn-plugins
private void readZipFile(File file) throws Exception {
File unzipDir = BPMNFileHelper.getOrCreateUnzipDirectory(file);
ZipHelper.getInstance().unzipFile(file,unzipDir);
//Read the bpmn definitions and diagram from the files and fill the instance
readBPMNFiles(unzipDir.listFiles());
//copy the possible attached files into the proper directory
File attachedFilesDir = WebEditorService.getInstance().getAttachedFilesDirectory(UserServiceImpl.getInstance().getLoggedUser(), instance);
File bpmnFile = BPMNFileHelper.getBPMNFileInList(unzipDir.listFiles());
File importedAttachmentsFile = new File(unzipDir,WebEditorService.ATTACHMENTS_DIR);
if(importedAttachmentsFile.exists()) {
for(File f : importedAttachmentsFile.listFiles()) {
FileHelper.copyFile(f, attachedFilesDir);
}
}
//normally it is not executed if the files were produced by the editor
for(File f : unzipDir.listFiles()) {
if(!f.equals(bpmnFile) && !f.equals(importedAttachmentsFile)) {
FileHelper.copyFile(f, attachedFilesDir);
}
}
}
代码示例来源:origin: com.ebmwebsourcing.petalsbpm/bpmn-plugins
if(importFiles!=null && importFiles.length>0) {
FileHelper.copyFile(attachedFilesDir, zipDir);
File zipFile = ZipHelper.getInstance().createZipFromFolder(path,directory+File.separator+defs.getId()+".zip");
return zipFile;
代码示例来源:origin: com.ebmwebsourcing.petalsbpm/bpmn-plugins
if(ZipHelper.getInstance().isZipFile(file)) {
bpmnFile = getMetaDataFromZip(file, format);
代码示例来源:origin: com.ebmwebsourcing.petalsbpm/bpmn-plugins
private File getMetaDataFromZip(File zipFile, IProjectInstanceFormat format) throws ZipException, IOException {
File unzipDir = BPMNFileHelper.getOrCreateUnzipDirectory(zipFile);
ZipHelper.getInstance().unzipFile(zipFile, unzipDir);
File attachedFilesDir = WebEditorService.getInstance().getAttachedFilesDirectory(UserServiceImpl.getInstance().getLoggedUser(),ProjectServiceImpl.getInstance().getCurrentProjectInstance());
File bpmnFile = BPMNFileHelper.getBPMNFileInList(unzipDir.listFiles());
for(File f : unzipDir.listFiles()) {
FileHelper.copyFile(f, attachedFilesDir);
}
return bpmnFile;
}
代码示例来源:origin: com.ebmwebsourcing.petalsbpm/bpmn-deployer
if(ZipHelper.getInstance().isZipFile(bpmnFile)) {
File zipDir = FileHelper.createTemporaryDirectory();
ZipHelper.getInstance().unzipFile(bpmnFile, zipDir);
for(File f : zipDir.listFiles()){
if((f.getName().startsWith("BPMN_") && f.getName().endsWith(".xml"))
代码示例来源:origin: com.ebmwebsourcing.petalsbpm/petalsbpm-utils
private void zipDir(String dir2zip, ZipOutputStream zos, String initialLocation) throws IOException{
File zipDir = new File(dir2zip);
String[] dirList = zipDir.list();
for(int i=0; i<dirList.length; i++){
File f = new File(zipDir, dirList[i]);
if(f.isDirectory()){
//if the File object is a directory, call this
//function again to add its content recursively
String filePath = f.getPath();
zipDir(filePath, zos, initialLocation);
//loop again
continue;
}
ZipEntry anEntry = new ZipEntry(f.getPath().replace(initialLocation, ""));
zos.putNextEntry(anEntry);
FileInputStream fis = new FileInputStream(f);
byte[] readBuffer = new byte[2156];
int bytesIn = 0;
while((bytesIn = fis.read(readBuffer)) != -1){
zos.write(readBuffer, 0, bytesIn);
}
fis.close();
}
}
内容来源于网络,如有侵权,请联系作者删除!