mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2025-12-15 18:28:47 +00:00
ListShare compiling
Make ListShare compile again
This commit is contained in:
parent
b81f3b3fd6
commit
bede2fc1a0
@ -85,9 +85,6 @@ public class List {
|
||||
|
||||
public void setUiPosition(Integer uiPosition) {
|
||||
this.uiPosition = uiPosition;
|
||||
|
||||
public ItemEntry[] getEntries() {
|
||||
return entries.toArray(new ItemEntry[entries.size()]);
|
||||
}
|
||||
|
||||
public void addItemEntry(ItemEntry entry) {
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
package com.example.listify.data;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ListShare {
|
||||
Integer listID;
|
||||
|
||||
@ -1,12 +0,0 @@
|
||||
import com.amazonaws.services.lambda.runtime.Context;
|
||||
import com.amazonaws.services.lambda.runtime.RequestHandler;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class ListShareDELETE implements RequestHandler<Map<String,Object>, Object> {
|
||||
|
||||
public Object handleRequest(Map<String, Object> inputMap, Context unfilled) {
|
||||
return BasicHandler.handleRequest(inputMap, unfilled, ListShareDeleter.class);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,65 +0,0 @@
|
||||
import java.security.AccessControlException;
|
||||
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 ListShareDeleter implements CallHandler {
|
||||
private final Connection connection;
|
||||
private final String cognitoID;
|
||||
|
||||
private final String GET_LIST_ACCESS = "SELECT * FROM List WHERE (owner = ? AND listID = ?);";
|
||||
private final String REMOVE_SHAREE = "DELETE FROM ListSharee WHERE listID = ? AND user = ?;";
|
||||
|
||||
public ListShareDeleter(Connection connection, String cognitoID) {
|
||||
this.connection = connection;
|
||||
this.cognitoID = cognitoID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object conductAction(Map<String, Object> bodyMap, HashMap<String, String> queryMap, String cognitoID) throws SQLException {
|
||||
Integer listID = Integer.parseInt(queryMap.get("id"));
|
||||
|
||||
InvokeRequest invokeRequest = new InvokeRequest();
|
||||
invokeRequest.setFunctionName("UserGET");
|
||||
invokeRequest.setPayload("{" +
|
||||
" \"body\": {" +
|
||||
" \"emailToCheck\": \"" + bodyMap.get("shareWithEmail").toString() + "\"" +
|
||||
" }," +
|
||||
" \"params\": {" +
|
||||
" \"querystring\": {" +
|
||||
" }" +
|
||||
" }," +
|
||||
" \"context\": {" +
|
||||
" \"sub\": \"not used\"" +
|
||||
" }" +
|
||||
"}");
|
||||
InvokeResult invokeResult = AWSLambdaClientBuilder.defaultClient().invoke(invokeRequest);
|
||||
|
||||
String shareeID = new String(invokeResult.getPayload().array()).replace("\"", "");
|
||||
|
||||
//Ensure that the user who is unsharing a list is the owner of that list
|
||||
PreparedStatement accessCheck = connection.prepareStatement(GET_LIST_ACCESS);
|
||||
accessCheck.setString(1, cognitoID);
|
||||
accessCheck.setInt(2, listID);
|
||||
|
||||
ResultSet userLists = accessCheck.executeQuery();
|
||||
|
||||
//User does not own the list; unshare attempt fails
|
||||
if (!userLists.next()) {
|
||||
throw new AccessControlException("User does not have access to list");
|
||||
}
|
||||
|
||||
//Unshare the list with the specified sharee
|
||||
PreparedStatement unshareList = connection.prepareStatement(REMOVE_SHAREE);
|
||||
unshareList.setInt(1, listID);
|
||||
unshareList.setInt(2, shareeID);
|
||||
|
||||
cleanAccess.executeUpdate();
|
||||
connection.commit();
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -2,7 +2,6 @@ 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;
|
||||
|
||||
@ -21,7 +20,7 @@ public class ListShareGetter implements CallHandler{
|
||||
public Object conductAction(Map<String, Object> bodyMap, HashMap<String, String> queryMap, String cognitoID) throws SQLException {
|
||||
Integer listID = Integer.parseInt(queryMap.get("id"));
|
||||
|
||||
PreparedStatement getList = connection.prepareStatement(GET_LIST);
|
||||
PreparedStatement getList = connection.prepareStatement(GET_LISTS);
|
||||
getList.setInt(1, listID);
|
||||
|
||||
ResultSet getListResults = getList.executeQuery();
|
||||
|
||||
@ -192,12 +192,12 @@ public class MainActivity extends AppCompatActivity implements CreateListDialogF
|
||||
takePicture.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
|
||||
startActivityForResult(takePicture, CAMERA_CAPTURE);
|
||||
});
|
||||
builder.setNeutralButton("Select picture", (dialog, which) -> {
|
||||
builder.setNegativeButton("Select picture", (dialog, which) -> {
|
||||
Intent pickPhoto = new Intent(Intent.ACTION_PICK,
|
||||
MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
|
||||
startActivityForResult(pickPhoto, IMAGE_SELECT);
|
||||
});
|
||||
builder.setNegativeButton("Cancel", (dialog, which) -> {
|
||||
builder.setNeutralButton("Cancel", (dialog, which) -> {
|
||||
});
|
||||
AlertDialog dialog = builder.create();
|
||||
dialog.show();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user