use of org.activiti.engine.ActivitiException in project Activiti by Activiti.
the class ProcessDiagramLayoutFactory method parseXml.
protected Document parseXml(InputStream bpmnXmlStream) {
// Initiate DocumentBuilderFactory
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
// Get one that understands namespaces
factory.setNamespaceAware(true);
DocumentBuilder builder;
Document bpmnModel;
try {
// Get DocumentBuilder
builder = factory.newDocumentBuilder();
// Parse and load the Document into memory
bpmnModel = builder.parse(bpmnXmlStream);
} catch (Exception e) {
throw new ActivitiException("Error while parsing BPMN model.", e);
}
return bpmnModel;
}
use of org.activiti.engine.ActivitiException in project Activiti by Activiti.
the class ProcessDiagramLayoutFactory method getDiagramBoundsFromImage.
protected DiagramNode getDiagramBoundsFromImage(InputStream imageStream, int offsetTop, int offsetBottom) {
BufferedImage image;
try {
image = ImageIO.read(imageStream);
} catch (IOException e) {
throw new ActivitiException("Error while reading process diagram image.", e);
}
DiagramNode diagramBoundsImage = getDiagramBoundsFromImage(image, offsetTop, offsetBottom);
return diagramBoundsImage;
}
use of org.activiti.engine.ActivitiException in project Activiti by Activiti.
the class DeploymentUploadReceiver method deployUploadedFile.
protected void deployUploadedFile() {
DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().name(fileName);
DeploymentFilter deploymentFilter = ExplorerApp.get().getComponentFactory(DeploymentFilterFactory.class).create();
try {
try {
if (fileName.endsWith(".bpmn20.xml") || fileName.endsWith(".bpmn")) {
validFile = true;
deploymentBuilder.addInputStream(fileName, new ByteArrayInputStream(outputStream.toByteArray()));
} else if (fileName.endsWith(".bar") || fileName.endsWith(".zip")) {
validFile = true;
deploymentBuilder.addZipInputStream(new ZipInputStream(new ByteArrayInputStream(outputStream.toByteArray())));
} else {
notificationManager.showErrorNotification(Messages.DEPLOYMENT_UPLOAD_INVALID_FILE, i18nManager.getMessage(Messages.DEPLOYMENT_UPLOAD_INVALID_FILE_EXPLANATION));
}
// If the deployment is valid, run it through the beforeDeploy and actually deploy it in Activiti
if (validFile) {
deploymentFilter.beforeDeploy(deploymentBuilder);
deployment = deploymentBuilder.deploy();
}
} catch (ActivitiException e) {
String errorMsg = e.getMessage().replace(System.getProperty("line.separator"), "<br/>");
notificationManager.showErrorNotification(Messages.DEPLOYMENT_UPLOAD_FAILED, errorMsg);
throw e;
}
} finally {
if (outputStream != null) {
try {
outputStream.close();
} catch (IOException e) {
notificationManager.showErrorNotification("Server-side error", e.getMessage());
}
}
}
}
use of org.activiti.engine.ActivitiException in project Activiti by Activiti.
the class IdentityServiceUserDetailsService method loadUserByUsername.
@Override
public UserDetails loadUserByUsername(String userId) throws UsernameNotFoundException {
User user = null;
try {
user = this.identityService.createUserQuery().userId(userId).singleResult();
} catch (ActivitiException ex) {
// don't care
}
if (null == user) {
throw new UsernameNotFoundException(String.format("user (%s) could not be found", userId));
}
// if the results not null then its active...
boolean active = true;
// get the granted authorities
List<GrantedAuthority> grantedAuthorityList = new ArrayList<GrantedAuthority>();
List<Group> groupsForUser = identityService.createGroupQuery().groupMember(user.getId()).list();
for (Group g : groupsForUser) {
grantedAuthorityList.add(new GroupGrantedAuthority(g));
}
return new org.springframework.security.core.userdetails.User(user.getId(), user.getPassword(), active, active, active, active, grantedAuthorityList);
}
use of org.activiti.engine.ActivitiException in project midpoint by Evolveum.
the class MiscDataUtil method isAmongCandidates.
// principal != null, principal.getOid() != null, principal.getUser() != null
private boolean isAmongCandidates(MidPointPrincipal principal, String taskId) {
String currentUserOid = principal.getOid();
List<IdentityLink> identityLinks;
try {
TaskService taskService = activitiEngine.getTaskService();
identityLinks = taskService.getIdentityLinksForTask(taskId);
} catch (ActivitiException e) {
throw new SystemException("Couldn't determine user authorization, because the task candidate users and groups couldn't be retrieved: " + e.getMessage(), e);
}
for (IdentityLink identityLink : identityLinks) {
if (identityLink.getUserId() != null && identityLink.getUserId().equals(currentUserOid)) {
return true;
}
if (identityLink.getGroupId() != null) {
if (isMemberOfActivitiGroup(principal.getUser(), identityLink.getGroupId())) {
return true;
}
}
}
return false;
}
Aggregations