Skip to content
Snippets Groups Projects
Unverified Commit d867eee3 authored by Timm Fitschen's avatar Timm Fitschen
Browse files

MAINT: include changes from f-awi

parent ec86b939
Branches
Tags
No related merge requests found
caosdb-webui @ d02f34fa
Subproject commit 32fa3b8af945d4d0bf4e98818b2456bdc8f375c0
Subproject commit d02f34facc0409817daeac8a3a226a6cfcd0b895
......@@ -292,7 +292,7 @@ public class UTCDateTime implements Interval {
@Override
public String toString() {
return toDateTimeString(TimeZone.getDefault());
throw new NullPointerException("toString method!!!");
}
public static UTCDateTime UTCSeconds(final Long utcseconds, final Integer nanosecond) {
......
......@@ -79,20 +79,20 @@ public class Message extends Exception implements Comparable<Message>, ToElement
this(type, code, null, null);
}
public Message(final int code, final String description) {
public Message(final Integer code, final String description) {
this("Message", code, description, null);
}
public Message(final MessageType type, final int code, final String description) {
public Message(final MessageType type, final Integer code, final String description) {
this(type.toString(), code, description, null);
}
public Message(
final MessageType type, final int code, final String description, final String body) {
final MessageType type, final Integer code, final String description, final String body) {
this(type.toString(), code, description, body);
}
public Message(final String type, final int code, final String description) {
public Message(final String type, final Integer code, final String description) {
this(type, code, description, null);
}
......
......@@ -233,8 +233,12 @@ public abstract class Job extends AbstractObservable implements Observer {
if (flagName.length() > 0) {
allClasses.put(flagName.toLowerCase(), c);
}
if (c.getAnnotation(JobAnnotation.class).loadAlways()) {
loadAlways.add(c);
}
}
}
// TODO merge these two parts of this function. Its the same!
jobPackage = new Reflections("caosdb.server.jobs.extension");
allClassesSet = jobPackage.getSubTypesOf(Job.class);
for (final Class<? extends Job> c : allClassesSet) {
......@@ -289,7 +293,8 @@ public abstract class Job extends AbstractObservable implements Observer {
final ArrayList<Job> jobs = new ArrayList<>();
// load permanent jobs
for (Class<? extends Job> j : loadAlways) {
if (j.getAnnotation(JobAnnotation.class).transaction().isInstance(transaction)) {
if (EntityJob.class.isAssignableFrom(j)
&& j.getAnnotation(JobAnnotation.class).transaction().isInstance(transaction)) {
jobs.add(getJob(j, Mode.MUST, entity, transaction));
}
}
......@@ -425,4 +430,16 @@ public abstract class Job extends AbstractObservable implements Observer {
public JobExecutionTime getExecutionTime() {
return this.time;
}
public static List<Job> loadPermanentContainerJobs(Transaction<?> transaction) {
final ArrayList<Job> jobs = new ArrayList<>();
// load permanent jobs
for (Class<? extends Job> j : loadAlways) {
if (ContainerJob.class.isAssignableFrom(j)
&& j.getAnnotation(JobAnnotation.class).transaction().isInstance(transaction)) {
jobs.add(getJob(j, Mode.MUST, null, transaction));
}
}
return jobs;
}
}
......@@ -27,11 +27,15 @@ import caosdb.server.entity.EntityInterface;
import caosdb.server.jobs.ContainerJob;
import caosdb.server.jobs.JobAnnotation;
import caosdb.server.jobs.JobExecutionTime;
import caosdb.server.transaction.WriteTransaction;
import caosdb.server.utils.EntityStatus;
import caosdb.server.utils.Observable;
import caosdb.server.utils.ServerMessages;
@JobAnnotation(time = JobExecutionTime.POST_CHECK)
@JobAnnotation(
time = JobExecutionTime.POST_CHECK,
transaction = WriteTransaction.class,
loadAlways = true)
public class Atomic extends ContainerJob {
private boolean doCheck() {
......
......@@ -7,6 +7,7 @@ import caosdb.server.jobs.JobAnnotation;
import caosdb.server.utils.EntityStatus;
import caosdb.server.utils.ServerMessages;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
@JobAnnotation(
......@@ -35,6 +36,7 @@ public class CheckNoAdditionalPropertiesPresent extends EntityJob {
for (EntityInterface parentProperty : parent.getProperties()) {
if (sameProperty(property, parentProperty) && !used.contains(parentProperty)) {
used.add(parentProperty);
return;
}
}
// not found!
......@@ -51,6 +53,6 @@ public class CheckNoAdditionalPropertiesPresent extends EntityJob {
}
private boolean sameProperty(EntityInterface property, EntityInterface parentProperty) {
return property.getId() == parentProperty.getId();
return property.getId() != null && Objects.equals(property.getId(), parentProperty.getId());
}
}
......@@ -48,7 +48,7 @@ public class EntityACL {
public static final long OWNER_BITSET = 1;
private final Collection<EntityACI> acl;
EntityACL(final Collection<EntityACI> acl) {
public EntityACL(final Collection<EntityACI> acl) {
if (acl != null) {
this.acl = acl;
} else {
......@@ -60,13 +60,16 @@ public class EntityACL {
final EntityACLFactory f = new EntityACLFactory();
f.grant(OWNER_ROLE, "*");
f.grant(OTHER_ROLE, "RETRIEVE:*");
f.grant(OTHER_ROLE, "USE:*");
f.grant(Role.ANONYMOUS_ROLE, "RETRIEVE:*");
f.grant(Role.ANONYMOUS_ROLE, "USE:*");
f.deny(OTHER_ROLE, "UPDATE:*");
f.deny(OTHER_ROLE, "DELETE");
f.deny(OTHER_ROLE, true, "EDIT:ACL");
return f.create();
}
EntityACL(final EntityACI... aci) {
public EntityACL(final EntityACI... aci) {
this.acl = new ArrayList<>();
for (final EntityACI a : aci) {
this.acl.add(a);
......
......@@ -236,10 +236,12 @@ pov returns [POV filter] locals [Query.Pattern p, String o, String v, String a]
(
property {$p = $property.pp; $a=$property.agg;}
(
( LIKE {$o = $LIKE.text;}
(
LIKE {$o = $LIKE.text;}
( like_pattern {$v = $like_pattern.ep.toString();}
| value {$v = $value.str;} )
| OPERATOR {$o = $OPERATOR.text;} value {$v = $value.str;})
| OPERATOR {$o = $OPERATOR.text;} value {$v = $value.str;}
)
| IS_NULL {$o = "0";}
| IS_NOT_NULL {$o = "!0";}
| IN datetime {$o = "("; $v=$datetime.text;}
......@@ -248,11 +250,14 @@ pov returns [POV filter] locals [Query.Pattern p, String o, String v, String a]
)
|
(
OPERATOR {$o = $OPERATOR.text;} value {$v = $value.str;}
(
AS_A
property {$p = $property.pp;}
)?
( LIKE {$o = $LIKE.text;}
( like_pattern {$v = $like_pattern.ep.toString();}
| value {$v = $value.str;} )
)
| ( OPERATOR {$o = $OPERATOR.text;} value {$v = $value.str;}
( AS_A
property {$p = $property.pp;} )?
)
)
;
......
......@@ -38,7 +38,6 @@ import caosdb.server.jobs.Job;
import caosdb.server.jobs.JobExecutionTime;
import caosdb.server.jobs.Schedule;
import caosdb.server.jobs.core.AccessControl;
import caosdb.server.jobs.core.Atomic;
import caosdb.server.jobs.core.CheckDatatypePresent;
import caosdb.server.jobs.core.CheckEntityACLRoles;
import caosdb.server.jobs.core.Mode;
......@@ -86,13 +85,13 @@ public abstract class Transaction<C extends TransactionContainer> extends Abstra
this.schedule.add(loadContainerFlags);
this.schedule.runJob(loadContainerFlags);
// all transactions are atomic
this.schedule.add(Job.getJob(Atomic.class.getSimpleName(), Mode.MUST, null, this));
// AccessControl
this.schedule.add(Job.getJob(AccessControl.class.getSimpleName(), Mode.MUST, null, this));
this.schedule.add(Job.getJob(CheckEntityACLRoles.class.getSimpleName(), Mode.MUST, null, this));
// load permanent container jobs
this.schedule.addAll(Job.loadPermanentContainerJobs(this));
for (final EntityInterface e : getContainer()) {
final List<Job> loadJobs = Job.loadJobs(e, this);
this.schedule.addAll(loadJobs);
......
......@@ -423,7 +423,7 @@ public class ServerMessages {
new Message(
MessageType.Warning,
0,
"This property is an additional property which has no corresponding properties among the properties of the parents.");
"This property is an additional property which has no corresponding property among the properties of the parents.");
public static final Message PROPERTY_WITH_DATATYPE_OVERRIDE =
new Message(MessageType.Warning, 0, "This property overrides the datatype.");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment