mirror of
https://github.com/sismics/docs.git
synced 2024-11-24 22:57:56 +01:00
Init file share
This commit is contained in:
parent
7822045ee7
commit
99978a12b7
@ -8,5 +8,6 @@
|
||||
<option name="processLiterals" value="true" />
|
||||
<option name="processComments" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="SqlNoDataSourceInspection" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
</profile>
|
||||
</component>
|
11
.idea/sqldialects.xml
Normal file
11
.idea/sqldialects.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="SqlDialectMappings">
|
||||
<file url="file://$PROJECT_DIR$/docs-core/src/main/resources/db/update/dbupdate-000-0.sql" dialect="HSQLDB" />
|
||||
<file url="file://$PROJECT_DIR$/docs-core/src/main/resources/db/update/dbupdate-001-0.sql" dialect="HSQLDB" />
|
||||
<file url="file://$PROJECT_DIR$/docs-core/src/main/resources/db/update/dbupdate-002-0.sql" dialect="HSQLDB" />
|
||||
<file url="file://$PROJECT_DIR$/docs-core/src/main/resources/db/update/dbupdate-003-0.sql" dialect="HSQLDB" />
|
||||
<file url="file://$PROJECT_DIR$/docs-core/src/main/resources/db/update/dbupdate-004-0.sql" dialect="HSQLDB" />
|
||||
</component>
|
||||
</project>
|
||||
|
1127
.idea/workspace.xml
Normal file
1127
.idea/workspace.xml
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,83 @@
|
||||
package com.sismics.docs.core.model.jpa;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* File share.
|
||||
*
|
||||
* @author bgamard
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "T_FILESHARE")
|
||||
public class FileShare {
|
||||
/**
|
||||
* File share ID.
|
||||
*/
|
||||
@Id
|
||||
@Column(name = "FSH_ID_C", length = 36)
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* File ID.
|
||||
*/
|
||||
@Column(name = "FSH_IDFILE_C", nullable = false, length = 36)
|
||||
private String fileId;
|
||||
|
||||
/**
|
||||
* Creation date.
|
||||
*/
|
||||
@Column(name = "FSH_CREATEDATE_D", nullable = false)
|
||||
private Date createDate;
|
||||
|
||||
/**
|
||||
* Deletion date.
|
||||
*/
|
||||
@Column(name = "FSH_DELETEDATE_D")
|
||||
private Date deleteDate;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getFileId() {
|
||||
return fileId;
|
||||
}
|
||||
|
||||
public void setFileId(String fileId) {
|
||||
this.fileId = fileId;
|
||||
}
|
||||
|
||||
public Date getCreateDate() {
|
||||
return createDate;
|
||||
}
|
||||
|
||||
public void setCreateDate(Date createDate) {
|
||||
this.createDate = createDate;
|
||||
}
|
||||
|
||||
public Date getDeleteDate() {
|
||||
return deleteDate;
|
||||
}
|
||||
|
||||
public void setDeleteDate(Date deleteDate) {
|
||||
this.deleteDate = deleteDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("id", id)
|
||||
.add("tagId", fileId)
|
||||
.toString();
|
||||
}
|
||||
}
|
@ -15,5 +15,6 @@
|
||||
<class>com.sismics.docs.core.model.jpa.Document</class>
|
||||
<class>com.sismics.docs.core.model.jpa.Tag</class>
|
||||
<class>com.sismics.docs.core.model.jpa.DocumentTag</class>
|
||||
<class>com.sismics.docs.core.model.jpa.FileShare</class>
|
||||
</persistence-unit>
|
||||
</persistence>
|
@ -1 +1 @@
|
||||
db.version=3
|
||||
db.version=4
|
@ -0,0 +1 @@
|
||||
create cached table T_FILESHARE ( FSH_ID_C varchar(36) not null, FSH_IDFILE_C varchar(36) not null, FSH_CREATEDATE_D datetime, FSH_DELETEDATE_D datetime, primary key (FSH_ID_C) );
|
@ -1,3 +1,3 @@
|
||||
api.current_version=${project.version}
|
||||
api.min_version=1.0
|
||||
db.version=3
|
||||
db.version=4
|
@ -57,6 +57,7 @@ public class FileResource extends BaseResource {
|
||||
File fileDb;
|
||||
try {
|
||||
fileDb = fileDao.getFile(id);
|
||||
// TODO Check that the current user owns the document linked to this file
|
||||
} catch (NoResultException e) {
|
||||
throw new ClientException("FileNotFound", MessageFormat.format("File not found: {0}", id));
|
||||
}
|
||||
@ -243,6 +244,7 @@ public class FileResource extends BaseResource {
|
||||
File file;
|
||||
try {
|
||||
file = fileDao.getFile(id);
|
||||
// TODO Check that the current user owns the document linked to this file
|
||||
} catch (NoResultException e) {
|
||||
throw new ClientException("FileNotFound", MessageFormat.format("File not found: {0}", id));
|
||||
}
|
||||
@ -278,6 +280,7 @@ public class FileResource extends BaseResource {
|
||||
File file;
|
||||
try {
|
||||
file = fileDao.getFile(id);
|
||||
// TODO Check that the current user owns the document linked to this file
|
||||
} catch (NoResultException e) {
|
||||
throw new ClientException("FileNotFound", MessageFormat.format("File not found: {0}", id));
|
||||
}
|
||||
|
@ -0,0 +1,91 @@
|
||||
package com.sismics.docs.rest.resource;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import org.codehaus.jettison.json.JSONException;
|
||||
import org.codehaus.jettison.json.JSONObject;
|
||||
|
||||
import com.sismics.rest.exception.ForbiddenClientException;
|
||||
import com.sismics.rest.util.ValidationUtil;
|
||||
import com.sun.jersey.multipart.FormDataParam;
|
||||
|
||||
/**
|
||||
* File share REST resources.
|
||||
*
|
||||
* @author bgamard
|
||||
*/
|
||||
@Path("/share")
|
||||
public class FileShareResource extends BaseResource {
|
||||
/**
|
||||
* Add a file share to a file.
|
||||
*
|
||||
* @param fileId File ID
|
||||
* @param fileBodyPart File to add
|
||||
* @return Response
|
||||
* @throws JSONException
|
||||
*/
|
||||
@PUT
|
||||
@Consumes("multipart/form-data")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Response add(
|
||||
@FormDataParam("id") String fileId) throws JSONException {
|
||||
if (!authenticate()) {
|
||||
throw new ForbiddenClientException();
|
||||
}
|
||||
|
||||
// Validate input data
|
||||
ValidationUtil.validateRequired(fileId, "id");
|
||||
|
||||
// Get the file
|
||||
// TODO Not implemented
|
||||
|
||||
// Always return ok
|
||||
JSONObject response = new JSONObject();
|
||||
response.put("status", "ok");
|
||||
response.put("id", fileId);
|
||||
return Response.ok().entity(response).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a file share.
|
||||
*
|
||||
* @param id File shqre ID
|
||||
* @return Response
|
||||
* @throws JSONException
|
||||
*/
|
||||
@DELETE
|
||||
@Path("{id: [a-z0-9\\-]+}")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Response delete(
|
||||
@PathParam("id") String id) throws JSONException {
|
||||
if (!authenticate()) {
|
||||
throw new ForbiddenClientException();
|
||||
}
|
||||
|
||||
// Get the file shqre
|
||||
// FileShareDao fileShareDao = new FileShareDao();
|
||||
// FileShare fileShare;
|
||||
// try {
|
||||
// fileShare = fileShareDao.getFileShare(id);
|
||||
// } catch (NoResultException e) {
|
||||
// throw new ClientException("FileNotFound", MessageFormat.format("File not found: {0}", id));
|
||||
// }
|
||||
//
|
||||
// // Delete the file share
|
||||
// fileShareDao.delete(fileShare.getId());
|
||||
|
||||
// TODO Not implemented
|
||||
|
||||
// Always return ok
|
||||
JSONObject response = new JSONObject();
|
||||
response.put("status", "ok");
|
||||
return Response.ok().entity(response).build();
|
||||
}
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
api.current_version=${project.version}
|
||||
api.min_version=1.0
|
||||
db.version=3
|
||||
db.version=4
|
Loading…
Reference in New Issue
Block a user