@Override public Either<ErrorCollection, PermissionGrantInput> fromBean(final PermissionGrantBean grantBean) { return validated(grantBean).map(new Function<PermissionGrantBean, PermissionGrantInput>() { @Override public PermissionGrantInput apply(final PermissionGrantBean grantBean) { return PermissionGrantInput.newGrant( holder(getActorType(grantBean).get(), grantBean.getHolder().getParameter()), new ProjectPermissionKey(grantBean.getPermission())); } }); }
@Override public Either<ErrorCollection, Collection<PermissionGrantInput>> fromBean(final List<PermissionGrantBean> permissions) { return sequenceRight(transform(firstNonNull(permissions, Collections.<PermissionGrantBean>emptyList()), new Function<PermissionGrantBean, Either<ErrorCollection, PermissionGrantInput>>() { @Override public Either<ErrorCollection, PermissionGrantInput> apply(final PermissionGrantBean grantBean) { return fromBean(grantBean); } })).map(new Function<Iterable<PermissionGrantInput>, Collection<PermissionGrantInput>>() { @Override public Collection<PermissionGrantInput> apply(final Iterable<PermissionGrantInput> grants) { return ImmutableList.copyOf(grants); } }); }
@Override public Either<ErrorCollection, PermissionSchemeInput> apply(final PermissionSchemeBean permissionScheme) { return fromBean(permissionScheme.getPermissions()).map(new Function<Collection<PermissionGrantInput>, PermissionSchemeInput>() { @Override public PermissionSchemeInput apply(final Collection<PermissionGrantInput> permissionGrants) { return PermissionSchemeInput.builder(permissionScheme.getName()) .setDescription(permissionScheme.getDescription()) .setPermissions(permissionGrants) .build(); } }); } });
@Override public Either<AttachmentError, ChangeItemBean> apply( @SuppressWarnings ("NullableProblems") final TemporaryWebAttachment tempAttachment) { final Either<AttachmentError, ChangeItemBean> conversionResult = attachmentManager.convertTemporaryAttachment( ConvertTemporaryAttachmentParams.builder() .setAuthor(user) .setIssue(issue) .setTemporaryAttachmentId(tempAttachment.getTemporaryAttachmentId()) .setFilename(tempAttachment.getFilename()) .setContentType(tempAttachment.getContentType()) .setFileSize(tempAttachment.getSize()) .setCreatedTime(tempAttachment.getCreated()) .build() ); return conversionResult.map(new Function<ChangeItemBean, ChangeItemBean>() { @Override public ChangeItemBean apply(@SuppressWarnings ("NullableProblems") final ChangeItemBean changeItemBean) { monitor.removeById(selectedAttachmentId); return changeItemBean; } }); } };