Skip to content
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
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestions Media3dProcessor or Object3dProcessor


@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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class ResourceMetadata implements IResourceMetadata {
private ImageResourceMetadata imageResourceMetadata;
private TextResourceMetadata textResourceMetadata;
private VideoResourceMetadata videoResourceMetadata;
private ThreeDResourceMetadata threeDResourceMetadata;

/**
* Constructor for audio resources.
Expand Down Expand Up @@ -66,6 +67,18 @@ public ResourceMetadata(VideoResourceMetadata videoResourceMetadata) {
this.videoResourceMetadata = videoResourceMetadata;
}

/**
* Constructor for 3D resources.
*
* @param threeDResourceMetadata The resource metadata.
*/
public ResourceMetadata(ThreeDResourceMetadata threeDResourceMetadata) {
if (threeDResourceMetadata == null) {
throw new IllegalArgumentException();
}
this.threeDResourceMetadata = threeDResourceMetadata;
}

/**
* Constructor. Don't use this: it's required for deserialization.
*/
Expand All @@ -82,6 +95,8 @@ AbstractResourceMetadata getMetaData() {
result = textResourceMetadata;
} else if (videoResourceMetadata != null) {
result = videoResourceMetadata;
} else if (threeDResourceMetadata != null){
result = threeDResourceMetadata;
} else {
throw new IllegalStateException();
}
Expand Down
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{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestions Object3dResourceMetadata or Media3dResourceMetadata


/**
* 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);
}
}
Loading