Search in sources :

Example 91 with MangoPermission

use of com.infiniteautomation.mango.permission.MangoPermission in project ma-core-public by infiniteautomation.

the class EventDao method savePreRelationalData.

public void savePreRelationalData(EventInstance vo) {
    MangoPermission readPermission = permissionService.findOrCreate(vo.getReadPermission());
    vo.setReadPermission(readPermission);
}
Also used : MangoPermission(com.infiniteautomation.mango.permission.MangoPermission)

Example 92 with MangoPermission

use of com.infiniteautomation.mango.permission.MangoPermission in project ma-core-public by infiniteautomation.

the class EventHandlerDao method mapRecord.

@Override
@NonNull
public AbstractEventHandlerVO mapRecord(@NonNull Record record) {
    AbstractEventHandlerVO h = (AbstractEventHandlerVO) SerializationHelper.readObjectInContextFromArray(record.get(table.data));
    h.setId(record.get(table.id));
    h.setXid(record.get(table.xid));
    h.setAlias(record.get(table.alias));
    h.setDefinition(ModuleRegistry.getEventHandlerDefinition(record.get(table.eventHandlerType)));
    MangoPermission read = new MangoPermission(record.get(table.readPermissionId));
    h.supplyReadPermission(() -> read);
    MangoPermission edit = new MangoPermission(record.get(table.editPermissionId));
    h.supplyEditPermission(() -> edit);
    // Ensure the recipient list is clean
    switch(h.getHandlerType()) {
        case EmailEventHandlerDefinition.TYPE_NAME:
            EmailEventHandlerVO ehVo = (EmailEventHandlerVO) h;
            mailingListDao.cleanRecipientList(ehVo.getActiveRecipients());
            mailingListDao.cleanRecipientList(ehVo.getEscalationRecipients());
            mailingListDao.cleanRecipientList(ehVo.getInactiveRecipients());
            break;
    }
    return h;
}
Also used : EmailEventHandlerVO(com.serotonin.m2m2.vo.event.EmailEventHandlerVO) AbstractEventHandlerVO(com.serotonin.m2m2.vo.event.AbstractEventHandlerVO) MangoPermission(com.infiniteautomation.mango.permission.MangoPermission) NonNull(org.checkerframework.checker.nullness.qual.NonNull)

Example 93 with MangoPermission

use of com.infiniteautomation.mango.permission.MangoPermission in project ma-core-public by infiniteautomation.

the class JsonDataDao method savePreRelationalData.

@Override
public void savePreRelationalData(JsonDataVO existing, JsonDataVO vo) {
    MangoPermission readPermission = permissionService.findOrCreate(vo.getReadPermission());
    vo.setReadPermission(readPermission);
    MangoPermission editPermission = permissionService.findOrCreate(vo.getEditPermission());
    vo.setEditPermission(editPermission);
}
Also used : MangoPermission(com.infiniteautomation.mango.permission.MangoPermission)

Aggregations

MangoPermission (com.infiniteautomation.mango.permission.MangoPermission)93 Role (com.serotonin.m2m2.vo.role.Role)22 HashSet (java.util.HashSet)21 Set (java.util.Set)18 HashMap (java.util.HashMap)13 NotFoundException (com.infiniteautomation.mango.util.exception.NotFoundException)12 PermissionDefinition (com.serotonin.m2m2.module.PermissionDefinition)11 JsonException (com.serotonin.json.JsonException)10 ValidationException (com.infiniteautomation.mango.util.exception.ValidationException)9 TranslatableJsonException (com.serotonin.m2m2.i18n.TranslatableJsonException)8 JsonValue (com.serotonin.json.type.JsonValue)7 ArrayList (java.util.ArrayList)7 JsonArray (com.serotonin.json.type.JsonArray)6 JsonObject (com.serotonin.json.type.JsonObject)6 User (com.serotonin.m2m2.vo.User)6 OutputStream (java.io.OutputStream)5 Test (org.junit.Test)5 TranslatableMessage (com.serotonin.m2m2.i18n.TranslatableMessage)4 IOException (java.io.IOException)4 ResultSet (java.sql.ResultSet)4