本文整理汇总了Java中org.ofbiz.minilang.MiniLangException类的典型用法代码示例。如果您正苦于以下问题:Java MiniLangException类的具体用法?Java MiniLangException怎么用?Java MiniLangException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MiniLangException类属于org.ofbiz.minilang包,在下文中一共展示了MiniLangException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: CheckPermission
import org.ofbiz.minilang.MiniLangException; //导入依赖的package包/类
public CheckPermission(Element element, SimpleMethod simpleMethod) throws MiniLangException {
super(element, simpleMethod);
if (MiniLangValidate.validationOn()) {
MiniLangValidate.attributeNames(simpleMethod, element, "permission", "action", "error-list-name");
MiniLangValidate.constantAttributes(simpleMethod, element, "error-list-name");
MiniLangValidate.childElements(simpleMethod, element, "alt-permission", "fail-message", "fail-property");
MiniLangValidate.requireAnyChildElement(simpleMethod, element, "fail-message", "fail-property");
}
errorListFma = FlexibleMapAccessor.getInstance(MiniLangValidate.checkAttribute(element.getAttribute("error-list-name"), "error_list"));
primaryPermissionInfo = new PermissionInfo(element);
List<? extends Element> altPermElements = UtilXml.childElementList(element, "alt-permission");
if (!altPermElements.isEmpty()) {
List<PermissionInfo> permissionInfoList = new ArrayList<PermissionInfo>(altPermElements.size());
for (Element altPermElement : altPermElements) {
permissionInfoList.add(new PermissionInfo(altPermElement));
}
altPermissionInfoList = Collections.unmodifiableList(permissionInfoList);
} else {
altPermissionInfoList = null;
}
messageElement = MessageElement.fromParentElement(element, simpleMethod);
}
示例2: EmptyCondition
import org.ofbiz.minilang.MiniLangException; //导入依赖的package包/类
public EmptyCondition(Element element, SimpleMethod simpleMethod) throws MiniLangException {
super(element, simpleMethod);
if (MiniLangValidate.validationOn()) {
MiniLangValidate.attributeNames(simpleMethod, element, "field");
MiniLangValidate.requiredAttributes(simpleMethod, element, "field");
MiniLangValidate.expressionAttributes(simpleMethod, element, "field");
}
this.fieldFma = FlexibleMapAccessor.getInstance(element.getAttribute("field"));
Element childElement = UtilXml.firstChildElement(element);
if (childElement != null && !"else".equals(childElement.getTagName())) {
this.subOps = Collections.unmodifiableList(SimpleMethod.readOperations(element, simpleMethod));
} else {
this.subOps = null;
}
Element elseElement = UtilXml.firstChildElement(element, "else");
if (elseElement != null) {
this.elseSubOps = Collections.unmodifiableList(SimpleMethod.readOperations(elseElement, simpleMethod));
} else {
this.elseSubOps = null;
}
}
示例3: ToString
import org.ofbiz.minilang.MiniLangException; //导入依赖的package包/类
public ToString(Element element, SimpleMethod simpleMethod) throws MiniLangException {
super(element, simpleMethod);
if (MiniLangValidate.validationOn()) {
MiniLangValidate.handleError("<to-string> element is deprecated (use <set>)", simpleMethod, element);
MiniLangValidate.attributeNames(simpleMethod, element, "field", "format", "numeric-padding");
MiniLangValidate.requiredAttributes(simpleMethod, element, "field");
MiniLangValidate.constantAttributes(simpleMethod, element, "format", "numeric-padding");
MiniLangValidate.expressionAttributes(simpleMethod, element, "field");
MiniLangValidate.noChildElements(simpleMethod, element);
}
fieldFma = FlexibleMapAccessor.getInstance(element.getAttribute("field"));
format = element.getAttribute("format");
Integer numericPadding = null;
String npAttribute = element.getAttribute("numeric-padding");
if (!npAttribute.isEmpty()) {
try {
numericPadding = Integer.valueOf(npAttribute);
} catch (Exception e) {
MiniLangValidate.handleError("Exception thrown while parsing numeric-padding attribute: " + e.getMessage(), simpleMethod, element);
}
}
this.numericPadding = numericPadding;
}
示例4: exec
import org.ofbiz.minilang.MiniLangException; //导入依赖的package包/类
@Override
public boolean exec(MethodContext methodContext) throws MiniLangException {
if (this.compareClass == null) {
throw new MiniLangRuntimeException("Invalid class name " + className, this);
}
boolean runSubOps = false;
Object fieldVal = fieldFma.get(methodContext.getEnvMap());
if (fieldVal != null) {
runSubOps = ObjectType.instanceOf(fieldVal.getClass(), compareClass);
}
if (runSubOps) {
return SimpleMethod.runSubOps(subOps, methodContext);
} else {
if (elseSubOps != null) {
return SimpleMethod.runSubOps(elseSubOps, methodContext);
} else {
return true;
}
}
}
示例5: exec
import org.ofbiz.minilang.MiniLangException; //导入依赖的package包/类
@Override
public boolean exec(MethodContext methodContext) throws MiniLangException {
boolean beganTransaction = false;
Boolean beganTransactionBoolean = beganTransactionFma.get(methodContext.getEnvMap());
if (beganTransactionBoolean != null) {
beganTransaction = beganTransactionBoolean.booleanValue();
}
try {
TransactionUtil.rollback(beganTransaction, "Explicit rollback in simple-method [" + this.simpleMethod.getShortDescription() + "]", null);
} catch (GenericTransactionException e) {
String errMsg = "Exception thrown while rolling back transaction: " + e.getMessage();
Debug.logWarning(e, errMsg, module);
simpleMethod.addErrorMessage(methodContext, errMsg);
return false;
}
beganTransactionFma.remove(methodContext.getEnvMap());
return true;
}
示例6: Assert
import org.ofbiz.minilang.MiniLangException; //导入依赖的package包/类
public Assert(Element element, SimpleMethod simpleMethod) throws MiniLangException {
super(element, simpleMethod);
if (MiniLangValidate.validationOn()) {
MiniLangValidate.attributeNames(simpleMethod, element, "title", "error-list-name");
MiniLangValidate.constantAttributes(simpleMethod, element, "title", "error-list-name");
}
errorListFma = FlexibleMapAccessor.getInstance(MiniLangValidate.checkAttribute(element.getAttribute("error-list-name"), "error_list"));
titleExdr = FlexibleStringExpander.getInstance(element.getAttribute("title"));
List<? extends Element> childElements = UtilXml.childElementList(element);
if (MiniLangValidate.validationOn() && childElements.isEmpty()) {
MiniLangValidate.handleError("No conditional elements.", simpleMethod, element);
}
List<Conditional> conditionalList = new ArrayList<Conditional>(childElements.size());
for (Element conditionalElement : UtilXml.childElementList(element)) {
conditionalList.add(ConditionalFactory.makeConditional(conditionalElement, simpleMethod));
}
this.conditionalList = Collections.unmodifiableList(conditionalList);
}
示例7: Trace
import org.ofbiz.minilang.MiniLangException; //导入依赖的package包/类
public Trace(Element element, SimpleMethod simpleMethod) throws MiniLangException {
super(element, simpleMethod);
if (MiniLangValidate.validationOn()) {
MiniLangValidate.attributeNames(simpleMethod, element, "level");
MiniLangValidate.constantAttributes(simpleMethod, element, "level");
}
String levelAttribute = MiniLangValidate.checkAttribute(element.getAttribute("level"), "info");
Integer levelInt = Debug.getLevelFromString(levelAttribute);
if (levelInt == null) {
MiniLangValidate.handleError("Invalid level attribute", simpleMethod, element);
this.level = Debug.INFO;
} else {
this.level = levelInt.intValue();
}
methodOperations = Collections.unmodifiableList(SimpleMethod.readOperations(element, simpleMethod));
}
示例8: SessionToField
import org.ofbiz.minilang.MiniLangException; //导入依赖的package包/类
public SessionToField(Element element, SimpleMethod simpleMethod) throws MiniLangException {
super(element, simpleMethod);
if (MiniLangValidate.validationOn()) {
MiniLangValidate.attributeNames(simpleMethod, element, "field", "session-name", "default");
MiniLangValidate.requiredAttributes(simpleMethod, element, "field");
MiniLangValidate.expressionAttributes(simpleMethod, element, "field");
MiniLangValidate.noChildElements(simpleMethod, element);
}
this.fieldFma = FlexibleMapAccessor.getInstance(element.getAttribute("field"));
String attributeName = element.getAttribute("session-name");
if (!attributeName.isEmpty()) {
this.attributeNameFse = FlexibleStringExpander.getInstance(attributeName);
} else {
this.attributeNameFse = FlexibleStringExpander.getInstance(this.fieldFma.toString());
}
this.defaultFse = FlexibleStringExpander.getInstance(element.getAttribute("default"));
}
示例9: exec
import org.ofbiz.minilang.MiniLangException; //导入依赖的package包/类
@Override
public boolean exec(MethodContext methodContext) throws MiniLangException {
while (condition.checkCondition(methodContext)) {
try {
for (MethodOperation methodOperation : thenSubOps) {
if (!methodOperation.exec(methodContext)) {
return false;
}
}
} catch (MiniLangException e) {
if (e instanceof BreakElementException) {
break;
}
if (e instanceof ContinueElementException) {
continue;
}
throw e;
}
}
return true;
}
示例10: exec
import org.ofbiz.minilang.MiniLangException; //导入依赖的package包/类
@Override
public boolean exec(MethodContext methodContext) throws MiniLangException {
if (methodContext.getMethodType() == MethodContext.EVENT) {
String resource = resourceFse.expandString(methodContext.getEnvMap());
ServletContext servletContext = (ServletContext) methodContext.getRequest().getAttribute("servletContext");
URL propsUrl = null;
try {
propsUrl = servletContext.getResource(resource);
} catch (java.net.MalformedURLException e) {
throw new MiniLangRuntimeException("Exception thrown while finding properties file " + resource + ": " + e.getMessage(), this);
}
if (propsUrl == null) {
throw new MiniLangRuntimeException("Properties file " + resource + " not found.", this);
}
String property = propertyFse.expandString(methodContext.getEnvMap());
String fieldVal = UtilProperties.getPropertyValue(propsUrl, property);
if (fieldVal == null) {
fieldVal = defaultFse.expandString(methodContext.getEnvMap());
}
fieldFma.put(methodContext.getEnvMap(), fieldVal);
}
return true;
}
示例11: CombinedCondition
import org.ofbiz.minilang.MiniLangException; //导入依赖的package包/类
public CombinedCondition(Element element, SimpleMethod simpleMethod) throws MiniLangException {
super(element, simpleMethod);
List<? extends Element> childElements = UtilXml.childElementList(element);
if (MiniLangValidate.validationOn() && childElements.isEmpty()) {
MiniLangValidate.handleError("No conditional elements.", simpleMethod, element);
}
List<Conditional> conditionalList = new ArrayList<Conditional>(childElements.size());
for (Element conditionalElement : UtilXml.childElementList(element)) {
conditionalList.add(ConditionalFactory.makeConditional(conditionalElement, simpleMethod));
}
this.subConditions = Collections.unmodifiableList(conditionalList);
}
示例12: runAction
import org.ofbiz.minilang.MiniLangException; //导入依赖的package包/类
@Override
public void runAction(Map<String, Object> context) {
context.put("_LIST_ITERATOR_", null);
if (location.endsWith(".xml")) {
Map<String, Object> localContext = new HashMap<String, Object>();
localContext.putAll(context);
DispatchContext ctx = WidgetWorker.getDispatcher(context).getDispatchContext();
MethodContext methodContext = new MethodContext(ctx, localContext, null);
try {
SimpleMethod.runSimpleMethod(location, method, methodContext);
context.putAll(methodContext.getResults());
} catch (MiniLangException e) {
throw new RuntimeException("Error running simple method at location [" + location + "]", e);
}
} else {
ScriptUtil.executeScript(this.location, this.method, context);
}
Object obj = context.get("_LIST_ITERATOR_");
if (this.getModelSubNode() != null) {
if (obj != null && (obj instanceof EntityListIterator || obj instanceof ListIterator<?>)) {
ListIterator<? extends Map<String, ? extends Object>> listIt = UtilGenerics.cast(obj);
this.getModelSubNode().setListIterator(listIt, context);
} else {
if (obj instanceof List<?>) {
List<? extends Map<String, ? extends Object>> list = UtilGenerics.checkList(obj);
this.getModelSubNode().setListIterator(list.listIterator(), context);
}
}
}
}
示例13: PermissionInfo
import org.ofbiz.minilang.MiniLangException; //导入依赖的package包/类
private PermissionInfo(Element element) throws MiniLangException {
if (MiniLangValidate.validationOn()) {
MiniLangValidate.attributeNames(simpleMethod, element, "permission", "action");
MiniLangValidate.requiredAttributes(simpleMethod, element, "permission");
}
this.permissionFse = FlexibleStringExpander.getInstance(element.getAttribute("permission"));
this.actionFse = FlexibleStringExpander.getInstance(element.getAttribute("action"));
}
示例14: IfNotEmpty
import org.ofbiz.minilang.MiniLangException; //导入依赖的package包/类
public IfNotEmpty(Element element, SimpleMethod simpleMethod) throws MiniLangException {
super(element, simpleMethod);
this.fieldFma = FlexibleMapAccessor.getInstance(element.getAttribute("field"));
this.subOps = Collections.unmodifiableList(SimpleMethod.readOperations(element, simpleMethod));
Element elseElement = UtilXml.firstChildElement(element, "else");
if (elseElement != null) {
this.elseSubOps = Collections.unmodifiableList(SimpleMethod.readOperations(elseElement, simpleMethod));
} else {
this.elseSubOps = null;
}
}
示例15: exec
import org.ofbiz.minilang.MiniLangException; //导入依赖的package包/类
@Override
public boolean exec(MethodContext methodContext) throws MiniLangException {
Object fieldVal = fieldFma.get(methodContext.getEnvMap());
if (!ObjectType.isEmpty(fieldVal)) {
return SimpleMethod.runSubOps(subOps, methodContext);
} else {
if (elseSubOps != null) {
return SimpleMethod.runSubOps(elseSubOps, methodContext);
} else {
return true;
}
}
}