forked from eclipse-sw360/sw360
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request eclipse-sw360#517 from endocode/nikolas/todos
feat(licenses): adding support for project-only obligations review-by: [email protected] tested-by: [email protected]
- Loading branch information
Showing
21 changed files
with
466 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
...tend/sw360-portlet/src/main/java/org/eclipse/sw360/portal/portlets/admin/TodoPortlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 [email protected] | ||
*/ | ||
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<Todo> 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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.