io.securecodebox.persistence.defectdojo.service.UserProfileService Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of defectdojo-client Show documentation
Show all versions of defectdojo-client Show documentation
This library helps with interacting with the REST API of DefectDojo.
The newest version!
// SPDX-FileCopyrightText: the secureCodeBox authors
//
// SPDX-License-Identifier: Apache-2.0
package io.securecodebox.persistence.defectdojo.service;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import io.securecodebox.persistence.defectdojo.config.Config;
import io.securecodebox.persistence.defectdojo.model.PaginatedResult;
import io.securecodebox.persistence.defectdojo.model.UserProfile;
import lombok.NonNull;
import java.util.List;
public final class UserProfileService extends GenericDefectDojoService {
public UserProfileService(Config config) {
super(config);
}
@Override
protected String getUrlPath() {
return "user_profile";
}
@Override
protected Class getModelClass() {
return UserProfile.class;
}
@Override
protected PaginatedResult deserializeList(@NonNull String response) throws JsonProcessingException {
/* GenericDefectDojoService expects that the response from the defectdojo api is a list.
* This endpoint returns a single object though, to not break the code this response
* gets converted to a defectdojo response.
*/
final var userProfile = this.objectMapper.readValue(response, new TypeReference() {
});
final var result = new PaginatedResult();
result.setResults(List.of(userProfile));
result.setCount(1);
return result;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy