Skip to content

Commit

Permalink
Merge pull request #5951 from kitodo/master
Browse files Browse the repository at this point in the history
[hibernate-search] (Update)
  • Loading branch information
solth authored Feb 29, 2024
2 parents 2477cbc + 92e7f32 commit b043289
Show file tree
Hide file tree
Showing 169 changed files with 5,454 additions and 1,353 deletions.
82 changes: 82 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
pull_request:
branches: [ master ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

schedule:
- cron: '18 20 * * 2'

jobs:
analyze:
name: Analyze
# Runner size impacts CodeQL analysis time. To learn more, please see:
# - https://gh.io/recommended-hardware-resources-for-running-codeql
# - https://gh.io/supported-runners-and-hardware-resources
# - https://gh.io/using-larger-runners
# Consider using larger runners for possible analysis time improvements.
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
permissions:
# required for all workflows
security-events: write

# only required for workflows in private repositories
actions: read
contents: read

strategy:
fail-fast: false
matrix:
language: [ 'java-kotlin', 'javascript-typescript' ]
# CodeQL supports [ 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' ]
# Use only 'java-kotlin' to analyze code written in Java, Kotlin or both
# Use only 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
queries: security-extended,security-and-quality


- name: set up JDK 11
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'adopt'

- name: run build
run:
mvn clean install -B '-P!development' -DskipTests=true

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
13 changes: 6 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

name: CI

# Controls when the action will run.
# Controls when the action will run.
on:
# Triggers the workflow on push and pull request events but only for pull_requests on the master branch
push:
Expand All @@ -20,22 +20,21 @@ jobs:
runs-on: ubuntu-20.04
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: update chrome to latest stable
- name: update chrome to latest stable
run: |
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
sudo apt-get update
sudo apt-get --only-upgrade install google-chrome-stable
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: copy files
run: |
cp $GITHUB_WORKSPACE/config/database.yml.actions $GITHUB_WORKSPACE/config/database.yml
cp $GITHUB_WORKSPACE/Kitodo-DataManagement/src/main/resources/db/config/flyway.properties.actions $GITHUB_WORKSPACE/Kitodo-DataManagement/src/main/resources/db/config/flyway.properties
# Runs a set of commands using the runners shell
- name: start mysql
run:
Expand All @@ -57,15 +56,15 @@ jobs:
run:
mysql -u root -proot kitodo < $GITHUB_WORKSPACE/Kitodo/setup/default.sql
- name: set up JDK 11
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'adopt'
- name: check java version
run:
java --version
- name: check maven version
run:
run:
mvn --version
- name: run build
run:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ public enum FunctionalDivision {
/**
* A division whose children are created from this division directly.
*/
CREATE_CHILDREN_FROM_PARENT("createChildrenFromParent");
CREATE_CHILDREN_FROM_PARENT("createChildrenFromParent"),

/**
* Indicate the division for media partial usage.
*/
MEDIA_PARTIAL("mediaPartial");

/**
* With the logger, text can be written to a log file or to the console.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
* (c) Kitodo. Key to digital objects e. V. <[email protected]>
*
* This file is part of the Kitodo project.
*
* It is licensed under GNU General Public License version 3 or later.
*
* For the full copyright and license information, please read the
* GPL3-License.txt file that was distributed with this source code.
*/

package org.kitodo.api.dataformat;

import java.util.Objects;

/**
* MediaPartial is part of a {@link PhysicalDivision} of type
* {@link PhysicalDivision#TYPE_TRACK} and contains additional
* information about the start and length.
*/
public class MediaPartial {

private String begin;

private String extent;

/**
* Constructs a media partial object.
*
* @param begin
* The begin as formatted time in form of
* {@link org.kitodo.production.helper.metadata.MediaPartialHelper#FORMATTED_TIME_PATTERN}
*/
public MediaPartial(String begin) {
this.begin = begin;
}

/**
* Constructs a media partial object.
*
* @param begin
* The begin as formatted time in form of
* {@link org.kitodo.production.helper.metadata.MediaPartialHelper#FORMATTED_TIME_PATTERN}
* @param extent
* The extent as formatted time in form of
* {@link org.kitodo.production.helper.metadata.MediaPartialHelper#FORMATTED_TIME_PATTERN}
*/
public MediaPartial(String begin, String extent) {
this(begin);
this.extent = extent;
}

public void setBegin(String begin) {
this.begin = begin;
}

public String getBegin() {
return begin;
}

public String getExtent() {
return extent;
}

public void setExtent(String extent) {
this.extent = extent;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!getClass().isInstance(o)) {
return false;
}

MediaPartial mediaPartial = (MediaPartial) o;

return (Objects.isNull(begin) && Objects.isNull(mediaPartial.begin)) || begin.equals(mediaPartial.getBegin());
}

@Override
public int hashCode() {
final int prime = 31;
return prime * super.hashCode() + Objects.hash(begin, extent);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public class PhysicalDivision extends Division<PhysicalDivision> {
*/
private Map<MediaVariant, URI> mediaFiles = new HashMap<>();

private MediaPartial mediaPartial;

/**
* Saves the METS identifier for the division.
*/
Expand Down Expand Up @@ -115,6 +117,34 @@ public List<LogicalDivision> getLogicalDivisions() {
return logicalDivisions;
}

/**
* Set the media partial.
*
* @param mediaPartial
* The media partial
*/
public void setMediaPartial(MediaPartial mediaPartial) {
this.mediaPartial = mediaPartial;
}

/**
* Check if physical division has media partial.
*
* @return True if has media partial
*/
public boolean hasMediaPartial() {
return Objects.nonNull(mediaPartial);
}

/**
* Get the media partial.
*
* @return The media partial.
*/
public MediaPartial getMediaPartial() {
return mediaPartial;
}

@Override
public String toString() {
String fileName = "No file (";
Expand All @@ -141,14 +171,18 @@ public boolean equals(Object o) {
return false;
}
PhysicalDivision physicalDivision = (PhysicalDivision) o;
return Objects.equals(mediaFiles, physicalDivision.mediaFiles);
return Objects.equals(mediaFiles, physicalDivision.mediaFiles) && Objects.equals(mediaPartial,
physicalDivision.mediaPartial);
}

@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((mediaFiles == null) ? 0 : mediaFiles.hashCode());
result = prime * result + ((Objects.isNull(mediaPartial) || Objects.isNull(mediaPartial.getBegin()))
? 0
: mediaPartial.getBegin().hashCode());
return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class FileNameBeginsAndEndsWithFilter implements FilenameFilter {
* Strings
*/
public FileNameBeginsAndEndsWithFilter(String begin, String end) {
if (begin == null || begin.equals("") || end == null || end.equals("")) {
if (begin == null || begin.isEmpty() || end == null || end.isEmpty()) {
throw new IllegalArgumentException("No filter or empty filter for file begin or end is given.");
}
this.begin = begin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class FileNameEndsAndDoesNotBeginWithFilter implements FilenameFilter {
* Strings
*/
public FileNameEndsAndDoesNotBeginWithFilter(String notBegin, String end) {
if (notBegin == null || notBegin.equals("") || end == null || end.equals("")) {
if (notBegin == null || notBegin.isEmpty() || end == null || end.isEmpty()) {
throw new IllegalArgumentException("No filter or empty filter for file begin or end is given.");
}
this.notBegin = notBegin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class FileNameEndsWithFilter implements FilenameFilter {
* it is thrown in case parameter is null or empty String
*/
public FileNameEndsWithFilter(String end) {
if (end == null || end.equals("")) {
if (end == null || end.isEmpty()) {
throw new IllegalArgumentException("No filter or empty filter for file end is given.");
}
this.end = end;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class FileNameMatchesFilter implements FilenameFilter {
* it is thrown in case parameter is null or empty String
*/
public FileNameMatchesFilter(String name) {
if (name == null || name.equals("")) {
if (name == null || name.isEmpty()) {
throw new IllegalArgumentException("No filter or empty name is given.");
}
this.name = name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,6 @@ public interface ImageManagementInterface {
boolean createDerivative(URI imageFileUri, double percent, URI resultFileUri, ImageFileFormat resultFileFormat)
throws IOException;

/**
* Scales an image at a given path and returns it.
*
* @param imageFileUri
* the URI to the image which should be scaled
* @param percent
* the percentage for scaling
* @return the scaled image
* @throws IOException
* if the plug-in is configured incorrectly, the image is
* missing or corrupted, etc.
*/
Image getScaledWebImage(URI imageFileUri, double percent) throws IOException;

/**
* Changes the size (in pixel) of the image.
*
Expand All @@ -77,5 +63,4 @@ boolean createDerivative(URI imageFileUri, double percent, URI resultFileUri, Im
* missing or corrupted, etc.
*/
Image getSizedWebImage(URI imageFileUri, int pixelWidth) throws IOException;

}
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,10 @@ ValidationResult validate(URI metsFileUri, URI rulesetFileUri, List<LanguageRang
* {@code metadataNotEnoughElements},
* {@code metadataNotOneElement}, and
* {@code metadataStructureWithoutMedia}.
* @param checkMedia
* whether to check for missing or unlinked media
* @return A validation result.
*/
ValidationResult validate(Workpiece workpiece, RulesetManagementInterface ruleset,
List<LanguageRange> metadataLanguage, Map<String, String> translations);
List<LanguageRange> metadataLanguage, Map<String, String> translations, boolean checkMedia);
}
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ private void loadModulesIntoClasspath() {

// create a single URL class loader with all jars
// such that plugins can load classes from each other
if (jarsToBeAdded.size() > 0) {
if (!jarsToBeAdded.isEmpty()) {

for (URL url : jarsToBeAdded) {
logger.info("Loading module jar file from path " + url.toString());
Expand Down
Loading

0 comments on commit b043289

Please sign in to comment.