本文整理汇总了Java中org.eclipse.che.api.user.shared.dto.ProfileDto类的典型用法代码示例。如果您正苦于以下问题:Java ProfileDto类的具体用法?Java ProfileDto怎么用?Java ProfileDto使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ProfileDto类属于org.eclipse.che.api.user.shared.dto包,在下文中一共展示了ProfileDto类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getById
import org.eclipse.che.api.user.shared.dto.ProfileDto; //导入依赖的package包/类
@GET
@Path("/{id}")
@Produces(APPLICATION_JSON)
@GenerateLink(rel = LINK_REL_CURRENT_PROFILE)
@ApiOperation("Get profile by user's id")
@ApiResponses({
@ApiResponse(code = 200, message = "The response contains requested profile entity"),
@ApiResponse(
code = 404,
message = "Profile for the user with requested identifier doesn't exist"
),
@ApiResponse(code = 500, message = "Couldn't retrieve profile due to internal server error")
})
public ProfileDto getById(@ApiParam("User identifier") @PathParam("id") String userId)
throws NotFoundException, ServerException {
return linksInjector.injectLinks(
asDto(profileManager.getById(userId), userManager.getById(userId)), getServiceContext());
}
示例2: updateAttributes
import org.eclipse.che.api.user.shared.dto.ProfileDto; //导入依赖的package包/类
@PUT
@Path("/attributes")
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@GenerateLink(rel = LINK_REL_CURRENT_PROFILE_ATTRIBUTES)
@ApiOperation(
value = "Update the profile attributes of the currently logged in user",
notes =
"The replace strategy is used for the update, so all the existing profile "
+ "attributes will be override with incoming values"
)
public ProfileDto updateAttributes(
@ApiParam("New profile attributes") Map<String, String> updates)
throws NotFoundException, ServerException, BadRequestException {
checkAttributes(updates);
final ProfileImpl profile = new ProfileImpl(profileManager.getById(userId()));
profile.setAttributes(updates);
profileManager.update(profile);
return linksInjector.injectLinks(
asDto(profile, userManager.getById(profile.getUserId())), getServiceContext());
}
示例3: getName
import org.eclipse.che.api.user.shared.dto.ProfileDto; //导入依赖的package包/类
private String getName() {
try {
Link link =
DtoFactory.getInstance()
.createDto(Link.class)
.withMethod("GET")
.withHref(UriBuilder.fromUri(apiEndpoint).path("profile").build().toString());
final ProfileDto profile = HttpJsonHelper.request(ProfileDto.class, link);
String name = profile.getAttributes().get("firstName");
String lastName = profile.getAttributes().get("lastName");
if (null != lastName) {
name = null != name ? name + " " + lastName : lastName;
}
return name;
} catch (IOException
| ServerException
| UnauthorizedException
| ForbiddenException
| NotFoundException
| ConflictException e) {
LOG.warn(e.getLocalizedMessage());
}
return EnvironmentContext.getCurrent().getSubject().getUserId();
}
示例4: getCurrent
import org.eclipse.che.api.user.shared.dto.ProfileDto; //导入依赖的package包/类
@GET
@Produces(APPLICATION_JSON)
@GenerateLink(rel = LINK_REL_CURRENT_PROFILE)
@ApiOperation("Get profile of the logged in user")
@ApiResponses({
@ApiResponse(code = 200, message = "The response contains requested profile entity"),
@ApiResponse(code = 404, message = "Currently logged in user doesn't have profile"),
@ApiResponse(code = 500, message = "Couldn't retrieve profile due to internal server error")
})
public ProfileDto getCurrent() throws ServerException, NotFoundException {
final ProfileImpl profile = new ProfileImpl(profileManager.getById(userId()));
return linksInjector.injectLinks(
asDto(profile, userManager.getById(profile.getUserId())), getServiceContext());
}
示例5: updateAttributesById
import org.eclipse.che.api.user.shared.dto.ProfileDto; //导入依赖的package包/类
@PUT
@Path("/{id}/attributes")
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@ApiOperation(
value = "Update the profile attributes of the user with requested identifier",
notes =
"The replace strategy is used for the update, so all the existing profile "
+ "attributes will be override by the profile update"
)
@ApiResponses({
@ApiResponse(
code = 200,
message =
"The profile successfully updated and the response contains "
+ "newly updated profile entity"
),
@ApiResponse(
code = 404,
message = "When profile for the user with requested identifier doesn't exist"
),
@ApiResponse(code = 500, message = "Couldn't retrieve profile due to internal server error")
})
public ProfileDto updateAttributesById(
@ApiParam("Id of the user") @PathParam("id") String userId,
@ApiParam("New profile attributes") Map<String, String> updates)
throws NotFoundException, ServerException, BadRequestException {
checkAttributes(updates);
final ProfileImpl profile = new ProfileImpl(profileManager.getById(userId));
profile.setAttributes(updates);
profileManager.update(profile);
return linksInjector.injectLinks(
asDto(profile, userManager.getById(userId)), getServiceContext());
}
示例6: shouldGetCurrentProfile
import org.eclipse.che.api.user.shared.dto.ProfileDto; //导入依赖的package包/类
@Test
public void shouldGetCurrentProfile() throws Exception {
final Response response =
given()
.auth()
.basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD)
.when()
.get(SECURE_PATH + "/profile");
assertEquals(response.getStatusCode(), 200);
final ProfileDto profileDto = unwrapDto(response, ProfileDto.class);
assertEquals(profileDto.getUserId(), SUBJECT.getUserId());
}
示例7: shouldGetProfileById
import org.eclipse.che.api.user.shared.dto.ProfileDto; //导入依赖的package包/类
@Test
public void shouldGetProfileById() throws Exception {
final Response response =
given()
.auth()
.basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD)
.when()
.get(SECURE_PATH + "/profile/" + SUBJECT.getUserId());
assertEquals(response.getStatusCode(), 200);
final ProfileDto profileDto = unwrapDto(response, ProfileDto.class);
assertEquals(profileDto.getUserId(), SUBJECT.getUserId());
}
示例8: shouldInjectProfileLinks
import org.eclipse.che.api.user.shared.dto.ProfileDto; //导入依赖的package包/类
@Test
public void shouldInjectProfileLinks() throws Exception {
final ProfileDto profileDto =
DtoFactory.newDto(ProfileDto.class).withUserId("user123").withEmail("[email protected]");
linksInjector.injectLinks(profileDto, serviceContext);
// [rel, method] pairs links
final Set<Pair<String, String>> links =
profileDto
.getLinks()
.stream()
.map(link -> Pair.of(link.getMethod(), link.getRel()))
.collect(Collectors.toSet());
final Set<Pair<String, String>> expectedLinks =
new HashSet<>(
asList(
Pair.of("GET", Constants.LINK_REL_SELF),
Pair.of("GET", Constants.LINK_REL_CURRENT_PROFILE),
Pair.of("PUT", Constants.LINK_REL_PROFILE_ATTRIBUTES),
Pair.of("PUT", Constants.LINK_REL_CURRENT_PROFILE_ATTRIBUTES),
Pair.of("DELETE", Constants.LINK_REL_CURRENT_PROFILE_ATTRIBUTES)));
assertEquals(
links,
expectedLinks,
"Difference " + Sets.symmetricDifference(links, expectedLinks) + "\n");
}
示例9: loadProfile
import org.eclipse.che.api.user.shared.dto.ProfileDto; //导入依赖的package包/类
private Promise<ProfileDto> loadProfile() {
return getUserProfile()
.catchError(
(Operation<PromiseError>)
arg -> {
throw new OperationException("Unable to load user's profile: " + arg.getCause());
});
}
示例10: asDto
import org.eclipse.che.api.user.shared.dto.ProfileDto; //导入依赖的package包/类
private static ProfileDto asDto(Profile profile, User user) {
return DtoFactory.newDto(ProfileDto.class)
.withUserId(profile.getUserId())
.withEmail(user.getEmail())
.withAttributes(profile.getAttributes());
}
示例11: injectLinks
import org.eclipse.che.api.user.shared.dto.ProfileDto; //导入依赖的package包/类
public ProfileDto injectLinks(ProfileDto profileDto, ServiceContext serviceContext) {
final UriBuilder uriBuilder = serviceContext.getServiceUriBuilder();
final List<Link> links = new ArrayList<>(5);
links.add(
createLink(
HttpMethod.GET,
uriBuilder.clone().path(ProfileService.class, "getCurrent").build().toString(),
null,
APPLICATION_JSON,
LINK_REL_CURRENT_PROFILE));
links.add(
createLink(
HttpMethod.GET,
uriBuilder
.clone()
.path(ProfileService.class, "getById")
.build(profileDto.getUserId())
.toString(),
null,
APPLICATION_JSON,
LINK_REL_SELF));
links.add(
createLink(
HttpMethod.PUT,
uriBuilder.clone().path(ProfileService.class, "updateAttributes").build().toString(),
APPLICATION_JSON,
APPLICATION_JSON,
LINK_REL_CURRENT_PROFILE_ATTRIBUTES));
links.add(
createLink(
HttpMethod.DELETE,
uriBuilder
.clone()
.path(ProfileService.class, "removeAttributes")
.build(profileDto.getUserId())
.toString(),
APPLICATION_JSON,
APPLICATION_JSON,
LINK_REL_CURRENT_PROFILE_ATTRIBUTES));
links.add(
createLink(
HttpMethod.PUT,
uriBuilder
.clone()
.path(ProfileService.class, "updateAttributesById")
.build(profileDto.getUserId())
.toString(),
APPLICATION_JSON,
APPLICATION_JSON,
LINK_REL_PROFILE_ATTRIBUTES));
return profileDto.withLinks(links);
}
示例12: getUserProfile
import org.eclipse.che.api.user.shared.dto.ProfileDto; //导入依赖的package包/类
private Promise<ProfileDto> getUserProfile() {
return asyncRequestFactory
.createGetRequest(appContext.getMasterApiEndpoint() + "/profile/")
.header(ACCEPT, APPLICATION_JSON)
.send(dtoUnmarshallerFactory.newUnmarshaller(ProfileDto.class));
}