Add new method to delete a work report from the web service
FEA: ItEr77S06AllowDeleteWorkReports
This commit is contained in:
parent
8bde7df447
commit
8509515e75
4 changed files with 60 additions and 1 deletions
|
|
@ -3,7 +3,7 @@
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009-2010 Fundación para o Fomento da Calidade Industrial e
|
* Copyright (C) 2009-2010 Fundación para o Fomento da Calidade Industrial e
|
||||||
* Desenvolvemento Tecnolóxico de Galicia
|
* Desenvolvemento Tecnolóxico de Galicia
|
||||||
* Copyright (C) 2010-2011 Igalia, S.L.
|
* Copyright (C) 2010-2012 Igalia, S.L.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
|
@ -39,4 +39,6 @@ public interface IWorkReportService {
|
||||||
|
|
||||||
public Response getWorkReport(String code);
|
public Response getWorkReport(String code);
|
||||||
|
|
||||||
|
Response removeWorkReport(String code);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -22,12 +22,14 @@
|
||||||
package org.libreplan.ws.workreports.impl;
|
package org.libreplan.ws.workreports.impl;
|
||||||
|
|
||||||
import javax.ws.rs.Consumes;
|
import javax.ws.rs.Consumes;
|
||||||
|
import javax.ws.rs.DELETE;
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.GET;
|
||||||
import javax.ws.rs.POST;
|
import javax.ws.rs.POST;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
import javax.ws.rs.PathParam;
|
import javax.ws.rs.PathParam;
|
||||||
import javax.ws.rs.Produces;
|
import javax.ws.rs.Produces;
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
|
import javax.ws.rs.core.Response.Status;
|
||||||
|
|
||||||
import org.libreplan.business.common.daos.IIntegrationEntityDAO;
|
import org.libreplan.business.common.daos.IIntegrationEntityDAO;
|
||||||
import org.libreplan.business.common.exceptions.InstanceNotFoundException;
|
import org.libreplan.business.common.exceptions.InstanceNotFoundException;
|
||||||
|
|
@ -122,4 +124,22 @@ public class WorkReportServiceREST extends
|
||||||
public Response getWorkReport(@PathParam("code") String code) {
|
public Response getWorkReport(@PathParam("code") String code) {
|
||||||
return getDTOByCode(code);
|
return getDTOByCode(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@DELETE
|
||||||
|
@Path("/{code}/")
|
||||||
|
@Transactional
|
||||||
|
public Response removeWorkReport(@PathParam("code") String code) {
|
||||||
|
try {
|
||||||
|
WorkReport workReport = workReportDAO.findByCode(code);
|
||||||
|
sumChargedEffortDAO
|
||||||
|
.updateRelatedSumChargedEffortWithDeletedWorkReportLineSet(workReport
|
||||||
|
.getWorkReportLines());
|
||||||
|
workReportDAO.remove(workReport.getId());
|
||||||
|
return Response.ok().build();
|
||||||
|
} catch (InstanceNotFoundException e) {
|
||||||
|
return Response.status(Status.NOT_FOUND).build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -25,6 +25,9 @@
|
||||||
<intercept-url pattern="/ws/rest/**"
|
<intercept-url pattern="/ws/rest/**"
|
||||||
access="ROLE_WS_WRITER"
|
access="ROLE_WS_WRITER"
|
||||||
method="POST" />
|
method="POST" />
|
||||||
|
<intercept-url pattern="/ws/rest/**"
|
||||||
|
access="ROLE_WS_WRITER"
|
||||||
|
method="DELETE" />
|
||||||
|
|
||||||
<!-- Web application -->
|
<!-- Web application -->
|
||||||
<intercept-url pattern="/common/img/**"
|
<intercept-url pattern="/common/img/**"
|
||||||
|
|
|
||||||
34
scripts/rest-clients/remove-work-report.sh
Executable file
34
scripts/rest-clients/remove-work-report.sh
Executable file
|
|
@ -0,0 +1,34 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. ./rest-common-env.sh
|
||||||
|
|
||||||
|
printf "Username: "
|
||||||
|
read loginName
|
||||||
|
printf "Password: "
|
||||||
|
read password
|
||||||
|
|
||||||
|
code=$1
|
||||||
|
|
||||||
|
if [ "$1" = "--prod" ]; then
|
||||||
|
baseServiceURL=$PRODUCTION_BASE_SERVICE_URL
|
||||||
|
certificate=$PRODUCTION_CERTIFICATE
|
||||||
|
code=$2
|
||||||
|
elif [ "$1" = "--dev" ]; then
|
||||||
|
baseServiceURL=$DEVELOPMENT_BASE_SERVICE_URL
|
||||||
|
certificate=$DEVELOPMENT_CERTIFICATE
|
||||||
|
code=$2
|
||||||
|
else
|
||||||
|
baseServiceURL=$DEMO_BASE_SERVICE_URL
|
||||||
|
certificate=$DEMO_CERTIFICATE
|
||||||
|
fi
|
||||||
|
|
||||||
|
authorization=`echo -n "$loginName:$password" | base64`
|
||||||
|
|
||||||
|
result=`curl -sv -X DELETE $certificate --header "Authorization: Basic $authorization" \
|
||||||
|
$baseServiceURL/workreports/$code`
|
||||||
|
|
||||||
|
if hash tidy &> /dev/null; then
|
||||||
|
echo $result | tidy -xml -i -q -utf8
|
||||||
|
else
|
||||||
|
echo $result
|
||||||
|
fi
|
||||||
Loading…
Add table
Reference in a new issue