/*-
 * ~~~~~~licensing~~~~~~
 * permission-api
 * ==========
 * Copyright (C) 2020 - 2025 EmDev LLC
 * ==========
 * You may not use this file except in accordance with the License Terms of the Copyright
 * Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
 * rights to the Software and any copies are the property of the Copyright Holder. Unless
 * it is explicitly allowed the Copyright Holder, the User is prohibited from using the
 * Software for commercial purposes to provide services to third parties.
 * 
 * The Copyright Holder hereby declares that the Software is provided on an "AS IS".
 * Under no circumstances does the Copyright Holder guarantee or promise that the
 * Software provided by him will be suitable or not suitable for the specific purposes
 * of the User, that the Software will meet all commercial and personal subjective
 * expectations of the User, that the Software will work properly, without technical
 * errors, quickly and uninterruptedly.
 * 
 * Under no circumstances shall the Copyright Holder or its Affiliates is not liable
 * to the User for any direct or indirect losses of the User, his expenses or actual
 * damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
 * or damage to data, property, etc.
 * ~~~~~~/licensing~~~~~~
 */
package ru.entaxy.esb.system.core.permission.jpa;

import org.hibernate.Session;
import ru.entaxy.esb.system.core.permission.jpa.entity.Permission;

import java.util.List;
import java.util.Optional;

public interface PermissionService {

    List<Permission> list();

    Permission get(long id);

    List<Permission> getAllById(long id, String type);

    List<Permission> getAllById(Session s, long id, String type);

    Optional<Permission> fetch(long id);

    List<Permission> get(long objectId, String objectType, String action);

    List<Permission> get(Session session, long objectId, String objectType, String action);

    Permission getByAllParameters(long objectId, String objectType, String subjectId, String subjectType, String action);

    Permission getByAllParameters(Session session, long objectId, String objectType, String subjectId, String subjectType, String action);

    Optional<Permission> fetchByAllParameters(long objectId, String objectType, String subjectId, String subjectType, String action);

    boolean existByAllParameters(long objectId, String objectType, String subjectId, String subjectType, String action);

    Permission add(Permission permission);

    Permission addIfNotExist(long objectId, String objectType, String subjectId, String subjectType, String action);

    Permission add(long objectId, String objectType, String subjectId, String subjectType, String action);

    /**
     * Bulk addition of permission
     *
     * @param objectId
     * @param objectType
     * @param subject    - list of list with parameters siquence 1. subjectId 2.subjectType 3.action
     * @return list of permission
     */
    List<Permission> addAll(long objectId, String objectType, List<List<String>> subjects);

    List<Permission> addAll(List<Permission> permissions);

    Permission update(Permission permission);

    Permission update(long permissionId, long objectId, String objectType, String subjectId, String subjectType, String action);

    void remove(long id);

    void remove(long objectId, String objectType, String subjectId, String subjectType, String action);

    void remove(long objectId, String objectType);

    void remove(long objectId, String objectType, String action);

    void remove(String subjectId, String subjectType);

    void remove(String subjectId, String subjectType, String action);

    void removeAll(long objectId, String objectType);

    void removeAll(Session s, long objectId, String objectType);
}
