package com.aip.gateway.api.aip.manager;

import com.aip.gateway.api.aip.AuthDelegateImpl;
import com.microsoft.informationprotection.Identity;
import com.microsoft.informationprotection.MipContext;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@Data
abstract class AbstractManager {

    protected int lastErrNo;
    protected String lastErrMsg;

    protected void setError(int errNo, String errMsg1, String errMsg2) {
        lastErrNo = errNo;
        if (errMsg2 == null || errMsg2.isEmpty()) {
            lastErrMsg = errMsg1;
        }
        else {
            lastErrMsg = errMsg1 + "\r\n" + errMsg2;
        }
        log.error("AbstractManager::setError ==> {}, {}", errNo, lastErrMsg);
    }

    abstract public boolean createProfile(MipContext mipContext);
    abstract public boolean createEngine(Identity identity, AuthDelegateImpl authDelegate);
    abstract public void dispose();

}
