Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/maven/fixes/9.0' into maven/rele…
Browse files Browse the repository at this point in the history
…ase/9.0
  • Loading branch information
metaventis-build committed Sep 9, 2024
2 parents e67e4d6 + 6051242 commit a883615
Show file tree
Hide file tree
Showing 27 changed files with 182 additions and 238 deletions.
3 changes: 1 addition & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ default:
command: [ "dockerd-entrypoint.sh" ]

stages:
- lint
- test
- deploy

Expand Down Expand Up @@ -202,7 +201,7 @@ e2e:
- $E2E_TEST == "true"

check-helmreadme:
stage: lint
stage: test
image: node:lts-alpine3.20
before_script:
- ln -s $CI_PROJECT_DIR/deploy/docker/helm/search-solr/src/main/chart /tmp/search-solr && cp /tmp/search-solr/README.md /tmp/README_search-solr.md
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ public MetadataKeyRelated(Relation relation) {
private String icon;
private String description;
private String parent;
/**
* Hint if the given key shall be removed. Use in conjunction with @MetadataWidget.ValuespaceMerge
*/
@Getter
@Setter
private Boolean delete = false;
private String locale;
/**
* List of other keys this child is a precedor of
Expand All @@ -54,4 +60,6 @@ public void setParent(String parent) {
public void addRelated(MetadataKeyRelated related) {
this.related.add(related);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,8 @@ private List<MetadataWidget> getWidgets() throws Exception {
for (ValuespaceInfo v : valuespaces) {
ValuespaceData values = getValuespace(v, widget, valuespaceI18n, valuespaceI18nPrefix);
keys.addAll(values.getEntries());
// remove keys which have the delete flag attached
values.getEntries().stream().filter(MetadataKey::getDelete).forEach(k -> keys.removeIf(k2 -> Objects.equals(k2.getKey(), k.getKey())));
}
}
widget.setValues(keys);
Expand Down Expand Up @@ -661,6 +663,8 @@ private List<MetadataKey> getValues(NodeList keysNode, String valuespaceI18n, St
key.setI18nPrefix(valuespaceI18nPrefix);
if (attributes != null && attributes.getNamedItem("parent") != null)
key.setParent(attributes.getNamedItem("parent").getTextContent());
if (attributes != null && attributes.getNamedItem("delete") != null)
key.setDelete(attributes.getNamedItem("delete").getTextContent().equalsIgnoreCase("true"));
if (attributes != null && attributes.getNamedItem("icon") != null)
key.setIcon(attributes.getNamedItem("icon").getTextContent());
if (attributes != null && attributes.getNamedItem("url") != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ public static Map<String, Aggregation> getAggregations(MetadataSet mds, Metadata
String currentLocale = new AuthenticationToolAPI().getCurrentLocale();
for (String facet : facets) {

Map<String, String[]> tmp = new HashMap<>(parameters);
Map<String, String[]> tmp = new HashMap<>(parameters == null ? Collections.emptyMap() : parameters);
if (excludeOwn.stream().anyMatch(mdqp -> mdqp.getName().equals(facet))) {
tmp.remove(facet);
}
Expand Down Expand Up @@ -376,7 +376,7 @@ public static Map<String, Aggregation> getAggregations(MetadataSet mds, Metadata
);
}

if(parameters.get(facet) != null && parameters.get(facet).length > 0) {
if(parameters != null && parameters.get(facet) != null && parameters.get(facet).length > 0) {
List<MetadataQueryParameter.MetadataQueryFacet> facetDetails = query.findParameterByName(facet).getFacets();
result.put(
facet + "_selected",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ public static HashMap<String, String[]> convertProps(Map<String, Object> props)
HashMap<String, String[]> propsConverted = new HashMap<>();
for(String key : props.keySet()){
String keyLocal= CCConstants.getValidLocalName(key);

if(props.get(key) == null) continue;
if(keyLocal == null || props.get(key) == null) continue;

String[] values=ValueTool.getMultivalue(props.get(key).toString());
propsConverted.put(keyLocal, values);
Expand Down Expand Up @@ -381,7 +380,7 @@ private String renderTemplate(MetadataTemplate template) throws IllegalArgumentE
}
}
if (persistentIdUrl != null && !persistentIdUrl.isEmpty()) {
widgetHtml.append("<br><a href=\"").append(persistentIdUrl)
widgetHtml.append("<a href=\"").append(persistentIdUrl)
.append("\" target=\"blank\">")
.append(MetadataHelper.getTranslation("vcard_link_persistent_id"))
.append("</a>");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ protected String getValue(String type, String prop, Object _value, String metada
return result;
} else if (_value instanceof List && ((List) _value).size() == 0) {
// cause empty list toString returns "[]"
return "";
return null;
} else if (_value instanceof String) {
return (String) _value;
} else if (_value instanceof Number) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp)
resp.getWriter().write("<body class= \"eduservlet-render-body\">");
String response;
try {
response = renderingService.getDetails(node_id, version,DEFAULT_DISPLAY_MODE, params);
response = renderingService.getDetails(node_id, version,DEFAULT_DISPLAY_MODE, params).getDetails();
response = response.replace("{{{LMS_INLINE_HELPER_SCRIPT}}}", URLHelper.getNgRenderNodeUrl(node_id,version)+"?");
TrackingServiceFactory.getTrackingService().trackActivityOnNode(new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, node_id), null, TrackingService.EventType.VIEW_MATERIAL_EMBEDDED);
} catch (Throwable t) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ private NodeDao(org.alfresco.service.cmr.repository.NodeRef nodeRef) throws Thro
isCollectionHomePath = false; // TODO do we need to resolve this here?
}

public String getVersion() {
return version;
}

public static NodeStatsEntry.NodeStats getStats(NodeDao node) throws DAOException {
if(!node.isFromRemoteRepository()) {
if(!node.access.contains(PermissionService.CHANGE_PERMISSIONS)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.Map;

import org.apache.log4j.Logger;
import org.edu_sharing.service.rendering.RenderingDetails;
import org.edu_sharing.service.rendering.RenderingTool;

public class RenderingDao {
Expand All @@ -13,7 +14,7 @@ public RenderingDao(RepositoryDao repoDao) {
this.repoDao = repoDao;
}

public String getDetails(String nodeId,String nodeVersion, String displayMode,Map<String,String> parameters) throws DAOException{
public RenderingDetails getDetails(String nodeId, String nodeVersion, String displayMode, Map<String,String> parameters) throws DAOException{
try{
return repoDao.getRenderingServiceClient().getDetails(nodeId,nodeVersion,
displayMode==null || displayMode.isEmpty() ? RenderingTool.DISPLAY_DYNAMIC : displayMode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,26 @@
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.Response;
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
import org.apache.log4j.Logger;
import org.edu_sharing.repository.client.tools.CCConstants;
import org.edu_sharing.repository.server.tracking.TrackingTool;
import org.edu_sharing.restservices.ApiService;
import org.edu_sharing.restservices.NodeDao;
import org.edu_sharing.restservices.RenderingDao;
import org.edu_sharing.restservices.RepositoryDao;
import org.edu_sharing.restservices.*;
import org.edu_sharing.restservices.rendering.v1.model.RenderingDetailsEntry;
import org.edu_sharing.restservices.shared.ErrorResponse;
import org.edu_sharing.restservices.shared.Filter;
import org.edu_sharing.restservices.shared.Node;
import org.edu_sharing.service.rendering.RenderingDetails;
import org.edu_sharing.service.rendering.RenderingTool;
import org.edu_sharing.service.repoproxy.RepoProxy;
import org.edu_sharing.service.repoproxy.RepoProxyFactory;
import org.edu_sharing.service.tracking.NodeTrackingDetails;
import org.edu_sharing.service.tracking.TrackingService;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.Response;
import java.util.*;
import java.util.Arrays;
import java.util.Map;


@Path("/rendering/v1")
Expand Down Expand Up @@ -109,13 +107,15 @@ public Response getDetailsSnippetWithParameters(
org.edu_sharing.generated.repository.backend.services.rest.client.model.RenderingDetailsEntry entity = (org.edu_sharing.generated.repository.backend.services.rest.client.model.RenderingDetailsEntry) RepoProxyFactory.getRepoProxy().getDetailsSnippetWithParameters(remote.getRepository(), remote.getNodeId(), nodeVersion, displayMode, parameters, req).getEntity();
return Response.status(Response.Status.OK).entity(entity).build();
} else {
NodeDao nodeDao = NodeDao.getNodeWithVersion(repoDao, node, nodeVersion);
Node nodeJson = nodeDao.asNode();

String detailsSnippet = new RenderingDao(repoDao).getDetails(node, nodeVersion, displayMode, parameters);

String mimeType = nodeJson.getMimetype();

RenderingDetails detailsSnippet = new RenderingDao(repoDao).getDetails(node, nodeVersion, displayMode, parameters);
if(detailsSnippet.getException() != null) {
if(detailsSnippet.getException().getNested() != null) {
DAOException mapped = DAOException.mapping(detailsSnippet.getException().getNested());
if(mapped instanceof DAOMissingException) {
throw mapped;
}
}
}
if (repoDao.isHomeRepo()) {
NodeTrackingDetails details = (NodeTrackingDetails) org.edu_sharing.alfresco.repository.server.authentication.
Context.getCurrentInstance().getRequest().getSession().getAttribute(CCConstants.SESSION_RENDERING_DETAILS);
Expand All @@ -134,9 +134,12 @@ public Response getDetailsSnippetWithParameters(
}

RenderingDetailsEntry response = new RenderingDetailsEntry();
response.setDetailsSnippet(detailsSnippet);
response.setMimeType(mimeType);
response.setNode(nodeJson);
response.setDetailsSnippet(detailsSnippet.getDetails());
if(detailsSnippet.getRenderingServiceData() != null) {
String mimeType = detailsSnippet.getRenderingServiceData().getNode().getMimetype();
response.setMimeType(mimeType);
response.setNode(detailsSnippet.getRenderingServiceData().getNode());
}

return Response.status(Response.Status.OK).entity(response).build();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.edu_sharing.service.rendering;

import lombok.*;
import org.edu_sharing.repository.server.rendering.RenderingException;
import org.edu_sharing.restservices.NodeDao;

@Data
@AllArgsConstructor
@RequiredArgsConstructor
public class RenderingDetails {
@NonNull
String details;
RenderingServiceData renderingServiceData;
RenderingException exception;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

public interface RenderingService {

String getDetails(String nodeId, String nodeVersion, String displayMode, Map<String, String> parameters) throws InsufficientPermissionException, Exception;
RenderingDetails getDetails(String nodeId, String nodeVersion, String displayMode, Map<String, String> parameters) throws InsufficientPermissionException, Exception;

String getDetails(String renderingServiceUrl, RenderingServiceData data) throws JsonProcessingException, UnsupportedEncodingException;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
package org.edu_sharing.service.rendering;

import lombok.Getter;
import lombok.Setter;
import org.codehaus.jackson.annotate.JsonProperty;
import org.edu_sharing.repository.client.tools.I18nAngular;
import org.edu_sharing.restservices.NodeDao;
import org.edu_sharing.restservices.shared.*;
import org.edu_sharing.alfresco.service.config.model.Values;

import java.io.Serializable;
import java.util.List;

@Getter
@Setter
public class RenderingServiceData implements Serializable {
private Node node;
private List<Node> children;
Expand All @@ -20,62 +25,6 @@ public class RenderingServiceData implements Serializable {

private List<Editor> editors;

public Node getNode() {
return node;
}

public void setNode(Node node) {
this.node = node;
}

public void setUser(UserRender user) {
this.user = user;
}

public UserRender getUser() {
return user;
}

public void setMetadataHTML(String metadataHTML) {
this.metadataHTML = metadataHTML;
}

public String getMetadataHTML() {
return metadataHTML;
}

public void setConfigValues(Values configValues) {
this.configValues = configValues;
}

public Values getConfigValues() {
return configValues;
}

public void setChildren(List<Node> children) {
this.children = children;
}

public List<Node> getChildren() {
return children;
}

public void setNodeUrls(NodeUrls nodeUrls) {
this.nodeUrls = nodeUrls;
}

public NodeUrls getNodeUrls() {
return nodeUrls;
}

public void setEditors(List<Editor> editors) {
this.editors = editors;
}

public List<Editor> getEditors() {
return editors;
}

static class Editor implements Serializable {

private String id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ public RenderingVersionInfo getVersion() throws GeneralSecurityException {
}

@Override
public String getDetails(String nodeId,String nodeVersion,String displayMode,Map<String,String> parameters) throws InsufficientPermissionException, Exception{
public RenderingDetails getDetails(String nodeId,String nodeVersion,String displayMode,Map<String,String> parameters) throws InsufficientPermissionException, Exception{

if(!this.permissionService.hasPermission(StoreRef.PROTOCOL_WORKSPACE,StoreRef.STORE_REF_WORKSPACE_SPACESSTORE.getIdentifier(),nodeId,CCConstants.PERMISSION_READ)){
throw new InsufficientPermissionException("no read permission");
}
Expand All @@ -117,11 +117,15 @@ public String getDetails(String nodeId,String nodeVersion,String displayMode,Map
options.displayMode = displayMode;
options.parameters = parameters;
RenderingServiceData data = getData(appInfo, nodeId, nodeVersion, AuthenticationUtil.getFullyAuthenticatedUser(), options);
return getDetails(renderingServiceUrl, data);
RenderingDetails details = new RenderingDetails(getDetails(renderingServiceUrl, data));
details.setRenderingServiceData(data);
return details;
}catch(Throwable t) {
logger.warn(t.getMessage(),t);
return RenderingErrorServlet.errorToHTML(null,
new RenderingException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,t.getMessage(),RenderingException.I18N.unknown,t));
RenderingException exception = new RenderingException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, t.getMessage(), RenderingException.I18N.unknown, t);
RenderingDetails details = new RenderingDetails(RenderingErrorServlet.errorToHTML(null, exception));
details.setException(exception);
return details;
/*
String repository=VersionService.getVersionNoException(VersionService.Type.REPOSITORY);
String rs=VersionService.getVersionNoException(VersionService.Type.RENDERSERVICE);
Expand All @@ -138,7 +142,7 @@ public String getDetails(String nodeId,String nodeVersion,String displayMode,Map
}
*/
}

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public RenderingServiceNotSupported(String appId){
}

@Override
public String getDetails(String nodeId,String nodeVersion,String displayMode,Map<String,String> parameters) throws InsufficientPermissionException, Exception{
public RenderingDetails getDetails(String nodeId,String nodeVersion,String displayMode,Map<String,String> parameters) throws InsufficientPermissionException, Exception{
throw new NotImplementedException();
}

Expand Down
Loading

0 comments on commit a883615

Please sign in to comment.