use of org.eclipse.sw360.datahandler.common.SW360Utils.printName in project sw360portal by sw360.
the class ComponentPortlet method generateComponentMergeWizardStep0Response.
private void generateComponentMergeWizardStep0Response(ActionRequest request, JsonGenerator jsonGenerator) throws IOException, TException {
User sessionUser = UserCacheHolder.getUserFromRequest(request);
ComponentService.Iface cClient = thriftClients.makeComponentClient();
List<Component> componentSummary = cClient.getComponentSummary(sessionUser);
jsonGenerator.writeStartObject();
jsonGenerator.writeArrayFieldStart("components");
componentSummary.stream().forEach(component -> {
try {
jsonGenerator.writeStartObject();
jsonGenerator.writeStringField("id", component.getId());
jsonGenerator.writeStringField("name", SW360Utils.printName(component));
jsonGenerator.writeStringField("createdBy", component.getCreatedBy());
jsonGenerator.writeNumberField("releases", component.getReleaseIdsSize());
jsonGenerator.writeEndObject();
} catch (IOException e) {
log.error("An error occurred while generating wizard response", e);
}
});
jsonGenerator.writeEndArray();
jsonGenerator.writeEndObject();
}
use of org.eclipse.sw360.datahandler.common.SW360Utils.printName in project sw360portal by sw360.
the class ModerationDatabaseHandler method createRequest.
public RequestStatus createRequest(Component component, User user, Boolean isDeleteRequest) {
Component dbcomponent;
try {
dbcomponent = componentDatabaseHandler.getComponent(component.getId(), user);
} catch (SW360Exception e) {
log.error("Could not get original component from database. Could not generate moderation request.", e);
return RequestStatus.FAILURE;
}
// Define moderators
Set<String> moderators = new HashSet<>();
CommonUtils.add(moderators, dbcomponent.getCreatedBy());
try {
String department = getDepartmentByUserEmail(component.getCreatedBy());
CommonUtils.addAll(moderators, getUsersAtLeast(UserGroup.CLEARING_ADMIN, department));
} catch (TException e) {
log.error("Could not get user from database. Clearing admins not added as moderators, since department is missing.");
}
CommonUtils.addAll(moderators, getUsersAtLeast(UserGroup.ADMIN));
ModerationRequest request = createStubRequest(user, isDeleteRequest, component.getId(), moderators);
// Set meta-data
request.setDocumentType(DocumentType.COMPONENT);
request.setDocumentName(SW360Utils.printName(dbcomponent));
// Fill the request
ModerationRequestGenerator generator = new ComponentModerationRequestGenerator();
request = generator.setAdditionsAndDeletions(request, component, dbcomponent);
if (component.isSetComponentType()) {
request.setComponentType(component.getComponentType());
}
addOrUpdate(request, user);
return RequestStatus.SENT_TO_MODERATOR;
}
use of org.eclipse.sw360.datahandler.common.SW360Utils.printName in project sw360portal by sw360.
the class ModerationDatabaseHandler method createRequest.
public void createRequest(User user) {
// Define moderators
Set<String> admins = getUsersAtLeast(UserGroup.CLEARING_ADMIN, user.getDepartment());
ModerationRequest request = createStubRequest(user, false, user.getId(), admins);
// Set meta-data
request.setDocumentType(DocumentType.USER);
request.setDocumentName(SW360Utils.printName(user));
// Set the object
request.setUser(user);
addOrUpdate(request, user);
}
use of org.eclipse.sw360.datahandler.common.SW360Utils.printName in project sw360portal by sw360.
the class ModerationDatabaseHandler method createRequest.
public RequestStatus createRequest(Release release, User user, Boolean isDeleteRequest, Function<Release, Set<String>> moderatorsProvider) {
Release dbrelease;
try {
dbrelease = componentDatabaseHandler.getRelease(release.getId(), user);
} catch (SW360Exception e) {
log.error("Could not get original release from database. Could not generate moderation request.", e);
return RequestStatus.FAILURE;
}
Set<String> moderators = moderatorsProvider.apply(dbrelease);
ModerationRequest request = createStubRequest(user, isDeleteRequest, release.getId(), moderators);
// Set meta-data
request.setDocumentType(DocumentType.RELEASE);
request.setDocumentName(SW360Utils.printName(dbrelease));
// Fill the rest
SW360Utils.setVendorId(release);
SW360Utils.setVendorId(dbrelease);
ModerationRequestGenerator generator = new ReleaseModerationRequestGenerator();
request = generator.setAdditionsAndDeletions(request, release, dbrelease);
try {
Component parentComponent = componentDatabaseHandler.getComponent(release.getComponentId(), user);
request.setComponentType(parentComponent.getComponentType());
} catch (SW360Exception e) {
log.error("Could not retrieve parent component type of release with ID=" + release.getId());
}
addOrUpdate(request, user);
return RequestStatus.SENT_TO_MODERATOR;
}
use of org.eclipse.sw360.datahandler.common.SW360Utils.printName in project sw360portal by sw360.
the class ModerationDatabaseHandler method createRequest.
public RequestStatus createRequest(License license, User user) {
License dblicense;
try {
dblicense = licenseDatabaseHandler.getLicenseForOrganisation(license.getId(), user.getDepartment());
} catch (SW360Exception e) {
log.error("Could not get original license from database. Could not generate moderation request.", e);
return RequestStatus.FAILURE;
}
// Define moderators
Set<String> moderators = getLicenseModerators(user.getDepartment());
ModerationRequest request = createStubRequest(user, false, license.getId(), moderators);
// Set meta-data
request.setDocumentType(DocumentType.LICENSE);
request.setDocumentName(SW360Utils.printName(license));
// Fill the request
ModerationRequestGenerator generator = new LicenseModerationRequestGenerator();
request = generator.setAdditionsAndDeletions(request, license, dblicense);
addOrUpdate(request, user);
return RequestStatus.SENT_TO_MODERATOR;
}
Aggregations