public static Icon toIcon(SIcon icon) { return new IconImpl(icon.getId(), icon.getMimeType(), icon.getContent()); }
private void replaceIcon(EntityUpdateDescriptor updateDescriptor, byte[] content, String filename, SHavingIcon element) throws SRecorderException, SBonitaReadException { SIcon newIcon = createIcon(filename, content); updateDescriptor.addField("iconId", newIcon.getId()); Long previousIconId = element.getIconId(); if (previousIconId != null) { deleteIcon(previousIconId); } }
private void replaceIcon(EntityUpdateDescriptor updateDescriptor, byte[] content, String filename, SHavingIcon element) throws SRecorderException, SBonitaReadException { SIcon newIcon = createIcon(filename, content); updateDescriptor.addField("iconId", newIcon.getId()); Long previousIconId = element.getIconId(); if (previousIconId != null) { deleteIcon(previousIconId); } }
public static Icon toIcon(SIcon icon) { return new IconImpl(icon.getId(), icon.getMimeType(), icon.getContent()); }
@Override public void createRole(final SRole role, String iconFilename, byte[] iconContent) throws SIdentityException { final String methodName = "createRole"; final SRoleLogBuilder logBuilder = getRoleLog(ActionType.CREATED, "Adding a new role with name " + role.getName()); try { if (iconFilename != null && iconContent != null) { SIcon icon = createIcon(iconFilename, iconContent); (((SRoleImpl) role)).setIconId(icon.getId()); } recorder.recordInsert(new InsertRecord(role), ROLE); log(role.getId(), SQueriableLog.STATUS_OK, logBuilder, methodName); } catch (final SRecorderException e) { log(role.getId(), SQueriableLog.STATUS_FAIL, logBuilder, methodName); throw new SIdentityException("Can't add role " + role, e); } }
@Override public void createRole(final SRole role, String iconFilename, byte[] iconContent) throws SIdentityException { final String methodName = "createRole"; final SRoleLogBuilder logBuilder = getRoleLog(ActionType.CREATED, "Adding a new role with name " + role.getName()); try { if (iconFilename != null && iconContent != null) { SIcon icon = createIcon(iconFilename, iconContent); (((SRoleImpl) role)).setIconId(icon.getId()); } recorder.recordInsert(new InsertRecord(role), ROLE); log(role.getId(), SQueriableLog.STATUS_OK, logBuilder, methodName); } catch (final SRecorderException e) { log(role.getId(), SQueriableLog.STATUS_FAIL, logBuilder, methodName); throw new SIdentityException("Can't add role " + role, e); } }
@Override public void createGroup(final SGroup group, String iconFileName, byte[] iconContent) throws SGroupCreationException { final String methodName = "createGroup"; final long objectId = group.getId(); final SGroupLogBuilder logBuilder = getGroupLog(ActionType.CREATED, "Adding a new group with name " + group.getName()); try { if (iconFileName != null && iconContent != null) { SIcon icon = createIcon(iconFileName, iconContent); ((SGroupImpl) group).setIconId(icon.getId()); } final InsertRecord insertRecord = new InsertRecord(group); recorder.recordInsert(insertRecord, GROUP); final int status = SQueriableLog.STATUS_OK; log(insertRecord.getEntity().getId(), status, logBuilder, methodName); } catch (final SRecorderException re) { final int status = SQueriableLog.STATUS_FAIL; log(objectId, status, logBuilder, methodName); throw new SGroupCreationException(re); } }
@Override public void createGroup(final SGroup group, String iconFileName, byte[] iconContent) throws SGroupCreationException { final String methodName = "createGroup"; final long objectId = group.getId(); final SGroupLogBuilder logBuilder = getGroupLog(ActionType.CREATED, "Adding a new group with name " + group.getName()); try { if (iconFileName != null && iconContent != null) { SIcon icon = createIcon(iconFileName, iconContent); ((SGroupImpl) group).setIconId(icon.getId()); } final InsertRecord insertRecord = new InsertRecord(group); recorder.recordInsert(insertRecord, GROUP); final int status = SQueriableLog.STATUS_OK; log(insertRecord.getEntity().getId(), status, logBuilder, methodName); } catch (final SRecorderException re) { final int status = SQueriableLog.STATUS_FAIL; log(objectId, status, logBuilder, methodName); throw new SGroupCreationException(re); } }
@Override public SUser createUser(SUser sUser, SContactInfo personalContactInfo, SContactInfo proContactInfo, String iconFilename, byte[] iconContent) throws SUserCreationException { if (iconFilename != null && iconContent != null) { try { SIcon icon = createIcon(iconFilename, iconContent); ((SUserImpl) sUser).setIconId(icon.getId()); } catch (SRecorderException e) { throw new SUserCreationException(e); } } SUser user = createUser(sUser); if (personalContactInfo != null) { createUserContactInfo(BuilderFactory.get(SContactInfoBuilderFactory.class).createNewInstance(personalContactInfo).setUserId(user.getId()).done()); } if (proContactInfo != null) { createUserContactInfo(BuilderFactory.get(SContactInfoBuilderFactory.class).createNewInstance(proContactInfo).setUserId(user.getId()).done()); } return user; }
@Override public SUser createUser(SUser sUser, SContactInfo personalContactInfo, SContactInfo proContactInfo, String iconFilename, byte[] iconContent) throws SUserCreationException { if (iconFilename != null && iconContent != null) { try { SIcon icon = createIcon(iconFilename, iconContent); ((SUserImpl) sUser).setIconId(icon.getId()); } catch (SRecorderException e) { throw new SUserCreationException(e); } } SUser user = createUser(sUser); if (personalContactInfo != null) { createUserContactInfo(BuilderFactory.get(SContactInfoBuilderFactory.class).createNewInstance(personalContactInfo).setUserId(user.getId()).done()); } if (proContactInfo != null) { createUserContactInfo(BuilderFactory.get(SContactInfoBuilderFactory.class).createNewInstance(proContactInfo).setUserId(user.getId()).done()); } return user; }