diff --git a/backend/src/src-licenses/src/main/java/org/eclipse/sw360/licenses/LicenseHandler.java b/backend/src/src-licenses/src/main/java/org/eclipse/sw360/licenses/LicenseHandler.java index f80a7fc561..5969ac8fa9 100644 --- a/backend/src/src-licenses/src/main/java/org/eclipse/sw360/licenses/LicenseHandler.java +++ b/backend/src/src-licenses/src/main/java/org/eclipse/sw360/licenses/LicenseHandler.java @@ -319,4 +319,11 @@ public RequestSummary importAllSpdxLicenses(User user) throws TException { return handler.importAllSpdxLicenses(user); } + @Override + public RequestStatus deleteTodo(String id, User user) throws TException { + assertId(id); + assertUser(user); + return handler.deleteTodo(id, user); + } + } diff --git a/backend/src/src-licenses/src/main/java/org/eclipse/sw360/licenses/db/LicenseDatabaseHandler.java b/backend/src/src-licenses/src/main/java/org/eclipse/sw360/licenses/db/LicenseDatabaseHandler.java index d20ab4994f..c83f4d9e4f 100644 --- a/backend/src/src-licenses/src/main/java/org/eclipse/sw360/licenses/db/LicenseDatabaseHandler.java +++ b/backend/src/src-licenses/src/main/java/org/eclipse/sw360/licenses/db/LicenseDatabaseHandler.java @@ -27,6 +27,7 @@ import org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest; import org.eclipse.sw360.datahandler.thrift.users.RequestedAction; import org.eclipse.sw360.datahandler.thrift.users.User; +import org.eclipse.sw360.datahandler.thrift.users.UserGroup; import org.eclipse.sw360.licenses.tools.SpdxConnector; import org.apache.log4j.Logger; @@ -43,7 +44,6 @@ import static org.eclipse.sw360.datahandler.common.SW360Assert.assertNotNull; import static org.eclipse.sw360.datahandler.permissions.PermissionUtils.makePermission; import static org.eclipse.sw360.datahandler.thrift.ThriftValidate.*; -import static org.eclipse.sw360.datahandler.thrift.users.UserGroup.CLEARING_ADMIN; /** * Class for accessing the CouchDB database @@ -222,7 +222,7 @@ private void fillLicenseForOrganisation(String organisation, License license) { * @return ID of the added todo. */ public String addTodo(@NotNull Todo todo, User user) throws SW360Exception { - if (!PermissionUtils.isUserAtLeast(CLEARING_ADMIN, user)){ + if (!PermissionUtils.isUserAtLeast(UserGroup.CLEARING_ADMIN, user)){ return null; } prepareTodo(todo); @@ -533,7 +533,7 @@ private List getLicenseTypesFromLicenses(List licenses) { } public List addRiskCategories(List riskCategories, User user) throws SW360Exception { - if (!PermissionUtils.isUserAtLeast(CLEARING_ADMIN, user)){ + if (!PermissionUtils.isUserAtLeast(UserGroup.CLEARING_ADMIN, user)){ return null; } for (RiskCategory riskCategory : riskCategories) { @@ -547,7 +547,7 @@ public List addRiskCategories(List riskCategories, U } public List addRisks(List risks, User user) throws SW360Exception { - if (!PermissionUtils.isUserAtLeast(CLEARING_ADMIN, user)){ + if (!PermissionUtils.isUserAtLeast(UserGroup.CLEARING_ADMIN, user)){ return null; } for (Risk risk : risks) { @@ -561,7 +561,7 @@ public List addRisks(List risks, User user) throws SW360Exception { } public List addLicenseTypes(List licenseTypes, User user) { - if (!PermissionUtils.isUserAtLeast(CLEARING_ADMIN, user)){ + if (!PermissionUtils.isUserAtLeast(UserGroup.CLEARING_ADMIN, user)){ return null; } final List documentOperationResults = licenseTypeRepository.executeBulk(licenseTypes); @@ -605,7 +605,7 @@ public List addOrOverwriteLicenses(List licenses, User user, b } public List addObligations(List obligations, User user) throws SW360Exception { - if (!PermissionUtils.isUserAtLeast(CLEARING_ADMIN, user)){ + if (!PermissionUtils.isUserAtLeast(UserGroup.CLEARING_ADMIN, user)){ return null; } for (Obligation obligation : obligations) { @@ -619,7 +619,7 @@ public List addObligations(List obligations, User user) } public List addTodos(List todos, User user) throws SW360Exception { - if (!PermissionUtils.isUserAtLeast(CLEARING_ADMIN, user)){ + if (!PermissionUtils.isUserAtLeast(UserGroup.CLEARING_ADMIN, user)){ return null; } for (Todo todo : todos) { @@ -897,4 +897,18 @@ public RequestSummary importAllSpdxLicenses(User user) { .setTotalElements(spdxIds.size()) .setRequestStatus(RequestStatus.SUCCESS); } + + public RequestStatus deleteTodo(String id, User user) throws SW360Exception { + Todo todo = todoRepository.get(id); + assertNotNull(todo); + + // Remove the license if the user is allowed to do it by himself + if (PermissionUtils.isUserAtLeast(UserGroup.SW360_ADMIN, user)) { + todoRepository.remove(todo); + return RequestStatus.SUCCESS; + } else { + log.error(user + " does not have the permission to delete todo."); + return RequestStatus.ACCESS_DENIED; + } + } } diff --git a/frontend/configuration/PrivatePages.lar b/frontend/configuration/PrivatePages.lar index b042315726..b5c15110ce 100644 Binary files a/frontend/configuration/PrivatePages.lar and b/frontend/configuration/PrivatePages.lar differ diff --git a/frontend/sw360-portlet/src/main/java/org/eclipse/sw360/portal/common/PortalConstants.java b/frontend/sw360-portlet/src/main/java/org/eclipse/sw360/portal/common/PortalConstants.java index 9ca4704300..226bc6a7de 100644 --- a/frontend/sw360-portlet/src/main/java/org/eclipse/sw360/portal/common/PortalConstants.java +++ b/frontend/sw360-portlet/src/main/java/org/eclipse/sw360/portal/common/PortalConstants.java @@ -58,6 +58,7 @@ public class PortalConstants { public static final String PAGENAME_DETAIL = "detail"; public static final String PAGENAME_VIEW = "view"; public static final String PAGENAME_IMPORT = "import"; + public static final String PAGENAME_ADD = "add"; public static final String PAGENAME_EDIT = "edit"; public static final String PAGENAME_ACTION = "action"; public static final String PAGENAME_DUPLICATE = "duplicate"; @@ -126,6 +127,10 @@ public class PortalConstants { public static final String VENDOR_ID = "vendorId"; public static final String VENDOR_LIST = "vendorList"; + //! Specialized keys for todos + public static final String TODO_LIST = "todoList"; + public static final String TODO_ID = "todoId"; + //! Specialized keys for attachments public static final String ATTACHMENTS = "attachments"; public static final String SPDX_ATTACHMENTS = "spdxAttachments"; @@ -341,6 +346,9 @@ public class PortalConstants { // vendor actions public static final String REMOVE_VENDOR = "remove_vendor"; + // todo actions + public static final String REMOVE_TODO = "removeTodo"; + // user actions public static final String USER_PREFIX = "user"; public static final String USER_SEARCH = USER_PREFIX + "search"; diff --git a/frontend/sw360-portlet/src/main/java/org/eclipse/sw360/portal/portlets/admin/TodoPortlet.java b/frontend/sw360-portlet/src/main/java/org/eclipse/sw360/portal/portlets/admin/TodoPortlet.java new file mode 100644 index 0000000000..576b215893 --- /dev/null +++ b/frontend/sw360-portlet/src/main/java/org/eclipse/sw360/portal/portlets/admin/TodoPortlet.java @@ -0,0 +1,108 @@ +/* + * Copyright Siemens AG, 2013-2015. Part of the SW360 Portal Project. + * + * SPDX-License-Identifier: EPL-1.0 + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.eclipse.sw360.portal.portlets.admin; + +import org.apache.log4j.Logger; +import org.apache.thrift.TException; +import org.eclipse.sw360.datahandler.permissions.PermissionUtils; +import org.eclipse.sw360.datahandler.thrift.RequestStatus; +import org.eclipse.sw360.datahandler.thrift.licenses.LicenseService; +import org.eclipse.sw360.datahandler.thrift.licenses.Todo; +import org.eclipse.sw360.datahandler.thrift.users.User; +import org.eclipse.sw360.datahandler.thrift.users.UserGroup; +import org.eclipse.sw360.portal.common.UsedAsLiferayAction; +import org.eclipse.sw360.portal.portlets.Sw360Portlet; +import org.eclipse.sw360.portal.portlets.components.ComponentPortletUtils; +import org.eclipse.sw360.portal.users.UserCacheHolder; + +import javax.portlet.*; +import java.io.IOException; +import java.util.Collections; +import java.util.List; + +import static org.eclipse.sw360.portal.common.PortalConstants.*; + +/** + * Todo portlet implementation + * + * @author nikolas@endocode.com + */ +public class TodoPortlet extends Sw360Portlet { + + private static final Logger log = Logger.getLogger(TodoPortlet.class); + + + //! Serve resource and helpers + @Override + public void serveResource(ResourceRequest request, ResourceResponse response) { + + final String id = request.getParameter("id"); + final User user = UserCacheHolder.getUserFromRequest(request); + + LicenseService.Iface licenseClient = thriftClients.makeLicenseClient(); + + + try { + RequestStatus status = licenseClient.deleteTodo(id, user); + renderRequestStatus(request,response, status); + } catch (TException e) { + log.error("Error deleting todo", e); + renderRequestStatus(request,response, RequestStatus.FAILURE); + } + } + + + //! VIEW and helpers + @Override + public void doView(RenderRequest request, RenderResponse response) throws IOException, PortletException { + + + String pageName = request.getParameter(PAGENAME); + if (PAGENAME_ADD.equals(pageName)) { + include("/html/admin/todos/add.jsp", request, response); + } else { + prepareStandardView(request); + super.doView(request, response); + } + } + + private void prepareStandardView(RenderRequest request) { + List todoList; + try { + final User user = UserCacheHolder.getUserFromRequest(request); + LicenseService.Iface licenseClient = thriftClients.makeLicenseClient(); + + todoList = licenseClient.getTodos(); + + } catch (TException e) { + log.error("Could not get Todos from backend ", e); + todoList = Collections.emptyList(); + } + + request.setAttribute(TODO_LIST, todoList); + } + + @UsedAsLiferayAction + public void addTodo(ActionRequest request, ActionResponse response) { + + final Todo todo = new Todo(); + ComponentPortletUtils.updateTodoFromRequest(request, todo); + + try { + LicenseService.Iface licenseClient = thriftClients.makeLicenseClient(); + final User user = UserCacheHolder.getUserFromRequest(request); + + licenseClient.addTodo(todo, user); + } catch (TException e) { + log.error("Error adding todo", e); + } + } +} diff --git a/frontend/sw360-portlet/src/main/java/org/eclipse/sw360/portal/portlets/components/ComponentPortletUtils.java b/frontend/sw360-portlet/src/main/java/org/eclipse/sw360/portal/portlets/components/ComponentPortletUtils.java index 721c250d97..a54159188e 100644 --- a/frontend/sw360-portlet/src/main/java/org/eclipse/sw360/portal/portlets/components/ComponentPortletUtils.java +++ b/frontend/sw360-portlet/src/main/java/org/eclipse/sw360/portal/portlets/components/ComponentPortletUtils.java @@ -15,6 +15,7 @@ import org.eclipse.sw360.datahandler.common.SW360Utils; import org.eclipse.sw360.datahandler.thrift.*; import org.eclipse.sw360.datahandler.thrift.components.*; +import org.eclipse.sw360.datahandler.thrift.licenses.Todo; import org.eclipse.sw360.datahandler.thrift.users.RequestedAction; import org.eclipse.sw360.datahandler.thrift.users.User; import org.eclipse.sw360.datahandler.thrift.vendors.Vendor; @@ -148,6 +149,12 @@ public static void updateVendorFromRequest(PortletRequest request, Vendor vendor setFieldValue(request, vendor, Vendor._Fields.URL); } + public static void updateTodoFromRequest(PortletRequest request, Todo todo) { + setFieldValue(request, todo, Todo._Fields.TITLE); + setFieldValue(request, todo, Todo._Fields.TEXT); + setFieldValue(request, todo, Todo._Fields.VALID_FOR_PROJECT); + } + private static void updateLinkedReleaseFromRequest(PortletRequest request, Map linkedReleases) { linkedReleases.clear(); String[] ids = request.getParameterValues(Release._Fields.RELEASE_ID_TO_RELATIONSHIP.toString() + ReleaseLink._Fields.ID.toString()); @@ -186,6 +193,10 @@ private static void setFieldValue(PortletRequest request, Vendor vendor, Vendor. PortletUtils.setFieldValue(request, vendor, field, Vendor.metaDataMap.get(field), ""); } + private static void setFieldValue(PortletRequest request, Todo todo, Todo._Fields field) { + PortletUtils.setFieldValue(request, todo, field, Todo.metaDataMap.get(field), ""); + } + public static RequestStatus deleteRelease(PortletRequest request, Logger log) { String releaseId = request.getParameter(PortalConstants.RELEASE_ID); if (releaseId != null) { diff --git a/frontend/sw360-portlet/src/main/java/org/eclipse/sw360/portal/tags/CompareTodos.java b/frontend/sw360-portlet/src/main/java/org/eclipse/sw360/portal/tags/CompareTodos.java index 7c7330d0de..d715df52f0 100644 --- a/frontend/sw360-portlet/src/main/java/org/eclipse/sw360/portal/tags/CompareTodos.java +++ b/frontend/sw360-portlet/src/main/java/org/eclipse/sw360/portal/tags/CompareTodos.java @@ -188,7 +188,7 @@ private static boolean isFieldRelevant(Todo._Fields field) { case REVISION: case TYPE: case OBLIGATION_DATABASE_IDS: - case TODO_ID: + case TITLE: case DEVELOPMENT_STRING: case DISTRIBUTION_STRING: case WHITELIST: diff --git a/frontend/sw360-portlet/src/main/webapp/WEB-INF/liferay-display.xml b/frontend/sw360-portlet/src/main/webapp/WEB-INF/liferay-display.xml index cecef4f774..dce4e8c7b7 100644 --- a/frontend/sw360-portlet/src/main/webapp/WEB-INF/liferay-display.xml +++ b/frontend/sw360-portlet/src/main/webapp/WEB-INF/liferay-display.xml @@ -15,6 +15,7 @@ + diff --git a/frontend/sw360-portlet/src/main/webapp/WEB-INF/liferay-portlet.xml b/frontend/sw360-portlet/src/main/webapp/WEB-INF/liferay-portlet.xml index 5381ae11bd..d534b5d878 100644 --- a/frontend/sw360-portlet/src/main/webapp/WEB-INF/liferay-portlet.xml +++ b/frontend/sw360-portlet/src/main/webapp/WEB-INF/liferay-portlet.xml @@ -112,6 +112,17 @@ /js/main.js + + todos + /icon.png + false + false + /css/main.css + /css/print.css + /css/tooltips.css + /js/main.js + + projects /icon.png diff --git a/frontend/sw360-portlet/src/main/webapp/WEB-INF/portlet.xml b/frontend/sw360-portlet/src/main/webapp/WEB-INF/portlet.xml index 6ef0331999..3625af148d 100644 --- a/frontend/sw360-portlet/src/main/webapp/WEB-INF/portlet.xml +++ b/frontend/sw360-portlet/src/main/webapp/WEB-INF/portlet.xml @@ -656,6 +656,31 @@ + + todos + TODOs + + org.eclipse.sw360.portal.portlets.admin.TodoPortlet + + + view-template + /html/admin/todos/view.jsp + + 0 + + text/html + view + + + TODOs + TODOs + + + + administrator + + + signup Sign-Up diff --git a/frontend/sw360-portlet/src/main/webapp/html/admin/todos/add.jsp b/frontend/sw360-portlet/src/main/webapp/html/admin/todos/add.jsp new file mode 100644 index 0000000000..4909993592 --- /dev/null +++ b/frontend/sw360-portlet/src/main/webapp/html/admin/todos/add.jsp @@ -0,0 +1,100 @@ +<%-- + ~ Copyright Siemens AG, 2013-2017. Part of the SW360 Portal Project. + ~ + ~ SPDX-License-Identifier: EPL-1.0 + ~ + ~ All rights reserved. This program and the accompanying materials + ~ are made available under the terms of the Eclipse Public License v1.0 + ~ which accompanies this distribution, and is available at + ~ http://www.eclipse.org/legal/epl-v10.html + --%> +<%@ page import="org.eclipse.sw360.portal.common.PortalConstants" %> +<%@include file="/html/init.jsp"%> +<%-- the following is needed by liferay to display error messages--%> +<%@include file="/html/utils/includes/errorKeyToMessage.jspf"%> + + + +<%@ page import="javax.portlet.PortletRequest" %> +<%@ page import="com.liferay.portlet.PortletURLFactoryUtil" %> +<%@ page import="org.eclipse.sw360.datahandler.thrift.licenses.Todo" %> + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ + + + + + + + + + + + + + + + +
Add TODO
+ + + + + + + + +
+ + +
+ + +
+ + diff --git a/frontend/sw360-portlet/src/main/webapp/html/admin/todos/view.jsp b/frontend/sw360-portlet/src/main/webapp/html/admin/todos/view.jsp new file mode 100644 index 0000000000..f5ebfc29c8 --- /dev/null +++ b/frontend/sw360-portlet/src/main/webapp/html/admin/todos/view.jsp @@ -0,0 +1,135 @@ +<%-- + ~ Copyright Siemens AG, 2013-2017. Part of the SW360 Portal Project. + ~ + ~ SPDX-License-Identifier: EPL-1.0 + ~ + ~ All rights reserved. This program and the accompanying materials + ~ are made available under the terms of the Eclipse Public License v1.0 + ~ which accompanies this distribution, and is available at + ~ http://www.eclipse.org/legal/epl-v10.html + --%> +<%@ page import="org.eclipse.sw360.portal.common.PortalConstants" %> + +<%@ include file="/html/init.jsp" %> +<%-- the following is needed by liferay to display error messages--%> +<%@ include file="/html/utils/includes/errorKeyToMessage.jspf"%> + + + + + + + + + + + + + + + + + + + + + + + + +
+ <%@ include file="/html/utils/includes/quickfilter.jspf" %> +
+
+ + + + + + +
+
+ + + +<%--for javascript library loading --%> +<%@ include file="/html/utils/includes/requirejs.jspf" %> + diff --git a/libraries/exporters/src/main/java/org/eclipse/sw360/exporter/LicsExporter.java b/libraries/exporters/src/main/java/org/eclipse/sw360/exporter/LicsExporter.java index 2bf9cff52d..37e66d29f4 100644 --- a/libraries/exporters/src/main/java/org/eclipse/sw360/exporter/LicsExporter.java +++ b/libraries/exporters/src/main/java/org/eclipse/sw360/exporter/LicsExporter.java @@ -64,7 +64,7 @@ public Map getFilenameToCSVStreams() throws TException, IOE final List todos = licenseClient.getTodos(); List customProperties = new ArrayList<>(); - SetMultimap todoCustomPropertyMap = HashMultimap.create(); + SetMultimap todoCustomPropertyMap = HashMultimap.create(); ConvertRecord.fillTodoCustomPropertyInfo(todos, customProperties, todoCustomPropertyMap); fileNameToStreams.put(LicsArchive.TODO_CUSTOM_PROPERTIES_FILE, getCsvStream(serialize(todoCustomPropertyMap, ImmutableList.of("T_ID", "P_ID")))); fileNameToStreams.put(LicsArchive.CUSTOM_PROPERTIES_FILE, getCsvStream(serialize(customProperties, customPropertiesSerializer()))); diff --git a/libraries/exporters/src/main/java/org/eclipse/sw360/exporter/utils/ConvertRecord.java b/libraries/exporters/src/main/java/org/eclipse/sw360/exporter/utils/ConvertRecord.java index cb81bb85f8..5ad6cbee0c 100644 --- a/libraries/exporters/src/main/java/org/eclipse/sw360/exporter/utils/ConvertRecord.java +++ b/libraries/exporters/src/main/java/org/eclipse/sw360/exporter/utils/ConvertRecord.java @@ -21,9 +21,6 @@ import org.eclipse.sw360.datahandler.common.CommonUtils; import org.eclipse.sw360.datahandler.thrift.licenses.*; import org.apache.commons.csv.CSVRecord; -import org.apache.log4j.Logger; -import org.apache.thrift.TException; -import org.eclipse.sw360.datahandler.thrift.users.User; import org.eclipse.sw360.datahandler.common.ThriftEnumUtils; import org.eclipse.sw360.datahandler.thrift.Ternary; import org.jetbrains.annotations.NotNull; @@ -169,13 +166,13 @@ private static boolean isValidPropertyRecord(CSVRecord record){ return true; } - public static void fillTodoCustomPropertyInfo(List todos, List customProperties, SetMultimap todoCustomPropertyMap) { + public static void fillTodoCustomPropertyInfo(List todos, List customProperties, SetMultimap todoCustomPropertyMap) { int nextPropertyId = 0; for(Todo todo : todos){ if(todo.isSetCustomPropertyToValue()){ for(Map.Entry entry : todo.getCustomPropertyToValue().entrySet()){ customProperties.add(new PropertyWithValueAndId(nextPropertyId, entry.getKey(), entry.getValue())); - todoCustomPropertyMap.put(todo.getTodoId(), nextPropertyId); + todoCustomPropertyMap.put(todo.getId(), nextPropertyId); nextPropertyId++; } } @@ -210,10 +207,13 @@ public static List convertTodos(List records) { for (CSVRecord record : records) { if (record.size() < 2) break; - String id = record.get(0); + + String title = record.get(0); String text = record.get(1); - Todo todo = new Todo().setTodoId(Integer.parseInt(id)).setText(text); + Todo todo = new Todo(); + todo.setTitle(title); + todo.setText(text); // Parse boolean values @@ -249,7 +249,7 @@ public Function> transformer() { final ArrayList out = new ArrayList<>(5); - out.add(((Integer) todo.getTodoId()).toString()); + out.add(todo.getTitle()); out.add(todo.getText()); out.add(((Boolean) todo.isDevelopment()).toString()); out.add(((Boolean) todo.isDistribution()).toString()); @@ -263,7 +263,7 @@ public Function> transformer() { @Override public List headers() { - return ImmutableList.of("ID", "Text", "Development", "Distribution", "External IDs"); + return ImmutableList.of("Title", "Text", "Development", "Distribution", "External IDs"); } }; } @@ -541,13 +541,13 @@ private static boolean parseBoolean(String string) { } @NotNull - public static SetMultimap getTodoToObligationMap(List todos) { - SetMultimap obligationTodo = HashMultimap.create(); + public static SetMultimap getTodoToObligationMap(List todos) { + SetMultimap obligationTodo = HashMultimap.create(); for (Todo todo : todos) { if (todo.isSetObligations()) { for (Obligation obligation : todo.getObligations()) { - obligationTodo.put(obligation.getObligationId(), todo.getTodoId()); + obligationTodo.put(obligation.getObligationId(), todo.getId()); } } } @@ -555,13 +555,13 @@ public static SetMultimap getTodoToObligationMap(List to } @NotNull - public static SetMultimap getLicenseToTodoMap(List licenses) { - SetMultimap licenseToTodo = HashMultimap.create(); + public static SetMultimap getLicenseToTodoMap(List licenses) { + SetMultimap licenseToTodo = HashMultimap.create(); for (License license : licenses) { if (license.isSetTodos()) { for (Todo todo : license.getTodos()) { - licenseToTodo.put(license.getId(), todo.getTodoId()); + licenseToTodo.put(license.getId(), todo.getId()); } } } diff --git a/libraries/exporters/src/main/java/org/eclipse/sw360/exporter/utils/TypeMappings.java b/libraries/exporters/src/main/java/org/eclipse/sw360/exporter/utils/TypeMappings.java index 5ba06b865b..99a20d923e 100644 --- a/libraries/exporters/src/main/java/org/eclipse/sw360/exporter/utils/TypeMappings.java +++ b/libraries/exporters/src/main/java/org/eclipse/sw360/exporter/utils/TypeMappings.java @@ -72,7 +72,7 @@ public static Function getTodoIdentifier() { return new Function() { @Override public Integer apply(Todo input) { - return input.getTodoId(); + return -1; } }; } diff --git a/libraries/exporters/src/test/java/org/eclipse/sw360/exporter/utils/ConvertRecordTest.java b/libraries/exporters/src/test/java/org/eclipse/sw360/exporter/utils/ConvertRecordTest.java index 345a9b8ac1..65508d3f24 100644 --- a/libraries/exporters/src/test/java/org/eclipse/sw360/exporter/utils/ConvertRecordTest.java +++ b/libraries/exporters/src/test/java/org/eclipse/sw360/exporter/utils/ConvertRecordTest.java @@ -70,16 +70,16 @@ public void prepare() { String full = "headers\n 1,A,A1 \n 2,A,A2 \n 3,A,A3 \n 4,B,B1 \n 5,B,B2"; fullRecord = readToRecord(full); - String fullTodo = "header \n '1','text1','true','true' \n '2','text2','false','false', '{\"key\": \"value\"}'"; + String fullTodo = "header \n 'title1','text1','true','true' \n 'title2','text2','false','false', '{\"key\": \"value\"}'"; fullTodoRecord = readToRecord(fullTodo); Map todoCustomProperties1 = new HashMap<>(); todoCustomProperties1.put("A", "A1"); - Todo todo1 = new Todo().setTodoId(1).setCustomPropertyToValue(todoCustomProperties1); + Todo todo1 = new Todo().setId("1").setCustomPropertyToValue(todoCustomProperties1); Map todoCustomProperties2 = new HashMap<>(); todoCustomProperties2.put("A", "A2"); todoCustomProperties2.put("C", "C2"); - Todo todo2 = new Todo().setTodoId(2).setCustomPropertyToValue(todoCustomProperties2); + Todo todo2 = new Todo().setId("2").setCustomPropertyToValue(todoCustomProperties2); todos = Arrays.asList(todo1, todo2); } @@ -179,7 +179,7 @@ public void testConvertCustomPropertiesByIdFull() throws Exception { @Test public void testFillTodoCustomPropertyInfoEmpty() throws Exception { List customProperties = new ArrayList<>(); - SetMultimap todoCustomPropertyMap = HashMultimap.create(); + SetMultimap todoCustomPropertyMap = HashMultimap.create(); fillTodoCustomPropertyInfo(Collections.EMPTY_LIST, customProperties, todoCustomPropertyMap); assertThat(customProperties.size(), is(0)); assertThat(todoCustomPropertyMap.size(), is(0)); @@ -188,11 +188,11 @@ public void testFillTodoCustomPropertyInfoEmpty() throws Exception { @Test public void testFillTodoCustomPropertyInfoFull() throws Exception { List customProperties = new ArrayList<>(); - SetMultimap todoCustomPropertyMap = HashMultimap.create(); + SetMultimap todoCustomPropertyMap = HashMultimap.create(); fillTodoCustomPropertyInfo(todos, customProperties, todoCustomPropertyMap); assertThat(customProperties.size(), is(3)); assertThat(todoCustomPropertyMap.size(), is(3)); - int id = todoCustomPropertyMap.get(1).stream().findFirst().get(); + int id = todoCustomPropertyMap.get("1").stream().findFirst().get(); assertThat(customProperties.get(id).getProperty(), is("A")); assertThat(customProperties.get(id).getValue(), is("A1")); } @@ -208,11 +208,9 @@ public void testConvertTodosFull() throws Exception { List todos = convertTodos(fullTodoRecord); assertThat(todos.size(), is(2)); assertThat(todos.get(0).getText(), is("text1")); - assertThat(todos.get(0).getTodoId(), is(1)); assertThat(todos.get(0).isDevelopment(), is(true)); assertThat(todos.get(0).isDistribution(), is(true)); assertThat(todos.get(1).getText(), is("text2")); - assertThat(todos.get(1).getTodoId(), is(2)); assertThat(todos.get(1).isDevelopment(), is(false)); assertThat(todos.get(1).isDistribution(), is(false)); assertThat(todos.get(1).getExternalIds().size(), is(1)); diff --git a/libraries/lib-datahandler/src/main/java/org/eclipse/sw360/datahandler/thrift/ThriftValidate.java b/libraries/lib-datahandler/src/main/java/org/eclipse/sw360/datahandler/thrift/ThriftValidate.java index b32939a44b..6fe7f00b52 100644 --- a/libraries/lib-datahandler/src/main/java/org/eclipse/sw360/datahandler/thrift/ThriftValidate.java +++ b/libraries/lib-datahandler/src/main/java/org/eclipse/sw360/datahandler/thrift/ThriftValidate.java @@ -58,7 +58,7 @@ public static void prepareTodo(Todo todo) throws SW360Exception { // Check required fields assertNotNull(todo); assertNotEmpty(todo.getText()); - assertNotNull(todo.getTodoId()); + assertNotNull(todo.getTitle()); if (todo.isSetObligations() && !todo.isSetObligationDatabaseIds()) { for (Obligation obligation : todo.getObligations()) { diff --git a/libraries/lib-datahandler/src/main/thrift/licenses.thrift b/libraries/lib-datahandler/src/main/thrift/licenses.thrift index 323df2118a..a1a0a474ca 100644 --- a/libraries/lib-datahandler/src/main/thrift/licenses.thrift +++ b/libraries/lib-datahandler/src/main/thrift/licenses.thrift @@ -41,7 +41,7 @@ struct Todo { 7: optional bool distribution, 8: optional list obligations, 9: optional set obligationDatabaseIds, - 10: required i32 todoId, + 10: optional string title, 11: optional map customPropertyToValue, // These two are a quick fix to receiving booleans in PHP not working at the moment @@ -305,4 +305,8 @@ service LicenseService { RequestSummary deleteAllLicenseInformation(1: User user); RequestSummary importAllSpdxLicenses(1: User user); + /** + * delete todo from database if user has permissions + **/ + RequestStatus deleteTodo(1: string id, 2: User user); } diff --git a/libraries/lib-datahandler/src/main/thrift/sw360.thrift b/libraries/lib-datahandler/src/main/thrift/sw360.thrift index 0935bf6db8..f79706e9e9 100644 --- a/libraries/lib-datahandler/src/main/thrift/sw360.thrift +++ b/libraries/lib-datahandler/src/main/thrift/sw360.thrift @@ -23,10 +23,11 @@ enum RequestStatus { SUCCESS = 0, SENT_TO_MODERATOR = 1, FAILURE = 2, - IN_USE=3, + IN_USE = 3, FAILED_SANITY_CHECK = 4, DUPLICATE = 5, DUPLICATE_ATTACHMENT = 6, + ACCESS_DENIED = 7, } enum RemoveModeratorRequestStatus {