Package org.ofbiz.service

Examples of org.ofbiz.service.GenericServiceException


            if (Debug.infoOn()) Debug.logInfo("in createBinaryFileMethod, rootDir:" + rootDir, module);
            try {
                file = DataResourceWorker.getContentFile(dataResourceTypeId, objectInfo, rootDir);
            } catch (FileNotFoundException e) {
                    Debug.logWarning(e, module);
                    throw new GenericServiceException(e.getMessage());
            } catch (GeneralException e2) {
                    Debug.logWarning(e2, module);
                    throw new GenericServiceException(e2.getMessage());
            }
        if (Debug.infoOn()) Debug.logInfo("in createBinaryFileMethod, file:" + file, module);
        if (Debug.infoOn()) Debug.logInfo("in createBinaryFileMethod, imageData:" + imageData.length, module);
            if (imageData != null && imageData.length > 0) {
                try {
                    FileOutputStream out = new FileOutputStream(file);
                    out.write(imageData);
                    if (Debug.infoOn()) Debug.logInfo("in createBinaryFileMethod, length:" + file.length(), module);
                    out.close();
                } catch (IOException e) {
                    Debug.logWarning(e, module);
                    throw new GenericServiceException(e.getMessage());
                }
            }

        return result;
    }
View Full Code Here


            if (Debug.infoOn()) Debug.logInfo("in updateBinaryFileMethod, rootDir:" + rootDir, module);
            try {
                file = DataResourceWorker.getContentFile(dataResourceTypeId, objectInfo, rootDir);
            } catch (FileNotFoundException e) {
                    Debug.logWarning(e, module);
                    throw new GenericServiceException(e.getMessage());
            } catch (GeneralException e2) {
                    Debug.logWarning(e2, module);
                    throw new GenericServiceException(e2.getMessage());
            }
        if (Debug.infoOn()) Debug.logInfo("in updateBinaryFileMethod, file:" + file, module);
        if (Debug.infoOn()) Debug.logInfo("in updateBinaryFileMethod, imageData:" + imageData, module);
            if (imageData != null && imageData.length > 0) {
                try {
                    FileOutputStream out = new FileOutputStream(file);
                    out.write(imageData);
                    if (Debug.infoOn()) Debug.logInfo("in updateBinaryFileMethod, length:" + file.length(), module);
                    out.close();
                } catch (IOException e) {
                    Debug.logWarning(e, module);
                    throw new GenericServiceException(e.getMessage());
                }
            }

        return result;
    }
View Full Code Here

            // associate the email with anonymous user TODO: do we need a custom contact mech purpose type, say MARKETING_EMAIL?
            input = UtilMisc.toMap("userLogin", userLogin, "emailAddress", email, "partyId", "_NA_", "fromDate", fromDate, "contactMechPurposeTypeId", "OTHER_EMAIL");
            Map<String, Object> serviceResults = dispatcher.runSync("createPartyEmailAddress", input);
            if (ServiceUtil.isError(serviceResults)) {
                throw new GenericServiceException(ServiceUtil.getErrorMessage(serviceResults));
            }
            String contactMechId = (String) serviceResults.get("contactMechId");

            // create a new association at this fromDate to the anonymous party with status accepted
            input = UtilMisc.toMap("userLogin", userLogin, "contactListId", contactList.get("contactListId"),
                    "partyId", "_NA_", "fromDate", fromDate, "statusId", "CLPT_ACCEPTED", "preferredContactMechId", contactMechId);
            serviceResults = dispatcher.runSync("createContactListParty", input);
            if (ServiceUtil.isError(serviceResults)) {
                throw new GenericServiceException(ServiceUtil.getErrorMessage(serviceResults));
            }
        } catch (GenericEntityException e) {
            String error = UtilProperties.getMessage(resourceOrder, "checkhelper.problems_reading_database", locale);
            Debug.log(e, error + e.getMessage(), module);
            return ServiceUtil.returnError(error);
View Full Code Here

                while (pi.hasNext()) {
                    GenericValue pay = (GenericValue) pi.next();
                    try {
                        Map cancelResults = dispatcher.runSync("setPaymentStatus", UtilMisc.toMap("userLogin", userLogin, "paymentId", pay.get("paymentId"), "statusId", "PMNT_CANCELLED"));
                        if (ServiceUtil.isError(cancelResults)) {
                            throw new GenericServiceException(ServiceUtil.getErrorMessage(cancelResults));
                        }
                    } catch (GenericServiceException e) {
                        Debug.logError(e, "Unable to cancel Payment : " + pay, module);
                    }
                }
View Full Code Here

        GenericValue userLogin = (GenericValue) context.get("userLogin");

        String paymentId = (String) context.get("paymentId");
        try {
            GenericValue payment = delegator.findByPrimaryKey("Payment", UtilMisc.toMap("paymentId", paymentId));
            if (payment == null) throw new GenericServiceException("Payment with ID [" + paymentId  + "] not found!");

            List paymentApplications = payment.getRelated("PaymentApplication");
            if (UtilValidate.isEmpty(paymentApplications)) return ServiceUtil.returnSuccess();

            // TODO: this is inefficient -- instead use HashSet to construct a distinct Set of invoiceIds, then iterate over it and call checkInvoicePaymentAppls
View Full Code Here

            List items = orh.getOrderItems();

            Map serviceParam = UtilMisc.toMap("orderId", orderId, "billItems", items, "userLogin", userLogin);
            Map serviceRes = dispatcher.runSync("createInvoiceForOrder", serviceParam);
            if (ServiceUtil.isError(serviceRes)) {
                throw new GenericServiceException(ServiceUtil.getErrorMessage(serviceRes));
            }
        }
    }
View Full Code Here

    public Map<String, Object> runSync(String localName, ModelService modelService, Map<String, Object> context) throws GenericServiceException {
        Object[] params = new Object[] { dispatcher.getLocalContext(localName), context };
        try {
            return (Map) WebslingerContainer.runEvent(modelService.engineName, modelService.location, paramNames, paramTypes, params);
        } catch (IOException e) {
            throw (GenericServiceException) new GenericServiceException(e.getMessage()).initCause(e);
        } catch (BSFException e) {
            throw (GenericServiceException) new GenericServiceException(e.getMessage()).initCause(e);
        }
    }
View Full Code Here

    public Map<String, Object> runSync(String localName, ModelService modelService, Map<String, Object> context) throws GenericServiceException {
        GenericDelegator delegator = dispatcher.getDelegator();
        try {
            GenericValue found = EntityUtil.getFirst(delegator.findByAndCache("WebslingerLayout", UtilMisc.toMap("webslingerServerId", modelService.location)));
            if (found == null) throw new GenericServiceException("Couldn't find server mapping for(" + modelService.location + ")");
            return (Map<String, Object>) WebslingerServletContext.invokeInVM(found.getString("hostName"), 8080, modelService.invoke, context);
        } catch (RuntimeException e) {
            throw e;
        } catch (GenericServiceException e) {
            throw e;
        } catch (Exception e) {
            throw (GenericServiceException) new GenericServiceException(e.getMessage()).initCause(e);
        }
    }
View Full Code Here

                    if (ServiceUtil.isError(thisResult) || ServiceUtil.isFailure(thisResult) || UtilValidate.isNotEmpty(errMsg)) {
                        return ServiceUtil.returnError(errMsg);
                    }
                }
            } catch (GenericEntityException e) {
                throw new GenericServiceException(e.toString());
            } catch (Exception e2) {
                throw new GenericServiceException(e2.toString());
            }
            String errMsg = ServiceUtil.getErrorMessage(thisResult);
            if (UtilValidate.isNotEmpty(errMsg)) {
                return ServiceUtil.returnError(errMsg);
            }
View Full Code Here

            dataId = delegator.getNextSeqId("RuntimeData");
            GenericValue runtimeData = delegator.makeValue("RuntimeData", UtilMisc.toMap("runtimeDataId", dataId));
            runtimeData.set("runtimeInfo", XmlSerializer.serialize(context));
            delegator.create(runtimeData);
        } catch (GenericEntityException ee) {
            throw new GenericServiceException(ee.getMessage(), ee);
        } catch (SerializeException se) {
            throw new GenericServiceException(se.getMessage(), se);
        } catch (IOException ioe) {
            throw new GenericServiceException(ioe.getMessage(), ioe);
        }
        Map aFields = UtilMisc.toMap("applicationId", applicationId, "workEffortId", workEffortId,
                "partyId", partyId, "roleTypeId", roleTypeId, "fromDate", fromDate, "runtimeDataId", dataId);

        GenericValue appV = null;
        try {
            appV = delegator.makeValue("ApplicationSandbox", aFields);
            delegator.create(appV);
        } catch (GenericEntityException e) {
            throw new GenericServiceException(e.getMessage(), e);
        }
        return applicationId;
    }
View Full Code Here

TOP

Related Classes of org.ofbiz.service.GenericServiceException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.