Skip to content

Commit

Permalink
Merge branch 'develop' into fdias-2476-spaces-after-links-in-mails
Browse files Browse the repository at this point in the history
  • Loading branch information
diasf authored May 29, 2024
2 parents 21c6c40 + 17abc49 commit a1c50af
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,9 @@ public void setDatasetId(Long datasetId) {
public void setDownloadDate(Date downloadDate) {
this.downloadDate = downloadDate;
}

@Override
public String toString() {
return "DownloadDatasetLog [id=" + id + ", datasetId=" + datasetId + ", downloadDate=" + downloadDate + ']';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,6 @@ public DownloadInstance tabularDatafileMetadataPreprocessed(@PathParam("fileId")
@Path("datafiles/{fileIds}")
@GET
@Produces({"application/zip"})
@ApiWriteOperation
public Response datafiles(@PathParam("fileIds") String fileIds, @QueryParam("gbrecs") Boolean gbrecs,
@Context UriInfo uriInfo, @Context HttpServletResponse response) throws WebApplicationException {
assertOrThrowBadRequest(() -> StringUtils.isNotBlank(fileIds));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,6 @@ public Response listVersionFiles(@PathParam("id") String datasetId, @PathParam("
@GET
@Path("{id}/versions/{versionId}/files/download")
@Produces({"application/zip"})
@ApiWriteOperation
public Response getVersionFiles(@PathParam("id") String datasetId, @PathParam("versionId") String versionId, @QueryParam("gbrecs") boolean gbrecs,
@Context HttpServletResponse response, @Context UriInfo uriInfo) {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
package edu.harvard.iq.dataverse.dataset;

import edu.harvard.iq.dataverse.persistence.dataset.DownloadDatasetLog;
import edu.harvard.iq.dataverse.util.SystemConfig;

import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.util.Date;
import java.util.logging.Logger;

@Stateless
public class DownloadDatasetLogService {

private static final Logger logger = Logger.getLogger(DownloadDatasetLogService.class.getCanonicalName());

@PersistenceContext(unitName = "VDCNet-ejbPU")
private EntityManager em;

@EJB
protected SystemConfig systemConfig;

// -------------------- LOGIC --------------------

/**
Expand All @@ -22,6 +30,10 @@ public void logWholeSetDownload(Long datasetId) {
DownloadDatasetLog downloadDatasetLog = new DownloadDatasetLog();
downloadDatasetLog.setDatasetId(datasetId);
downloadDatasetLog.setDownloadDate(new Date());
em.persist(downloadDatasetLog);
if (systemConfig.isReadonlyMode()) {
logger.info(downloadDatasetLog.toString());
} else {
em.persist(downloadDatasetLog);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,8 @@ public CreateGuestbookResponseCommand(DataverseRequest aRequest, GuestbookRespon
protected void executeImpl(CommandContext ctxt) {
Timestamp createDate = new Timestamp(new Date().getTime());
response.setResponseTime(createDate);

if (ctxt.systemConfig().isReadonlyMode()) {
log.info(response.toString());
} else {
ctxt.responses().save(response);
}

ctxt.responses().save(response);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
import edu.harvard.iq.dataverse.persistence.user.AuthenticatedUser;
import edu.harvard.iq.dataverse.persistence.user.GuestUser;
import edu.harvard.iq.dataverse.persistence.user.User;
import edu.harvard.iq.dataverse.util.SystemConfig;

import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
Expand Down Expand Up @@ -93,6 +95,9 @@ public class GuestbookResponseServiceBean {
@PersistenceContext(unitName = "VDCNet-ejbPU")
private EntityManager em;

@EJB
protected SystemConfig systemConfig;

public List<GuestbookResponse> findAll() {
return em.createQuery("select object(o) from GuestbookResponse as o order by o.responseTime desc", GuestbookResponse.class).getResultList();
}
Expand Down Expand Up @@ -701,7 +706,11 @@ public GuestbookResponse findById(Long id) {

@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public void save(GuestbookResponse guestbookResponse) {
em.persist(guestbookResponse);
if (systemConfig.isReadonlyMode()) {
logger.info(guestbookResponse.toString());
} else {
em.persist(guestbookResponse);
}
}


Expand Down

0 comments on commit a1c50af

Please sign in to comment.