Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/maven/fixes/8.1' into maven/rele…
Browse files Browse the repository at this point in the history
…ase/8.1
  • Loading branch information
metaventis-build committed Nov 16, 2024
2 parents 293c1d9 + 1d9be74 commit f2f01e1
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package org.edu_sharing.repository.server.jobs.helper;

import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.StoreRef;
import org.apache.log4j.Logger;
import org.edu_sharing.repository.client.tools.CCConstants;
import org.edu_sharing.repository.server.jobs.quartz.BulkEditNodesJob;
import org.edu_sharing.repository.server.tools.HttpQueryTool;
import org.edu_sharing.service.nodeservice.NodeServiceFactory;
import org.edu_sharing.service.nodeservice.NodeServiceHelper;

import java.io.InputStream;
import java.util.function.Consumer;

/**
* to be used with @BulkEditNodesJob
*/
public class NodeCustomClasses {
public static class ImportExternalThumbnail implements Consumer<NodeRef> {
@Override
public void accept(NodeRef nodeRef) {
String thumbUrl = NodeServiceHelper.getProperty(nodeRef, CCConstants.CCM_PROP_IO_THUMBNAILURL);
if (thumbUrl == null) {
Logger.getLogger(BulkEditNodesJob.class).info(nodeRef + " has no " + CCConstants.CCM_PROP_IO_THUMBNAILURL + ", skipping...");
return;
}
try {
HttpQueryTool.Callback<Throwable> callback = new HttpQueryTool.Callback<Throwable>() {
@Override
public void handle(InputStream is) {
try {
NodeServiceFactory.getLocalService().writeContent(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, nodeRef.getId(), is,
"image/jpeg", null, CCConstants.CCM_PROP_IO_USERDEFINED_PREVIEW);
} catch (Exception e) {
Logger.getLogger(BulkEditNodesJob.class).warn("Thumb fetching failed for " + nodeRef + " " + thumbUrl);
}
}
};
new HttpQueryTool().queryStream(thumbUrl, callback);
if (callback.getResult() != null) {
Logger.getLogger(BulkEditNodesJob.class).warn("Thumb fetching failed for " + nodeRef + " " + thumbUrl + ": " + callback.getResult());
} else {
NodeServiceHelper.removeProperty(nodeRef, CCConstants.CCM_PROP_IO_THUMBNAILURL);
Logger.getLogger(BulkEditNodesJob.class).info(nodeRef + " thumb imported: " + thumbUrl);
}
} catch (Throwable t) {
Logger.getLogger(BulkEditNodesJob.class).warn("Thumb fetching failed for " + nodeRef + " " + thumbUrl);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,9 @@ public void updateNodeNative(StoreRef store, String nodeId, Map<String, ?> _prop
logger.warn("Error while calling interceptor " + i.getClass().getName() + ": " + e.toString());
}
}
Map<QName, Serializable> propsStore = propsFinal.entrySet().stream().collect(
Map<QName, Serializable> propsStore = propsFinal.entrySet().stream().
filter(e -> e.getValue() != null).
collect(
HashMap::new,
(m,entry)-> m.put(QName.createQName(entry.getKey()), (Serializable) entry.getValue()),
HashMap::putAll
Expand Down

0 comments on commit f2f01e1

Please sign in to comment.