Source:
public final Response createType(@Context final HttpServletRequest req, final ContentTypeForm form) throws DotDataException { final InitDataObject initData = this.webResource.init(null, true, req, true, null); final User user = initData.getUser(); Response response = null; try { Logger.debug(this, String.format("Saving new content type", form.getRequestJson())); final Iterable<ContentTypeForm.ContentTypeFormEntry> typesToSave = form.getIterable(); final List<Map<Object, Object>> retTypes = new ArrayList<>(); for (final ContentTypeForm.ContentTypeFormEntry entry : typesToSave) { final ContentType type = entry.contentType; final List<String> workflowsIds = entry.workflowsIds; if (UtilMethods.isSet(type.id()) && !UUIDUtil.isUUID(type.id())) { return ExceptionMapperUtil.createResponse(null, "ContentType 'id' if set, should be a uuid"); } final ContentType contentTypeSaved = APILocator.getContentTypeAPI(user, true).save(type); this.workflowHelper.saveSchemesByContentType(contentTypeSaved.id(), user, workflowsIds); ImmutableMap<Object, Object> responseMap = ImmutableMap.builder() .putAll(new JsonContentTypeTransformer(contentTypeSaved).mapObject()) .put("workflows", this.workflowHelper.findSchemesByContentType(contentTypeSaved.id(), initData.getUser())) .build(); retTypes.add(responseMap); req.getSession().setAttribute("selectedStructure",contentTypeSaved.inode()); } response = Response.ok(new ResponseEntityView(retTypes)).build(); } catch (DotStateException | DotDataException e) { Logger.error(this, e.getMessage(), e); response = ExceptionMapperUtil .createResponse(null, "Content-type is not valid (" + e.getMessage() + ")"); } catch (DotSecurityException e) { throw new ForbiddenException(e); } catch (Exception e) { response = ExceptionMapperUtil.createResponse(e, Response.Status.INTERNAL_SERVER_ERROR); } return response; }

Target:
public final Response createType(@Context final HttpServletRequest req, final ContentTypeForm form) throws DotDataException { final InitDataObject initData = this.webResource.init(null, true, req, true, null); final User user = initData.getUser(); Response response = null; try { Logger.debug(this, String.format("Saving new content type", form.getRequestJson())); final HttpSession session = req.getSession(false); final Iterable<ContentTypeForm.ContentTypeFormEntry> typesToSave = form.getIterable(); final List<Map<Object, Object>> retTypes = new ArrayList<>(); for (final ContentTypeForm.ContentTypeFormEntry entry : typesToSave) { final ContentType type = entry.contentType; final List<String> workflowsIds = entry.workflowsIds; if (UtilMethods.isSet(type.id()) && !UUIDUtil.isUUID(type.id())) { return ExceptionMapperUtil.createResponse(null, "ContentType 'id' if set, should be a uuid"); } final ContentType contentTypeSaved = APILocator.getContentTypeAPI(user, true).save(type); this.workflowHelper.saveSchemesByContentType(contentTypeSaved.id(), user, workflowsIds); ImmutableMap<Object, Object> responseMap = ImmutableMap.builder() .putAll(new JsonContentTypeTransformer(contentTypeSaved).mapObject()) .put("workflows", this.workflowHelper.findSchemesByContentType(contentTypeSaved.id(), initData.getUser())) .build(); retTypes.add(responseMap); if(null != session){ session.setAttribute("selectedStructure", contentTypeSaved.inode()); } } response = Response.ok(new ResponseEntityView(retTypes)).build(); } catch (DotStateException | DotDataException e) { Logger.error(this, e.getMessage(), e); response = ExceptionMapperUtil .createResponse(null, "Content-type is not valid (" + e.getMessage() + ")"); } catch (DotSecurityException e) { throw new ForbiddenException(e); } catch (Exception e) { response = ExceptionMapperUtil.createResponse(e, Response.Status.INTERNAL_SERVER_ERROR); } return response; }