Skip to content
Snippets Groups Projects
Verified Commit 34360b86 authored by Timm Fitschen's avatar Timm Fitschen
Browse files

Merge branch 'f-fsm' into f-fsm-v0.2

parents 4eb85a56 e60190f4
No related branches found
No related tags found
3 merge requests!21Release v0.4.0,!7F fsm,!6Draft: F acm permissions2
caosdb-webui @ 5dfe8797
Subproject commit 8c59cc861d646cbdba0ec749ba052656f67fd58d Subproject commit 5dfe879722bd01acc5209c581b60bf0ac49635b6
...@@ -39,6 +39,7 @@ import java.util.LinkedList; ...@@ -39,6 +39,7 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.UUID;
import org.antlr.v4.runtime.CharStreams; import org.antlr.v4.runtime.CharStreams;
import org.antlr.v4.runtime.CommonTokenStream; import org.antlr.v4.runtime.CommonTokenStream;
import org.apache.commons.jcs.access.behavior.ICacheAccess; import org.apache.commons.jcs.access.behavior.ICacheAccess;
...@@ -238,6 +239,8 @@ public class Query implements QueryInterface, ToElementable, TransactionInterfac ...@@ -238,6 +239,8 @@ public class Query implements QueryInterface, ToElementable, TransactionInterfac
*/ */
private boolean cachable = true; private boolean cachable = true;
private static String cacheETag = UUID.randomUUID().toString();
public Type getType() { public Type getType() {
return this.type; return this.type;
} }
...@@ -668,6 +671,7 @@ public class Query implements QueryInterface, ToElementable, TransactionInterfac ...@@ -668,6 +671,7 @@ public class Query implements QueryInterface, ToElementable, TransactionInterfac
/** Remove all cached queries from the cache. */ /** Remove all cached queries from the cache. */
public static void clearCache() { public static void clearCache() {
cacheETag = UUID.randomUUID().toString();
cache.clear(); cache.clear();
} }
...@@ -678,10 +682,12 @@ public class Query implements QueryInterface, ToElementable, TransactionInterfac ...@@ -678,10 +682,12 @@ public class Query implements QueryInterface, ToElementable, TransactionInterfac
* @param resultSet * @param resultSet
*/ */
private void setCache(String key, List<IdVersionPair> resultSet) { private void setCache(String key, List<IdVersionPair> resultSet) {
if (resultSet instanceof Serializable) { synchronized (cache) {
cache.put(key, (Serializable) resultSet); if (resultSet instanceof Serializable) {
} else { cache.put(key, (Serializable) resultSet);
cache.put(key, new ArrayList<>(resultSet)); } else {
cache.put(key, new ArrayList<>(resultSet));
}
} }
} }
...@@ -859,6 +865,7 @@ public class Query implements QueryInterface, ToElementable, TransactionInterfac ...@@ -859,6 +865,7 @@ public class Query implements QueryInterface, ToElementable, TransactionInterfac
ret.setAttribute("results", "0"); ret.setAttribute("results", "0");
} }
ret.setAttribute("cached", Boolean.toString(this.cached)); ret.setAttribute("cached", Boolean.toString(this.cached));
ret.setAttribute("etag", cacheETag);
final Element parseTreeElem = new Element("ParseTree"); final Element parseTreeElem = new Element("ParseTree");
if (this.el.hasErrors()) { if (this.el.hasErrors()) {
......
...@@ -215,13 +215,7 @@ public class WriteTransaction extends Transaction<WritableContainer> ...@@ -215,13 +215,7 @@ public class WriteTransaction extends Transaction<WritableContainer>
.setFile(oldEntity.getFileProperties().retrieveFromFileSystem()); .setFile(oldEntity.getFileProperties().retrieveFromFileSystem());
} }
try { ((UpdateEntity) entity).setOriginal(oldEntity);
checkPermissions(entity, deriveUpdate(entity, oldEntity));
} catch (final AuthorizationException exc) {
entity.setEntityStatus(EntityStatus.UNQUALIFIED);
entity.addError(ServerMessages.AUTHORIZATION_ERROR);
entity.addInfo(exc.getMessage());
}
} }
break innerLoop; break innerLoop;
} }
...@@ -290,6 +284,18 @@ public class WriteTransaction extends Transaction<WritableContainer> ...@@ -290,6 +284,18 @@ public class WriteTransaction extends Transaction<WritableContainer>
@Override @Override
protected void preCheck() throws InterruptedException, Exception { protected void preCheck() throws InterruptedException, Exception {
for (final EntityInterface entity : getContainer()) { for (final EntityInterface entity : getContainer()) {
try {
if (entity.getEntityStatus() == EntityStatus.QUALIFIED) {
checkPermissions(entity, deriveUpdate(entity, ((UpdateEntity) entity).getOriginal()));
}
} catch (final AuthorizationException exc) {
entity.setEntityStatus(EntityStatus.UNQUALIFIED);
entity.addError(ServerMessages.AUTHORIZATION_ERROR);
entity.addInfo(exc.getMessage());
} catch (ClassCastException exc) {
// not an update entity. ignore.
}
// set default EntityACL if none present // set default EntityACL if none present
if (entity.getEntityACL() == null) { if (entity.getEntityACL() == null) {
entity.setEntityACL(EntityACL.getOwnerACLFor(SecurityUtils.getSubject())); entity.setEntityACL(EntityACL.getOwnerACLFor(SecurityUtils.getSubject()));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment