package io.digdag.core.repository;

import java.util.List;
import java.util.Map;
import java.time.ZoneId;
import com.google.common.base.Optional;

public interface ProjectStore
{
    List<StoredProject> getProjects(int pageSize, Optional<Integer> lastId);

    ProjectMap getProjectsByIdList(List<Integer> projIdList);

    StoredProject getProjectById(int projId)
        throws ResourceNotFoundException;

    StoredProject getProjectByName(String projName)
        throws ResourceNotFoundException;

    interface ProjectLockAction <T>
    {
        T call(ProjectControlStore store, StoredProject storedProject)
            throws ResourceConflictException;
    }

    <T> T putAndLockProject(Project project, ProjectLockAction<T> func)
        throws ResourceConflictException;

    interface ProjectObsoleteAction <T>
    {
        T call(ProjectControlStore store, StoredProject storedProject)
            throws ResourceNotFoundException;
    }

    <T> T deleteProject(int projId, ProjectObsoleteAction<T> func)
        throws ResourceNotFoundException;


    StoredRevision getRevisionById(int revId)
        throws ResourceNotFoundException;

    StoredRevision getRevisionByName(int projId, String revName)
        throws ResourceNotFoundException;

    StoredRevision getLatestRevision(int projId)
        throws ResourceNotFoundException;

    List<StoredRevision> getRevisions(int projId, int pageSize, Optional<Integer> lastId);

    byte[] getRevisionArchiveData(int revId)
            throws ResourceNotFoundException;


    List<StoredWorkflowDefinition> getWorkflowDefinitions(int revId, int pageSize, Optional<Long> lastId);

    StoredWorkflowDefinition getWorkflowDefinitionByName(int revId, String name)
        throws ResourceNotFoundException;

    StoredWorkflowDefinitionWithProject getWorkflowDefinitionById(long wfId)
        throws ResourceNotFoundException;

    StoredWorkflowDefinitionWithProject getLatestWorkflowDefinitionByName(int projId, String name)
        throws ResourceNotFoundException;

    List<StoredWorkflowDefinitionWithProject> getLatestActiveWorkflowDefinitions(int pageSize, Optional<Long> lastId)
        throws ResourceNotFoundException;

    TimeZoneMap getWorkflowTimeZonesByIdList(List<Long> defIdList);
}

@@ -99,16 +99,17 @@
 ZoneId;%0A
+%0A
 import c
@@ -139,16 +139,58 @@
 ptional;
+%0Aimport io.digdag.spi.ac.AccessController;
 %0A%0Apublic
@@ -281,32 +281,70 @@
 %3CInteger%3E lastId
+, AccessController.ListFilter acFilter
 );%0A%0A    ProjectM
@@ -1709,32 +1709,70 @@
 nal%3CLong%3E lastId
+, AccessController.ListFilter acFilter
 );%0A%0A    StoredWo
@@ -2261,16 +2261,54 @@
 %3E lastId
+, AccessController.ListFilter acFilter
 )%0A      

Update digdag-core's ProjectStore