From d876715421f34c6c28aeab00076b530f893e7976 Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Wed, 16 Aug 2023 17:27:58 -0400 Subject: [PATCH] fix merge issues --- doc/release-notes/9558-async-indexing.md | 3 - .../edu/harvard/iq/dataverse/DatasetPage.java | 3 +- .../edu/harvard/iq/dataverse/DvObject.java | 13 +- .../iq/dataverse/DvObjectServiceBean.java | 73 -------- .../iq/dataverse/util/SessionUtil.java | 15 +- src/main/webapp/filesFragment.xhtml | 56 +++--- src/main/webapp/resources/css/structure.css | 20 ++- src/main/webapp/search-include-fragment.xhtml | 7 +- .../harvard/iq/dataverse/api/SearchIT.java | 6 +- .../edu/harvard/iq/dataverse/api/UtilIT.java | 161 ++++++++++++++---- 10 files changed, 193 insertions(+), 164 deletions(-) delete mode 100644 doc/release-notes/9558-async-indexing.md diff --git a/doc/release-notes/9558-async-indexing.md b/doc/release-notes/9558-async-indexing.md deleted file mode 100644 index a44eac1ff75..00000000000 --- a/doc/release-notes/9558-async-indexing.md +++ /dev/null @@ -1,3 +0,0 @@ -Performance improvements, especially for large datasets containing thousands of files. -Uploading files one by one to the dataset is much faster now, allowing uploading thousands of files in an acceptable timeframe. Not only uploading a file, but all edit operations on datasets containing many files, got faster. -Performance tweaks include indexing of the datasets in the background and optimizations in the amount of the indexing operations needed. Furthermore, updates to the dateset no longer wait for ingesting to finish. Ingesting was already running in the background, but it took a lock, preventing updating the dataset and degrading performance for datasets containing many files. \ No newline at end of file diff --git a/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java b/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java index 766c5e6d68a..2d72967afd8 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java +++ b/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java @@ -1863,6 +1863,7 @@ private String init(boolean initFull) { if (persistentId != null) { setIdByPersistentId(); } + if (this.getId() != null) { // Set Working Version and Dataset by Datasaet Id and Version @@ -1877,7 +1878,7 @@ private String init(boolean initFull) { // all we need, we are not using any of the entities produced // below. - dataset = datasetService.findDeep(this.getId()); + dataset = datasetService.find(this.getId()); if (dataset == null) { logger.warning("No such dataset: "+dataset); diff --git a/src/main/java/edu/harvard/iq/dataverse/DvObject.java b/src/main/java/edu/harvard/iq/dataverse/DvObject.java index 3866d2ea396..fe6a4a2de3a 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DvObject.java +++ b/src/main/java/edu/harvard/iq/dataverse/DvObject.java @@ -73,17 +73,6 @@ public String getDType() { } } - public enum DType { - Dataverse("Dataverse"), Dataset("Dataset"),DataFile("DataFile"); - - String dtype; - DType(String dt) { - dtype = dt; - } - public String getDType() { - return dtype; - } - } public static final Visitor NamePrinter = new Visitor(){ @Override @@ -196,7 +185,7 @@ public boolean isPreviewImageAvailable() { public void setPreviewImageAvailable(boolean status) { this.previewImageAvailable = status; } - + /** * Indicates whether a previous attempt to generate a preview image has failed, * regardless of size. This could be due to the file not being accessible, or a diff --git a/src/main/java/edu/harvard/iq/dataverse/DvObjectServiceBean.java b/src/main/java/edu/harvard/iq/dataverse/DvObjectServiceBean.java index e22824d4ce8..c9127af7c2b 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DvObjectServiceBean.java +++ b/src/main/java/edu/harvard/iq/dataverse/DvObjectServiceBean.java @@ -179,79 +179,6 @@ public DvObject findByGlobalId(GlobalId globalId) { } } - public boolean isGlobalIdLocallyUnique(GlobalId globalId) { - return em.createNamedQuery("DvObject.findByProtocolIdentifierAuthority") - .setParameter("identifier", globalId.getIdentifier()) - .setParameter("authority", globalId.getAuthority()) - .setParameter("protocol", globalId.getProtocol()) - .getResultList().isEmpty(); - } - - public DvObject findByAltGlobalId(GlobalId globalId, DvObject.DType dtype) { - Query query = em.createNamedQuery("DvObject.findByAlternativeGlobalId"); - return runFindByGlobalId(query, globalId, dtype); - } - - public Long findIdByGlobalId(GlobalId globalId, DvObject.DType dtype) { - Query query = em.createNamedQuery("DvObject.findIdByGlobalId"); - return runFindIdByGlobalId(query, globalId, dtype); - } - - public Long findIdByAltGlobalId(GlobalId globalId, DvObject.DType dtype) { - Query query = em.createNamedQuery("DvObject.findIdByAlternativeGlobalId"); - return runFindIdByGlobalId(query, globalId, dtype); - } - - private DvObject runFindByGlobalId(Query query, GlobalId gid, DvObject.DType dtype) { - DvObject foundDvObject = null; - try { - query.setParameter("identifier", gid.getIdentifier()); - query.setParameter("protocol", gid.getProtocol()); - query.setParameter("authority", gid.getAuthority()); - query.setParameter("dtype", dtype.getDType()); - foundDvObject = (DvObject) query.getSingleResult(); - } catch (javax.persistence.NoResultException e) { - // (set to .info, this can fill the log file with thousands of - // these messages during a large harvest run) - logger.fine("no dvObject found: " + gid.asString()); - // DO nothing, just return null. - return null; - } catch (Exception ex) { - logger.info("Exception caught in findByGlobalId: " + ex.getLocalizedMessage()); - return null; - } - - return foundDvObject; - } - - private Long runFindIdByGlobalId(Query query, GlobalId gid, DvObject.DType dtype) { - Long foundDvObject = null; - try { - query.setParameter("identifier", gid.getIdentifier()); - query.setParameter("protocol", gid.getProtocol()); - query.setParameter("authority", gid.getAuthority()); - query.setParameter("dtype", dtype.getDType()); - foundDvObject = (Long) query.getSingleResult(); - } catch (javax.persistence.NoResultException e) { - // (set to .info, this can fill the log file with thousands of - // these messages during a large harvest run) - logger.fine("no dvObject found: " + gid.asString()); - // DO nothing, just return null. - return null; - } catch (Exception ex) { - logger.info("Exception caught in findByGlobalId: " + ex.getLocalizedMessage()); - return null; - } - return foundDvObject; - } - - public DvObject findByGlobalId(GlobalId globalId) { - return (DvObject) em.createNamedQuery("DvObject.findByProtocolIdentifierAuthority") - .setParameter("identifier", globalId.getIdentifier()) - .setParameter("authority", globalId.getAuthority()) - .setParameter("protocol", globalId.getProtocol()).getSingleResult(); - } - public boolean isGlobalIdLocallyUnique(GlobalId globalId) { return em.createNamedQuery("DvObject.findByProtocolIdentifierAuthority") .setParameter("identifier", globalId.getIdentifier()) diff --git a/src/main/java/edu/harvard/iq/dataverse/util/SessionUtil.java b/src/main/java/edu/harvard/iq/dataverse/util/SessionUtil.java index 444bafcef17..e070b75a817 100644 --- a/src/main/java/edu/harvard/iq/dataverse/util/SessionUtil.java +++ b/src/main/java/edu/harvard/iq/dataverse/util/SessionUtil.java @@ -10,15 +10,11 @@ public class SessionUtil { /** - * Changes the session id (jsessionId) - for use when the session's authority - * increases (i.e. at login) Servlet 3.1 Note: This method is needed while using - * Servlets 2.0. 3.1 has a HttpServletRequest.chageSessionId(); method that can - * be used instead. - * - * @param h - * the current HttpServletRequest e.g. for pages you can get this - * from (HttpServletRequest) - * FacesContext.getCurrentInstance().getExternalContext().getRequest(); + * Changes the session id (jsessionId) - for use when the session's authority increases (i.e. at login) + * Servlet 3.1 Note: This method is needed while using Servlets 2.0. 3.1 has a HttpServletRequest.chageSessionId(); method that can be used instead. + * + * @param h the current HttpServletRequest + * e.g. for pages you can get this from (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest(); */ public static void changeSessionId(HttpServletRequest h) { HttpSession session = h.getSession(false); @@ -34,6 +30,5 @@ public static void changeSessionId(HttpServletRequest h) { for (Entry entry : sessionAttributes.entrySet()) { session.setAttribute(entry.getKey(), entry.getValue()); } - } } diff --git a/src/main/webapp/filesFragment.xhtml b/src/main/webapp/filesFragment.xhtml index a5110b179e3..082570f8288 100644 --- a/src/main/webapp/filesFragment.xhtml +++ b/src/main/webapp/filesFragment.xhtml @@ -144,7 +144,7 @@