View Javadoc
1   package de.dlr.shepard.auth.apikey.daos;
2   
3   import de.dlr.shepard.auth.apikey.entities.ApiKey;
4   import de.dlr.shepard.common.neo4j.daos.GenericDAO;
5   import jakarta.enterprise.context.RequestScoped;
6   import java.util.UUID;
7   
8   @RequestScoped
9   public class ApiKeyDAO extends GenericDAO<ApiKey> {
10  
11    /**
12     * Find an apiKey by uid
13     *
14     * @param id Identifies the apiKey
15     * @return the found apiKey
16     */
17    public ApiKey find(UUID id) {
18      ApiKey entity = session.load(getEntityType(), id, DEPTH_ENTITY);
19      return entity;
20    }
21  
22    /**
23     * Find an apiKey by uid
24     *
25     * @param id Identifies the apiKey
26     * @return true if deletion was successful
27     */
28    public boolean delete(UUID id) {
29      ApiKey entity = session.load(getEntityType(), id);
30      if (entity != null) {
31        session.delete(entity);
32        return true;
33      }
34      return false;
35    }
36  
37    @Override
38    public Class<ApiKey> getEntityType() {
39      return ApiKey.class;
40    }
41  }