if (!permissionAPI.doesUserHavePermission(destination, PermissionAPI.PERMISSION_WRITE, user, respectFrontendRoles)) {
throw new DotSecurityException("You don't have permission to wirte in the destination folder.");
}
Link newLink = new Link();
newLink.copy(sourceLink);
// translating internal link if internal and different host than the target folder
if(sourceLink.getLinkType().equals(Link.LinkType.INTERNAL.toString()) &&
!APILocator.getIdentifierAPI().find(sourceLink).getHostId().equals(destination.getHostId())) {
Host destHost=APILocator.getHostAPI().find(destination.getHostId(),user,false);
if(sourceLink.getUrl()!=null && sourceLink.getUrl().contains("/")) {
String assetPath=sourceLink.getUrl().substring(sourceLink.getUrl().indexOf('/'));
newLink.setUrl(destHost.getHostname()+assetPath);
}
// using source internal link ident get URI on source host. Link to same asset in dest host
Identifier ident=APILocator.getIdentifierAPI().find(sourceLink.getInternalLinkIdentifier());
if(ident!=null && UtilMethods.isSet(ident.getId())) {
Identifier newTargetIdent=APILocator.getIdentifierAPI().find(destHost, ident.getURI());
if(newTargetIdent!=null && UtilMethods.isSet(newTargetIdent.getId())) {
String newLinkIdent=newTargetIdent.getId();
newLink.setInternalLinkIdentifier(newLinkIdent);
}
}
}
newLink.setFriendlyName(sourceLink.getFriendlyName());
newLink.setTitle(sourceLink.getTitle());
newLink.setShowOnMenu(sourceLink.isShowOnMenu());
newLink.setProtocal(sourceLink.getProtocal());
newLink.setLinkCode(sourceLink.getLinkCode());
newLink.setLinkType(sourceLink.getLinkType());
//persists the webasset
save(newLink, destination, user, respectFrontendRoles);
if(sourceLink.isLive())