Skip to content
This repository was archived by the owner on Jun 17, 2020. It is now read-only.
Merged
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
42 changes: 1 addition & 41 deletions src/main/java/org/opentosca/csarrepo/model/CsarFile.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.opentosca.csarrepo.model;

import java.util.Date;
import java.util.UUID;

import javax.persistence.Column;
import javax.persistence.Entity;
Expand All @@ -25,25 +24,19 @@ public class CsarFile {

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id")
@Column(name = "csar_file_id")
private long id;

@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "csar_id")
private Csar csar;

@Column(name = "size")
private long size;

@Column(name = "version")
private String version;

@Column(name = "upload_date")
private Date uploadDate;

@Column(name = "file_id")
private UUID fileId;

@Column(name = "name")
private String name;

Expand Down Expand Up @@ -84,24 +77,6 @@ public Csar getCsar() {
return csar;
}

/**
* Get the size of a CSAR
*
* @return size
*/
public long getSize() {
return size;
}

/**
* Sets the size of a CSAR
*
* @param size
*/
public void setSize(long size) {
this.size = size;
}

/**
* Gets the version of a CSAR
*
Expand Down Expand Up @@ -138,21 +113,6 @@ public void setUploadDate(Date uploadDate) {
this.uploadDate = uploadDate;
}

/**
* @return the fileIdForeign
*/
public UUID getFileId() {
return fileId;
}

/**
* @param fileId
* the fileId to set
*/
public void setFileId(UUID fileId) {
this.fileId = fileId;
}

/**
* @param name
* the name to set
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/org/opentosca/csarrepo/model/HashedFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ public class HashedFile {
@Column(name = "file_name")
private String fileName;

@Column(name = "size")
private String size;

@OneToMany(fetch = FetchType.EAGER, mappedBy = "hashedFile")
private List<CsarFile> csarFiles;

Expand Down Expand Up @@ -86,6 +89,23 @@ public String getFileName() {
return fileName;
}

/**
*
* @param size
* the size of the hashed file
*/
public void setSize(String size) {
this.size = size;
}

/**
*
* @return the size of the file
*/
public String getSize() {
return size;
}

/**
* Returns all CSAR files of the current CSAR
*
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/opentosca/csarrepo/model/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class User {

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "user_id")
private long id;

@Column(name = "name")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ private void storeFile(UUID csarId, InputStream is, String name) {

CsarFile csarFile = new CsarFile();
csarFile.setHashedFile(hashedFile);
csarFile.setSize(fs.getFileSize(csarId));
csarFile.setVersion("1.0");
csarFile.setFileId(csarId);
// TODO: set Date correctly
// check if file.lastModified() uses same long as Date(long)
csarFile.setUploadDate(new Date());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,21 @@ public CsarDetailsServlet() {
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
* response)
*/
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try {
//TODO: length-check
// TODO: length-check
String[] pathInfo = request.getPathInfo().split("/");
//TODO: handle exception
// TODO: handle exception
long csarId = Long.parseLong(pathInfo[1]); // {id}

// TODO: add real UserID
ShowCsarService showService = new ShowCsarService(0L, csarId);
if (showService.hasErrors()) {
// FIXME, get all errors - not only first
throw new ServletException("csarService has errors:"
+ showService.getErrors().get(0));
throw new ServletException("csarService has errors:" + showService.getErrors().get(0));
}

Map<String, Object> root = new HashMap<String, Object>();
Csar result = showService.getResult();
root.put("csar", result);
Expand All @@ -65,4 +64,4 @@ protected void doGet(HttpServletRequest request,
}
}

}
}