diff --git a/Lambdas/Lists/Item/src/Item.java b/Lambdas/Lists/Item/src/Item.java new file mode 100644 index 0000000..dcdbdd6 --- /dev/null +++ b/Lambdas/Lists/Item/src/Item.java @@ -0,0 +1,124 @@ +import java.math.BigDecimal; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.time.LocalDateTime; + +public class Item { + Integer productID; + Integer chainID; + String upc; + String description; + BigDecimal price; + String imageURL; + String department; + LocalDateTime retrievedDate; + Integer fetchCounts; + + Item(ResultSet itemRow) throws SQLException { + this.productID = itemRow.getInt(1); + System.out.println(this.productID); + this.chainID = itemRow.getInt(2); + System.out.println(this.chainID); + this.upc = itemRow.getString(3); + System.out.println(this.upc); + this.description = itemRow.getString(4); + System.out.println(this.description); + this.price = itemRow.getBigDecimal(5); + System.out.println(this.price); + this.imageURL = itemRow.getString(6); + System.out.println(imageURL); + this.department = itemRow.getString(7); + System.out.println(department); + this.retrievedDate = itemRow.getObject(8, LocalDateTime.class); + System.out.println(retrievedDate); + this.fetchCounts = itemRow.getInt(9); + System.out.println(fetchCounts); + } + + @Override + public String toString() { + return "Item{" + + "productID=" + productID + + ", chainID=" + chainID + + ", upc='" + upc + '\'' + + ", description='" + description + '\'' + + ", price=" + price + + ", imageURL='" + imageURL + '\'' + + ", department='" + department + '\'' + + ", retrievedDate=" + retrievedDate + + ", fetchCounts=" + fetchCounts + + '}'; + } + + public Integer getProductID() { + return productID; + } + + public void setProductID(Integer productID) { + this.productID = productID; + } + + public Integer getChainID() { + return chainID; + } + + public void setChainID(Integer chainID) { + this.chainID = chainID; + } + + public String getUpc() { + return upc; + } + + public void setUpc(String upc) { + this.upc = upc; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public BigDecimal getPrice() { + return price; + } + + public void setPrice(BigDecimal price) { + this.price = price; + } + + public String getImageURL() { + return imageURL; + } + + public void setImageURL(String imageURL) { + this.imageURL = imageURL; + } + + public String getDepartment() { + return department; + } + + public void setDepartment(String department) { + this.department = department; + } + + public LocalDateTime getRetrievedDate() { + return retrievedDate; + } + + public void setRetrievedDate(LocalDateTime retrievedDate) { + this.retrievedDate = retrievedDate; + } + + public Integer getFetchCounts() { + return fetchCounts; + } + + public void setFetchCounts(Integer fetchCounts) { + this.fetchCounts = fetchCounts; + } +} diff --git a/Lambdas/Lists/Item/src/ItemGET.java b/Lambdas/Lists/Item/src/ItemGET.java new file mode 100644 index 0000000..71c0804 --- /dev/null +++ b/Lambdas/Lists/Item/src/ItemGET.java @@ -0,0 +1,11 @@ +import com.amazonaws.services.lambda.runtime.Context; +import com.amazonaws.services.lambda.runtime.RequestHandler; + +import java.util.Map; + +public class ItemGET implements RequestHandler, Object> { + + public Object handleRequest(Map inputMap, Context unfilled) { + return BasicHandler.handleRequest(inputMap, unfilled, ItemGetter.class); + } +} diff --git a/Lambdas/Lists/Item/src/ItemGetter.java b/Lambdas/Lists/Item/src/ItemGetter.java new file mode 100644 index 0000000..2414e3a --- /dev/null +++ b/Lambdas/Lists/Item/src/ItemGetter.java @@ -0,0 +1,36 @@ +import com.google.gson.Gson; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.HashMap; +import java.util.Map; + +public class ItemGetter implements CallHandler{ + private final DBConnector connector; + + private final String GET_ITEM = "SELECT * FROM Product WHERE productID = ?;"; + + public ItemGetter(DBConnector connector, String cognitoID) { + this.connector = connector; + } + + @Override + public Object conductAction(Map bodyMap, HashMap queryMap, String cognitoID) throws SQLException { + Connection connection = connector.getConnection(); + try { + PreparedStatement statement = connection.prepareStatement(GET_ITEM); + statement.setInt(1, Integer.parseInt(queryMap.get("id"))); + System.out.println(statement); + ResultSet queryResults = statement.executeQuery(); + queryResults.first(); + System.out.println(queryResults); + Item retrievedItem = new Item(queryResults); + System.out.println(retrievedItem); + return retrievedItem; + } finally { + connection.close(); + } + } +} diff --git a/Lambdas/Lists/List/src/ItemEntry.java b/Lambdas/Lists/List/src/ItemEntry.java new file mode 100644 index 0000000..f03e910 --- /dev/null +++ b/Lambdas/Lists/List/src/ItemEntry.java @@ -0,0 +1,50 @@ +import java.sql.ResultSet; +import java.sql.SQLException; +import java.time.LocalDateTime; + +public class ItemEntry { + Integer listID; + Integer productID; + Integer quantity; + LocalDateTime addedDate; + Boolean purchased; + public ItemEntry(Integer listID, ResultSet listRow) throws SQLException { + this.listID = listID; + productID = listRow.getInt(1); + quantity = listRow.getInt(2); + addedDate = listRow.getObject(3, LocalDateTime.class); + purchased = listRow.getBoolean(4); + } + + public Integer getProductID() { + return productID; + } + + public void setProductID(Integer productID) { + this.productID = productID; + } + + public Integer getQuantity() { + return quantity; + } + + public void setQuantity(Integer quantity) { + this.quantity = quantity; + } + + public LocalDateTime getAddedDate() { + return addedDate; + } + + public void setAddedDate(LocalDateTime addedDate) { + this.addedDate = addedDate; + } + + public Boolean getPurchased() { + return purchased; + } + + public void setPurchased(Boolean purchased) { + this.purchased = purchased; + } +} diff --git a/Lambdas/Lists/List/src/List.java b/Lambdas/Lists/List/src/List.java new file mode 100644 index 0000000..1216c26 --- /dev/null +++ b/Lambdas/Lists/List/src/List.java @@ -0,0 +1,72 @@ +import java.sql.ResultSet; +import java.sql.SQLException; +import java.time.Instant; +import java.time.LocalDateTime; +import java.util.ArrayList; + +public class List { + Integer itemID; + String name; + String owner; + long lastUpdated; + ArrayList entries; + + public List(ResultSet listRow) throws SQLException { + itemID = listRow.getInt("listID"); + name = listRow.getString("name"); + owner = listRow.getString("owner"); + lastUpdated = listRow.getTimestamp("lastUpdated").toInstant().toEpochMilli(); + entries = new ArrayList<>(); + } + + public void addItemEntry(ItemEntry entry) { + entries.add(entry); + } + + @Override + public String toString() { + return "List{" + + "itemID=" + itemID + + ", name='" + name + '\'' + + ", owner='" + owner + '\'' + + ", lastUpdated=" + lastUpdated + + ", entries=" + entries + + '}'; + } + + public ItemEntry[] getEntries() { + return entries.toArray(new ItemEntry[entries.size()]); + } + + public Integer getItemID() { + return itemID; + } + + public void setItemID(Integer itemID) { + this.itemID = itemID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public long getLastUpdated() { + return lastUpdated; + } + + public void setLastUpdated(long lastUpdated) { + this.lastUpdated = lastUpdated; + } +} diff --git a/Lambdas/Lists/List/src/ListAdder.java b/Lambdas/Lists/List/src/ListAdder.java new file mode 100644 index 0000000..011cbc9 --- /dev/null +++ b/Lambdas/Lists/List/src/ListAdder.java @@ -0,0 +1,33 @@ +import java.sql.*; +import java.time.Instant; +import java.time.ZoneOffset; +import java.util.HashMap; +import java.util.Map; + +public class ListAdder implements CallHandler { + + private DBConnector connector; + private String cognitoID; + + private final String LIST_CREATE = "INSERT INTO List (name, owner, lastUpdated) VALUES (?, ?, ?)"; + + public ListAdder(DBConnector connector, String cognitoID) { + this.connector = connector; + this.cognitoID = cognitoID; + } + + public Object conductAction(Map bodyMap, HashMap queryString, String cognitoID) throws SQLException { + Connection connection = connector.getConnection(); + PreparedStatement statement = connection.prepareStatement(LIST_CREATE, Statement.RETURN_GENERATED_KEYS); + statement.setString(1, bodyMap.get("name").toString());//Needs safe checking + statement.setString(2, cognitoID); + statement.setTimestamp(3, Timestamp.from(Instant.now())); + System.out.println(statement); + statement.executeUpdate(); + ResultSet newIDRS = statement.getGeneratedKeys(); + newIDRS.first(); + Integer newID = newIDRS.getInt(1); + connection.commit(); + return newID; + } +} diff --git a/Lambdas/Lists/List/src/ListGET.java b/Lambdas/Lists/List/src/ListGET.java new file mode 100644 index 0000000..12a0889 --- /dev/null +++ b/Lambdas/Lists/List/src/ListGET.java @@ -0,0 +1,12 @@ +import com.amazonaws.services.lambda.runtime.Context; +import com.amazonaws.services.lambda.runtime.RequestHandler; + +import java.util.Map; + +public class ListGET implements RequestHandler, Object> { + + public Object handleRequest(Map inputMap, Context unfilled) { + return BasicHandler.handleRequest(inputMap, unfilled, ListGetter.class); + } + +} \ No newline at end of file diff --git a/Lambdas/Lists/List/src/ListGetter.java b/Lambdas/Lists/List/src/ListGetter.java new file mode 100644 index 0000000..e34366c --- /dev/null +++ b/Lambdas/Lists/List/src/ListGetter.java @@ -0,0 +1,58 @@ +import com.google.gson.Gson; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +public class ListGetter implements CallHandler{ + private final DBConnector connector; + private final String cognitoID; + + private final String GET_LIST = "SELECT * FROM List WHERE listID = ?;"; + private final String GET_LISTS = "SELECT listID FROM List WHERE owner = ?;"; + private final String GET_ENTRIES = "SELECT * FROM ListProduct WHERE listID = ?;"; + + public ListGetter(DBConnector connector, String cognitoID) { + this.connector = connector; + this.cognitoID = cognitoID; + } + + @Override + public Object conductAction(Map bodyMap, HashMap queryMap, String cognitoID) throws SQLException { + try (Connection connection = connector.getConnection()) { + Integer id = Integer.parseInt(queryMap.get("id")); + if (id == -1) { + PreparedStatement getLists = connection.prepareStatement(GET_LISTS); + getLists.setString(1, cognitoID); + System.out.println(getLists); + ResultSet getListsResults = getLists.executeQuery(); + System.out.println(getListsResults); + ArrayList listIds = new ArrayList<>(); + while (getListsResults.next()) { + listIds.add(getListsResults.getInt(1)); + } + return listIds; + } + PreparedStatement getList = connection.prepareStatement(GET_LIST); + getList.setInt(1, id); + System.out.println(getList); + ResultSet getListResults = getList.executeQuery(); + getListResults.first(); + System.out.println(getListResults); + List retrievedList = new List(getListResults); + System.out.println(retrievedList); + PreparedStatement getListEntries = connection.prepareStatement(GET_ENTRIES); + getListEntries.setInt(1, id); + ResultSet getEntryResults = getListEntries.executeQuery(); + while (getEntryResults.next()) { + retrievedList.addItemEntry(new ItemEntry(id, getEntryResults)); + } + System.out.println(retrievedList); + return retrievedList; + } + } +} diff --git a/Lambdas/Lists/List/src/ListPOST.java b/Lambdas/Lists/List/src/ListPOST.java new file mode 100644 index 0000000..4d47863 --- /dev/null +++ b/Lambdas/Lists/List/src/ListPOST.java @@ -0,0 +1,11 @@ +import java.util.Map; + +import com.amazonaws.services.lambda.runtime.Context; +import com.amazonaws.services.lambda.runtime.RequestHandler; + +public class ListPOST implements RequestHandler, Object>{ + + public Object handleRequest(Map inputMap, Context unfilled) { + return BasicHandler.handleRequest(inputMap, unfilled, ListAdder.class); + } +} diff --git a/Lambdas/Lists/ListEntry/src/ListEntryAdder.java b/Lambdas/Lists/ListEntry/src/ListEntryAdder.java new file mode 100644 index 0000000..2145cd5 --- /dev/null +++ b/Lambdas/Lists/ListEntry/src/ListEntryAdder.java @@ -0,0 +1,38 @@ +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.time.Instant; +import java.time.ZoneOffset; +import java.util.HashMap; +import java.util.Map; + +public class ListEntryAdder implements CallHandler { + + private DBConnector connector; + private String cognitoID; + + private final String ITEM_TO_LIST = "INSERT INTO ListProduct (productID, listID, quantity, addedDate, purchased) VALUES (?, ?, ?, ?, ?)"; + + public ListEntryAdder(DBConnector connector, String cognitoID) { + this.connector = connector; + this.cognitoID = cognitoID; + } + + public Object conductAction(Map bodyMap, HashMap queryString, String cognitoID) throws SQLException { + Connection connection = connector.getConnection(); + try { + PreparedStatement statement = connection.prepareStatement(ITEM_TO_LIST); + statement.setInt(1, (Integer) bodyMap.get("productID")); + statement.setInt(2, (Integer) bodyMap.get("listID")); + statement.setInt(3, (Integer) bodyMap.get("quantity")); + statement.setObject(4, Instant.now().atZone(ZoneOffset.UTC).toLocalDateTime()); + statement.setBoolean(5, (Boolean) bodyMap.get("purchased")); + System.out.println(statement); + statement.executeUpdate(); + connection.commit(); + } finally { + connection.close(); + } + return null; + } +} diff --git a/Lambdas/Lists/ListEntry/src/ListEntryDELETE.java b/Lambdas/Lists/ListEntry/src/ListEntryDELETE.java new file mode 100644 index 0000000..ad3045d --- /dev/null +++ b/Lambdas/Lists/ListEntry/src/ListEntryDELETE.java @@ -0,0 +1,11 @@ +import com.amazonaws.services.lambda.runtime.Context; +import com.amazonaws.services.lambda.runtime.RequestHandler; + +import java.util.Map; + +public class ListEntryDELETE implements RequestHandler, Object> { + + public Object handleRequest(Map inputMap, Context unfilled) { + return BasicHandler.handleRequest(inputMap, unfilled, ListEntryDeleter.class); + } +} \ No newline at end of file diff --git a/Lambdas/Lists/ListEntry/src/ListEntryDeleter.java b/Lambdas/Lists/ListEntry/src/ListEntryDeleter.java new file mode 100644 index 0000000..af074cd --- /dev/null +++ b/Lambdas/Lists/ListEntry/src/ListEntryDeleter.java @@ -0,0 +1,33 @@ +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.util.HashMap; +import java.util.Map; + +public class ListEntryDeleter implements CallHandler { + + private DBConnector connector; + private String cognitoID; + + private final String REMOVE_FROM_LIST = "DELETE FROM ListProduct WHERE (ProductID = ? AND ListID = ?);"; + + public ListEntryDeleter(DBConnector connector, String cognitoID) { + this.connector = connector; + this.cognitoID = cognitoID; + } + + public Object conductAction(Map bodyMap, HashMap queryString, String cognitoID) throws SQLException { + Connection connection = connector.getConnection(); + try { + PreparedStatement statement = connection.prepareStatement(REMOVE_FROM_LIST); + statement.setInt(1, (Integer) bodyMap.get("ProductID")); + statement.setInt(2, (Integer) bodyMap.get("ListID")); + System.out.println(statement); + statement.executeUpdate(); + connection.commit(); + } finally { + connection.close(); + } + return null; + } +} diff --git a/Lambdas/Lists/ListEntry/src/ListEntryPOST.java b/Lambdas/Lists/ListEntry/src/ListEntryPOST.java new file mode 100644 index 0000000..828c43c --- /dev/null +++ b/Lambdas/Lists/ListEntry/src/ListEntryPOST.java @@ -0,0 +1,11 @@ +import com.amazonaws.services.lambda.runtime.Context; +import com.amazonaws.services.lambda.runtime.RequestHandler; + +import java.util.Map; + +public class ListEntryPOST implements RequestHandler, Object> { + + public Object handleRequest(Map inputMap, Context unfilled) { + return BasicHandler.handleRequest(inputMap, unfilled, ListEntryAdder.class); + } +} diff --git a/Lambdas/Lists/User/resources/cognitoProperties.json b/Lambdas/Lists/User/resources/cognitoProperties.json new file mode 100644 index 0000000..a01aefd --- /dev/null +++ b/Lambdas/Lists/User/resources/cognitoProperties.json @@ -0,0 +1,3 @@ +{ + "userPoolId": "us-east-2_MFgSVKQMd", +} \ No newline at end of file diff --git a/Lambdas/Lists/User/src/UserDELETE.java b/Lambdas/Lists/User/src/UserDELETE.java new file mode 100644 index 0000000..b1a7076 --- /dev/null +++ b/Lambdas/Lists/User/src/UserDELETE.java @@ -0,0 +1,11 @@ +import com.amazonaws.services.lambda.runtime.Context; +import com.amazonaws.services.lambda.runtime.RequestHandler; + +import java.util.Map; + +public class UserDELETE implements RequestHandler, Object> { + + public Object handleRequest(Map inputMap, Context unfilled) { + return BasicHandler.handleRequest(inputMap, unfilled, UserDeleter.class); + } +} \ No newline at end of file diff --git a/Lambdas/Lists/User/src/UserDeleter.java b/Lambdas/Lists/User/src/UserDeleter.java new file mode 100644 index 0000000..14f08ae --- /dev/null +++ b/Lambdas/Lists/User/src/UserDeleter.java @@ -0,0 +1,58 @@ +import com.amazonaws.services.cognitoidp.AWSCognitoIdentityProvider; +import com.amazonaws.services.cognitoidp.AWSCognitoIdentityProviderClientBuilder; +import com.amazonaws.services.cognitoidp.model.AdminDeleteUserRequest; +import com.amazonaws.services.cognitoidp.model.AdminUserGlobalSignOutRequest; + +import java.io.IOException; +import java.sql.SQLException; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +public class UserDeleter implements CallHandler { + + private DBConnector connector; + private String cognitoID; + + //private final String REMOVE_FROM_LIST = "DELETE FROM ListProduct WHERE (ProductID = ? AND ListID = ?);"; + + public UserDeleter(DBConnector connector, String cognitoID) { + this.connector = connector; + this.cognitoID = cognitoID; + } + + public Object conductAction(Map bodyMap, HashMap queryString, String cognitoID) throws SQLException { + AWSCognitoIdentityProvider awsCognitoIdentityProvider = AWSCognitoIdentityProviderClientBuilder.defaultClient(); + Properties cognitoProperties; + try { + cognitoProperties = DBConnector.loadProperties("cognitoProperties.json"); + } catch (IOException e) { + e.printStackTrace(); + return null; + } + String userPoolId = cognitoProperties.get("userPoolId").toString(); + System.out.println(userPoolId); + AdminUserGlobalSignOutRequest adminUserGlobalSignOutRequest = new AdminUserGlobalSignOutRequest().withUserPoolId(userPoolId); + adminUserGlobalSignOutRequest.setUsername(cognitoID); + System.out.println(adminUserGlobalSignOutRequest); + awsCognitoIdentityProvider.adminUserGlobalSignOut(adminUserGlobalSignOutRequest); + AdminDeleteUserRequest adminDeleteUserRequest = new AdminDeleteUserRequest().withUserPoolId(userPoolId); + adminDeleteUserRequest.setUsername(cognitoID); + System.out.println(adminDeleteUserRequest); + awsCognitoIdentityProvider.adminDeleteUser(adminDeleteUserRequest); + return null; + + // Connection connection = connector.getConnection(); +// try { +// PreparedStatement statement = connection.prepareStatement(REMOVE_FROM_LIST); +// statement.setInt(1, (Integer) bodyMap.get("ProductID")); +// statement.setInt(2, (Integer) bodyMap.get("ListID")); +// System.out.println(statement); +// statement.executeUpdate(); +// connection.commit(); +// } finally { +// connection.close(); +// } +// return null; + } +} diff --git a/Lambdas/Lists/pom.xml b/Lambdas/Lists/pom.xml index 8d77579..9fb5565 100644 --- a/Lambdas/Lists/pom.xml +++ b/Lambdas/Lists/pom.xml @@ -39,6 +39,56 @@ mariadb-java-client 2.7.0 + + org.apache.httpcomponents + httpclient + 4.5.12 + + + com.google.code.gson + gson + 2.8.6 + + + com.amazonaws + aws-java-sdk-cognitoidentity + 1.11.875 + + + com.amazonaws + aws-java-sdk-cognitoidp + 1.11.875 + + + software.amazon.ion + ion-java + 1.5.1 + + + joda-time + joda-time + 2.10.6 + + + commons-logging + commons-logging + 1.2 + + + com.fasterxml.jackson.dataformat + jackson-dataformat-cbor + 2.11.3 + + + com.fasterxml.jackson.dataformat + jackson-dataformat-xml + 2.8.5 + + + com.fasterxml.jackson.core + jackson-databind + 2.11.3 + 1.11 diff --git a/Lambdas/Lists/src/main/java/BasicHandler.java b/Lambdas/Lists/src/main/java/BasicHandler.java new file mode 100644 index 0000000..8c3e1d3 --- /dev/null +++ b/Lambdas/Lists/src/main/java/BasicHandler.java @@ -0,0 +1,31 @@ +import com.amazonaws.services.lambda.runtime.Context; + +import java.io.IOException; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.sql.SQLException; +import java.util.HashMap; +import java.util.Map; + +public class BasicHandler { + public static Object handleRequest(Map inputMap, Context unfilled, Class toCall) { + String cognitoID = InputUtils.getCognitoIDFromBody(inputMap); + HashMap queryMap = InputUtils.getQueryParams(inputMap); + try { + DBConnector connector = new DBConnector(); + try { + Constructor constructor = toCall.getConstructor(DBConnector.class, String.class); + CallHandler callHandler = constructor.newInstance(connector, cognitoID); + return callHandler.conductAction(InputUtils.getBody(inputMap), queryMap, cognitoID); + } catch (SQLException | NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) { + e.printStackTrace(); + } finally { + connector.close(); + } + } catch (IOException |SQLException|ClassNotFoundException e) { + e.printStackTrace(); + throw new RuntimeException(e.getLocalizedMessage()); + } + return null; + } +} diff --git a/Lambdas/Lists/src/main/java/CallHandler.java b/Lambdas/Lists/src/main/java/CallHandler.java new file mode 100644 index 0000000..a637412 --- /dev/null +++ b/Lambdas/Lists/src/main/java/CallHandler.java @@ -0,0 +1,7 @@ +import java.sql.SQLException; +import java.util.HashMap; +import java.util.Map; + +public interface CallHandler { + Object conductAction(Map bodyMap, HashMap queryString, String cognitoID) throws SQLException; +} diff --git a/Lambdas/Lists/src/main/java/DBConnector.java b/Lambdas/Lists/src/main/java/DBConnector.java index 074f4de..798cfc3 100644 --- a/Lambdas/Lists/src/main/java/DBConnector.java +++ b/Lambdas/Lists/src/main/java/DBConnector.java @@ -12,11 +12,11 @@ public class DBConnector { Connection connection; - DBConnector() throws IOException, SQLException, ClassNotFoundException { + public DBConnector() throws IOException, SQLException, ClassNotFoundException { this(loadProperties("dbProperties.json")); } - DBConnector(Properties dbProperties) throws SQLException, ClassNotFoundException { + public DBConnector(Properties dbProperties) throws SQLException, ClassNotFoundException { Class.forName("org.mariadb.jdbc.Driver"); System.out.println(dbProperties); System.out.println(DBConnector.buildURL(dbProperties)); diff --git a/Lambdas/Lists/src/main/java/InputUtils.java b/Lambdas/Lists/src/main/java/InputUtils.java index 46a0694..2a4e8bc 100644 --- a/Lambdas/Lists/src/main/java/InputUtils.java +++ b/Lambdas/Lists/src/main/java/InputUtils.java @@ -1,3 +1,9 @@ +import org.apache.http.NameValuePair; +import org.apache.http.client.utils.URLEncodedUtils; + +import java.nio.charset.StandardCharsets; +import java.util.HashMap; +import java.util.List; import java.util.Map; public class InputUtils { @@ -19,6 +25,24 @@ public class InputUtils { return getMap(inputMap, "body"); } + private static String getQueryString(Map inputMap) { + return (String) (getMap(inputMap, "params").get("querystring")); + } + + public static HashMap getQueryParams(Map inputMap) { + return (HashMap) (getMap(inputMap, "params").get("querystring")); + +// String queryString = getQueryString(inputMap); +// List queryparams = URLEncodedUtils.parse(queryString, StandardCharsets.UTF_8); +// HashMap mappedParams = new HashMap<>(); +// for (NameValuePair param : queryparams) { +// mappedParams.put(param.getName(), param.getValue()); +// } +// return mappedParams; + } + + + public static Map getMap(Map parentMap, String childKey) { if ((parentMap.get(childKey) != null) && (parentMap.get(childKey) instanceof Map)) { return ((Map) parentMap.get(childKey)); diff --git a/Lambdas/Lists/src/main/java/ListAdder.java b/Lambdas/Lists/src/main/java/ListAdder.java deleted file mode 100644 index e1598b7..0000000 --- a/Lambdas/Lists/src/main/java/ListAdder.java +++ /dev/null @@ -1,27 +0,0 @@ -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.SQLException; -import java.util.Map; - -public class ListAdder { - - private DBConnector connector; - private String cognitoID; - - private final String LIST_CREATE = "INSERT INTO Lists (Name, Owner) VALUES (?, ?)"; - - ListAdder(DBConnector connector, String cognitoID) { - this.connector = connector; - this.cognitoID = cognitoID; - } - - public void add(Map bodyMap) throws SQLException { - Connection connection = connector.getConnection(); - PreparedStatement statement = connection.prepareStatement(LIST_CREATE); - statement.setString(1, bodyMap.get("name").toString());//Needs safe checking - statement.setString(2, cognitoID); - System.out.println(statement); - statement.executeUpdate(); - connection.commit(); - } -} diff --git a/Lambdas/Lists/src/main/java/ListPOST.java b/Lambdas/Lists/src/main/java/ListPOST.java deleted file mode 100644 index c2fc63c..0000000 --- a/Lambdas/Lists/src/main/java/ListPOST.java +++ /dev/null @@ -1,28 +0,0 @@ -import java.io.IOException; -import java.sql.SQLException; -import java.util.Map; - -import com.amazonaws.services.lambda.runtime.Context; -import com.amazonaws.services.lambda.runtime.RequestHandler; - -public class ListPOST implements RequestHandler, String>{ - - - public String handleRequest(Map inputMap, Context unfilled) { - String cognitoID = InputUtils.getCognitoIDFromBody(inputMap); - try { - DBConnector connector = new DBConnector(); - try { - new ListAdder(connector, cognitoID).add(InputUtils.getBody(inputMap)); - } catch (SQLException e) { - e.printStackTrace(); - } finally { - connector.close(); - } - } catch (IOException|SQLException|ClassNotFoundException e) { - e.printStackTrace(); - throw new RuntimeException(e.getMessage()); - } - return null; - } -} diff --git a/Lambdas/Lists/target/Lists-1.0-SNAPSHOT.jar b/Lambdas/Lists/target/Lists-1.0-SNAPSHOT.jar new file mode 100644 index 0000000..a611fef Binary files /dev/null and b/Lambdas/Lists/target/Lists-1.0-SNAPSHOT.jar differ diff --git a/Lambdas/Lists/target/maven-archiver/pom.properties b/Lambdas/Lists/target/maven-archiver/pom.properties new file mode 100644 index 0000000..68bd418 --- /dev/null +++ b/Lambdas/Lists/target/maven-archiver/pom.properties @@ -0,0 +1,5 @@ +#Generated by Maven +#Mon Oct 05 10:19:24 EDT 2020 +groupId=groupId +artifactId=Lists +version=1.0-SNAPSHOT diff --git a/Lambdas/Lists/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/Lambdas/Lists/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..db1626f --- /dev/null +++ b/Lambdas/Lists/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,4 @@ +/Users/MNM/Documents/GitHub/Listify/Lambdas/Lists/src/main/java/CallHandler.java +/Users/MNM/Documents/GitHub/Listify/Lambdas/Lists/src/main/java/DBConnector.java +/Users/MNM/Documents/GitHub/Listify/Lambdas/Lists/src/main/java/BasicHandler.java +/Users/MNM/Documents/GitHub/Listify/Lambdas/Lists/src/main/java/InputUtils.java diff --git a/Listify/app/build.gradle b/Listify/app/build.gradle index 099077a..0ad5dc3 100644 --- a/Listify/app/build.gradle +++ b/Listify/app/build.gradle @@ -50,5 +50,6 @@ dependencies { implementation 'org.json:json:20200518' implementation 'com.github.bumptech.glide:glide:4.11.0' annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0' + implementation 'com.squareup.okhttp3:okhttp:4.8.1' } \ No newline at end of file diff --git a/Listify/app/src/main/java/com/example/listify/AuthManager.java b/Listify/app/src/main/java/com/example/listify/AuthManager.java index 4e67ed3..1248a05 100644 --- a/Listify/app/src/main/java/com/example/listify/AuthManager.java +++ b/Listify/app/src/main/java/com/example/listify/AuthManager.java @@ -8,6 +8,7 @@ import com.amplifyframework.auth.options.AuthSignUpOptions; import com.amplifyframework.auth.result.AuthSignInResult; import com.amplifyframework.auth.result.AuthSignUpResult; import com.amplifyframework.core.Amplify; +import com.example.listify.data.User; import org.json.JSONException; import org.json.JSONObject; @@ -44,6 +45,17 @@ public class AuthManager { } public String getUserToken() { + if (authSession == null) { + try { + fetchAuthSession(); + } catch (AuthException e) { + e.printStackTrace(); + return ""; + } + } + if (authSession.isSignedIn() == false) { + return ""; + } return authSession.getUserPoolTokens().getValue().getIdToken(); } @@ -78,6 +90,10 @@ public class AuthManager { waiting = false; } + public void signOutSuccess() { + waiting = false; + } + public void startSignUp(String email, String password) throws AuthException { this.email = email; this.password = password; @@ -117,7 +133,17 @@ public class AuthManager { throwIfAuthError(); } + public void deleteUser(Requestor requestor) throws AuthException { + requestor.deleteObject("N/A", User.class); + signOutUser(); + } + public void signOutUser() throws AuthException { + authSession = null; + waiting = true; + Amplify.Auth.signOut(this::signOutSuccess, error -> setAuthError(error)); + throwIfAuthError(); + } public static Properties loadProperties(Context context, String path) throws IOException, JSONException { Properties toReturn = new Properties(); diff --git a/Listify/app/src/main/java/com/example/listify/MainActivity.java b/Listify/app/src/main/java/com/example/listify/MainActivity.java index 0549e08..5590ccd 100644 --- a/Listify/app/src/main/java/com/example/listify/MainActivity.java +++ b/Listify/app/src/main/java/com/example/listify/MainActivity.java @@ -13,11 +13,18 @@ import androidx.navigation.Navigation; import androidx.navigation.ui.AppBarConfiguration; import androidx.navigation.ui.NavigationUI; import com.amplifyframework.auth.AuthException; +import com.example.listify.data.Item; +import com.example.listify.data.List; +import com.example.listify.data.ListEntry; import com.google.android.material.navigation.NavigationView; import org.json.JSONException; import java.io.IOException; +import java.time.Instant; +import java.time.ZoneOffset; +import java.util.Arrays; import java.util.Properties; +import java.util.Random; public class MainActivity extends AppCompatActivity { private AppBarConfiguration mAppBarConfiguration; @@ -25,42 +32,84 @@ public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + + //------------------------------Auth Testing---------------------------------------------// - /*AuthManager authManager = new AuthManager(); - try { - authManager.signIn("merzn@purdue.edu", "Password123"); - Log.i("Authentication", authManager.getAuthSession().toString()); - Log.i("Token", authManager.getAuthSession().getUserPoolTokens().getValue().getIdToken()); - } - catch (AuthException e) { - Log.i("Authentication", "Login failed. User probably needs to register. Exact error: " + e.getMessage()); - try { - authManager.startSignUp("merzn@purdue.edu", "Password123"); - authManager.confirmSignUp("######"); - } catch (AuthException signUpError) { - Log.e("Authentication", "SignUp error: " + signUpError.getMessage()); - } - }*/ + boolean testAuth = false; + if (testAuth) { + + AuthManager authManager = new AuthManager(); + try { + authManager.signIn("merzn@purdue.edu", "Password123"); + Log.i("Authentication", authManager.getAuthSession().toString()); + Log.i("Token", authManager.getAuthSession().getUserPoolTokens().getValue().getIdToken()); + } catch (AuthException e) { + Log.i("Authentication", "Login failed. User probably needs to register. Exact error: " + e.getMessage()); + try { + authManager.startSignUp("merzn@purdue.edu", "Password123"); + authManager.confirmSignUp("######"); + } catch (AuthException signUpError) { + Log.e("Authentication", "SignUp error: " + signUpError.getMessage()); + } + } + } + //NOTE: deleteUser is slightly unusual in that it requires a Requestor. See below for building one + //authManager.deleteUser(requestor); + + //------------------------------------------------------------------------------------------// + + + boolean testAPI = false; //----------------------------------API Testing---------------------------------------------// - /*Properties configs = new Properties(); - try { - configs = AuthManager.loadProperties(this, "android.resource://" + getPackageName() + "/raw/auths.json"); - } - catch (IOException|JSONException e) { - e.printStackTrace(); - }*/ + if (testAPI) { + AuthManager authManager = new AuthManager(); + try { + authManager.signIn("merzn@purdue.edu", "Password123"); + } catch (AuthException e) { + e.printStackTrace(); + } + Properties configs = new Properties(); + try { + configs = AuthManager.loadProperties(this, "android.resource://" + getPackageName() + "/raw/auths.json"); + } catch (IOException | JSONException e) { + e.printStackTrace(); + } - /*Requestor requestor = new Requestor(this, authManager,configs.getProperty("apiKey")); - List testList = new List("IAmATestList"); - try { - requestor.postObject(testList); + Requestor requestor = new Requestor(authManager, configs.getProperty("apiKey")); + + + //The name is the only part of this that is used, the rest is generated by the Lambda. + List testList = new List(-1, "New List", "user filled by lambda", Instant.now().toEpochMilli()); + //Everything except addedDate is used for ItemEntry + ListEntry entry = new ListEntry(1, 1, new Random().nextInt(), Instant.now().atZone(ZoneOffset.UTC).toLocalDateTime(),false); + SynchronousReceiver idReceiver = new SynchronousReceiver<>(); + try { + requestor.postObject(testList, idReceiver, idReceiver); + System.out.println(idReceiver.await()); + requestor.postObject(entry); + } catch (Exception e) { + e.printStackTrace(); + } + + SynchronousReceiver itemReceiver = new SynchronousReceiver<>(); + requestor.getObject("1", Item.class, itemReceiver, itemReceiver); + SynchronousReceiver listReceiver = new SynchronousReceiver<>(); + requestor.getObject("39", List.class, listReceiver, listReceiver); + SynchronousReceiver listIdsReceiver = new SynchronousReceiver<>(); + requestor.getListOfIds(List.class, listIdsReceiver, listIdsReceiver); + try { + System.out.println(itemReceiver.await()); + System.out.println(listReceiver.await()); + System.out.println(Arrays.toString(listIdsReceiver.await())); + } catch (Exception receiverError) { + receiverError.printStackTrace(); + } } - catch (JSONException e) { - e.printStackTrace(); - }*/ + //------------------------------------------------------------------------------------------// + setContentView(R.layout.activity_main); Toolbar toolbar = findViewById(R.id.toolbar); diff --git a/Listify/app/src/main/java/com/example/listify/Requestor.java b/Listify/app/src/main/java/com/example/listify/Requestor.java index 0c7b48d..84043f1 100644 --- a/Listify/app/src/main/java/com/example/listify/Requestor.java +++ b/Listify/app/src/main/java/com/example/listify/Requestor.java @@ -1,66 +1,130 @@ package com.example.listify; -import android.content.Context; -import com.android.volley.RequestQueue; -import com.android.volley.Response; -import com.android.volley.toolbox.JsonObjectRequest; -import com.android.volley.toolbox.Volley; +import android.util.Log; import com.google.gson.Gson; +import com.google.gson.JsonSyntaxException; +import okhttp3.*; +import org.jetbrains.annotations.NotNull; import org.json.JSONException; -import org.json.JSONObject; -import java.util.HashMap; -import java.util.Map; +import java.io.IOException; public class Requestor { private final String DEV_BASEURL = "https://datoh7woc9.execute-api.us-east-2.amazonaws.com/Development"; AuthManager authManager; - RequestQueue queue; String apiKey; + OkHttpClient client; - Requestor(Context context, AuthManager authManager, String apiKey) { - queue = Volley.newRequestQueue(context); + Requestor(AuthManager authManager, String apiKey) { this.authManager = authManager; this.apiKey = apiKey; + client = new OkHttpClient(); + } + + public void getListOfIds(Class ofType, Receiver successHandler, RequestErrorHandler failureHandler) { + String getURL = DEV_BASEURL + "/" + ofType.getSimpleName() + "?id=-1"; + Request postRequest = buildBaseRequest(getURL, "GET", null); + launchCall(postRequest, successHandler, Integer[].class, failureHandler); } public void getObject(String id, Class classType, Receiver receiver) { - String getURL = DEV_BASEURL + "/" + classType.getSimpleName() + "?id=" + id; + getObject(id, classType, receiver, null); } - public void postObject(Object toPost, Response.ErrorListener failureHandler) throws JSONException { - String postURL = DEV_BASEURL + "/" + toPost.getClass().getSimpleName(); - queue.add(buildRequest(postURL, toPost, null, failureHandler)); + public void getObject(String id, Class classType, Receiver successHandler, RequestErrorHandler failureHandler) { + String getURL = DEV_BASEURL + "/" + classType.getSimpleName() + "?id=" + id; + Request getRequest = buildBaseRequest(getURL, "GET", null); + launchCall(getRequest, successHandler, classType, failureHandler); + } + + public void deleteObject(String id, Class classType) { + deleteObject(id, classType, null); + } + + public void deleteObject(String id, Class classType, RequestErrorHandler failureHandler) { + String deleteURL = DEV_BASEURL + "/" + classType.getSimpleName() + "?id=" + id; + Request deleteRequest = buildBaseRequest(deleteURL, "DELETE", "{}"); + launchCall(deleteRequest, null, classType, failureHandler); } public void postObject(Object toPost) throws JSONException { - postObject(toPost, null); + postObject(toPost, (RequestErrorHandler) null); } - private JsonObjectRequest buildRequest(String url, Object toJSONify, Response.Listener successHandler, Response.ErrorListener failureHandler) throws JSONException { - return buildRequest(url, new JSONObject(new Gson().toJson(toJSONify)), successHandler, failureHandler); + public void postObject(Object toPost, RequestErrorHandler failureHandler) throws JSONException { + postObject(toPost, null, failureHandler); } - private JsonObjectRequest buildRequest(String url, JSONObject jsonBody, Response.Listener successHandler, Response.ErrorListener failureHandler) { - return new JsonObjectRequest(url, jsonBody, successHandler, failureHandler) { + public void postObject(Object toPost, Receiver idReceiver) throws JSONException { + postObject(toPost, idReceiver, null); + } + + public void postObject(Object toPost, Receiver idReceiver, RequestErrorHandler failureHandler) throws JSONException { + String postURL = DEV_BASEURL + "/" + toPost.getClass().getSimpleName(); + Request postRequest = buildBaseRequest(postURL, "POST", new Gson().toJson(toPost)); + launchCall(postRequest, idReceiver, Integer.class, failureHandler); + } + + private void launchCall(Request toLaunch, Receiver receiver, Class classType, RequestErrorHandler failureHandler) { + client.newCall(toLaunch).enqueue(new Callback() { @Override - public Map getHeaders() { - HashMap headers = new HashMap<>(); - System.out.println(authManager.getUserToken()); - headers.put("Authorization", authManager.getUserToken()); - headers.put("Content-Type", "application/json"); - headers.put("X-API-Key", apiKey); - return headers; + public void onResponse(@NotNull Call call, @NotNull okhttp3.Response response) throws IOException { + String responseString = response.body().string(); + if (receiver != null) { + if (classType == null) { + Log.e("Requestor Contract Error", "classType while receiver populated"); + } + try { + receiver.acceptDelivery(new Gson().fromJson(responseString, classType)); + } catch (JsonSyntaxException e) { + System.out.println(e); + Log.e("API response was not proper JSON", responseString); + if (failureHandler != null) { + failureHandler.acceptError(e); + } + //throw new JsonSyntaxException(e); + } + } + Log.d("API Response", responseString); } - }; + @Override + public void onFailure(@NotNull Call call, IOException e) { + if (failureHandler != null) { + failureHandler.acceptError(e); + } else { + Log.e("Network Error", e.getLocalizedMessage()); + } + } + }); } - public class Receiver { - public void acceptDelivery(T delivered) { + public static final MediaType JSON + = MediaType.parse("application/json; charset=utf-8"); + private Request buildBaseRequest(String url, String method, String bodyJSON) { + Request.Builder requestBase = addAuthHeaders(new Request.Builder().url(url)); + if (method == "GET") { + requestBase.get(); + } else { + requestBase.method(method, RequestBody.create(bodyJSON, JSON)); } + return requestBase.build(); + } + + private Request.Builder addAuthHeaders(Request.Builder toAuthorize) { + toAuthorize.addHeader("Authorization", authManager.getUserToken()); + toAuthorize.addHeader("X-API-Key", apiKey); + return toAuthorize; + } + + public interface Receiver { + void acceptDelivery(T delivered); + } + + public interface RequestErrorHandler { + void acceptError(Exception error); } } diff --git a/Listify/app/src/main/java/com/example/listify/SynchronousReceiver.java b/Listify/app/src/main/java/com/example/listify/SynchronousReceiver.java new file mode 100644 index 0000000..07e390b --- /dev/null +++ b/Listify/app/src/main/java/com/example/listify/SynchronousReceiver.java @@ -0,0 +1,37 @@ +package com.example.listify; + +public class SynchronousReceiver implements Requestor.Receiver, Requestor.RequestErrorHandler { + private volatile boolean waiting; + private volatile Exception error; + private T toReturn; + + public SynchronousReceiver() { + waiting = true; + error = null; + } + + public T await() throws Exception { + while (waiting) { + Thread.yield(); + } + waiting = true; + if (error != null) { + Exception toThrow = error; + error = null; + throw toThrow; + } + return toReturn; + } + + @Override + public void acceptDelivery(Object delivered) { + toReturn = (T) delivered; + waiting = false; + } + + @Override + public void acceptError(Exception error) { + waiting = false; + this.error = error; + } +} diff --git a/Listify/app/src/main/java/com/example/listify/data/Item.java b/Listify/app/src/main/java/com/example/listify/data/Item.java new file mode 100644 index 0000000..07662b5 --- /dev/null +++ b/Listify/app/src/main/java/com/example/listify/data/Item.java @@ -0,0 +1,116 @@ +package com.example.listify.data; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +public class Item { + Integer productID; + Integer chainID; + String upc; + String description; + BigDecimal price; + String imageURL; + String department; + LocalDateTime retrievedDate; + Integer fetchCounts; + + public Item(Integer productID, Integer chainID, String upc, String description, BigDecimal price, + String imageURL, String department, LocalDateTime retrievedDate, Integer fetchCounts) { + this.productID = productID; + this.chainID = chainID; + this.upc = upc; + this.description = description; + this.price = price; + this.imageURL = imageURL; + this.department = department; + this.retrievedDate = retrievedDate; + this.fetchCounts = fetchCounts; + } + + @Override + public String toString() { + return "Item{" + + "productID=" + productID + + ", chainID=" + chainID + + ", upc='" + upc + '\'' + + ", description='" + description + '\'' + + ", price=" + price + + ", imageURL='" + imageURL + '\'' + + ", department='" + department + '\'' + + ", retrievedDate=" + (retrievedDate == null ? null : retrievedDate) + + ", fetchCounts=" + fetchCounts + + '}'; + } + + public Integer getProductID() { + return productID; + } + + public void setProductID(Integer productID) { + this.productID = productID; + } + + public Integer getChainID() { + return chainID; + } + + public void setChainID(Integer chainID) { + this.chainID = chainID; + } + + public String getUpc() { + return upc; + } + + public void setUpc(String upc) { + this.upc = upc; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public BigDecimal getPrice() { + return price; + } + + public void setPrice(BigDecimal price) { + this.price = price; + } + + public String getImageURL() { + return imageURL; + } + + public void setImageURL(String imageURL) { + this.imageURL = imageURL; + } + + public String getDepartment() { + return department; + } + + public void setDepartment(String department) { + this.department = department; + } + + public LocalDateTime getRetrievedDate() { + return retrievedDate; + } + + public void setRetrievedDate(LocalDateTime retrievedDate) { + this.retrievedDate = retrievedDate; + } + + public Integer getFetchCounts() { + return fetchCounts; + } + + public void setFetchCounts(Integer fetchCounts) { + this.fetchCounts = fetchCounts; + } +} diff --git a/Listify/app/src/main/java/com/example/listify/data/List.java b/Listify/app/src/main/java/com/example/listify/data/List.java new file mode 100644 index 0000000..23d77ea --- /dev/null +++ b/Listify/app/src/main/java/com/example/listify/data/List.java @@ -0,0 +1,70 @@ +package com.example.listify.data; + +import java.util.Arrays; + +public class List { + Integer itemID; + String name; + String owner; + long lastUpdated; + final ListEntry[] entries; + + public List(Integer itemID, String name, String owner, long lastUpdated, ListEntry[] entries) { + this.itemID = itemID; + this.name = name; + this.owner = owner; + this.lastUpdated = lastUpdated; + this.entries = entries; + } + + public List(Integer itemID, String name, String owner, long lastUpdated) { + this(itemID, name, owner, lastUpdated, null); + } + + @Override + public String toString() { + return "List{" + + "itemID=" + itemID + + ", name='" + name + '\'' + + ", owner='" + owner + '\'' + + ", lastUpdated=" + lastUpdated + + ", entries=" + Arrays.toString(entries) + + '}'; + } + + public Integer getItemID() { + return itemID; + } + + public void setItemID(Integer itemID) { + this.itemID = itemID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public long getLastUpdated() { + return lastUpdated; + } + + public void setLastUpdated(long lastUpdated) { + this.lastUpdated = lastUpdated; + } + + public ListEntry[] getEntries() { + return entries; + } +} diff --git a/Listify/app/src/main/java/com/example/listify/data/ListEntry.java b/Listify/app/src/main/java/com/example/listify/data/ListEntry.java new file mode 100644 index 0000000..404f649 --- /dev/null +++ b/Listify/app/src/main/java/com/example/listify/data/ListEntry.java @@ -0,0 +1,70 @@ +package com.example.listify.data; + +import java.time.LocalDateTime; + +public class ListEntry { + Integer listID; + Integer productID; + Integer quantity; + LocalDateTime addedDate; + Boolean purchased; + + public ListEntry(Integer listID, Integer productID, Integer quantity, LocalDateTime addedDate, Boolean purchased) { + this.listID = listID; + this.productID = productID; + this.quantity = quantity; + this.addedDate = addedDate; + this.purchased = purchased; + } + + @Override + public String toString() { + return "ListEntry{" + + "listID=" + listID + + ", productID=" + productID + + ", quantity=" + quantity + + ", addedDate=" + addedDate + + ", purchased=" + purchased + + '}'; + } + + public Integer getListID() { + return listID; + } + + public void setListID(Integer listID) { + this.listID = listID; + } + + public Integer getProductID() { + return productID; + } + + public void setProductID(Integer productID) { + this.productID = productID; + } + + public Integer getQuantity() { + return quantity; + } + + public void setQuantity(Integer quantity) { + this.quantity = quantity; + } + + public LocalDateTime getAddedDate() { + return addedDate; + } + + public void setAddedDate(LocalDateTime addedDate) { + this.addedDate = addedDate; + } + + public Boolean getPurchased() { + return purchased; + } + + public void setPurchased(Boolean purchased) { + this.purchased = purchased; + } +} diff --git a/Listify/app/src/main/java/com/example/listify/data/User.java b/Listify/app/src/main/java/com/example/listify/data/User.java new file mode 100644 index 0000000..65ba3e6 --- /dev/null +++ b/Listify/app/src/main/java/com/example/listify/data/User.java @@ -0,0 +1,4 @@ +package com.example.listify.data; + +public class User { +} diff --git a/Tooling/EndpointSetup.sh b/Tooling/EndpointSetup.sh index 9b8940d..7d72d34 100644 --- a/Tooling/EndpointSetup.sh +++ b/Tooling/EndpointSetup.sh @@ -11,7 +11,7 @@ REL_SCRIPT_DIR=$(dirname "${BASH_SOURCE[0]}") source ${REL_SCRIPT_DIR}/VarSetup.sh -RAWLAMBDA=$(aws lambda create-function --function-name ${functionName}${method} --zip-file fileb://${jarPath} --runtime ${LANGUAGE} --role ${LAMBDAROLE} --handler ${functionName}${method} 2>${DEBUGFILE}) +RAWLAMBDA=$(aws lambda create-function --function-name ${functionName}${method} --zip-file fileb://${jarPath} --runtime ${LANGUAGE} --role ${LAMBDAROLE} --handler ${functionName}${method} --memory-size 512 2>${DEBUGFILE}) if [[ $? -ne 0 ]]; then