}
}
}
if (resourceBpmn == null) {
throw new FixFlowException("发布的流程资源文件必须含有.bpmn");
}
byte[] bytes = resourceBpmn.getBytes();
ResourceSet resourceSet = getResourceSet();
String tmp = ProcessEngineManagement.getDefaultProcessEngine().getProcessEngineConfiguration().getDefaultTemplatePath();
String filePath = this.getClass().getClassLoader().getResource(tmp).toString();
Resource ddddResource = null;
if (!filePath.startsWith("jar")) {
try {
filePath = java.net.URLDecoder.decode(ReflectUtil.getResource(tmp).getFile(), "utf-8");
} catch (UnsupportedEncodingException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
throw new FixFlowException("流程定义文件加载失败!", e);
}
ddddResource = resourceSet.createResource(URI.createFileURI(filePath));
} else {
ddddResource = resourceSet.createResource(URI.createURI(filePath));
}
try {
ddddResource.load(new ByteArrayInputStream(bytes), null);
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
throw new FixFlowException("定义文件加载失败!", e);
} catch (IOException e) {
// TODO Auto-generated catch block
throw new FixFlowException("定义文件加载失败!", e);
}
DefinitionsBehavior definitions = (DefinitionsBehavior) ddddResource.getContents().get(0).eContents().get(0);
ProcessDefinitionBehavior process = null;
for (RootElement rootElement : definitions.getRootElements()) {
if (rootElement instanceof ProcessDefinitionBehavior) {
// ProcessDefinitionBehavior
// processObj=(ProcessDefinitionBehavior)rootElement;
// if(processObj.getProcessDefinitionKey().equals("")){
process = (ProcessDefinitionBehavior) rootElement;
break;
// }
}
}
//增加模型验证,by ych 2013 12 27
if(process.isVerification()){
@SuppressWarnings("unused")
StringBuffer sb = new StringBuffer();
String result = VerificationUtil.verifyAll(process);
if(result.length() > 0){
throw new FixFlowException(result);
}
}
process.setDefinitions(definitions);
process.setResourceName(resourceBpmn.getName());