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

Story/vspc 208 #341

Open
wants to merge 117 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 110 commits
Commits
Show all changes
117 commits
Select commit Hold shift + click to select a range
7f6dc06
[VSPC-208] added UI changes to include space link, module link and ex…
bnayak4 Jun 9, 2022
efffdaa
[VSPC-208] connected backend to frontend
bnayak4 Jun 14, 2022
bbfe3d8
[VSPC-208] code changes to remove csrf token error
bnayak4 Jun 16, 2022
96df53e
[VSPC-208] added changes for bean class
bnayak4 Jun 16, 2022
95a03e1
[VSPC-208] tried creating new form to remove the error
bnayak4 Jun 22, 2022
4d434db
[VSPC-208] added the controller and did cosmetic UI changes
bnayak4 Jun 23, 2022
c69e265
[VSPC-208] added controller changes
bnayak4 Jun 27, 2022
c71368c
[VSPC-208] used Apache Tika to extract data from the images and store it
bnayak4 Jun 28, 2022
46ba692
[VSPC-208] refactored the code
bnayak4 Jul 5, 2022
abbc260
[VSPC-208] added changes to save the spaceLinkImage
bnayak4 Oct 6, 2022
301ed4c
[VSPC-208] added changes to save images with spaceId
bnayak4 Oct 17, 2022
949999d
[VSPC-208] deleted defaultImageRepository
bnayak4 Oct 27, 2022
d65016e
[VSPC-208] link changes started
bnayak4 Oct 27, 2022
c05d011
[VSPC-208] need to set the bgImage fields
bnayak4 Dec 2, 2022
c02f795
[VSPC-208] added changes for the image resize
bnayak4 Dec 16, 2022
782b1f0
[VSPC-208] image extraction when image not uploaded
bnayak4 Dec 16, 2022
5b24201
[VSPC-208] added changes to make the arrow field visible in the front…
bnayak4 Dec 20, 2022
06936e9
[VSPC-208] added changed to print the image in the frontEnd
bnayak4 Dec 20, 2022
9cd2331
[VSPC-208] added changes after testing the staff side
bnayak4 Dec 21, 2022
f9cb545
[VSPC-208] Added changes to remove the images
bnayak4 Dec 23, 2022
f0afaad
[VSPC-208] getting images in the front end side
bnayak4 Jan 4, 2023
ec5b455
[VSPC-208] hibernate exception removed
bnayak4 Jan 5, 2023
a36c852
[VSPC-208] getting hibernate error
bnayak4 Jan 7, 2023
e391851
[VSPC-208] added changes
bnayak4 Jan 11, 2023
fff11aa
[VSPC-208] removed and changed the code to include it for all the exh…
bnayak4 Jan 13, 2023
2f00e2c
[VSPC-208] added changes
bnayak4 Jan 13, 2023
4870da9
[VSPC-208] added changes
bnayak4 Jan 18, 2023
9f401c0
[VSPC-208] adding changes
bnayak4 Jan 20, 2023
18e8fc1
[VSPC-208] added changes to show imageLink in the UI
bnayak4 Jan 25, 2023
47e5029
[VSPC-208] added changes
bnayak4 Jan 27, 2023
e8cdd0c
[VSPC-208] added changes
bnayak4 Jan 27, 2023
e1ba617
[VSPC-208] added changes
bnayak4 Jan 31, 2023
305e14e
[VSPC-208] added changes to VSPC-208
bnayak4 Feb 2, 2023
62a04c9
[VSPC-208] added changes to set flag if there is default imag eor not
bnayak4 Feb 16, 2023
6949fcd
[VSPC-208] added changes to modify the exhibition image
bnayak4 Feb 16, 2023
72ffe3f
[VSPC-208] added changes to default images story
bnayak4 Feb 17, 2023
7ff86ba
[VSPC-208] controller for each space Links
bnayak4 Feb 17, 2023
aeed62a
[VSPC-208] added flag
bnayak4 Feb 21, 2023
74e1915
[VSPC-208] added controller to check image
bnayak4 Feb 21, 2023
5be7820
[vspc-208] added link image changes
bnayak4 Feb 23, 2023
c0c2004
[VSPC-208] added minor changes and junits
bnayak4 Feb 23, 2023
22ac299
[VSPC-208] added JUNITS
bnayak4 Feb 24, 2023
5c87eb7
[VSPC-208] removed merge conflicts
bnayak4 Feb 24, 2023
58b37fa
[VSPC-208] added changes to remove merge conflicts
bnayak4 Feb 24, 2023
5edf002
[VSPC-208] removed merge conflict
bnayak4 Feb 28, 2023
a2104cb
[VSPC-208] removed indentation issue
bnayak4 Feb 28, 2023
2f42ccb
[VSPC-208] removed indentation issue
bnayak4 Feb 28, 2023
5b9c6f5
[VSPC-208] removed indentation issue
bnayak4 Feb 28, 2023
aaf1332
[VSPC-208] removed indentation issue
bnayak4 Feb 28, 2023
7ce57fa
[VSPC-208] removed indentation issue
bnayak4 Feb 28, 2023
dc63645
[VSPC-208] addressed review comments
bnayak4 Mar 6, 2023
f251edf
[VSPC-208] added review comments changes
bnayak4 Mar 7, 2023
3733bac
[VSPC-208] added changes to incorporate PR Review comments
bnayak4 Mar 7, 2023
f583d7a
[VSPC-208] addressed review comments
bnayak4 Mar 8, 2023
77f770b
[VSPC-208] addressed review comments
bnayak4 Mar 8, 2023
4576101
[VSPC-208] addressed review comments
bnayak4 Mar 9, 2023
dd97b30
[VSPC-208] addressed review comments
bnayak4 Mar 9, 2023
936c04e
[VSPC-208] addressed review comments
bnayak4 Mar 30, 2023
abbe9d9
[VSPC-208] addressed review comments
bnayak4 Mar 31, 2023
4519395
[VSPC-208] addressed review comments
bnayak4 Apr 4, 2023
0ddc6f4
[VSPC-208] addressed review comments
bnayak4 Apr 6, 2023
73602fa
[VSPC-208] addressed review comments
bnayak4 Apr 7, 2023
8473445
[VSPC-208] addressed review comment
bnayak4 Apr 11, 2023
08ad4f6
[VSPC-208] addressed review comments
bnayak4 Apr 11, 2023
51e9547
[VSPC-208] refactored code
bnayak4 Apr 11, 2023
27a2e92
[VSPC-208] Updated image display and debugged code fault to make it m…
tusanand Sep 22, 2023
4ac3440
[VSPC-208] Updated code to display proper default image with text on …
tusanand Sep 28, 2023
854ace9
[VSPC-208] Updated code to display default images on exhibition page
tusanand Oct 4, 2023
964c54e
Merge branch 'develop' of https://github.com/diging/virtual-spaces-2.…
tusanand Oct 4, 2023
5f33152
addressed code review comments
pooja-thalur Apr 3, 2024
1482735
refactored code as per code review comments
pooja-thalur Apr 5, 2024
8f4713d
Merge branch 'develop' into story/VSPC-208
pooja-thalur Apr 8, 2024
b968db9
addressed pr comments, fixed indentation issues
pooja-thalur Apr 15, 2024
4ad972e
fixed indentation issues
pooja-thalur Apr 15, 2024
54b66fa
fixed some more identation issues
pooja-thalur Apr 15, 2024
fe4438c
addressed pr comments
pooja-thalur Apr 15, 2024
d58889e
addresed pr comments
pooja-thalur Apr 15, 2024
9676263
refactored code
pooja-thalur Apr 17, 2024
5f80f11
codefactor issue
pooja-thalur Apr 19, 2024
7935521
Refactored code according to pr comments
pooja-thalur Apr 19, 2024
894ebd9
addressed pr comments
pooja-thalur Apr 19, 2024
aa23813
removed unnecessary spaces
pooja-thalur Apr 19, 2024
9876314
Fixed indentation issues
pooja-thalur Apr 19, 2024
5aa51a3
removed unnecessary changes
pooja-thalur Apr 19, 2024
b3c9979
reverting the unnecessary file changes to develop version
pooja-thalur Apr 19, 2024
5b1fd5b
reverted the file changes to develop version
pooja-thalur Apr 19, 2024
170cbce
reverting file changes to develop version
pooja-thalur Apr 19, 2024
fb201e0
reverting to develop version
pooja-thalur Apr 19, 2024
eee5ed8
removed extra spaces
pooja-thalur Apr 19, 2024
6ccf6c9
Removed unrelated changes
pooja-thalur Apr 22, 2024
61e9139
Removed unrelated file changes
pooja-thalur Apr 22, 2024
3b6eab3
fixed indentation issue
pooja-thalur Apr 22, 2024
9ee5d7a
Addressed pr comments
pooja-thalur May 13, 2024
0d6e7bb
VSPC-208 resolved pr comment
pooja-thalur May 15, 2024
e2f95af
[VSPC-208] addressed few pr comments
pooja-thalur May 16, 2024
7a4a0d0
[VSPC-208] separated the default space link image from general config…
pooja-thalur May 17, 2024
e677be3
[VSPC-208] Code cleanup and addressed pr comments
pooja-thalur May 20, 2024
2c5e586
[VSPC-208] indentation fix
pooja-thalur May 20, 2024
74a8474
[VSPC-208] indentation fix
pooja-thalur May 20, 2024
945290f
[VSPC-208] Fixed indentation
pooja-thalur May 20, 2024
e898247
[VSPC-208] addressed pr comments
pooja-thalur May 28, 2024
3966fbf
[VSPC-208] addressed pr comments
pooja-thalur May 29, 2024
814741e
[VSPC-208] javadoc changes
pooja-thalur May 29, 2024
6be13b0
[VSPC-208] addressed pr comments
pooja-thalur Jun 5, 2024
1e47eaf
[VSPC-208] addressed pr comments
pooja-thalur Jun 6, 2024
6925d29
[VSPC-208] Merge branch 'develop' into story/VSPC-208
pooja-thalur Jun 10, 2024
e281969
[VSPC-208] addressed pr comments
pooja-thalur Jun 13, 2024
5154844
[VSPC-208] code factor
pooja-thalur Jun 13, 2024
2bb0739
[VSPC-208] code factor
pooja-thalur Jun 13, 2024
057b477
[VSPC-208] code cleanup
pooja-thalur Jun 14, 2024
6436850
[VSPC-208] resolved test cases failure
pooja-thalur Jun 27, 2024
0244148
[VSPC-208] addressed pr comment
pooja-thalur Jun 27, 2024
27f9f3e
[VSPC-208] addressed pr comments
pooja-thalur Jul 5, 2024
50c7cd4
[VSPC-208] addressed pr comments
pooja-thalur Jul 8, 2024
6e9de01
[VSPC-208] mapped link type to its method
pooja-thalur Jul 9, 2024
af68d29
[VSPC-208] addressed pr comments
pooja-thalur Jul 12, 2024
949abb9
Merge branch 'develop' into story/VSPC-208
pooja-thalur Sep 6, 2024
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
Expand Up @@ -28,6 +28,18 @@ public interface IExhibition extends IVSpaceElement {

void setAboutPageConfigured(boolean aboutPageConfigured);

IVSImage getSpaceLinkDefaultImage();

void setSpaceLinkDefaultImage(IVSImage spaceLinkDefaultImage);

IVSImage getModuleLinkDefaultImage();

void setModuleLinkDefaultImage(IVSImage moduleLinkDefaultImage);

IVSImage getExternalLinkDefaultImage();

void setExternalLinkDefaultImage(IVSImage externalLinkDefaultImage);

List<IExhibitionLanguage> getLanguages();

ExhibitionModes getMode();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package edu.asu.diging.vspace.core.model.impl;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
Expand All @@ -14,14 +12,17 @@
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.hibernate.annotations.Parameter;

import edu.asu.diging.vspace.core.model.ExhibitionModes;
import edu.asu.diging.vspace.core.model.IContentBlock;
import edu.asu.diging.vspace.core.model.IExhibition;
import edu.asu.diging.vspace.core.model.IExhibitionLanguage;
import edu.asu.diging.vspace.core.model.IExternalLink;
import edu.asu.diging.vspace.core.model.ISpace;
import edu.asu.diging.vspace.core.model.IVSImage;

/**
* Represents an exhibition that can have a default start space.
Expand All @@ -47,6 +48,18 @@ public class Exhibition extends VSpaceElement implements IExhibition {

private String customMessage;

@OneToOne(targetEntity = VSImage.class)
@NotFound(action = NotFoundAction.IGNORE)
private IVSImage spaceLinkDefaultImage;

@OneToOne(targetEntity = VSImage.class)
@NotFound(action = NotFoundAction.IGNORE)
private IVSImage moduleLinkDefaultImage;

@OneToOne(targetEntity = VSImage.class)
@NotFound(action = NotFoundAction.IGNORE)
private IVSImage externalLinkDefaultImage;

private boolean aboutPageConfigured;

@OneToMany(targetEntity = ExhibitionLanguage.class, mappedBy = "exhibition", cascade = CascadeType.ALL, orphanRemoval=true)
Expand Down Expand Up @@ -122,16 +135,39 @@ public void setCustomMessage(String customMessage) {
this.customMessage = customMessage;
}

@Override
public IVSImage getSpaceLinkDefaultImage() {
return spaceLinkDefaultImage;
}
@Override
public void setSpaceLinkDefaultImage(IVSImage spaceLinkDefaultImage) {
this.spaceLinkDefaultImage = spaceLinkDefaultImage;
}
@Override
public IVSImage getModuleLinkDefaultImage() {
return moduleLinkDefaultImage;
}
@Override
public void setModuleLinkDefaultImage(IVSImage moduleLinkDefaultImage) {
this.moduleLinkDefaultImage = moduleLinkDefaultImage;
}
@Override
public IVSImage getExternalLinkDefaultImage() {
return externalLinkDefaultImage;
}
@Override
public void setExternalLinkDefaultImage(IVSImage externalLinkDefaultImage) {
this.externalLinkDefaultImage = externalLinkDefaultImage;
}
@Override
public boolean isAboutPageConfigured() {
return aboutPageConfigured;
}

@Override
public void setAboutPageConfigured(boolean aboutPageConfigured) {
this.aboutPageConfigured = aboutPageConfigured;
}

public List<IExhibitionLanguage> getLanguages() {
return languages;
}
Expand All @@ -152,7 +188,7 @@ public void setPreviewId(String previewId) {
public int hashCode() {
return Objects.hash(id);
}

@Override
public boolean equals(Object obj) {
if (this == obj)
Expand All @@ -163,4 +199,5 @@ public boolean equals(Object obj) {
return false;
return Objects.equals(id, ((Exhibition) obj).id);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,8 @@ public interface IImageService {

Page<VSImage> getPaginatedImagesBySearchTerm(int pageNo, ImageCategory category,
String searchTerm, String sortedBy, String order);

IVSImage storeImage(byte[] image, String filename);

byte[] getImageContent(IVSImage image);
}
jdamerow marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.util.Optional;
import javax.imageio.ImageIO;

import org.apache.tika.Tika;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -19,7 +20,10 @@
import org.springframework.stereotype.Service;

import edu.asu.diging.vspace.core.data.ImageRepository;
import edu.asu.diging.vspace.core.exception.FileStorageException;
import edu.asu.diging.vspace.core.exception.ImageDoesNotExistException;
import edu.asu.diging.vspace.core.factory.IImageFactory;
import edu.asu.diging.vspace.core.file.IStorageEngine;
import edu.asu.diging.vspace.core.model.IVSImage;
import edu.asu.diging.vspace.core.model.ImageCategory;
import edu.asu.diging.vspace.core.model.SortByField;
Expand All @@ -36,9 +40,18 @@ public class ImageService implements IImageService {
@Autowired
private ImageRepository imageRepo;

@Autowired
private IImageFactory imageFactory;

@Autowired
private IStorageEngine storage;

@Value("${page_size}")
private int pageSize;

private final String DEFAULT_IMAGE_EXCEPTION = "Default image could not be stored: ";
private final String NO_IMAGE_EXCEPTION = "Image doesn't exist for image id";

/*
* (non-Javadoc)
*
Expand Down Expand Up @@ -218,7 +231,7 @@ public IVSImage getImageById(String imageId) throws ImageDoesNotExistException {
if(imageOptional.isPresent()) {
return imageOptional.get();
} else {
throw new ImageDoesNotExistException("Image doesn't exist for image id" + imageId);
throw new ImageDoesNotExistException(NO_IMAGE_EXCEPTION + imageId);
}
}

Expand Down Expand Up @@ -247,6 +260,63 @@ public void addCategory(IVSImage image, ImageCategory category) {
public void removeCategory(IVSImage image, ImageCategory category) {
image.getCategories().remove(category);
imageRepo.save((VSImage) image);
}

/**
* Method to store an image in the file location
Copy link
Member

Choose a reason for hiding this comment

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

what file location? this is confusing. the method only gets an image and a filename, right? nothing about location?

*
*@param image - The image data as a byte array
*@param filename - The name of the file to be stored
*@return {@link IVSImage} instance
*/
@Override
public IVSImage storeImage(byte[] image, String filename) {

IVSImage storedImage = null;
if (image != null && image.length > 0) {
Tika tika = new Tika();
String contentType = tika.detect(image);
storedImage = imageFactory.createImage(filename, contentType);
storedImage = imageRepo.save((VSImage) storedImage);
}

CreationReturnValue returnValue = new CreationReturnValue();
returnValue.setErrorMsgs(new ArrayList<>());

if (storedImage != null) {
String relativePath = null;
try {
relativePath = storage.storeFile(image, filename, storedImage.getId());
} catch (FileStorageException e) {
logger.error(DEFAULT_IMAGE_EXCEPTION,e);
returnValue.getErrorMsgs().add(DEFAULT_IMAGE_EXCEPTION + e.getMessage());
Copy link
Member

Choose a reason for hiding this comment

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

if this is the case and the image can't be stored, the vsimage object should not be stored either.

Copy link
Member

Choose a reason for hiding this comment

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

?

Copy link
Member Author

Choose a reason for hiding this comment

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

in line 291 deleting the vsimage object if an exception occurs, as we are using its id to store the image

}
storedImage.setParentPath(relativePath);
ImageData imageData = getImageData(image);

if (imageData != null) {
storedImage.setHeight(imageData.getHeight());
storedImage.setWidth(imageData.getWidth());
}
imageRepo.save((VSImage) storedImage);
}
return storedImage;
}

/**
*Method to return content of the image
*
*@param image - {@link IVSImage} instance of the image to be retrieved
*@return byte[] - the image content as byte array
*/
@Override
public byte[] getImageContent(IVSImage image) {
jdamerow marked this conversation as resolved.
Show resolved Hide resolved
try {
return storage.getMediaContent(image.getId(), image.getFilename());
} catch (IOException e) {
logger.error("Could not retrieve the image",e);
}
return null;
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package edu.asu.diging.vspace.web.staff;

import java.util.ArrayList;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.CacheControl;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.google.gson.JsonObject;

import edu.asu.diging.vspace.core.model.IExhibition;
import edu.asu.diging.vspace.core.model.IVSImage;
import edu.asu.diging.vspace.core.services.IExhibitionManager;
import edu.asu.diging.vspace.core.services.IImageService;

@Controller
public class DefaultImageController {

public static final String API_DEFAULT_SPACE_IMAGE_PATH = "/api/image/default/link/space/";
public static final String API_DEFAULT_MODULE_IMAGE_PATH = "/api/image/default/link/module/";
public static final String API_DEFAULT_EXTERNAL_IMAGE_PATH = "/api/image/default/link/external/";
public static final String API_DEFAULT_SPACE_IMAGE_STATUS = "/api/exhibition/default/link/image/status/";
Copy link
Member

Choose a reason for hiding this comment

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

API endpoints should be in the api package.


@Autowired
private IImageService imageService;

@Autowired
private IExhibitionManager exhibitManager;

@RequestMapping(value = API_DEFAULT_SPACE_IMAGE_PATH, method = RequestMethod.GET)
public ResponseEntity<byte[]> getDefaultSpaceImage() {
IExhibition exhibition = exhibitManager.getStartExhibition();
IVSImage spaceImage = exhibition.getSpaceLinkDefaultImage();
return getResponseWithDefaultHeaders(spaceImage);
}

@RequestMapping(value = API_DEFAULT_MODULE_IMAGE_PATH, method = RequestMethod.GET)
public ResponseEntity<byte[]> getDefaultModuleImage() {
IExhibition exhibition = exhibitManager.getStartExhibition();
IVSImage moduleImage = exhibition.getModuleLinkDefaultImage();
return getResponseWithDefaultHeaders(moduleImage);
}

@RequestMapping(value = API_DEFAULT_EXTERNAL_IMAGE_PATH, method = RequestMethod.GET)
public ResponseEntity<byte[]> getDefaultExternalImage() {
IExhibition exhibition = exhibitManager.getStartExhibition();
IVSImage externalLinkImage = exhibition.getExternalLinkDefaultImage();
return getResponseWithDefaultHeaders(externalLinkImage);
}

/**
* Retrieves the status of default images for exhibition links
* @return A JSON response containing flags indicating the availability of default images.
*/
@RequestMapping(value = API_DEFAULT_SPACE_IMAGE_STATUS, method = RequestMethod.GET)
public ResponseEntity<String> getDefaultImageStatus() {
IExhibition exhibition = exhibitManager.getStartExhibition();
exhibition.getSpaceLinkDefaultImage();

JsonObject jsonObj = new JsonObject();
jsonObj.addProperty("defaultSpaceImageFlag", exhibition.getSpaceLinkDefaultImage() != null? true : false);
jsonObj.addProperty("defaultModuleImageFlag", exhibition.getModuleLinkDefaultImage() != null? true : false);
jsonObj.addProperty("defaultExternalLinkImageFlag", exhibition.getExternalLinkDefaultImage() != null? true : false);
return new ResponseEntity<>(jsonObj.toString(), HttpStatus.OK);
}

private ResponseEntity<byte[]> getResponseWithDefaultHeaders(IVSImage image) {
if(image == null) {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
byte[] imageContent = imageService.getImageContent(image);
HttpHeaders headers = new HttpHeaders();
headers.setCacheControl(CacheControl.noCache().getHeaderValue());
headers.setContentType(MediaType.parseMediaType(image.getFileType()));
return new ResponseEntity<>(imageContent, headers, HttpStatus.OK);
}

}
Loading