本文整理汇总了Java中org.activiti.engine.identity.Picture.getMimeType方法的典型用法代码示例。如果您正苦于以下问题:Java Picture.getMimeType方法的具体用法?Java Picture.getMimeType怎么用?Java Picture.getMimeType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.activiti.engine.identity.Picture
的用法示例。
在下文中一共展示了Picture.getMimeType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initPicture
import org.activiti.engine.identity.Picture; //导入方法依赖的package包/类
protected void initPicture(IdentityService identityService, boolean renderPicture, final String userName) {
if(renderPicture) {
Picture picture = identityService.getUserPicture(userName);
if(picture != null) {
Resource imageResource = new StreamResource(new InputStreamStreamSource(picture.getInputStream()),
userName + picture.getMimeType(), ExplorerApp.get());
Embedded image = new Embedded(null, imageResource);
image.addStyleName(ExplorerLayout.STYLE_CLICKABLE);
image.setType(Embedded.TYPE_IMAGE);
image.setHeight(30, Embedded.UNITS_PIXELS);
image.setWidth(30, Embedded.UNITS_PIXELS);
image.addListener(new MouseEvents.ClickListener() {
private static final long serialVersionUID = 7341560240277898495L;
public void click(com.vaadin.event.MouseEvents.ClickEvent event) {
viewManager.showProfilePopup(userName);
}
});
addComponent(image);
setComponentAlignment(image, Alignment.MIDDLE_LEFT);
} else {
// TODO: what when no image is available?
}
}
}
示例2: setPicture
import org.activiti.engine.identity.Picture; //导入方法依赖的package包/类
public void setPicture(Picture picture) {
if (pictureByteArrayId!=null) {
Context
.getCommandContext()
.getDbSqlSession()
.delete(ByteArrayEntity.class, pictureByteArrayId);
}
if (picture!=null) {
pictureByteArray = new ByteArrayEntity(picture.getMimeType(), picture.getBytes());
Context
.getCommandContext()
.getDbSqlSession()
.insert(pictureByteArray);
pictureByteArrayId = pictureByteArray.getId();
} else {
pictureByteArrayId = null;
pictureByteArray = null;
}
}
示例3: getPicture
import org.activiti.engine.identity.Picture; //导入方法依赖的package包/类
@Get
public InputRepresentation getPicture() {
if(authenticate() == false) return null;
String userId = (String) getRequest().getAttributes().get("userId");
if(userId == null) {
throw new ActivitiException("No userId provided");
}
Picture picture = ActivitiUtil.getIdentityService().getUserPicture(userId);
String contentType = picture.getMimeType();
MediaType mediatType = MediaType.IMAGE_PNG;
if(contentType != null) {
if(contentType.contains(";")) {
contentType = contentType.substring(0, contentType.indexOf(";"));
}
mediatType = MediaType.valueOf(contentType);
}
InputRepresentation output = new InputRepresentation(picture.getInputStream(), mediatType);
getResponse().getCacheDirectives().add(CacheDirective.maxAge(28800));
return output;
}