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

Load thumbnails when read-only #235

Merged
merged 3 commits into from
Jul 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions src/main/java/org/openmicroscopy/shoola/env/LookupNames.java
Original file line number Diff line number Diff line change
Expand Up @@ -447,4 +447,11 @@ public class LookupNames

/** Lookup name for characters which need to escaped for the login username / password */
public static final String LOGIN_ESCAPE_CHARACTERS="omero.client.login_escape_characters";

/** Lookup name for read-only status of server.*/
public static final String SERVER_DB = "omero.cluster.read_only.runtime.db";

/** Lookup name for read-only status of server.*/
public static final String SERVER_REPO = "omero.cluster.read_only.runtime.repo";

}
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,27 @@ public void connect(UserCredentials uc)
msg = new LogMessage("Could not load omero client properties from the server", e1);
registry.getLogger().warn(this, msg);
}

try {
// Load the omero server properties from the server
List agents = (List) registry.lookup(LookupNames.AGENTS);
Map<String, String> props = omeroGateway.getServerProperties(exp.getGroupId());
for (String key : props.keySet()) {
if (registry.lookup(key) == null)
registry.bind(key, props.get(key));

Registry agentReg;
for (Object agent : agents) {
agentReg = ((AgentInfo) agent).getRegistry();
if (agentReg != null && agentReg.lookup(key) == null)
agentReg.bind(key, props.get(key));
}
}
} catch (DSAccessException e1) {
msg = new LogMessage("Could not load omero client properties from the server", e1);
registry.getLogger().warn(this, msg);
}


Collection<GroupData> groups;
Set<GroupData> available;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1448,14 +1448,34 @@ Map<String, String> getOmeroClientProperties(long groupId)
throws DSOutOfServiceException, DSAccessException {
if (isConnected()) {
try {
return gw.getConfigService(new SecurityContext(groupId)).getClientConfigValues();
return gw.getConfigService(new SecurityContext(groupId)).getClientConfigValues();
} catch (Exception e) {
handleException(e, "Cannot access config service. ");
}
}
return null;
}

/**
* Get the server properties from the server
* @param The groupId for the {@link SecurityContext}
* @return See above.
* @throws DSAccessException
* @throws DSOutOfServiceException
*/
Map<String, String> getServerProperties(long groupId)
throws DSOutOfServiceException, DSAccessException {
if (isConnected()) {
try {
String regex = "^omero\\.cluster";
return gw.getConfigService(new SecurityContext(groupId)).getConfigValues(regex);
} catch (Exception e) {
handleException(e, "Cannot access config service. ");
}
}
return null;
}

/**
* Retrieves the system view hosting the repositories.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@

import java.awt.Dimension;
import java.awt.Image;
import java.lang.StackTraceElement;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
Expand Down Expand Up @@ -112,6 +113,16 @@ public class ThumbnailLoader extends BatchCallTree {
*/
private boolean asImage = false;

private boolean readOnly = false;

private boolean isReadOnly() {
String b = (String) context.lookup(LookupNames.SERVER_DB);
if (b != null) {
return Boolean.valueOf(b).booleanValue();
}
return false;
}

/**
* Creates a new instance.
* If bad arguments are passed, we throw a runtime exception so to fail
Expand Down Expand Up @@ -146,6 +157,7 @@ public ThumbnailLoader(SecurityContext ctx, Collection<DataObject> imgs,
this.userIDs = userIDs;
this.ctx = ctx;
this.service = context.getImageService();
this.readOnly = isReadOnly();
}

public ThumbnailLoader(SecurityContext ctx, Collection<DataObject> imgs, long userID) {
Expand Down Expand Up @@ -335,6 +347,9 @@ private byte[] loadThumbnail(ThumbnailStorePrx store, PixelsData pxd, long userI
store.setRenderingDefId(rndDefId);
}

if (readOnly) {
return store.getThumbnail(omero.rtypes.rint(sizeX), omero.rtypes.rint(sizeY));
}
return store.getThumbnailWithoutDefault(omero.rtypes.rint(sizeX),
omero.rtypes.rint(sizeY));
}
Expand Down