当前位置: 首页>>代码示例>>Java>>正文


Java GeneralRuntimeException类代码示例

本文整理汇总了Java中org.ofbiz.base.util.GeneralRuntimeException的典型用法代码示例。如果您正苦于以下问题:Java GeneralRuntimeException类的具体用法?Java GeneralRuntimeException怎么用?Java GeneralRuntimeException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


GeneralRuntimeException类属于org.ofbiz.base.util包,在下文中一共展示了GeneralRuntimeException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getEntityFieldValue

import org.ofbiz.base.util.GeneralRuntimeException; //导入依赖的package包/类
/**
 * SCIPIO: Gets the entity field value corresponding to the given prodCategoryContentTypeId.
 * DO NOT USE FROM TEMPLATES - NOT CACHED - intended for code that must replicate ProductContentWrapper behavior.
 * DEV NOTE: LOGIC DUPLICATED FROM getProductContentAsText ABOVE - PLEASE KEEP IN SYNC.
 * Added 2017-09-05.
 */
public static String getEntityFieldValue(GenericValue productCategory, String prodCatContentTypeId, Delegator delegator, LocalDispatcher dispatcher, boolean cache) throws GeneralException, IOException {
    if (delegator == null) {
        delegator = productCategory.getDelegator();
    }

    if (delegator == null) {
        throw new GeneralRuntimeException("Unable to find a delegator to use!");
    }
    
    String candidateFieldName = ModelUtil.dbNameToVarName(prodCatContentTypeId);
    ModelEntity categoryModel = delegator.getModelEntity("ProductCategory");
    if (categoryModel.isField(candidateFieldName)) {
        String candidateValue = productCategory.getString(candidateFieldName);
        if (UtilValidate.isNotEmpty(candidateValue)) {
            return candidateValue;
        }
    }
    return null;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:26,代码来源:CategoryContentWrapper.java

示例2: hasPrevious

import org.ofbiz.base.util.GeneralRuntimeException; //导入依赖的package包/类
/** PLEASE NOTE: Because of the nature of the JDBC ResultSet interface this method can be very inefficient; it is much better to just use previous() until it returns null */
public boolean hasPrevious() {
    try {
        if (resultSet.isFirst() || resultSet.isBeforeFirst()) {
            return false;
        } else {
            // do a quick game to see if the resultSet is empty:
            // if we are not in the last or afterLast positions and we haven't made any values yet, the result set is empty so return false
            if (!haveMadeValue && !resultSet.isAfterLast() && !resultSet.isLast()) {
                return false;
            } else {
                return true;
            }
        }
    } catch (SQLException e) {
        if (!closed) {
            try {
                this.close();
            } catch (GenericEntityException e1) {
                Debug.logError(e1, "Error auto-closing EntityListIterator on error, so info below for more info on original error; close error: " + e1.toString(), module);
            }
            Debug.logWarning("Warning: auto-closed EntityListIterator because of exception: " + e.toString(), module);
        }
        throw new GeneralRuntimeException("Error while checking to see if this is the first result", e);
    }
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:27,代码来源:EntityListIterator.java

示例3: nextIndex

import org.ofbiz.base.util.GeneralRuntimeException; //导入依赖的package包/类
/** Returns the index of the next result, but does not guarantee that there will be a next result */
public int nextIndex() {
    try {
        return currentIndex() + 1;
    } catch (GenericEntityException e) {
        if (!closed) {
            try {
                this.close();
            } catch (GenericEntityException e1) {
                Debug.logError(e1, "Error auto-closing EntityListIterator on error, so info below for more info on original error; close error: " + e1.toString(), module);
            }
            Debug.logWarning("Warning: auto-closed EntityListIterator because of exception: " + e.toString(), module);
        }
        throw new GeneralRuntimeException(e.getNonNestedMessage(), e.getNested());
    }
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:17,代码来源:EntityListIterator.java

示例4: previousIndex

import org.ofbiz.base.util.GeneralRuntimeException; //导入依赖的package包/类
/** Returns the index of the previous result, but does not guarantee that there will be a previous result */
public int previousIndex() {
    try {
        return currentIndex() - 1;
    } catch (GenericEntityException e) {
        if (!closed) {
            try {
                this.close();
            } catch (GenericEntityException e1) {
                Debug.logError(e1, "Error auto-closing EntityListIterator on error, so info below for more info on original error; close error: " + e1.toString(), module);
            }
            Debug.logWarning("Warning: auto-closed EntityListIterator because of exception: " + e.toString(), module);
        }
        throw new GeneralRuntimeException("Error getting the current index", e);
    }
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:17,代码来源:EntityListIterator.java

示例5: digestHash64

import org.ofbiz.base.util.GeneralRuntimeException; //导入依赖的package包/类
public static String digestHash64(String hashType, byte[] bytes) {
    if (hashType == null) {
        hashType = "SHA";
    }
    try {
        MessageDigest messagedigest = MessageDigest.getInstance(hashType);
        messagedigest.update(bytes);
        byte[] digestBytes = messagedigest.digest();

        StringBuilder sb = new StringBuilder();
        sb.append("{").append(hashType).append("}");
        sb.append(Base64.encodeBase64URLSafeString(digestBytes).replace('+', '.'));
        return sb.toString();
    } catch (NoSuchAlgorithmException e) {
        throw new GeneralRuntimeException("Error while computing hash of type " + hashType, e);
    }
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:18,代码来源:HashCrypt.java

示例6: ViewFactory

import org.ofbiz.base.util.GeneralRuntimeException; //导入依赖的package包/类
public ViewFactory(ServletContext context, URL controllerConfigURL) {
    // load all the view handlers
    try {
        Set<Map.Entry<String,String>> handlerEntries = ConfigXMLReader.getControllerConfig(controllerConfigURL).getViewHandlerMap().entrySet();
        if (handlerEntries != null) {
            for (Map.Entry<String,String> handlerEntry: handlerEntries) {
                ViewHandler handler = (ViewHandler) ObjectType.getInstance(handlerEntry.getValue());
                handler.setName(handlerEntry.getKey());
                handler.init(context);
                this.handlers.put(handlerEntry.getKey(), handler);
            }
        }
        // load the "default" type
        if (!this.handlers.containsKey("default")) {
            ViewHandler defaultHandler = (ViewHandler) ObjectType.getInstance("org.ofbiz.webapp.view.JspViewHandler");
            defaultHandler.init(context);
            this. handlers.put("default", defaultHandler);
        }
    } catch (Exception e) {
        Debug.logError(e, module);
        throw new GeneralRuntimeException(e);
    }
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:24,代码来源:ViewFactory.java

示例7: EventFactory

import org.ofbiz.base.util.GeneralRuntimeException; //导入依赖的package包/类
public EventFactory(ServletContext context, URL controllerConfigURL) {
    // load all the event handlers
    try {
        Set<Map.Entry<String,String>> handlerEntries = ConfigXMLReader.getControllerConfig(controllerConfigURL).getEventHandlerMap().entrySet();
        if (handlerEntries != null) {
            for (Map.Entry<String,String> handlerEntry: handlerEntries) {
                EventHandler handler = (EventHandler) ObjectType.getInstance(handlerEntry.getValue());
                handler.init(context);
                this.handlers.put(handlerEntry.getKey(), handler);
            }
        }
    } catch (Exception e) {
        Debug.logError(e, module);
        throw new GeneralRuntimeException(e);
    }
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:17,代码来源:EventFactory.java

示例8: getEntityFieldValue

import org.ofbiz.base.util.GeneralRuntimeException; //导入依赖的package包/类
/**
 * SCIPIO: Gets the entity field value corresponding to the given productContentTypeId.
 * DO NOT USE FROM TEMPLATES - NOT CACHED - intended for code that must replicate ProductContentWrapper behavior.
 * DEV NOTE: LOGIC DUPLICATED FROM getProductContentAsText ABOVE - PLEASE KEEP IN SYNC.
 * Added 2017-09-05.
 */
public static String getEntityFieldValue(GenericValue product, String productContentTypeId, Delegator delegator, LocalDispatcher dispatcher, boolean cache) throws GeneralException, IOException {
    String productId = product.getString("productId");

    if (delegator == null) {
        delegator = product.getDelegator();
    }

    if (delegator == null) {
        throw new GeneralRuntimeException("Unable to find a delegator to use!");
    }

    String candidateFieldName = ModelUtil.dbNameToVarName(productContentTypeId);
    ModelEntity productModel = delegator.getModelEntity("Product");
    
    if (productModel.isField(candidateFieldName)) {
            String candidateValue = product.getString(candidateFieldName);
            if (UtilValidate.isNotEmpty(candidateValue)) {
                return candidateValue;
            } else if ("Y".equals(product.getString("isVariant"))) {
                // look up the virtual product
                GenericValue parent = ProductWorker.getParentProduct(productId, delegator, cache);
                if (parent != null) {
                    candidateValue = parent.getString(candidateFieldName);
                    if (UtilValidate.isNotEmpty(candidateValue)) {
                        return candidateValue;
                    }
                }
            }
    }
    return null;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:38,代码来源:ProductContentWrapper.java

示例9: hasNext

import org.ofbiz.base.util.GeneralRuntimeException; //导入依赖的package包/类
/**
 * PLEASE NOTE: Because of the nature of the JDBC ResultSet interface this method can be very inefficient; it is much better to just use next() until it returns null
 * For example, you could use the following to iterate through the results in an EntityListIterator:
 *
 *      GenericValue nextValue = null;
 *      while ((nextValue = (GenericValue) this.next()) != null) { ... }
 *
 */
public boolean hasNext() {
    if (!haveShowHasNextWarning) {
        // DEJ20050207 To further discourage use of this, and to find existing use, always log a big warning showing where it is used:
        Exception whereAreWe = new Exception();
        Debug.logWarning(whereAreWe, "For performance reasons do not use the EntityListIterator.hasNext() method, just call next() until it returns null; see JavaDoc comments in the EntityListIterator class for details and an example", module);

        haveShowHasNextWarning = true;
    }

    try {
        if (resultSet.isLast() || resultSet.isAfterLast()) {
            return false;
        } else {
            // do a quick game to see if the resultSet is empty:
            // if we are not in the first or beforeFirst positions and we haven't made any values yet, the result set is empty so return false
            if (!haveMadeValue && !resultSet.isBeforeFirst() && !resultSet.isFirst()) {
                return false;
            } else {
                return true;
            }
        }
    } catch (SQLException e) {
        if (!closed) {
            try {
                this.close();
            } catch (GenericEntityException e1) {
                Debug.logError(e1, "Error auto-closing EntityListIterator on error, so info below for more info on original error; close error: " + e1.toString(), module);
            }
            Debug.logWarning("Warning: auto-closed EntityListIterator because of exception: " + e.toString(), module);
        }
        throw new GeneralRuntimeException("Error while checking to see if this is the last result", e);
    }
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:42,代码来源:EntityListIterator.java

示例10: getPartialList

import org.ofbiz.base.util.GeneralRuntimeException; //导入依赖的package包/类
/** Gets a partial list of results starting at start and containing at most number elements.
 * Start is a one based value, ie 1 is the first element.
 */
public List<GenericValue> getPartialList(int start, int number) throws GenericEntityException {
    try {
        if (number == 0) return new LinkedList<GenericValue>();
        List<GenericValue> list = new LinkedList<GenericValue>();

        // just in case the caller missed the 1 based thingy
        if (start == 0) start = 1;

        // if can't reposition to desired index, throw exception
        if (!this.absolute(start - 1)) {
            // maybe better to just return an empty list here...
            return list;
            //throw new GenericEntityException("Could not move to the start position of " + start + ", there are probably not that many results for this find.");
        }

        GenericValue nextValue = null;

        //number > 0 comparison goes first to avoid the unwanted call to next
        while (number > 0 && (nextValue = this.next()) != null) {
            list.add(nextValue);
            number--;
        }
        return list;
    } catch (GeneralRuntimeException e) {
        if (!closed) {
            this.close();
            Debug.logWarning("Warning: auto-closed EntityListIterator because of exception: " + e.toString(), module);
        }
        throw new GenericEntityException(e.getNonNestedMessage(), e.getNested());
    }
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:35,代码来源:EntityListIterator.java

示例11: getMessageDigest

import org.ofbiz.base.util.GeneralRuntimeException; //导入依赖的package包/类
public static MessageDigest getMessageDigest(String type) {
    try {
        return MessageDigest.getInstance(type);
    } catch (NoSuchAlgorithmException e) {
        throw new GeneralRuntimeException("Could not load digestor(" + type + ")", e);
    }
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:8,代码来源:HashCrypt.java

示例12: getCryptedBytes

import org.ofbiz.base.util.GeneralRuntimeException; //导入依赖的package包/类
private static String getCryptedBytes(String hashType, String salt, byte[] bytes) {
    try {
        MessageDigest messagedigest = MessageDigest.getInstance(hashType);
        messagedigest.update(salt.getBytes(UTF8));
        messagedigest.update(bytes);
        return Base64.encodeBase64URLSafeString(messagedigest.digest()).replace('+', '.');
    } catch (NoSuchAlgorithmException e) {
        throw new GeneralRuntimeException("Error while comparing password", e);
    }
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:11,代码来源:HashCrypt.java

示例13: digestHash

import org.ofbiz.base.util.GeneralRuntimeException; //导入依赖的package包/类
public static String digestHash(String hashType, String code, String str) {
    if (str == null) return null;
    byte[] codeBytes;
    try {
        if (code == null) codeBytes = str.getBytes();
        else codeBytes = str.getBytes(code);
    } catch (UnsupportedEncodingException e) {
        throw new GeneralRuntimeException("Error while computing hash of type " + hashType, e);
    }
    return digestHash(hashType, codeBytes);
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:12,代码来源:HashCrypt.java

示例14: testFromHexString

import org.ofbiz.base.util.GeneralRuntimeException; //导入依赖的package包/类
public void testFromHexString() {
    assertEquals("16 bytes", new byte[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, StringUtil.fromHexString("000102030405060708090a0b0c0d0e0f"));
    GeneralRuntimeException caught = null;
    try {
        StringUtil.fromHexString("0-");
    } catch (GeneralRuntimeException e) {
        caught = e;
    } finally {
        assertNotNull("bad-char", caught);
    }
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:12,代码来源:StringUtilTests.java

示例15: getMessage

import org.ofbiz.base.util.GeneralRuntimeException; //导入依赖的package包/类
public synchronized MimeMessage getMessage() {
    if (message == null) {
        // deserialize the message
        if (serializedBytes != null) {
            ByteArrayInputStream bais = new ByteArrayInputStream(serializedBytes);
            try {
                message = new MimeMessage(this.getSession(), bais);
            } catch (MessagingException e) {
                Debug.logError(e, module);
                throw new GeneralRuntimeException(e.getMessage(), e);
            }
        }
    }
    return message;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:16,代码来源:MimeMessageWrapper.java


注:本文中的org.ofbiz.base.util.GeneralRuntimeException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。