blob: 7b2742f8350da8056affe03d5ba9b8e23896a9ff [file] [log] [blame]
/**
* Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany)
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation
*
*
* This copyright notice shows up in the generated Java code
*/
package org.eclipse.osbp.xtext.authorizationdsl.validation;
import com.google.inject.Inject;
import org.eclipse.osbp.ui.api.useraccess.IUserAccessService;
import org.eclipse.osbp.xtext.authorizationdsl.AuthorizationDSLPackage;
import org.eclipse.osbp.xtext.authorizationdsl.Role;
import org.eclipse.osbp.xtext.authorizationdsl.RoleBlipProcess;
import org.eclipse.osbp.xtext.authorizationdsl.validation.AbstractAuthorizationDSLValidator;
import org.eclipse.osbp.xtext.basic.validation.IBasicValidatorDelegate;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.validation.Check;
/**
* This class contains custom validation rules.
*
* See https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#validation
*/
@SuppressWarnings("all")
public class AuthorizationDSLValidator extends AbstractAuthorizationDSLValidator {
@Inject(optional = true)
private IBasicValidatorDelegate delegate;
@Check
public void checkSecurityLicensed(final Role role) {
boolean _equals = IUserAccessService.ADMINISTRATOR.equals(role.getName());
if (_equals) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("The role \'");
_builder.append(IUserAccessService.ADMINISTRATOR);
_builder.append("\' is the already existing default role and its explicit definition is not allowed!");
this.error(_builder.toString(), role, null);
} else {
if (((this.delegate != null) && (!this.delegate.validateCommercial("authorization", "net.osbee.organization.permissions")))) {
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("Authorization is needed and not yet licensed. License Authorization at www.osbee.net");
this.info(_builder_1.toString(), role, null);
}
}
}
@Check
public void checkBPMLicensed(final RoleBlipProcess process) {
if (((this.delegate != null) && (!this.delegate.validateCommercial("authorization", "net.osbee.bpm")))) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("BPM is needed and not yet licensed. License BPM at www.osbee.net");
this.info(_builder.toString(), process, AuthorizationDSLPackage.Literals.ROLE_BLIP_PROCESS__PROCESS);
}
}
}