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

fix tests

parent e326435d
No related branches found
No related tags found
3 merge requests!21Release v0.4.0,!7F fsm,!6Draft: F acm permissions2
Pipeline #5880 passed
...@@ -22,11 +22,21 @@ ...@@ -22,11 +22,21 @@
*/ */
package org.caosdb.server.entity; package org.caosdb.server.entity;
import org.caosdb.server.transaction.WriteTransaction;
import org.caosdb.server.utils.EntityStatus; import org.caosdb.server.utils.EntityStatus;
import org.jdom2.Element; import org.jdom2.Element;
/**
* UpdateEntity class represents entities which are to be updated. The previous version is appeded
* during the {@link WriteTransaction} transactions initialization.
*
* @author Timm Fitschen (t.fitschen@indiscale.com)
*/
public class UpdateEntity extends WritableEntity { public class UpdateEntity extends WritableEntity {
/** The previous version of this entity. */
private EntityInterface original = null;
public UpdateEntity(final Element element) { public UpdateEntity(final Element element) {
super(element); super(element);
} }
...@@ -35,4 +45,12 @@ public class UpdateEntity extends WritableEntity { ...@@ -35,4 +45,12 @@ public class UpdateEntity extends WritableEntity {
public boolean skipJob() { public boolean skipJob() {
return getEntityStatus() != EntityStatus.QUALIFIED; return getEntityStatus() != EntityStatus.QUALIFIED;
} }
public void setOriginal(EntityInterface original) {
this.original = original;
}
public EntityInterface getOriginal() {
return this.original;
}
} }
...@@ -242,13 +242,19 @@ public abstract class AbstractEntityACLFactory<T extends EntityACL> { ...@@ -242,13 +242,19 @@ public abstract class AbstractEntityACLFactory<T extends EntityACL> {
for (EntityACI aci : permissions.getRules()) { for (EntityACI aci : permissions.getRules()) {
if (EntityACL.isAllowance(aci.getBitSet())) { if (EntityACL.isAllowance(aci.getBitSet())) {
if (EntityACL.isPriorityBitSet(aci.getBitSet())) { if (EntityACL.isPriorityBitSet(aci.getBitSet())) {
long bitset = this.priorityGrants.get(aci.getResponsibleAgent()); Long bitset = this.priorityGrants.get(aci.getResponsibleAgent());
if (bitset == null) {
continue;
}
long bitset2 = bitset; long bitset2 = bitset;
bitset2 &= aci.getBitSet(); bitset2 &= aci.getBitSet();
bitset ^= bitset2; bitset ^= bitset2;
this.priorityGrants.put(aci.getResponsibleAgent(), bitset); this.priorityGrants.put(aci.getResponsibleAgent(), bitset);
} else { } else {
long bitset = this.normalGrants.get(aci.getResponsibleAgent()); Long bitset = this.normalGrants.get(aci.getResponsibleAgent());
if (bitset == null) {
continue;
}
long bitset2 = bitset; long bitset2 = bitset;
bitset2 &= aci.getBitSet(); bitset2 &= aci.getBitSet();
bitset ^= bitset2; bitset ^= bitset2;
...@@ -256,13 +262,19 @@ public abstract class AbstractEntityACLFactory<T extends EntityACL> { ...@@ -256,13 +262,19 @@ public abstract class AbstractEntityACLFactory<T extends EntityACL> {
} }
} else { } else {
if (EntityACL.isPriorityBitSet(aci.getBitSet())) { if (EntityACL.isPriorityBitSet(aci.getBitSet())) {
long bitset = this.priorityDenials.get(aci.getResponsibleAgent()); Long bitset = this.priorityDenials.get(aci.getResponsibleAgent());
if (bitset == null) {
continue;
}
long bitset2 = bitset; long bitset2 = bitset;
bitset2 &= aci.getBitSet(); bitset2 &= aci.getBitSet();
bitset ^= bitset2; bitset ^= bitset2;
this.priorityDenials.put(aci.getResponsibleAgent(), bitset); this.priorityDenials.put(aci.getResponsibleAgent(), bitset);
} else { } else {
long bitset = this.normalDenials.get(aci.getResponsibleAgent()); Long bitset = this.normalDenials.get(aci.getResponsibleAgent());
if (bitset == null) {
continue;
}
long bitset2 = bitset; long bitset2 = bitset;
bitset2 &= aci.getBitSet(); bitset2 &= aci.getBitSet();
bitset ^= bitset2; bitset ^= bitset2;
......
...@@ -285,7 +285,9 @@ public class WriteTransaction extends Transaction<WritableContainer> ...@@ -285,7 +285,9 @@ public class WriteTransaction extends Transaction<WritableContainer>
protected void preCheck() throws InterruptedException, Exception { protected void preCheck() throws InterruptedException, Exception {
for (final EntityInterface entity : getContainer()) { for (final EntityInterface entity : getContainer()) {
try { try {
checkPermissions(entity, deriveUpdate(entity, ((UpdateEntity) entity).getOriginal())); if (entity.getEntityStatus() == EntityStatus.QUALIFIED) {
checkPermissions(entity, deriveUpdate(entity, ((UpdateEntity) entity).getOriginal()));
}
} catch (final AuthorizationException exc) { } catch (final AuthorizationException exc) {
entity.setEntityStatus(EntityStatus.UNQUALIFIED); entity.setEntityStatus(EntityStatus.UNQUALIFIED);
entity.addError(ServerMessages.AUTHORIZATION_ERROR); entity.addError(ServerMessages.AUTHORIZATION_ERROR);
...@@ -377,21 +379,6 @@ public class WriteTransaction extends Transaction<WritableContainer> ...@@ -377,21 +379,6 @@ public class WriteTransaction extends Transaction<WritableContainer>
newEntity.setEntityACL(oldEntity.getEntityACL()); newEntity.setEntityACL(oldEntity.getEntityACL());
} }
// new acl?
if (newEntity.hasEntityACL() && !newEntity.getEntityACL().equals(oldEntity.getEntityACL())) {
oldEntity.checkPermission(EntityPermission.EDIT_ACL);
if (!newEntity
.getEntityACL()
.getPriorityEntityACL()
.equals(oldEntity.getEntityACL().getPriorityEntityACL())) {
// priority acl is to be changed?
oldEntity.checkPermission(Permission.EDIT_PRIORITY_ACL);
}
updatetable = true;
} else if (!newEntity.hasEntityACL()) {
newEntity.setEntityACL(oldEntity.getEntityACL());
}
// new query template definition? // new query template definition?
if (!Objects.equals( if (!Objects.equals(
newEntity.getQueryTemplateDefinition(), oldEntity.getQueryTemplateDefinition())) { newEntity.getQueryTemplateDefinition(), oldEntity.getQueryTemplateDefinition())) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment