-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/met 5756 implement new media processor subclass #652
Merged
jeortizquan
merged 4 commits into
develop
from
feat/MET-5756_Implement_new_media_processor_subclass
Feb 5, 2024
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
cc73a33
MET-5756 Started implementation of new media processor
JoanaCMS 358669d
Merge branch 'develop' into feat/MET-5756_Implement_new_media_process…
JoanaCMS 1f87e92
MET-5756 Implementation of ThreeDProcessor
JoanaCMS e8c58f2
MET-5756 Code refactoring - Code review changes
JoanaCMS File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
...-service/src/main/java/eu/europeana/metis/mediaprocessing/extraction/ThreeDProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package eu.europeana.metis.mediaprocessing.extraction; | ||
|
||
import eu.europeana.metis.mediaprocessing.exception.MediaExtractionException; | ||
import eu.europeana.metis.mediaprocessing.model.Resource; | ||
import eu.europeana.metis.mediaprocessing.model.ResourceExtractionResult; | ||
import eu.europeana.metis.mediaprocessing.model.ResourceExtractionResultImpl; | ||
import eu.europeana.metis.mediaprocessing.model.ThreeDResourceMetadata; | ||
import java.io.IOException; | ||
|
||
class ThreeDProcessor implements MediaProcessor{ | ||
|
||
@Override | ||
public ResourceExtractionResult extractMetadata(Resource resource, String detectedMimeType, boolean mainThumbnailAvailable) | ||
throws MediaExtractionException { | ||
|
||
// Sanity check | ||
try { | ||
if (!resource.hasContent()) { | ||
throw new MediaExtractionException("File does not exist or does not have content."); | ||
} | ||
} catch (IOException e) { | ||
throw new MediaExtractionException("Could not determine whether resource has content.", e); | ||
} | ||
|
||
// Get the size of the resource | ||
final Long contentSize; | ||
try { | ||
contentSize = nullIfNegative(resource.getContentSize()); | ||
} catch (IOException e) { | ||
throw new MediaExtractionException( | ||
"Could not determine the size of the resource " + resource.getResourceUrl(), e); | ||
} | ||
|
||
// Set the metadata in the web resource. | ||
final ThreeDResourceMetadata resourceMetadata; | ||
resourceMetadata = new ThreeDResourceMetadata(detectedMimeType, resource.getResourceUrl(), contentSize); | ||
|
||
// Done. | ||
return new ResourceExtractionResultImpl(resourceMetadata, null); | ||
} | ||
|
||
@Override | ||
public ResourceExtractionResult copyMetadata(Resource resource, String detectedMimeType) throws MediaExtractionException { | ||
return new ResourceExtractionResultImpl(new ThreeDResourceMetadata(detectedMimeType, | ||
resource.getResourceUrl(), resource.getProvidedFileSize())); | ||
} | ||
|
||
@Override | ||
public boolean downloadResourceForFullProcessing() { | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...ervice/src/main/java/eu/europeana/metis/mediaprocessing/model/ThreeDResourceMetadata.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package eu.europeana.metis.mediaprocessing.model; | ||
|
||
import java.util.List; | ||
|
||
public class ThreeDResourceMetadata extends AbstractResourceMetadata{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestions |
||
|
||
/** | ||
* Constructor. | ||
* | ||
* @param mimeType The resource mime type. | ||
* @param resourceUrl The resource URL. | ||
* @param contentSize The file content size. | ||
* @param thumbnails The thumbnails generated for this text resource. | ||
*/ | ||
public ThreeDResourceMetadata(String mimeType, String resourceUrl, Long contentSize, | ||
List<? extends Thumbnail> thumbnails) { | ||
super(mimeType, resourceUrl, contentSize, thumbnails); | ||
} | ||
|
||
public ThreeDResourceMetadata(String mimeType, String resourceUrl, Long contentSize) { | ||
super(mimeType, resourceUrl, contentSize, null); | ||
} | ||
@Override | ||
protected ResourceMetadata prepareForSerialization() { | ||
return new ResourceMetadata(this); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestions
Media3dProcessor
orObject3dProcessor