Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/main/Config/AppConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import Organization.Organization;
import Organization.OrganizationController;
import PDF.PdfController;
import PDF.PdfControllerV2;
import Production.ProductionController;
import Security.AccountSecurityController;
import Security.EncryptionTools;
Expand All @@ -34,10 +35,9 @@
import com.mongodb.client.MongoDatabase;
import io.javalin.Javalin;
import io.javalin.http.HttpResponseException;
import org.bson.types.ObjectId;

import java.util.HashMap;
import java.util.Optional;
import org.bson.types.ObjectId;

public class AppConfig {
public static Long ASYNC_TIME_OUT = 10L;
Expand Down Expand Up @@ -82,6 +82,7 @@ public static Javalin appFactory(DeploymentLevel deploymentLevel) {
ProductionController productionController = new ProductionController(orgDao, userDao);
UserControllerV2 userControllerV2 = new UserControllerV2(userV2Dao);
BillingController billingController = new BillingController();
PdfControllerV2 pdfControllerV2 = new PdfControllerV2(fileDao, formDao, userDao, db);
// try { do not recomment this block of code, this will delete and regenerate our encryption
// key
// System.out.println("generating keyset");
Expand Down Expand Up @@ -116,6 +117,16 @@ public static Javalin appFactory(DeploymentLevel deploymentLevel) {
app.post("/get-form", formController.formGet);
app.post("/delete-form/", formController.formDelete);

/* -------------- PDF CONTROLLER v2 --------------------- */
app.post("/delete-pdf-2", pdfControllerV2.deletePDF);
app.post("/download-pdf-2", pdfControllerV2.downloadPDF);
app.post("/filter-pdf-2", pdfControllerV2.filterPDF);
app.post("/upload-pdf-2", pdfControllerV2.uploadPDF);
app.post("/upload-annotated-pdf-2", pdfControllerV2.uploadAnnotatedPDF);
app.post("/upload-signed-pdf-2", pdfControllerV2.uploadSignedPDF);
app.post("/get-questions-2", pdfControllerV2.getQuestions);
app.post("/fill-pdf-2", pdfControllerV2.fillPDF);

/* -------------- USER AUTHENTICATION/USER RELATED ROUTES-------------- */
app.post("/login", userController.loginUser);
app.post("/authenticate", userController.authenticateUser);
Expand Down
29 changes: 20 additions & 9 deletions src/main/File/File.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package File;

import java.io.InputStream;
import java.util.Date;
import java.util.Objects;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.bson.codecs.pojo.annotations.BsonIgnore;
import org.bson.codecs.pojo.annotations.BsonProperty;
import org.bson.types.ObjectId;

import java.io.InputStream;
import java.util.Date;
import java.util.Objects;
import org.json.JSONObject;

@Slf4j
public class File {
Expand All @@ -27,9 +27,7 @@ public class File {
@BsonProperty(value = "annotated")
private boolean isAnnotated;

@Getter
@Setter
private IdCategoryType idCategory;
@Getter @Setter private IdCategoryType idCategory;

@Getter @Setter private String contentType;

Expand Down Expand Up @@ -110,9 +108,9 @@ public int hashCode() {
public String toString() {
return "File{"
+ "id="
+ id
+ id.toString()
+ ", fileId="
+ fileId
+ fileId.toString()
+ ", filename='"
+ filename
+ '\''
Expand All @@ -136,6 +134,19 @@ public String toString() {
+ '}';
}

public JSONObject toJsonView() {
JSONObject fileMetadata =
new JSONObject()
.put("uploader", this.username)
.put("organizationName", this.organizationName)
.put("id", this.getId().toString())
.put("uploadDate", this.uploadedAt)
.put("idCategory", this.idCategory)
.put("filename", this.filename)
.put("annotated", this.isAnnotated);
return fileMetadata;
}

/*
Metadata fields from database:
filetype (str/enum) DONE
Expand Down
2 changes: 1 addition & 1 deletion src/main/PDF/PdfControllerV2.java
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ public Message setFileParamsUploadAnnotatedPDF(Context ctx) {
log.info("File is null");
return PdfMessage.INVALID_PDF;
}
this.fileOrgName = ctx.formParam("fileOrgName");
// this.fileOrgName = ctx.formParam("fileOrgName");
this.fileName = file.getFilename();
this.fileContentType = file.getContentType();
this.fileStream = file.getContent();
Expand Down
5 changes: 4 additions & 1 deletion src/main/PDF/Services/V2Services/FilterPDFServiceV2.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ public Message setFilter() {

public Message filter() {
List<File> filteredFiles = this.fileDao.getAll(this.filter);
this.files = new JSONArray(filteredFiles);
this.files = new JSONArray();
for (File filteredFile : filteredFiles) {
this.files.put(filteredFile.toJsonView());
}
return PdfMessage.SUCCESS;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class UploadAnnotatedPDFServiceV2 implements Service {
private List<FormQuestion> formQuestions;
private JSONObject userInfo;
private ObjectId uploadedFileId;
private String fileOrganizationName;
// private String fileOrganizationName;

public UploadAnnotatedPDFServiceV2(
FileDao fileDao,
Expand All @@ -69,7 +69,7 @@ public UploadAnnotatedPDFServiceV2(
this.fileName = fileParams.getFileName();
this.fileContentType = fileParams.getFileContentType();
this.fileStream = fileParams.getFileStream();
this.fileOrganizationName = fileParams.getFileOrgName();
// this.fileOrganizationName = fileParams.getFileOrgName();
this.encryptionController = encryptionController;
}

Expand Down Expand Up @@ -347,7 +347,8 @@ public Message upload() {
FileType.FORM,
IdCategoryType.NONE,
this.fileName,
this.fileOrganizationName,
this.organizationName,
// this.fileOrganizatiofileOrganizationNamenName,
true,
this.fileContentType);
ObjectId fileId = file.getId();
Expand Down