Skip to content

Commit

Permalink
Stash: CreateDataverseFeaturedItemCommand WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
GPortas committed Dec 23, 2024
1 parent d796959 commit 755fd4d
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 1 deletion.
22 changes: 22 additions & 0 deletions src/main/java/edu/harvard/iq/dataverse/DataverseFeaturedItem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package edu.harvard.iq.dataverse;

import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;

@Entity
public class DataverseFeaturedItem {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

public void setId(Long id) {
this.id = id;
}

public Long getId() {
return id;
}
}
4 changes: 3 additions & 1 deletion src/main/java/edu/harvard/iq/dataverse/api/Dataverses.java
Original file line number Diff line number Diff line change
Expand Up @@ -1734,6 +1734,7 @@ public Response getUserPermissionsOnDataverse(@Context ContainerRequestContext c
return ok(jsonObjectBuilder);
}

// TODO
@PUT
@AuthRequired
@Consumes(MediaType.MULTIPART_FORM_DATA)
Expand All @@ -1742,6 +1743,7 @@ public Response updateFeaturedItems(@Context ContainerRequestContext crc,
@PathParam("identifier") String dvIdtf,
@FormDataParam("title") String title,
@FormDataParam("content") String content,
@FormDataParam("order") int order,
@FormDataParam("file") InputStream fileInputStream,
@FormDataParam("file") FormDataContentDisposition contentDispositionHeader) {
Dataverse dataverse;
Expand All @@ -1757,7 +1759,7 @@ public Response updateFeaturedItems(@Context ContainerRequestContext crc,
uploadedFile.createNewFile();
}
File file = FileUtil.inputStreamToFile(fileInputStream);
if (file.length() > systemConfig.getUploadLogoSizeLimit()) {
if (file.length() > 1000000) {
return error(Response.Status.BAD_REQUEST, "File is larger than maximum size: " + systemConfig.getUploadLogoSizeLimit() + ".");
}
Files.copy(fileInputStream, uploadedFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package edu.harvard.iq.dataverse.engine.command.impl;

import edu.harvard.iq.dataverse.Dataverse;
import edu.harvard.iq.dataverse.DataverseFeaturedItem;
import edu.harvard.iq.dataverse.engine.command.AbstractCommand;
import edu.harvard.iq.dataverse.engine.command.CommandContext;
import edu.harvard.iq.dataverse.engine.command.DataverseRequest;
import edu.harvard.iq.dataverse.engine.command.RequiredPermissions;
import edu.harvard.iq.dataverse.engine.command.exception.CommandException;

/**
* A command that creates a featured item in a {@link Dataverse}.
*/
//TODO permissions
@RequiredPermissions({})
public class CreateDataverseFeaturedItemCommand extends AbstractCommand<DataverseFeaturedItem> {

private final Dataverse dataverse;

public CreateDataverseFeaturedItemCommand(DataverseRequest request, Dataverse dataverse) {
super(request, dataverse);
this.dataverse = dataverse;
}

@Override
public DataverseFeaturedItem execute(CommandContext ctxt) throws CommandException {
return null;
}
}

0 comments on commit 755fd4d

Please sign in to comment.