Skip to content

Commit

Permalink
customer/uk-it-15 (#541)
Browse files Browse the repository at this point in the history
* The cas.init() method is called in the VocabularyRestRepositoryIT#setup() method

* Update docker.yml (#502)

dspace-dependencies job was missing

* Update docker.yml (#503)

Fixed dspace-dependencies error

* Update docker.yml (#504)

* Empty commit - run actions

* use checkstyle before commit

* remove fix duplicate dependency

* remove discofeed related fetching from obsolete discojuice servers (#508)

* remove discofeed related fetching from obsolete discojuice servers

* check style, turned off in testing, turned of by default

* fix failing test

* ufal/cannot-upload-big-file (#533)

* Do not compute localChecksum because it takes too long for the big files. The checksum is computed using DigestInputStream object.
Copy content into sync local assetstore using buffered copying.

* Fixed checkstyle issue

* Updated comment about creating required directories

* ufal/license-agreement-wrong-behaviour (#534)

* The all transactions are not updated in the user metadata after a new download..

* Return the user metadata depending on user registration, bitstream, mapping and the last translation.

* Fixed checkstyle issues

* Fixed failing integration tests - do not fetch user metadata for testing by ID where there are more tests which creates the user metadata

* internal/discofeed-it (#535)

* Disable SSL check for specific discofeed requests

* Fixed checkstyle issues

* Do not throw error in private constructor

* Fixed failing IT - ssl check wasn't disabled

* Ignore integration test which is trying to connect to our private network.

* allow running from branch rework-actions for testing

* ufal/s3-check-etag (#537)

* Temp commit - upload a file by uploading 50MB parts

* Added uploading the file by parts - for every part is computed checksum and compared with UploadPartResult's ETag. This feature could be enabled or disabled by cfg.

* Undo S3BitStoreService changes

* Fixed checkstyle issues

* Prettify the code

* Changed cfg property to be better understandable and file size is converted into constant.

---------

Co-authored-by: MajoBerger <[email protected]>
Co-authored-by: Jozef Misutka <[email protected]>
  • Loading branch information
3 people authored Feb 21, 2024
1 parent e2a2252 commit 921ae57
Show file tree
Hide file tree
Showing 16 changed files with 666 additions and 104 deletions.
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
repos:
- repo: local
hooks:
- id: mvn-checkstyle
verbose: true
entry: python scripts/pre-commit/checkstyle.py
name: Runs maven checkstyle
language: python
files: \.(java)$
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import java.sql.SQLException;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
import java.util.stream.Collectors;

import org.apache.commons.lang.NullArgumentException;
import org.dspace.authorize.AuthorizeException;
Expand Down Expand Up @@ -76,4 +78,44 @@ public void delete(Context context, ClarinUserMetadata clarinUserMetadata) throw
}
clarinUserMetadataDAO.delete(context, clarinUserMetadata);
}

@Override
public List<ClarinUserMetadata> findByUserRegistrationAndBitstream(Context context, Integer userRegUUID,
UUID bitstreamUUID, boolean lastTransaction)
throws SQLException {
if (lastTransaction) {
return getLastTransactionUserMetadata(clarinUserMetadataDAO.findByUserRegistrationAndBitstream(context,
userRegUUID, bitstreamUUID));
}
return clarinUserMetadataDAO.findByUserRegistrationAndBitstream(context, userRegUUID, bitstreamUUID);
}

private List<ClarinUserMetadata> getLastTransactionUserMetadata(List<ClarinUserMetadata> userMetadataList) {
Integer latestTransactionId = getIdOfLastTransaction(userMetadataList);
if (latestTransactionId == null) {
return userMetadataList;
}

List<ClarinUserMetadata> filteredUserMetadata = null;
// Filter all user metadata by the last transaction
try {
filteredUserMetadata = userMetadataList.stream()
.filter(clarinUserMetadata -> clarinUserMetadata.getTransaction().getID()
.equals(latestTransactionId))
.collect(Collectors.toList());
} catch (Exception e) {
log.error("Error filtering user metadata by the last transaction", e);
}
return filteredUserMetadata;
}

private Integer getIdOfLastTransaction(List<ClarinUserMetadata> userMetadataList) {
// userMetadataList is filtered by the last transaction - first element is the last transaction
try {
return userMetadataList.get(0).getTransaction().getID();
} catch (IndexOutOfBoundsException e) {
log.error("No transaction found for the user metadata");
return null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,15 @@
*/
package org.dspace.content.dao.clarin;

import java.sql.SQLException;
import java.util.List;
import java.util.UUID;

import org.dspace.content.clarin.ClarinUserMetadata;
import org.dspace.core.Context;
import org.dspace.core.GenericDAO;

public interface ClarinUserMetadataDAO extends GenericDAO<ClarinUserMetadata> {
List<ClarinUserMetadata> findByUserRegistrationAndBitstream(Context context, Integer userRegUUID,
UUID bitstreamUUID) throws SQLException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,38 @@
*/
package org.dspace.content.dao.impl.clarin;

import java.sql.SQLException;
import java.util.List;
import java.util.UUID;
import javax.persistence.Query;

import org.dspace.content.clarin.ClarinUserMetadata;
import org.dspace.content.dao.clarin.ClarinUserMetadataDAO;
import org.dspace.core.AbstractHibernateDAO;
import org.dspace.core.Context;

public class ClarinUserMetadataDAOImpl extends AbstractHibernateDAO<ClarinUserMetadata>
implements ClarinUserMetadataDAO {

protected ClarinUserMetadataDAOImpl() {
super();
}

@Override
public List<ClarinUserMetadata> findByUserRegistrationAndBitstream(Context context, Integer userRegUUID,
UUID bitstreamUUID) throws SQLException {
Query query = createQuery(context, "SELECT cum FROM ClarinUserMetadata as cum " +
"JOIN cum.eperson as ur " +
"JOIN cum.transaction as clrua " +
"JOIN clrua.licenseResourceMapping as map " +
"WHERE ur.id = :userRegUUID " +
"AND map.bitstream.id = :bitstreamUUID " +
"ORDER BY clrua.id DESC");

query.setParameter("userRegUUID", userRegUUID);
query.setParameter("bitstreamUUID", bitstreamUUID);
query.setHint("org.hibernate.cacheable", Boolean.TRUE);

return list(query);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import java.sql.SQLException;
import java.util.List;
import java.util.UUID;

import org.dspace.authorize.AuthorizeException;
import org.dspace.content.clarin.ClarinUserMetadata;
Expand All @@ -22,4 +23,8 @@ public interface ClarinUserMetadataService {
List<ClarinUserMetadata> findAll(Context context) throws SQLException;
void update(Context context, ClarinUserMetadata clarinUserMetadata) throws SQLException;
void delete(Context context, ClarinUserMetadata clarinUserMetadata) throws SQLException, AuthorizeException;

List<ClarinUserMetadata> findByUserRegistrationAndBitstream(Context context, Integer userRegUUID,
UUID bitstreamUUID, boolean lastTransaction)
throws SQLException;
}
Loading

0 comments on commit 921ae57

Please sign in to comment.