I am trying to do something before Ingest processes it before the KIT DataManager ( GitHub code , it works on tomcat7) with an "intermediate recording processor" ...
adding a custom middleware
package edu.kit.dama.mdm.content.mets;
...
public class TryQuota extends AbstractStagingProcessor {
...
@Override
public final void performPreTransferProcessing(TransferTaskContainer pContainer) throws StagingProcessorException {
...
trying to get user data
... it works
UserData userResult = null;
try {
userResult = mdm.findSingleResult(
"Select u FROM UserData u WHERE u.email=?1",
new Object[]{"dama@kit.edu"},
email
admin user standard with userid
1
UserData.class
);
} catch (UnauthorizedAccessAttemptException e2) {
System.out.println("exception on extracting userid");
e2.printStackTrace();
}
try {
System.out.println("KIT DM ID: " + userResult.getUserId());
}catch(Exception e4) {
System.out.println("exception on output for userid");
e4.printStackTrace();
}
trying to get a quota from UserQuota p>
and on the other hand, the corresponding implementation does not do the work here (what I want to get)
Number UserQuota = null;
try {
UserQuota = mdm.findSingleResult(
"Select q.quota FROM UserQuota q WHERE q.uid=?1",
new Object[]{1},
Number.class
);
} catch (UnauthorizedAccessAttemptException e2) {
System.out.println("exception on userquota");
e2.printStackTrace();
}
System.out.println("quota is: " + UserQuota );
UserQuota
still null here
DB - PostgreSQL, table:
CREATE SEQUENCE userquota_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE;
CREATE TABLE userquota
(
id INTEGER NOT NULL DEFAULT nextval('userquota_seq'),
uid INTEGER NOT NULL DEFAULT 0,
quota DECIMAL NOT NULL DEFAULT 0,
CONSTRAINT uid_key UNIQUE (uid),
CONSTRAINT fk_uid FOREIGN KEY (uid) REFERENCES users(id)
);
This quota I want to get from db in the processor
INSERT INTO userquota (id, uid,quota) VALUES ( 0, 1, 1048576 );
So basically I want to get an entry for the user (here 1) from db: 1048576
like Long.
, .