Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
bc5fd0b
VSPC-196 new branch
ajay3568yadav May 30, 2024
53ed254
VSPC-196 minor space issue fixed
ajay3568yadav May 31, 2024
0466d24
replicating form VSPC-172
ajay3568yadav Jun 3, 2024
abb5e86
[VSPC-196] CSS fix for choose from existing
ajay3568yadav Jun 3, 2024
8570989
VSPC-196 edit module link fixed
ajay3568yadav Jun 5, 2024
e88f51c
[VSPC-196] fixed edit link
ajay3568yadav Jun 6, 2024
b4f181d
VSPC-196 merge
ajay3568yadav Jul 2, 2024
83af595
VSPC-196 added choose from exisitng images option to spaces
ajay3568yadav Jul 3, 2024
eead7d2
VSPC-196 added choose from existing image to modules
ajay3568yadav Jul 5, 2024
f0fb64f
VSPC-196 created custom formatTemplate
ajay3568yadav Jul 8, 2024
4eb3421
VSPC-196 added choose from exisitng option to the external links
ajay3568yadav Jul 10, 2024
8d554ba
VSPC-196 fixed external module link
ajay3568yadav Jul 11, 2024
16e70d5
VSPC-196 fixed edit links
ajay3568yadav Jul 12, 2024
782bc9d
VSPC-196 external link images not showing
ajay3568yadav Jul 18, 2024
ac9881b
VSPC-196 testing
ajay3568yadav Jul 19, 2024
6181c3c
VSPC-196 edit external links fixed
ajay3568yadav Jul 24, 2024
f438063
VSPC-196 removed comments
ajay3568yadav Jul 24, 2024
a3550c7
VSPC-196 fixed edit module error
ajay3568yadav Jul 24, 2024
931c1c7
VSPC-196 css issue
ajay3568yadav Aug 15, 2024
56ec6cc
VSPC-196 undo changes
ajay3568yadav Aug 16, 2024
bb8bab3
VSPC-196 review comments
Nov 13, 2024
757fd0b
VSPC-196 before merge
Nov 13, 2024
75e74b3
VSPC-196 revert
Nov 13, 2024
cd55e23
Merge branch 'develop' into story/vspc-196
Nov 13, 2024
fda3666
VSPC-196 fixed broken link
Nov 15, 2024
1103247
Merge branch 'develop' into story/vspc-196
ajay3568yadav Nov 15, 2024
8f67f83
Revert "VSPC-196 fixed broken link"
Nov 20, 2024
574a8fe
Revert "Revert "VSPC-196 fixed broken link""
Nov 20, 2024
3664213
Update pom.xml
ajay3568yadav Nov 20, 2024
b961df0
VSPC-196 review commnets and other error fixes
Dec 4, 2024
d43c21c
Merge branch 'story/vspc-196' of https://github.com/diging/virtual-sp…
Dec 4, 2024
62d4b17
VSPC-196 fixed test cases
Dec 6, 2024
5e06a9c
VSPC-196 test fixed
Dec 13, 2024
d836461
VSPC-196 indentation review comment
Dec 13, 2024
0b28067
VSPC-196 conflict resolution
Dec 20, 2024
3d1e014
VSPC-196 compilation errors fixed
Jan 6, 2025
628a36d
VSPC-196 added exception handler
Jan 8, 2025
6b5abca
VSPC-196 build failur fix added exceptions handlers
Jan 9, 2025
c881484
VSPC-196 build errors fixed
Jan 24, 2025
0ee7527
VSPC-196 review comments
Feb 7, 2025
9a8996e
VSPC-196 merge with develop
ajay3568yadav Jun 20, 2025
9a875e6
VSPC-196 bug fix attempt
ajay3568yadav Jun 26, 2025
939ee9b
VSPC-196 build fail fix
ajay3568yadav Jul 11, 2025
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
16 changes: 5 additions & 11 deletions vspace/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
Expand All @@ -27,20 +29,12 @@
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="test" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="target/generated-sources/annotations">
Expand All @@ -49,4 +43,4 @@
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
</classpath>
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@EnableAspectJAutoProxy
@ComponentScan({"edu.asu.diging.vspace", "edu.asu.diging.simpleusers"})
@EnableWebMvc
@PropertySource({"classpath:config.properties", "${appConfigFile:classpath:}/app.properties"})
@PropertySource({"classpath:config.properties", "${appConfigFile:classpath:app.properties}"})
public class VSpaceConfig {

@Value("${max_upload_size}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public interface SpaceRepository extends PagingAndSortingRepository<Space, Strin

Page<ISpace> findDistinctByNameContainingOrDescriptionContaining(Pageable requestedPage, String name,
String description);

List<Space> findByNameLike(String name);

Page<Space> findByNameLike(String searchTerm, Pageable pageable);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package edu.asu.diging.vspace.core.services;

import edu.asu.diging.vspace.core.exception.ImageCouldNotBeStoredException;
import edu.asu.diging.vspace.core.exception.ImageDoesNotExistException;
import edu.asu.diging.vspace.core.exception.LinkDoesNotExistsException;
import edu.asu.diging.vspace.core.exception.SpaceDoesNotExistException;
import edu.asu.diging.vspace.core.model.IExternalLink;
Expand All @@ -12,11 +13,11 @@
public interface IExternalLinkManager extends ILinkManager<IExternalLink, ExternalLinkValue, IExternalLinkDisplay>{

IExternalLinkDisplay createLink(String title, String id, float positionX, float positionY, int rotation, String linkedId,
String linkLabel, DisplayType displayType, byte[] linkImage, String imageFilename,ExternalLinkDisplayMode howToOpen)
throws SpaceDoesNotExistException, ImageCouldNotBeStoredException, SpaceDoesNotExistException;
String linkLabel, String desc, DisplayType displayType, byte[] linkImage, String imageFilename,ExternalLinkDisplayMode howToOpen, String imageId)
throws SpaceDoesNotExistException, ImageCouldNotBeStoredException, SpaceDoesNotExistException, ImageDoesNotExistException;

IExternalLinkDisplay updateLink(String title, String id, float positionX, float positionY, int rotation, String linkedId,
String linkLabel, String linkId, String linkDisplayId, DisplayType displayType, byte[] linkImage,
String imageFilename,ExternalLinkDisplayMode howToOpen)
throws SpaceDoesNotExistException, LinkDoesNotExistsException, ImageCouldNotBeStoredException;
}
String linkLabel, String desc, String linkId, String linkDisplayId, DisplayType displayType, byte[] linkImage,
String imageFilename, String existingImageId, ExternalLinkDisplayMode howToOpen)
throws SpaceDoesNotExistException, LinkDoesNotExistsException, ImageCouldNotBeStoredException, ImageDoesNotExistException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,28 @@
import java.util.List;

import edu.asu.diging.vspace.core.exception.ImageCouldNotBeStoredException;
import edu.asu.diging.vspace.core.exception.ImageDoesNotExistException;
import edu.asu.diging.vspace.core.exception.LinkDoesNotExistsException;
import edu.asu.diging.vspace.core.exception.SpaceDoesNotExistException;
import edu.asu.diging.vspace.core.model.ILink;
import edu.asu.diging.vspace.core.model.IVSpaceElement;
import edu.asu.diging.vspace.core.model.display.DisplayType;
import edu.asu.diging.vspace.core.model.display.ExternalLinkDisplayMode;
import edu.asu.diging.vspace.core.model.display.ILinkDisplay;

public interface ILinkManager<L extends ILink<T>, T extends IVSpaceElement, U extends ILinkDisplay> {

U createLink(String title, String id, float positionX, float positionY, int rotation, String linkedId,
String linkLabel, DisplayType displayType, byte[] linkImage, String imageFilename)
throws SpaceDoesNotExistException, ImageCouldNotBeStoredException, SpaceDoesNotExistException;
String linkLabel, String linkDesc, DisplayType displayType, byte[] linkImage, String imageFilename, String existingImageId)
throws SpaceDoesNotExistException, ImageCouldNotBeStoredException, SpaceDoesNotExistException, ImageDoesNotExistException;

U updateLink(String title, String id, float positionX, float positionY, int rotation, String linkedId,
String linkLabel, String linkId, String linkDisplayId, DisplayType displayType, byte[] linkImage,
String imageFilename)
throws SpaceDoesNotExistException, LinkDoesNotExistsException, ImageCouldNotBeStoredException;
String linkLabel, String linkDesc, String linkId, String linkDisplayId, DisplayType displayType, byte[] linkImage,
String imageFilename, String existingImageId)
throws SpaceDoesNotExistException, LinkDoesNotExistsException, ImageCouldNotBeStoredException, ImageDoesNotExistException;

List<U> getLinkDisplays(String spaceId);

void deleteLink(String linkId);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import edu.asu.diging.vspace.core.model.impl.ExternalLinkValue;
import edu.asu.diging.vspace.core.services.IExternalLinkManager;
import edu.asu.diging.vspace.core.services.ISpaceManager;
import edu.asu.diging.vspace.core.exception.ImageDoesNotExistException;
Comment thread
jdamerow marked this conversation as resolved.

@Transactional
@Service
Expand All @@ -49,23 +50,17 @@ public class ExternalLinkManager extends LinkManager<IExternalLink, ExternalLink
@Autowired
private IExternalLinkDisplayFactory externalLinkDisplayFactory;

@Autowired
private IImageFactory imageFactory;

@Autowired
private ImageRepository imageRepo;

@Autowired
private IStorageEngine storage;

@Override
public List<IExternalLinkDisplay> getLinkDisplays(String spaceId) {
return externalLinkDisplayRepo.findExternalLinkDisplaysForSpace(spaceId);
}

@Override
protected IExternalLink createLinkObject(String title, String id) {
protected IExternalLink createLinkObject(String title, String id) throws SpaceDoesNotExistException {
ISpace source = spaceManager.getSpace(id);
if (source == null) {
throw new SpaceDoesNotExistException("Space with id '" + id + "' does not exist.");
}
IExternalLink link = externalLinkFactory.createExternalLink(title, source);
return externalLinkRepo.save((ExternalLink) link);
}
Expand Down Expand Up @@ -121,9 +116,10 @@ protected void deleteLinkRepo(IExternalLink link) {

@Override
public IExternalLinkDisplay createLink(String title, String id, float positionX, float positionY, int rotation,
String linkedId, String linkLabel, DisplayType displayType, byte[] linkImage, String imageFilename,
ExternalLinkDisplayMode howToOpen)
throws SpaceDoesNotExistException, ImageCouldNotBeStoredException, SpaceDoesNotExistException {
String linkedId, String linkLabel, String desc, DisplayType displayType, byte[] linkImage, String imageFilename,
ExternalLinkDisplayMode howToOpen, String imageId )
throws SpaceDoesNotExistException, ImageCouldNotBeStoredException, ImageDoesNotExistException {


/*
* When createLink is called then inside updateLinkAndDisplay(link, displayLink)
Expand All @@ -133,17 +129,17 @@ public IExternalLinkDisplay createLink(String title, String id, float positionX,
* automatically persist howToOpen in database.
*/
IExternalLinkDisplay externalLinkDisplay = createLink(title, id, positionX, positionY, rotation, linkedId,
linkLabel, displayType, linkImage, imageFilename);
linkLabel, desc, displayType, linkImage, imageFilename, imageId);
externalLinkDisplay.setHowToOpen(howToOpen);
return externalLinkDisplay;

}

@Override
public IExternalLinkDisplay updateLink(String title, String id, float positionX, float positionY, int rotation,
String linkedId, String linkLabel, String linkId, String linkDisplayId, DisplayType displayType,
byte[] linkImage, String imageFilename, ExternalLinkDisplayMode howToOpen)
throws SpaceDoesNotExistException, LinkDoesNotExistsException, ImageCouldNotBeStoredException {
String linkedId, String linkLabel, String desc, String linkId, String linkDisplayId, DisplayType displayType,
byte[] linkImage, String imageFilename, String existingImageId, ExternalLinkDisplayMode howToOpen)
throws SpaceDoesNotExistException, LinkDoesNotExistsException, ImageCouldNotBeStoredException, ImageDoesNotExistException {

/*
* When updateLink is called then inside updateLinkAndDisplay(link, displayLink)
Expand All @@ -153,9 +149,9 @@ public IExternalLinkDisplay updateLink(String title, String id, float positionX,
* automatically persist howToOpen in database.
*/
IExternalLinkDisplay externalLinkDisplay = updateLink(title, id, positionX, positionY, rotation, linkedId,
linkLabel, linkId, linkDisplayId, displayType, linkImage, imageFilename);
linkLabel, desc, linkId, linkDisplayId, displayType, linkImage, imageFilename, existingImageId);
externalLinkDisplay.setHowToOpen(howToOpen);
return externalLinkDisplay;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
import edu.asu.diging.vspace.core.model.IVSImage;
import edu.asu.diging.vspace.core.model.IVSpaceElement;
import edu.asu.diging.vspace.core.model.display.DisplayType;
import edu.asu.diging.vspace.core.model.display.ExternalLinkDisplayMode;
import edu.asu.diging.vspace.core.model.display.ILinkDisplay;
import edu.asu.diging.vspace.core.model.impl.VSImage;
import edu.asu.diging.vspace.core.services.IImageService;
import edu.asu.diging.vspace.core.services.ILinkManager;
import edu.asu.diging.vspace.core.services.ISpaceManager;

import edu.asu.diging.vspace.core.exception.ImageDoesNotExistException;
@Transactional
public abstract class LinkManager<L extends ILink<T>, T extends IVSpaceElement, U extends ILinkDisplay>
implements ILinkManager<L, T, U> {
Expand All @@ -36,37 +38,82 @@ public abstract class LinkManager<L extends ILink<T>, T extends IVSpaceElement,

@Autowired
private IStorageEngine storage;

@Autowired
private IImageService imageService;

protected abstract void deleteLinkRepo(L link);

protected abstract void deleteLinkDisplayRepo(L link);

protected abstract void removeFromLinkList(ISpace space, L link);

protected abstract U updateLinkAndDisplay(L link, U displayLink);

protected abstract U getDisplayLink(String linkDisplayId) throws LinkDoesNotExistsException;

protected abstract L getLink(String linkId);

protected abstract L createLinkObject(String title, String id) throws SpaceDoesNotExistException;

protected abstract T getTarget(String linkedId);

protected abstract U createDisplayLink(L link);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm so confused, why is this here? I this needed for this ticket?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ah I see, this should not be moved

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This came from merging changes from the main branch

@Override
public U createLink(String title, String id, float positionX, float positionY, int rotation, String linkedId,
String linkLabel, DisplayType displayType, byte[] linkImage, String imageFilename)
throws SpaceDoesNotExistException, ImageCouldNotBeStoredException, SpaceDoesNotExistException {
String linkLabel, String linkDesc, DisplayType displayType, byte[] linkImage, String imageFilename, String existingImageId)
throws SpaceDoesNotExistException, ImageCouldNotBeStoredException, ImageDoesNotExistException {

if (title == null || title.trim().isEmpty()) {
throw new IllegalArgumentException("Title cannot be null or empty.");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this is not the right exception to throw; it's a runtime exception so it does not need to be caught and handled, because it would be thrown if it's an argument that simply can't be dealt with. Here, it can definitely be dealt with if the title is null (simply ask the user to enter a title). Also, I don't see why the title couldn't be empty. If the user, for instance, adds an image, there does not need to be title to make this work.

}
if (id == null || id.trim().isEmpty()) {
throw new IllegalArgumentException("ID cannot be null or empty.");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

see above, wrong exception to be thrown.

}
if (linkedId == null || linkedId.trim().isEmpty()) {
throw new SpaceDoesNotExistException("Linked ID cannot be null or empty.");
}
if (displayType == null) {
throw new IllegalArgumentException("DisplayType cannot be null.");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

see above

}
if ((linkImage == null || linkImage.length == 0) && (existingImageId == null || existingImageId.trim().isEmpty())) {
throw new ImageDoesNotExistException("Either linkImage or existingImageId must be provided.");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

wrong exception to throw. Image does not exist is different than no image provided.

}

L link = createLinkObject(title, id);
T target = getTarget(linkedId);
link.setName(linkLabel);
link.setDescription(linkDesc);
link.setTarget(target);
U displayLink = createDisplayLink(link);
setDisplayProperties(displayLink, id, positionX, positionY, rotation, displayType, linkImage, imageFilename);
if(existingImageId!=null && !existingImageId.trim().isEmpty()) {
setDisplayProperties(displayLink, positionX, positionY, rotation, displayType, existingImageId);
} else {
setDisplayProperties(displayLink, id, positionX, positionY, rotation, displayType, linkImage, imageFilename);
}
return updateLinkAndDisplay(link, displayLink);

}

@Override
public U updateLink(String title, String id, float positionX, float positionY, int rotation, String linkedId,
String linkLabel, String linkId, String linkDisplayId, DisplayType displayType, byte[] linkImage,
String imageFilename)
throws SpaceDoesNotExistException, LinkDoesNotExistsException, ImageCouldNotBeStoredException {

String linkLabel, String linkDesc, String linkId, String linkDisplayId, DisplayType displayType, byte[] linkImage,
String imageFilename, String existingImageId)
throws SpaceDoesNotExistException, LinkDoesNotExistsException, ImageCouldNotBeStoredException, ImageDoesNotExistException {
validateSpace(id);

L link = getLink(linkId);
T target = getTarget(linkedId);
link.setName(title);
link.setDescription(linkDesc);
link.setTarget(target);
U displayLink = getDisplayLink(linkDisplayId);
setDisplayProperties(displayLink, id, positionX, positionY, rotation, displayType, linkImage, imageFilename);
return updateLinkAndDisplay(link, displayLink);
if(existingImageId!=null && !existingImageId.trim().isEmpty()) {
setDisplayProperties(displayLink, positionX, positionY, rotation, displayType, existingImageId);
} else {
setDisplayProperties(displayLink, id, positionX, positionY, rotation, displayType, linkImage, imageFilename);
}
return updateLinkAndDisplay(link,displayLink);
}

@Override
Expand All @@ -77,38 +124,26 @@ public void deleteLink(String linkId) {
deleteLinkRepo(link);
}

protected abstract void deleteLinkRepo(L link);

protected abstract void deleteLinkDisplayRepo(L link);

protected abstract void removeFromLinkList(ISpace space, L link);

protected abstract U updateLinkAndDisplay(L link, U displayLink);

protected abstract U getDisplayLink(String linkDisplayId) throws LinkDoesNotExistsException;

protected abstract L getLink(String linkId);

protected abstract L createLinkObject(String title, String id);

protected abstract T getTarget(String linkedId);

protected abstract U createDisplayLink(L link);

protected void validateSpace(String id) throws SpaceDoesNotExistException {
ISpace source = spaceManager.getSpace(id);
if (source == null) {
throw new SpaceDoesNotExistException();
}
}

protected void setLinkDisplay(ILinkDisplay linkDisplay, float positionX, float positionY, int rotation, DisplayType displayType) {
linkDisplay.setPositionX(positionX);
linkDisplay.setPositionY(positionY);
linkDisplay.setRotation(rotation);
linkDisplay.setType(displayType != null ? displayType : DisplayType.ARROW);
}

protected void setDisplayProperties(ILinkDisplay linkDisplay, String id, float positionX, float positionY,
int rotation, DisplayType displayType, byte[] linkImage, String imageFilename)
throws ImageCouldNotBeStoredException {
linkDisplay.setPositionX(positionX);
linkDisplay.setPositionY(positionY);
linkDisplay.setRotation(rotation);
linkDisplay.setType(displayType != null ? displayType : DisplayType.ARROW);

setLinkDisplay(linkDisplay, positionX, positionY, rotation, displayType);

if (linkImage != null && linkImage.length > 0) {
Tika tika = new Tika();
String contentType = tika.detect(linkImage);
Expand All @@ -125,4 +160,15 @@ protected void setDisplayProperties(ILinkDisplay linkDisplay, String id, float p
linkDisplay.setImage(image);
}
}

protected void setDisplayProperties(ILinkDisplay linkDisplay, float positionX, float positionY, int rotation,
DisplayType displayType, String existingImageId) throws ImageCouldNotBeStoredException, ImageDoesNotExistException {
setLinkDisplay(linkDisplay, positionX, positionY, rotation, displayType);
if(existingImageId!=null && !existingImageId.trim().isEmpty()) {
IVSImage image = imageService.getImageById(existingImageId);
linkDisplay.setImage(image);
}

}

}
Loading