Example usage for java.lang Throwable Throwable

List of usage examples for java.lang Throwable Throwable

Introduction

In this page you can find the example usage for java.lang Throwable Throwable.

Prototype

public Throwable(Throwable cause) 

Source Link

Document

Constructs a new throwable with the specified cause and a detail message of (cause==null ?

Usage

From source file:de.unikiel.inf.comsys.neo4j.inference.SPARQLInferenceTest.java

@Test
public void additional() throws QueryEvaluationException, TupleQueryResultHandlerException, IOException,
        QueryResultParseException, QueryResultHandlerException {
    QueryResult q = this.runQuery();
    Multiset<BindingSet> additional = q.getActual();
    additional.removeAll(q.getExpected());
    for (BindingSet b : additional) {
        collector.addError(new Throwable(b + " shouldn't be in result set"));
    }//  ww w. ja  v a 2 s. c  o  m
}

From source file:org.apache.ode.bpel.rtrep.v1.ASSIGN.java

/**
  * Get the r-value. There are several possibilities:
  * <ul>//from   w w  w .ja v  a 2s  .co m
  * <li>a message is selected - an element representing the whole message is
  * returned.</li>
  * <li>a (element) message part is selected - the element is returned.
  * </li>
  * <li>a (typed) message part is select - a wrapper element is returned.
  * </li>
  * <li>an attribute is selected - an attribute node is returned. </li>
  * <li>a text node/string expression is selected - a text node is returned.
  * </li>
  * </ul>
  *
  * @param from
  *
  * @return Either {@link Element}, {@link org.w3c.dom.Text}, or
  *         {@link org.w3c.dom.Attr} node representing the r-value.
  *
  * @throws FaultException
  *             DOCUMENTME
  * @throws UnsupportedOperationException
  *             DOCUMENTME
  * @throws IllegalStateException
  *             DOCUMENTME
  */
private Node evalRValue(OAssign.RValue from) throws FaultException, ExternalVariableModuleException {
    if (__log.isDebugEnabled())
        __log.debug("Evaluating FROM expression \"" + from + "\".");

    Node retVal;
    if (from instanceof DirectRef) {
        OAssign.DirectRef dref = (OAssign.DirectRef) from;
        sendVariableReadEvent(_scopeFrame.resolve(dref.variable));
        Node data = fetchVariableData(_scopeFrame.resolve(dref.variable), false);
        retVal = DOMUtils.findChildByName((Element) data, dref.elName);
    } else if (from instanceof OAssign.VariableRef) {
        OAssign.VariableRef varRef = (OAssign.VariableRef) from;
        sendVariableReadEvent(_scopeFrame.resolve(varRef.variable));
        Node data = fetchVariableData(_scopeFrame.resolve(varRef.variable), false);
        retVal = evalQuery(data, varRef.part != null ? varRef.part : varRef.headerPart, varRef.location,
                getEvaluationContext());
    } else if (from instanceof OAssign.PropertyRef) {
        OAssign.PropertyRef propRef = (OAssign.PropertyRef) from;
        sendVariableReadEvent(_scopeFrame.resolve(propRef.variable));
        Node data = fetchVariableData(_scopeFrame.resolve(propRef.variable), false);
        retVal = evalQuery(data, propRef.propertyAlias.part, propRef.propertyAlias.location,
                getEvaluationContext());
    } else if (from instanceof OAssign.PartnerLinkRef) {
        OAssign.PartnerLinkRef pLinkRef = (OAssign.PartnerLinkRef) from;
        PartnerLinkInstance pLink = _scopeFrame.resolve(pLinkRef.partnerLink);
        Node tempVal = pLinkRef.isMyEndpointReference ? getBpelRuntime().fetchMyRoleEndpointReferenceData(pLink)
                : getBpelRuntime().fetchPartnerRoleEndpointReferenceData(pLink);
        if (__log.isDebugEnabled())
            __log.debug("RValue is a partner link, corresponding endpoint " + tempVal.getClass().getName()
                    + " has value " + DOMUtils.domToString(tempVal));
        retVal = tempVal;
    } else if (from instanceof OAssign.Expression) {
        OExpression expr = ((OAssign.Expression) from).expression;
        List<Node> l = getBpelRuntime().getExpLangRuntime().evaluate(expr, getEvaluationContext());
        if (l.size() == 0) {
            String msg = __msgs.msgRValueNoNodesSelected(expr.toString());
            if (__log.isDebugEnabled())
                __log.debug(from + ": " + msg);
            throw new FaultException(getOAsssign().getOwner().constants.qnSelectionFailure, msg,
                    new Throwable("ignoreMissingFromData"));
        } else if (l.size() > 1) {
            String msg = __msgs.msgRValueMultipleNodesSelected(expr.toString());
            if (__log.isDebugEnabled())
                __log.debug(from + ": " + msg);
            throw new FaultException(getOAsssign().getOwner().constants.qnSelectionFailure, msg);
        }
        retVal = (Node) l.get(0);
    } else if (from instanceof OAssign.Literal) {
        Element literalRoot = ((OAssign.Literal) from).getXmlLiteral().getDocumentElement();
        assert literalRoot.getLocalName().equals("literal");
        // We'd like a single text node...

        literalRoot.normalize();
        retVal = literalRoot.getFirstChild();

        // Adjust for whitespace before an element.
        if (retVal != null && retVal.getNodeType() == Node.TEXT_NODE
                && retVal.getTextContent().trim().length() == 0 && retVal.getNextSibling() != null) {
            retVal = retVal.getNextSibling();
        }

        if (retVal == null) {
            // Special case, no children --> empty TII
            retVal = literalRoot.getOwnerDocument().createTextNode("");
        } else if (retVal.getNodeType() == Node.ELEMENT_NODE) {
            // Make sure there is no more elements.
            Node x = retVal.getNextSibling();
            while (x != null) {
                if (x.getNodeType() == Node.ELEMENT_NODE) {
                    String msg = __msgs.msgLiteralContainsMultipleEIIs();
                    if (__log.isDebugEnabled())
                        __log.debug(from + ": " + msg);
                    throw new FaultException(getOAsssign().getOwner().constants.qnSelectionFailure, msg);

                }
                x = x.getNextSibling();
            }
        } else if (retVal.getNodeType() == Node.TEXT_NODE) {
            // Make sure there are no elements following this text node.
            Node x = retVal.getNextSibling();
            while (x != null) {
                if (x.getNodeType() == Node.ELEMENT_NODE) {
                    String msg = __msgs.msgLiteralContainsMixedContent();
                    if (__log.isDebugEnabled())
                        __log.debug(from + ": " + msg);
                    throw new FaultException(getOAsssign().getOwner().constants.qnSelectionFailure, msg);

                }
                x = x.getNextSibling();
            }

        }

        if (retVal == null) {
            String msg = __msgs.msgLiteralMustContainTIIorEII();
            if (__log.isDebugEnabled())
                __log.debug(from + ": " + msg);
            throw new FaultException(getOAsssign().getOwner().constants.qnSelectionFailure, msg);
        }
    } else {
        String msg = __msgs.msgInternalError("Unknown RVALUE type: " + from);
        if (__log.isErrorEnabled())
            __log.error(from + ": " + msg);
        throw new FaultException(getOAsssign().getOwner().constants.qnSelectionFailure, msg);
    }

    // Now verify we got something.
    if (retVal == null) {
        String msg = __msgs.msgEmptyRValue();
        if (__log.isDebugEnabled())
            __log.debug(from + ": " + msg);
        throw new FaultException(getOAsssign().getOwner().constants.qnSelectionFailure, msg);
    }

    // Now check that we got the right thing.
    switch (retVal.getNodeType()) {
    case Node.TEXT_NODE:
    case Node.ATTRIBUTE_NODE:
    case Node.ELEMENT_NODE:
    case Node.CDATA_SECTION_NODE:
        break;
    default:
        String msg = __msgs.msgInvalidRValue();
        if (__log.isDebugEnabled())
            __log.debug(from + ": " + msg);

        throw new FaultException(getOAsssign().getOwner().constants.qnSelectionFailure, msg);

    }

    return retVal;
}

From source file:org.apache.ode.bpel.rtrep.v2.ASSIGN.java

/**
 * Get the r-value. There are several possibilities:
 * <ul>/*from  w  w  w.  ja  v a2s.  co m*/
 * <li>a message is selected - an element representing the whole message is
 * returned.</li>
 * <li>a (element) message part is selected - the element is returned.
 * </li>
 * <li>a (typed) message part is select - a wrapper element is returned.
 * </li>
 * <li>an attribute is selected - an attribute node is returned. </li>
 * <li>a text node/string expression is selected - a text node is returned.
 * </li>
 * </ul>
 *
 * @param from
 *
 * @return Either {@link Element}, {@link org.w3c.dom.Text}, or
 *         {@link org.w3c.dom.Attr} node representing the r-value.
 *
 * @throws FaultException
 *             DOCUMENTME
 * @throws UnsupportedOperationException
 *             DOCUMENTME
 * @throws IllegalStateException
 *             DOCUMENTME
 */
private Node evalRValue(OAssign.RValue from) throws FaultException, ExternalVariableModuleException {
    if (__log.isDebugEnabled())
        __log.debug("Evaluating FROM expression \"" + from + "\".");

    Node retVal;
    if (from instanceof OAssign.DirectRef) {
        OAssign.DirectRef dref = (OAssign.DirectRef) from;
        sendVariableReadEvent(_scopeFrame.resolve(dref.variable));
        Node data = fetchVariableData(_scopeFrame.resolve(dref.variable), false);
        retVal = DOMUtils.findChildByName((Element) data, dref.elName);
    } else if (from instanceof OAssign.VariableRef) {
        OAssign.VariableRef varRef = (OAssign.VariableRef) from;
        sendVariableReadEvent(_scopeFrame.resolve(varRef.variable));
        Node data = fetchVariableData(_scopeFrame.resolve(varRef.variable), false);
        retVal = evalQuery(data, varRef.part != null ? varRef.part : varRef.headerPart, varRef.location,
                getEvaluationContext());
    } else if (from instanceof OAssign.PropertyRef) {
        OAssign.PropertyRef propRef = (OAssign.PropertyRef) from;
        sendVariableReadEvent(_scopeFrame.resolve(propRef.variable));
        Node data = fetchVariableData(_scopeFrame.resolve(propRef.variable), false);
        retVal = evalQuery(data, propRef.propertyAlias.part, propRef.propertyAlias.location,
                getEvaluationContext());
    } else if (from instanceof OAssign.PartnerLinkRef) {
        OAssign.PartnerLinkRef pLinkRef = (OAssign.PartnerLinkRef) from;
        PartnerLinkInstance pLink = _scopeFrame.resolve(pLinkRef.partnerLink);
        Node tempVal = pLinkRef.isMyEndpointReference ? getBpelRuntime().fetchMyRoleEndpointReferenceData(pLink)
                : getBpelRuntime().fetchPartnerRoleEndpointReferenceData(pLink);
        if (__log.isDebugEnabled())
            __log.debug("RValue is a partner link, corresponding endpoint " + tempVal.getClass().getName()
                    + " has value " + DOMUtils.domToString(tempVal));
        retVal = tempVal;
    } else if (from instanceof OAssign.Expression) {
        OExpression expr = ((OAssign.Expression) from).expression;
        List<Node> l = getBpelRuntime().getExpLangRuntime().evaluate(expr, getEvaluationContext());

        if (l.size() == 0) {
            String msg = __msgs.msgRValueNoNodesSelected(expr.toString());
            if (__log.isDebugEnabled())
                __log.debug(from + ": " + msg);
            throw new FaultException(getOAsssign().getOwner().constants.qnSelectionFailure, msg,
                    new Throwable("ignoreMissingFromData"));
        } else if (l.size() > 1) {
            String msg = __msgs.msgRValueMultipleNodesSelected(expr.toString());
            if (__log.isDebugEnabled())
                __log.debug(from + ": " + msg);
            throw new FaultException(getOAsssign().getOwner().constants.qnSelectionFailure, msg);
        }
        retVal = l.get(0);
    } else if (from instanceof OAssign.Literal) {
        Element literalRoot = ((OAssign.Literal) from).getXmlLiteral().getDocumentElement();
        assert literalRoot.getLocalName().equals("literal");
        // We'd like a single text node...

        literalRoot.normalize();
        retVal = literalRoot.getFirstChild();

        // Adjust for whitespace before an element.
        if (retVal != null && retVal.getNodeType() == Node.TEXT_NODE
                && retVal.getTextContent().trim().length() == 0 && retVal.getNextSibling() != null) {
            retVal = retVal.getNextSibling();
        }

        if (retVal == null) {
            // Special case, no children --> empty TII
            retVal = literalRoot.getOwnerDocument().createTextNode("");
        } else if (retVal.getNodeType() == Node.ELEMENT_NODE) {
            // Make sure there is no more elements.
            Node x = retVal.getNextSibling();
            while (x != null) {
                if (x.getNodeType() == Node.ELEMENT_NODE) {
                    String msg = __msgs.msgLiteralContainsMultipleEIIs();
                    if (__log.isDebugEnabled())
                        __log.debug(from + ": " + msg);
                    throw new FaultException(getOAsssign().getOwner().constants.qnSelectionFailure, msg);

                }
                x = x.getNextSibling();
            }
        } else if (retVal.getNodeType() == Node.TEXT_NODE) {
            // Make sure there are no elements following this text node.
            Node x = retVal.getNextSibling();
            while (x != null) {
                if (x.getNodeType() == Node.ELEMENT_NODE) {
                    String msg = __msgs.msgLiteralContainsMixedContent();
                    if (__log.isDebugEnabled())
                        __log.debug(from + ": " + msg);
                    throw new FaultException(getOAsssign().getOwner().constants.qnSelectionFailure, msg);

                }
                x = x.getNextSibling();
            }

        }

        if (retVal == null) {
            String msg = __msgs.msgLiteralMustContainTIIorEII();
            if (__log.isDebugEnabled())
                __log.debug(from + ": " + msg);
            throw new FaultException(getOAsssign().getOwner().constants.qnSelectionFailure, msg);
        }
    } else {
        String msg = __msgs.msgInternalError("Unknown RVALUE type: " + from);
        if (__log.isErrorEnabled())
            __log.error(from + ": " + msg);
        throw new FaultException(getOAsssign().getOwner().constants.qnSelectionFailure, msg);
    }

    // Now verify we got something.
    if (retVal == null) {
        String msg = __msgs.msgEmptyRValue();
        if (__log.isDebugEnabled())
            __log.debug(from + ": " + msg);
        throw new FaultException(getOAsssign().getOwner().constants.qnSelectionFailure, msg);
    }

    // Now check that we got the right thing.
    switch (retVal.getNodeType()) {
    case Node.TEXT_NODE:
    case Node.ATTRIBUTE_NODE:
    case Node.ELEMENT_NODE:
    case Node.CDATA_SECTION_NODE:
        break;
    default:
        String msg = __msgs.msgInvalidRValue();
        if (__log.isDebugEnabled())
            __log.debug(from + ": " + msg);

        throw new FaultException(getOAsssign().getOwner().constants.qnSelectionFailure, msg);

    }

    return retVal;
}

From source file:com.taobao.weex.bridge.WXBridgeManager.java

private void initWXBridge(boolean remoteDebug) {
    if (remoteDebug && WXEnvironment.isApkDebugable()) {
        WXEnvironment.sDebugServerConnectable = true;
    }//from  w  w  w.  j  a  v  a  2 s .co  m

    if (mWxDebugProxy != null) {
        mWxDebugProxy.stop(false);
    }
    if (WXEnvironment.sDebugServerConnectable
            && (WXEnvironment.isApkDebugable() || WXEnvironment.sForceEnableDevTool)) {
        if (WXEnvironment.getApplication() != null) {
            try {
                Class clazz = Class.forName("com.taobao.weex.devtools.debug.DebugServerProxy");
                if (clazz != null) {
                    Constructor constructor = clazz.getConstructor(Context.class, WXBridgeManager.class);
                    if (constructor != null) {
                        mWxDebugProxy = (IWXDebugProxy) constructor.newInstance(WXEnvironment.getApplication(),
                                WXBridgeManager.this);
                        if (mWxDebugProxy != null) {
                            mWxDebugProxy.start();
                        }
                    }
                }
            } catch (Throwable e) {
                //Ignore, It will throw Exception on Release environment
            }
            WXServiceManager.execAllCacheJsService();
        } else {
            WXLogUtils.e("WXBridgeManager", "WXEnvironment.sApplication is null, skip init Inspector");
            WXLogUtils.w("WXBridgeManager",
                    new Throwable("WXEnvironment.sApplication is null when init Inspector"));
        }
    }
    if (remoteDebug && mWxDebugProxy != null) {
        mWXBridge = mWxDebugProxy.getWXBridge();
    } else {
        mWXBridge = new WXBridge();
    }
}

From source file:com.boundlessgeo.spatialconnect.stores.GeoJsonStore.java

public Observable<SCStoreStatusEvent> start() {
    final GeoJsonStore storeInstance = this;
    storeInstance.setStatus(SCDataStoreStatus.SC_DATA_STORE_STARTED);

    return Observable.create(new Observable.OnSubscribe<SCStoreStatusEvent>() {
        @Override//from   ww  w. j  a v a2 s . c  om
        public void call(final Subscriber subscriber) {
            final String filePath = scStoreConfig.getUniqueID() + EXT;
            final File geoJsonFile = new File(getPath());

            if (!geoJsonFile.exists()) {
                if (scStoreConfig.getUri().startsWith("http")) {
                    //download from web
                    try {
                        URL theUrl = new URL(scStoreConfig.getUri());
                        download(theUrl.toString(), geoJsonFile).subscribe(new Action1<Float>() {
                            @Override
                            public void call(Float progress) {
                                setDownloadProgress(progress);
                                if (progress < 1) {
                                    setStatus(SCDataStoreStatus.SC_DATA_STORE_DOWNLOADING_DATA);
                                    subscriber.onNext(new SCStoreStatusEvent(
                                            SCDataStoreStatus.SC_DATA_STORE_DOWNLOADING_DATA));
                                } else {
                                    setStatus(SCDataStoreStatus.SC_DATA_STORE_RUNNING);
                                    geojsonFilePath = filePath;
                                    subscriber.onCompleted();
                                }
                            }
                        }, new Action1<Throwable>() {
                            @Override
                            public void call(Throwable t) {
                                subscriber.onNext(
                                        new SCStoreStatusEvent(SCDataStoreStatus.SC_DATA_STORE_START_FAILED));
                            }
                        });
                    } catch (IOException e) {
                        Log.w(LOG_TAG, "Couldn't download geojson store.", e);
                        GeoJsonStore parentStore = (GeoJsonStore) SpatialConnect.getInstance().getDataService()
                                .getStoreById(scStoreConfig.getUniqueID());
                        parentStore.setStatus(SCDataStoreStatus.SC_DATA_STORE_STOPPED);
                        e.printStackTrace();
                        subscriber.onError(e);
                    }
                } else {
                    //attempt to find file local
                    final String localUriPath = scStoreConfig.getUri().replace("file://", "");
                    File f = new File(context.getFilesDir(), localUriPath);
                    if (!f.exists()) {
                        Log.d(LOG_TAG, "File does not exist at " + scStoreConfig.getUri());
                        InputStream is = null;
                        // if the doesn't exist, then we attempt to create it by copying it from the raw
                        // resources to the destination specified in the config
                        GeoJsonStore parentStore = (GeoJsonStore) SpatialConnect.getInstance().getDataService()
                                .getStoreById(scStoreConfig.getUniqueID());
                        try {
                            Log.d(LOG_TAG,
                                    "Attempting to connect to " + scStoreConfig.getUri().split("\\.")[0]);
                            int resourceId = context.getResources().getIdentifier(
                                    scStoreConfig.getUri().split("\\.")[0], "raw", context.getPackageName());
                            if (resourceId != 0) {
                                is = context.getResources().openRawResource(resourceId);
                                FileUtils.copyInputStreamToFile(is, f);
                                geojsonFilePath = localUriPath;
                                parentStore.setStatus(SCDataStoreStatus.SC_DATA_STORE_RUNNING);
                                subscriber.onCompleted();
                            } else {
                                String errorString = "The config specified a store that should exist on the "
                                        + "filesystem but it could not be located.";
                                Log.w(LOG_TAG, errorString);
                                parentStore.setStatus(SCDataStoreStatus.SC_DATA_STORE_STOPPED);
                                subscriber.onError(new Throwable(errorString));
                            }
                        } catch (Exception e) {
                            Log.w(LOG_TAG, "Couldn't connect to geojson store.", e);
                            parentStore.setStatus(SCDataStoreStatus.SC_DATA_STORE_STOPPED);
                            e.printStackTrace();
                            subscriber.onError(e);
                        } finally {
                            if (is != null) {
                                try {
                                    is.close();
                                } catch (IOException e) {
                                    Log.e(LOG_TAG, "Couldn't close the stream.", e);
                                }
                            }
                        }
                    } else {
                        Log.d(LOG_TAG, "File already exists so set the status to connected.");
                        geojsonFilePath = localUriPath;
                        GeoJsonStore parentStore = (GeoJsonStore) SpatialConnect.getInstance().getDataService()
                                .getStoreById(scStoreConfig.getUniqueID());
                        parentStore.setStatus(SCDataStoreStatus.SC_DATA_STORE_RUNNING);
                        //adapterInstance.connected();
                        subscriber.onCompleted();
                    }
                }

            } else {
                GeoJsonStore parentStore = (GeoJsonStore) SpatialConnect.getInstance().getDataService()
                        .getStoreById(scStoreConfig.getUniqueID());
                parentStore.setStatus(SCDataStoreStatus.SC_DATA_STORE_RUNNING);
                geojsonFilePath = filePath;
                subscriber.onCompleted();
            }
        }
    });

}

From source file:com.trial.phonegap.plugin.calendar.CalendarAccessorGoogle.java

@Override
public JSONArray find(JSONObject options) {

    Date dateStartAfter = null;/* ww w.  j  a  va2s. c  o  m*/
    Date dateStartBefore = null;
    Date dateEndAfter = null;
    Date dateEndBefore = null;
    JSONArray events = new JSONArray();
    List<Event> eventList = null;
    try {

        JSONObject filter = options.getJSONObject("filter");

        //Loggers
        Log.i(TAG, "Date After: " + filter.getString("startAfter"));
        Log.i(TAG, "Date Before: " + filter.getString("startBefore"));
        Log.i(TAG, "Date After: " + filter.getString("endAfter"));
        Log.i(TAG, "Date Before: " + filter.getString("endBefore"));

        //obtain date objets for finding event given by parameters
        dateStartAfter = DateUtils.stringCalendarDateToDateGTM(filter.getString("startAfter"),
                "yyyy-MM-dd HH:mm:ss");
        dateStartBefore = DateUtils.stringCalendarDateToDateGTM(filter.getString("startBefore"),
                "yyyy-MM-dd HH:mm:ss");
        dateEndAfter = DateUtils.stringCalendarDateToDateGTM(filter.getString("endAfter"),
                "yyyy-MM-dd HH:mm:ss");
        dateEndBefore = DateUtils.stringCalendarDateToDateGTM(filter.getString("endBefore"),
                "yyyy-MM-dd HH:mm:ss");

        //remove date parameter from filter 
        filter.remove("startAfter");
        filter.remove("startBefore");
        filter.remove("endAfter");
        filter.remove("endBefore");

        // Google Calendar only provides one method for searching events, dates since dateStartAfter until dateStartBefore, 
        // so we have to configure and adapt the search with the others options, using this method

        // if dateStartAfter is after than dateEndAfter, the search from dateStarAfter 
        // will include all events which end be after dateEndAfter
        if ((dateStartAfter != null) && (dateEndAfter != null) && dateStartAfter.after(dateEndAfter)) {
            Log.i(TAG, "Flow enters in : CHANGE dateStartAfter  after than dateEndAfter");
            dateEndAfter = null;
        }

        // if dateStartBefore is after than dateEndbefore, we will search until dateEndBefore
        if ((dateStartBefore != null) && (dateEndBefore != null) && dateStartBefore.after(dateEndBefore)) {
            Log.i(TAG, "Flow enters in : CHANGE  dateStartBefore  after than dateEndBefore");
            dateStartBefore = dateEndBefore;
        }

        //The Find only does with three dates (dateEndBefore and dateStartBefore and dateStartAfter), because with dateEndAfter 
        //like startAfter don't ensures a correct finding

        //If dateStartAfter is after than dateStartBefore, No dates matching
        if ((dateStartAfter != null) && (dateStartBefore != null) && dateStartAfter.after(dateStartBefore)) {
            Log.i(TAG, "Flow enters in : dateStartAfter  after than dateStartBefore");
            return events;
            //If dateEndAfter is after than dateEndBefore, No dates matching
        } else if ((dateEndAfter != null) && (dateEndBefore != null) && dateEndAfter.after(dateEndBefore)) {
            Log.i(TAG, "Flow enters in : dateEndAfter  after than dateEndBefore");
            return events;
            //If dateStartBefore is not null then finds by dateStartBefore like dateStartBefore 
        } else if (dateStartBefore != null) {
            Log.i(TAG, "Flow enters in: dateStartBefore");
            eventList = calendar.findCalendarEventsBydate(dateStartAfter, dateStartBefore);
            //If dateEndBefore is not null and dateStartBefore is null then finds by dateEndBefore like dateStartBefore 
        } else if (dateEndBefore != null) {
            Log.i(TAG, "Flow enters in : dateEndBefore");
            eventList = calendar.findCalendarEventsBydate(dateStartAfter, dateEndBefore);
            // If dateEndBefore and dateStartBefore   are null, and dateStartAfter is not null the find only by this date
        } else if (dateStartAfter != null) {
            Log.i(TAG, "Flow enters in : dateStartAfter");
            eventList = calendar.findCalendarEventsBydate(dateStartAfter, dateStartBefore);
            //Othewise return all Events   
        } else {
            Log.i(TAG, "Flow enters in : Every event");
            eventList = calendar.getCalendarAllEventsList();
        }

        //After searching the google calendar by start event dates, the result of the searching must be 
        //filtered by the end of event dates
        eventList = filterEventsByEnd(eventList, dateEndBefore, dateEndAfter);

        //Filter the events by remaining parameters.
        if (filter.length() != 0) {
            Log.i(TAG, "Start events filtering  by " + filter.length() + " remaining parameters");

            JSONArray names = filter.names();
            for (int i = 0; i < names.length(); i++) {
                Log.i(TAG, "Filter by '" + names.getString(i) + "' parameter ,with value '"
                        + filter.getString(names.getString(i)) + "'");
                if (dbEventCalendarList.contains(names.getString(i))) {
                    if (!filter.isNull(names.getString(i))) {
                        eventList = filterByParameter(eventList, names.getString(i),
                                filter.getString(names.getString(i)));
                    }
                } else {
                    throw new Throwable(
                            "Parameter '" + names.getString(i) + "' doesn't exist on CalendarEvent");
                }
            }
        } else {
            Log.i(TAG, "No more remaining parameters");
        }

        //Finally transforms an eventList on a JSONArray
        int i = 0;
        for (Event event : eventList) {
            i++;
            events.put(eventToJsonEvent(event));
            Log.i(TAG, "Evento [" + i + "]: " + event.getTitle());
        }

        calendar.addEvents(eventList);

    } catch (JSONException jsonException) {
        jsonException.printStackTrace();
        //TODO Manage exception
    } catch (Throwable throwable) {
        throwable.printStackTrace();
        //TODO Manage exception
    }

    return events;
}

From source file:mod.rankshank.arbitraria.client.texture.CustomTextureMap.java

private TextureAtlasSprite makeAtlas(@Nonnull ResourceLocation location) {
    TextureAtlasSprite sprite = null;/*w ww  .jav a  2s .c  o m*/
    try {
        sprite = (TextureAtlasSprite) ClientReflectionHandles.TextureAtlasSprite_MakeAtlasSprite.invoke(null,
                location);
    } catch (Exception ex) {
        Arbitraria.error(new Throwable(String.format("ISSUE CREATING TEXTURE ATLAS from %s for %s",
                location.toString(), TEXTURE_KEY.toString())), ex);
    }
    return sprite;
}

From source file:com.tesora.dve.sql.logfile.LogFileTest.java

protected ProjectDDL getDDL(TestName tn, BackingSchema backingType) throws Throwable {
    if ((backingType == BackingSchema.MULTI) || (backingType == BackingSchema.MULTI_PORTAL)) {
        return (tn.isMT() ? getMultiSiteMTDDL() : getMultiSiteDDL());
    } else if ((backingType == BackingSchema.SINGLE) || (backingType == BackingSchema.SINGLE_PORTAL)) {
        return (tn.isMT() ? getSingleSiteMTDDL() : getSingleSiteDDL());
    } else if (backingType == BackingSchema.NATIVE) {
        return getNativeDDL();
    } else if (backingType == null) {
        return null;
    } else {/*  w ww. j  a  v  a 2s  .c  o  m*/
        throw new Throwable("Unknown backing schema type: " + backingType);
    }
}

From source file:gobblin.data.management.conversion.hive.validation.ValidationJob.java

/**
 * Validates that partitions are in a given format
 *///from w w  w  .j  a  v a  2 s  .c o m
private void runFileFormatValidation() throws IOException {
    Preconditions.checkArgument(this.props.containsKey(VALIDATION_FILE_FORMAT_KEY));
    Iterator<HiveDataset> iterator = this.datasetFinder.getDatasetsIterator();
    EventSubmitter.submit(Optional.of(this.eventSubmitter), EventConstants.VALIDATION_FIND_HIVE_TABLES_EVENT);
    while (iterator.hasNext()) {
        HiveDataset hiveDataset = iterator.next();
        if (!HiveUtils.isPartitioned(hiveDataset.getTable())) {
            continue;
        }
        for (Partition partition : hiveDataset.getPartitionsFromDataset()) {
            if (!shouldValidate(partition)) {
                continue;
            }
            String fileFormat = this.props.getProperty(VALIDATION_FILE_FORMAT_KEY);
            Optional<HiveSerDeWrapper.BuiltInHiveSerDe> hiveSerDe = Enums
                    .getIfPresent(HiveSerDeWrapper.BuiltInHiveSerDe.class, fileFormat.toUpperCase());
            if (!hiveSerDe.isPresent()) {
                throwables.add(new Throwable("Partition SerDe is either not supported or absent"));
                continue;
            }

            String serdeLib = partition.getTPartition().getSd().getSerdeInfo().getSerializationLib();
            if (!hiveSerDe.get().toString().equalsIgnoreCase(serdeLib)) {
                throwables.add(new Throwable("Partition " + partition.getCompleteName() + " SerDe " + serdeLib
                        + " doesn't match with the required SerDe " + hiveSerDe.get().toString()));
            }
        }
    }
    if (!this.throwables.isEmpty()) {
        for (Throwable e : this.throwables) {
            log.error("Failed to validate due to " + e);
        }
        throw new RuntimeException("Validation Job Failed");
    }
}

From source file:com.screenslicer.core.scrape.Scrape.java

private static void fetch(List<Result> results, RemoteWebDriver driver, boolean cached, String runGuid,
        HtmlNode[] clicks) throws ActionFailed {
    try {//from   w w  w  . j  ava 2  s.c om
        String origHandle = driver.getWindowHandle();
        String origUrl = driver.getCurrentUrl();
        String newHandle = null;
        if (cached) {
            newHandle = Util.newWindow(driver);
        }
        try {
            for (Result result : results) {
                if (!isUrlValid(result.url()) && Util.uriScheme.matcher(result.url()).matches()) {
                    continue;
                }
                if (ScreenSlicerBatch.isCancelled(runGuid)) {
                    return;
                }
                try {
                    Log.info("Fetching URL " + result.url() + ". Cached: " + cached, false);
                } catch (Throwable t) {
                    Log.exception(t);
                }
                try {
                    result.attach(getHelper(driver, result.urlNode(), result.url(), cached, runGuid, clicks));
                } catch (Throwable t) {
                    Log.exception(t);
                }
            }
        } catch (Throwable t) {
            Log.exception(t);
        } finally {
            if (cached && origHandle.equals(newHandle)) {
                Log.exception(new Throwable("Failed opening new window"));
                Util.get(driver, origUrl, true);
            } else {
                Util.cleanUpNewWindows(driver, origHandle);
            }
        }
    } catch (Throwable t) {
        Log.exception(t);
        throw new ActionFailed(t);
    } finally {
        Util.driverSleepRandLong();
    }
}