Skip to content

Commit

Permalink
server folder fix
Browse files Browse the repository at this point in the history
  • Loading branch information
owpk committed Sep 2, 2020
1 parent 9e5c86d commit 2574f22
Show file tree
Hide file tree
Showing 51 changed files with 3,649 additions and 3,629 deletions.
18 changes: 9 additions & 9 deletions .gitignore
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
7 changes: 7 additions & 0 deletions Cloud Storage downloads\client.properties
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
92 changes: 46 additions & 46 deletions README.md
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
```


8 changes: 4 additions & 4 deletions client.properties
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
158 changes: 79 additions & 79 deletions client/pom.xml
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 client/src/main/java/org/owpk/IODataHandler/AbsHandler.java
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;
}
Loading

0 comments on commit 2574f22

Please sign in to comment.