Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
javab_20230928
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
javab_20230928
Commits
3172720b
Commit
3172720b
authored
Nov 10, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
moduł soap-serwer
parent
cec4d802
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
207 additions
and
0 deletions
+207
-0
pom.xml
Wielomodulowy/pom.xml
+1
-0
pom.xml
Wielomodulowy/wielomodulowy-ear/pom.xml
+6
-0
pom.xml
Wielomodulowy/wielomodulowy-soap_serwer/pom.xml
+50
-0
PhotoUtil.java
...ulowy-soap_serwer/src/main/java/sklep/soap/PhotoUtil.java
+66
-0
Sklep.java
...omodulowy-soap_serwer/src/main/java/sklep/soap/Sklep.java
+84
-0
No files found.
Wielomodulowy/pom.xml
View file @
3172720b
...
@@ -20,5 +20,6 @@
...
@@ -20,5 +20,6 @@
<module>
wielomodulowy-klient_rest
</module>
<module>
wielomodulowy-klient_rest
</module>
<module>
wielomodulowy-web
</module>
<module>
wielomodulowy-web
</module>
<module>
wielomodulowy-ear
</module>
<module>
wielomodulowy-ear
</module>
<module>
wielomodulowy-soap_serwer
</module>
</modules>
</modules>
</project>
</project>
Wielomodulowy/wielomodulowy-ear/pom.xml
View file @
3172720b
...
@@ -23,6 +23,12 @@
...
@@ -23,6 +23,12 @@
<version>
${project.version}
</version>
<version>
${project.version}
</version>
<type>
war
</type>
<type>
war
</type>
</dependency>
</dependency>
<dependency>
<groupId>
${project.groupId}
</groupId>
<artifactId>
wielomodulowy-soap_serwer
</artifactId>
<version>
${project.version}
</version>
<type>
war
</type>
</dependency>
</dependencies>
</dependencies>
</project>
</project>
Wielomodulowy/wielomodulowy-soap_serwer/pom.xml
0 → 100644
View file @
3172720b
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<parent>
<groupId>
pl.alx.kjava
</groupId>
<artifactId>
Wielomodulowy
</artifactId>
<version>
1.0
</version>
</parent>
<artifactId>
wielomodulowy-soap_serwer
</artifactId>
<packaging>
war
</packaging>
<dependencies>
<dependency>
<groupId>
jakarta.xml.ws
</groupId>
<artifactId>
jakarta.xml.ws-api
</artifactId>
<version>
4.0.0
</version>
<scope>
provided
</scope>
</dependency>
<dependency>
<groupId>
jakarta.servlet
</groupId>
<artifactId>
jakarta.servlet-api
</artifactId>
<version>
6.0.0
</version>
<scope>
provided
</scope>
</dependency>
<dependency>
<groupId>
${project.groupId}
</groupId>
<artifactId>
wielomodulowy-model
</artifactId>
<version>
${project.version}
</version>
</dependency>
<dependency>
<groupId>
${project.groupId}
</groupId>
<artifactId>
wielomodulowy-baza
</artifactId>
<version>
${project.version}
</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-war-plugin
</artifactId>
<version>
3.4.0
</version>
<configuration>
<failOnMissingWebXml>
false
</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
</project>
Wielomodulowy/wielomodulowy-soap_serwer/src/main/java/sklep/soap/PhotoUtil.java
0 → 100644
View file @
3172720b
package
sklep
.
soap
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.nio.file.StandardCopyOption
;
import
java.nio.file.StandardOpenOption
;
import
sklep.db.DBException
;
import
sklep.db.DBSettings
;
import
sklep.db.RecordNotFound
;
public
class
PhotoUtil
{
private
static
final
String
EXT
=
".jpg"
;
public
static
File
getFile
(
int
productId
)
throws
DBException
,
RecordNotFound
{
Path
path
=
getPath
(
productId
);
File
file
=
path
.
toFile
();
if
(
file
.
exists
())
{
return
file
;
}
else
{
throw
new
RecordNotFound
(
"Cannot read photo for product id = "
+
productId
);
}
}
public
static
byte
[]
readBytes
(
int
productId
)
throws
DBException
,
RecordNotFound
{
Path
path
=
getPath
(
productId
);
try
{
return
Files
.
readAllBytes
(
path
);
}
catch
(
IOException
e
)
{
// System.err.println(e);
throw
new
RecordNotFound
(
"Cannot read photo for product id = "
+
productId
);
}
}
public
static
void
writeStream
(
int
productId
,
InputStream
inputStream
)
{
try
{
Path
path
=
getPath
(
productId
);
Files
.
copy
(
inputStream
,
path
,
StandardCopyOption
.
REPLACE_EXISTING
);
}
catch
(
Exception
e
)
{
// wypisujemy błąd, ale metoda kończy się normalnie
e
.
printStackTrace
();
}
}
public
static
void
writeBytes
(
int
productId
,
byte
[]
bytes
)
{
try
{
Path
path
=
getPath
(
productId
);
Files
.
write
(
path
,
bytes
,
StandardOpenOption
.
CREATE
);
}
catch
(
Exception
e
)
{
// wypisujemy błąd, ale metoda kończy się normalnie
e
.
printStackTrace
();
}
}
private
static
Path
getPath
(
int
productId
)
throws
DBException
{
String
dir
=
DBSettings
.
load
().
getProperty
(
"photo_dir"
);
String
fileName
=
productId
+
EXT
;
return
Paths
.
get
(
dir
,
fileName
);
}
}
Wielomodulowy/wielomodulowy-soap_serwer/src/main/java/sklep/soap/Sklep.java
0 → 100644
View file @
3172720b
package
sklep
.
soap
;
import
java.math.BigDecimal
;
import
java.util.List
;
import
jakarta.jws.WebParam
;
import
jakarta.jws.WebResult
;
import
jakarta.jws.WebService
;
import
jakarta.xml.ws.soap.MTOM
;
import
sklep.db.CustomerDAO
;
import
sklep.db.DBConnection
;
import
sklep.db.DBException
;
import
sklep.db.OrderDAO
;
import
sklep.db.ProductDAO
;
import
sklep.db.RecordNotFound
;
import
sklep.model.Customer
;
import
sklep.model.Order
;
import
sklep.model.Product
;
@WebService
@MTOM
public
class
Sklep
{
@WebResult
(
name
=
"product"
)
public
List
<
Product
>
readAll
()
throws
DBException
{
try
(
DBConnection
db
=
DBConnection
.
open
())
{
ProductDAO
productDAO
=
db
.
productDAO
();
return
productDAO
.
readAll
();
}
}
// @ResponseWrapper(localName = "wynikiWyszukiwania", targetNamespace = "http://soap.sklep/")
// @WebResult(name="product", targetNamespace = "http://soap.sklep/model")
@WebResult
(
name
=
"product"
)
public
List
<
Product
>
readByPrice
(
@WebParam
(
name
=
"min"
)
BigDecimal
min
,
@WebParam
(
name
=
"max"
)
BigDecimal
max
)
throws
DBException
{
try
(
DBConnection
db
=
DBConnection
.
open
())
{
ProductDAO
productDAO
=
db
.
productDAO
();
return
productDAO
.
findByPrice
(
min
,
max
);
}
}
@WebResult
(
name
=
"product"
)
public
Product
readOne
(
@WebParam
(
name
=
"id"
)
int
productId
)
throws
DBException
,
RecordNotFound
{
try
(
DBConnection
db
=
DBConnection
.
open
())
{
ProductDAO
productDAO
=
db
.
productDAO
();
return
productDAO
.
findById
(
productId
);
}
}
public
void
saveProduct
(
@WebParam
(
name
=
"product"
)
Product
product
)
throws
DBException
{
try
(
DBConnection
db
=
DBConnection
.
open
())
{
ProductDAO
productDAO
=
db
.
productDAO
();
productDAO
.
save
(
product
);
db
.
commit
();
}
}
@WebResult
(
name
=
"customer"
)
public
Customer
oneCustomer
(
@WebParam
(
name
=
"email"
)
String
email
)
throws
DBException
,
RecordNotFound
{
try
(
DBConnection
db
=
DBConnection
.
open
())
{
CustomerDAO
customerDAO
=
db
.
customerDAO
();
return
customerDAO
.
findByEmail
(
email
);
}
}
@WebResult
(
name
=
"order"
)
public
Order
oneOrder
(
@WebParam
(
name
=
"id"
)
int
orderId
)
throws
DBException
,
RecordNotFound
{
try
(
DBConnection
db
=
DBConnection
.
open
())
{
OrderDAO
orderDAO
=
db
.
orderDAO
();
return
orderDAO
.
findById
(
orderId
);
}
}
@WebResult
(
name
=
"bytes"
)
public
byte
[]
getPhoto
(
@WebParam
(
name
=
"id"
)
int
productId
)
throws
DBException
,
RecordNotFound
{
return
PhotoUtil
.
readBytes
(
productId
);
}
public
void
savePhoto
(
@WebParam
(
name
=
"id"
)
int
productId
,
@WebParam
(
name
=
"bytes"
)
byte
[]
bytes
)
{
PhotoUtil
.
writeBytes
(
productId
,
bytes
);
}
}
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