Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
java_weekendowa_20221008
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Patryk Czarnik
java_weekendowa_20221008
Commits
38307388
Commit
38307388
authored
Dec 11, 2022
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Response.created
parent
a80e44c2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
3 deletions
+8
-3
RProduct.java
PC35-RestSerwer/src/main/java/rest/RProduct.java
+8
-3
No files found.
PC35-RestSerwer/src/main/java/rest/RProduct.java
View file @
38307388
package
rest
;
import
java.math.BigDecimal
;
import
java.net.URI
;
import
java.util.List
;
import
javax.ws.rs.Consumes
;
...
...
@@ -11,6 +12,9 @@ import javax.ws.rs.PUT;
import
javax.ws.rs.Path
;
import
javax.ws.rs.PathParam
;
import
javax.ws.rs.Produces
;
import
javax.ws.rs.core.Context
;
import
javax.ws.rs.core.Response
;
import
javax.ws.rs.core.UriInfo
;
import
sklep.db.DBConnection
;
import
sklep.db.DBException
;
...
...
@@ -134,8 +138,8 @@ public class RProduct {
// w wyniku zostanie odesłany uzupełniony produkt
@POST
@Consumes
({
"application/json"
,
"application/xml"
})
@Produces
({
"application/json"
,
"application/xml"
})
public
Product
addProduct
(
Product
product
)
throws
DBException
{
public
Response
addProduct
(
Product
product
,
@Context
UriInfo
uriInfo
)
throws
DBException
{
try
(
DBConnection
db
=
DBConnection
.
open
())
{
ProductDAO
productDAO
=
db
.
productDAO
();
if
(
product
.
getProductId
()
!=
null
)
{
...
...
@@ -143,7 +147,8 @@ public class RProduct {
}
productDAO
.
insertNew
(
product
);
db
.
commit
();
return
product
;
URI
uri
=
uriInfo
.
getAbsolutePathBuilder
().
path
(
"/{id}"
).
build
(
product
.
getProductId
());
return
Response
.
created
(
uri
).
build
();
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment