-
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.
- Loading branch information
Showing
51 changed files
with
3,649 additions
and
3,629 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
.idea | ||
/client/target | ||
/server/clients_folders/ | ||
/client/Cloud Storage downloads/ | ||
/server/target | ||
/network/target | ||
/server/out | ||
/server/log/ | ||
*.iml | ||
.idea | ||
/client/target | ||
/server/clients_folders/ | ||
/client/Cloud Storage downloads/ | ||
/server/target | ||
/network/target | ||
/server/out | ||
/server/log/ | ||
*.iml | ||
*.log |
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,7 @@ | ||
#download_directory | ||
#Thu Sep 03 01:28:34 YAKT 2020 | ||
last_directory=C\:\\ | ||
download_directory=/home/owpk/Рабочий стол/cloudStorageProject/engine/CloudStorage/./Cloud Storage downloads | ||
port=8190 | ||
host=localhost | ||
connect_on_startup=false |
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 |
---|---|---|
@@ -1,46 +1,46 @@ | ||
# Simple Cloud Storage App | ||
|
||
An example of a simple file manager with the ability to exchange files between a remote server and a client. Supports drag-and-drop actions, simple authorization and sing up functions. | ||
The server implements the netty framework 4.1.51. | ||
|
||
* See client.properties and server.properties files to configure the app | ||
|
||
<a><img src="https://github.com/vzvz4/Test/blob/master/sc.jpg" width="500"/></a> | ||
|
||
## Building | ||
|
||
#### Prerequisites: | ||
|
||
1. Java (JDK) 8. | ||
|
||
#### Build | ||
|
||
```sh | ||
You can use Maven to build the app: | ||
From the project root, run ./mvnw clean install. | ||
``` | ||
**Open client/target and server/target folder and run "jar-with-dependencies.jar" files by using console.** | ||
**For example:** | ||
```sh | ||
server/target> $java -jar server-1.0-jar-with-dependencies.jar | ||
``` | ||
**You should see "[main] INFO org.owpk.core.Server - Server started at : 8190" message from the server and "connected : localhost/127.0.0.1:8190" message from the client if everything is ok.** | ||
|
||
* By default, server creates a "clients_folders" directory in server root as default users files storage. Client creates a "Cloud Storage downloads" directory in client root as default download directory. | ||
* If you want to customize some properties like port address, download dirs etc, look at client.properties and server.properties files, you can find it in project root or in target folder if you have already built the app. | ||
* The server uses MySQL connection to authorize and add a new user, in project root you can find a DDL script to build your own database server, connection properties described in /server/src/resources/META-INF/persistence.xml file. | ||
* You can also connect to the server with "test user" login and password. | ||
|
||
## Docker | ||
* You can run the server in docker | ||
- Install Docker on the machine you want to run it. | ||
- Go to project root and run the commands below by using console | ||
```sh | ||
$docker build -t java-app:cloud . | ||
$docker run java-app:cloud -p 8190:8190/tcp | ||
|
||
Or just pull it from repository | ||
$docker pull vzvz4/cloud:cloud | ||
``` | ||
|
||
|
||
# Simple Cloud Storage App | ||
|
||
An example of a simple file manager with the ability to exchange files between a remote server and a client. Supports drag-and-drop actions, simple authorization and sing up functions. | ||
The server implements the netty framework 4.1.51. | ||
|
||
* See client.properties and server.properties files to configure the app | ||
|
||
<a><img src="https://github.com/vzvz4/Test/blob/master/sc.jpg" width="500"/></a> | ||
|
||
## Building | ||
|
||
#### Prerequisites: | ||
|
||
1. Java (JDK) 8. | ||
|
||
#### Build | ||
|
||
```sh | ||
You can use Maven to build the app: | ||
From the project root, run ./mvnw clean install. | ||
``` | ||
**Open client/target and server/target folder and run "jar-with-dependencies.jar" files by using console.** | ||
**For example:** | ||
```sh | ||
server/target> $java -jar server-1.0-jar-with-dependencies.jar | ||
``` | ||
**You should see "[main] INFO org.owpk.core.Server - Server started at : 8190" message from the server and "connected : localhost/127.0.0.1:8190" message from the client if everything is ok.** | ||
|
||
* By default, server creates a "clients_folders" directory in server root as default users files storage. Client creates a "Cloud Storage downloads" directory in client root as default download directory. | ||
* If you want to customize some properties like port address, download dirs etc, look at client.properties and server.properties files, you can find it in project root or in target folder if you have already built the app. | ||
* The server uses MySQL connection to authorize and add a new user, in project root you can find a DDL script to build your own database server, connection properties described in /server/src/resources/META-INF/persistence.xml file. | ||
* You can also connect to the server with "test user" login and password. | ||
|
||
## Docker | ||
* You can run the server in docker | ||
- Install Docker on the machine you want to run it. | ||
- Go to project root and run the commands below by using console | ||
```sh | ||
$docker build -t java-app:cloud . | ||
$docker run java-app:cloud -p 8190:8190/tcp | ||
|
||
Or just pull it from repository | ||
$docker pull vzvz4/cloud:cloud | ||
``` | ||
|
||
|
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#last_directory | ||
#Tue Aug 25 03:02:49 YAKT 2020 | ||
last_directory=C\:\\ | ||
download_directory=C\:\\Users\\vzvz4\\Desktop\\PAPKA\\cloudStorageProject\\engine\\CloudStorage\\.\\Cloud Storage downloads | ||
#Thu Sep 03 02:08:43 YAKT 2020 | ||
last_directory=. | ||
port=8190 | ||
host=79.143.31.62 | ||
download_directory=/home/owpk/Рабочий стол/cloudStorageProject/engine/CloudStorage/./Cloud Storage downloads | ||
host=localhost | ||
connect_on_startup=false |
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 |
---|---|---|
@@ -1,80 +1,80 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>CloudStorage</artifactId> | ||
<groupId>org.owpk</groupId> | ||
<version>1.0</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>client</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
<properties> | ||
<commos.codec.version>1.11</commos.codec.version> | ||
</properties> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-assembly-plugin</artifactId> | ||
<version>${maven.assembly.version}</version> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>single</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<archive> | ||
<manifest> | ||
<addClasspath>true</addClasspath> | ||
<mainClass>org.owpk.app.Client</mainClass> | ||
</manifest> | ||
</archive> | ||
<descriptorRefs> | ||
<descriptorRef>jar-with-dependencies</descriptorRef> | ||
</descriptorRefs> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-antrun-plugin</artifactId> | ||
<version>1.8</version> | ||
<executions> | ||
<execution> | ||
<phase>test</phase> | ||
<goals> | ||
<goal>run</goal> | ||
</goals> | ||
<configuration> | ||
<tasks> | ||
<echo>Using env.test.properties</echo> | ||
<copy file="../client.properties" tofile="${basedir}/target/client.properties"/> | ||
</tasks> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>commons-codec</groupId> | ||
<artifactId>commons-codec</artifactId> | ||
<version>${commos.codec.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.owpk</groupId> | ||
<artifactId>network</artifactId> | ||
<version>1.0</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
</dependencies> | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>CloudStorage</artifactId> | ||
<groupId>org.owpk</groupId> | ||
<version>1.0</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>client</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
<properties> | ||
<commos.codec.version>1.11</commos.codec.version> | ||
</properties> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-assembly-plugin</artifactId> | ||
<version>${maven.assembly.version}</version> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>single</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<archive> | ||
<manifest> | ||
<addClasspath>true</addClasspath> | ||
<mainClass>org.owpk.app.Client</mainClass> | ||
</manifest> | ||
</archive> | ||
<descriptorRefs> | ||
<descriptorRef>jar-with-dependencies</descriptorRef> | ||
</descriptorRefs> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-antrun-plugin</artifactId> | ||
<version>1.8</version> | ||
<executions> | ||
<execution> | ||
<phase>test</phase> | ||
<goals> | ||
<goal>run</goal> | ||
</goals> | ||
<configuration> | ||
<tasks> | ||
<echo>Using env.test.properties</echo> | ||
<copy file="../client.properties" tofile="${basedir}/target/client.properties"/> | ||
</tasks> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>commons-codec</groupId> | ||
<artifactId>commons-codec</artifactId> | ||
<version>${commos.codec.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.owpk</groupId> | ||
<artifactId>network</artifactId> | ||
<version>1.0</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
74 changes: 37 additions & 37 deletions
74
client/src/main/java/org/owpk/IODataHandler/AbsHandler.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 |
---|---|---|
@@ -1,37 +1,37 @@ | ||
package org.owpk.IODataHandler; | ||
|
||
import io.netty.handler.codec.serialization.ObjectDecoderInputStream; | ||
import io.netty.handler.codec.serialization.ObjectEncoderOutputStream; | ||
import org.owpk.message.Message; | ||
import org.owpk.network.IONetworkServiceImpl; | ||
|
||
import java.io.IOException; | ||
|
||
public abstract class AbsHandler { | ||
private boolean handlerOver; | ||
|
||
protected void initDataListener() throws IOException, ClassNotFoundException { | ||
System.out.println("DataListener started : " + this.getClass().toString() + " : handler: " + handlerOver); | ||
ObjectDecoderInputStream in = (ObjectDecoderInputStream) IONetworkServiceImpl.getService().getIn(); | ||
Message<?> msg; | ||
while (!handlerOver) { | ||
if (in.available() > 0) { | ||
msg = (Message<?>) in.readObject(); | ||
listen(msg); | ||
} | ||
} | ||
} | ||
|
||
protected void writeMessage(Message<?> message) throws IOException { | ||
((ObjectEncoderOutputStream) IONetworkServiceImpl | ||
.getService() | ||
.getOut()) | ||
.writeObject(message); | ||
} | ||
|
||
public void setHandlerOver(boolean handlerOver) { | ||
this.handlerOver = handlerOver; | ||
} | ||
protected abstract void listen(Message<?> message) throws IOException; | ||
public abstract void execute() throws InterruptedException, IOException, ClassNotFoundException; | ||
} | ||
package org.owpk.IODataHandler; | ||
|
||
import io.netty.handler.codec.serialization.ObjectDecoderInputStream; | ||
import io.netty.handler.codec.serialization.ObjectEncoderOutputStream; | ||
import org.owpk.message.Message; | ||
import org.owpk.network.IONetworkServiceImpl; | ||
|
||
import java.io.IOException; | ||
|
||
public abstract class AbsHandler { | ||
private boolean handlerOver; | ||
|
||
protected void initDataListener() throws IOException, ClassNotFoundException { | ||
System.out.println("DataListener started : " + this.getClass().toString() + " : handler: " + handlerOver); | ||
ObjectDecoderInputStream in = (ObjectDecoderInputStream) IONetworkServiceImpl.getService().getIn(); | ||
Message<?> msg; | ||
while (!handlerOver) { | ||
if (in.available() > 0) { | ||
msg = (Message<?>) in.readObject(); | ||
listen(msg); | ||
} | ||
} | ||
} | ||
|
||
protected void writeMessage(Message<?> message) throws IOException { | ||
((ObjectEncoderOutputStream) IONetworkServiceImpl | ||
.getService() | ||
.getOut()) | ||
.writeObject(message); | ||
} | ||
|
||
public void setHandlerOver(boolean handlerOver) { | ||
this.handlerOver = handlerOver; | ||
} | ||
protected abstract void listen(Message<?> message) throws IOException; | ||
public abstract void execute() throws InterruptedException, IOException, ClassNotFoundException; | ||
} |
Oops, something went wrong.