Skip to content

Commit

Permalink
Merge pull request #1 from oer-bookr-6-24-2019/spencer-stock
Browse files Browse the repository at this point in the history
Spencer stock
  • Loading branch information
spencerstock authored Nov 5, 2019
2 parents b13d671 + 0536dcd commit 633253e
Show file tree
Hide file tree
Showing 49 changed files with 3,231 additions and 1 deletion.
29 changes: 29 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
HELP.md
/target/
!.mvn/wrapper/maven-wrapper.jar

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
/build/

### VS Code ###
.vscode/
128 changes: 128 additions & 0 deletions .mvn/wrapper/MavenWrapperDownloader.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.util.Properties;

public class MavenWrapperDownloader
{

/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar";

/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
* use instead of the default one.
*/
private static final String MAVEN_WRAPPER_PROPERTIES_PATH = ".mvn/wrapper/maven-wrapper.properties";

/**
* Path where the maven-wrapper.jar will be saved to.
*/
private static final String MAVEN_WRAPPER_JAR_PATH = ".mvn/wrapper/maven-wrapper.jar";

/**
* Name of the property which should be used to override the default download url for the wrapper.
*/
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";

public static void main(String args[])
{
System.out.println("- Downloader started");
File baseDirectory = new File(args[0]);
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());

// If the maven-wrapper.properties exists, read it and check if it contains a custom
// wrapperUrl parameter.
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
String url = DEFAULT_DOWNLOAD_URL;
if (mavenWrapperPropertyFile.exists())
{
FileInputStream mavenWrapperPropertyFileInputStream = null;
try
{
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
Properties mavenWrapperProperties = new Properties();
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
}
catch (IOException e)
{
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
}
finally
{
try
{
if (mavenWrapperPropertyFileInputStream != null)
{
mavenWrapperPropertyFileInputStream.close();
}
}
catch (IOException e)
{
// Ignore ...
}
}
}
System.out.println("- Downloading from: : " + url);

File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
if (!outputFile.getParentFile().exists())
{
if (!outputFile.getParentFile().mkdirs())
{
System.out.println("- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'");
}
}
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
try
{
downloadFileFromURL(url, outputFile);
System.out.println("Done");
System.exit(0);
}
catch (Throwable e)
{
System.out.println("- Error downloading");
e.printStackTrace();
System.exit(1);
}
}

private static void downloadFileFromURL(String urlString, File destination) throws Exception
{
URL website = new URL(urlString);
ReadableByteChannel rbc;
rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(destination);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
rbc.close();
}

}
Binary file added .mvn/wrapper/maven-wrapper.jar
Binary file not shown.
1 change: 1 addition & 0 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip
93 changes: 92 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,92 @@
# oer-bookr-BE
# oer-bookr-BackEnd

### Create user

Endpoint: https://sgs-lambda-bookr.herokuapp.com/createnewuser

Body (application/Json)
```
{
"username" : "yourUsername",
"password" : "yourPassword"
}
```

Returns
```
{
"access_token": "ba94fbf1-4dd6-41c9-9744-6b9b17829641",
"token_type": "bearer",
"refresh_token": "6c8a8105-3a4a-4296-9f1a-65997fd97aca",
"expires_in": 3599,
"scope": "read write trust"
}
```
https://sgs-lambda-bookr.herokuapp.com/users/users to list all users (must be admin)


### Login

Endpoint: https://sgs-lambda-bookr.herokuapp.com/loginuser

Body (application/Json)
```
{
"username" : "yourUsername",
"password" : "yourPassword"
}
```

Returns:
```
{
"access_token": "ff9803b8-6a3d-4e64-9321-4f34cd84f924",
"token_type": "bearer",
"refresh_token": "9fe8bf45-1f3e-405c-9a35-a1d401f7968a",
"expires_in": 3599,
"scope": "read write trust"
}
```


### Books

Documentation: https://sgs-lambda-bookr.herokuapp.com/swagger-ui.html#/books-controller

books/add Example:
```
{
"author": "string",
"booktitle": "string",
"imageurl": "string",
"license": "string",
"publisher": "string",
"url": "string"
}
```


### Reviews

Documentation: https://sgs-lambda-bookr.herokuapp.com/swagger-ui.html#/reviews-controller

reviews/add/bybookid/{bookid} Example:
```
{
"rating": 4,
"review": "string",
"user": "string"
}
```

reviews/update/byreview/{reviewid} Example:
```
{
"rating": 3,
"review": "changedString",
"user": "string"*
}
```
*required


27 changes: 27 additions & 0 deletions data.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
INSERT INTO section (sectionid, name) VALUES (1, 'Fiction');
INSERT INTO section (sectionid, name) VALUES (2, 'Technology');
INSERT INTO section (sectionid, name) VALUES (3, 'Travel');
INSERT INTO section (sectionid, name) VALUES (4, 'Business');
INSERT INTO section (sectionid, name) VALUES (5, 'Religion');

INSERT INTO author (authorid, fname, lname) VALUES (1, 'John', 'Mitchell');
INSERT INTO author (authorid, fname, lname) VALUES (2, 'Dan', 'Brown');
INSERT INTO author (authorid, fname, lname) VALUES (3, 'Jerry', 'Poe');
INSERT INTO author (authorid, fname, lname) VALUES (4, 'Wells', 'Teague');
INSERT INTO author (authorid, fname, lname) VALUES (5, 'George', 'Gallinger');
INSERT INTO author (authorid, fname, lname) VALUES (6, 'Ian', 'Stewart');

INSERT INTO book (bookid, title, ISBN, copy, sectionid) VALUES (1, 'Flatterland', '9780738206752', 2001, 1);
INSERT INTO book (bookid, title, ISBN, copy, sectionid) VALUES (2, 'Digital Fortess', '9788489367012', 2007, 1);
INSERT INTO book (bookid, title, ISBN, copy, sectionid) VALUES (3, 'The Da Vinci Code', '9780307474278', 2009, 1);
INSERT INTO book (bookid, title, ISBN, copy, sectionid) VALUES (4, 'Essentials of Finance', '1314241651234', NULL, 4);
INSERT INTO book (bookid, title, ISBN, copy, sectionid) VALUES (5, 'Calling Texas Home', '1885171382134', 2000, 3);

INSERT INTO wrote (bookid, authorid) VALUES (1, 6);
INSERT INTO wrote (bookid, authorid) VALUES (2, 2);
INSERT INTO wrote (bookid, authorid) VALUES (3, 2);
INSERT INTO wrote (bookid, authorid) VALUES (4, 5);
INSERT INTO wrote (bookid, authorid) VALUES (4, 3);
INSERT INTO wrote (bookid, authorid) VALUES (5, 4);

alter sequence hibernate_sequence restart with 25;
Loading

0 comments on commit 633253e

Please sign in to comment.