Example usage for java.lang InternalError InternalError

List of usage examples for java.lang InternalError InternalError

Introduction

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

Prototype

public InternalError(Throwable cause) 

Source Link

Document

Constructs an InternalError with the specified cause and a detail message of (cause==null ?

Usage

From source file:org.tsho.dmc2.core.chart.DmcLyapunovPlot.java

/**
 * Draws a representation of the data within the dataArea region.
 * <P>//from  w ww .j  a  v  a2 s.c o m
 * The <code>info</code> and <code>crosshairInfo</code> arguments may be <code>null</code>.
 *
 * @param g2  the graphics device.
 * @param dataArea  the region in which the data is to be drawn.
 * @param info  an optional object for collection dimension information.
 * @param crosshairInfo  an optional object for collecting crosshair info.
 */
public void render(Graphics2D g2, Rectangle2D dataArea, PlotRenderingInfo info) {

    stopped = false;
    CoreStatusEvent statusEv = new CoreStatusEvent(this);
    statusEv.setStatusString("plotting...");
    statusEv.setType(CoreStatusEvent.STARTED | CoreStatusEvent.STRING);
    notifyCoreStatusListeners(statusEv);

    boolean status;

    if (type == VSTIME)
        status = renderVsTime(g2, dataArea);
    else if (type == VSPAR)
        status = renderVsParameter(g2, dataArea);
    else if (type == AREA)
        status = renderArea(g2, dataArea);
    else {
        throw new InternalError("Invalid plot type");
    }

    if (status == true) {
        statusEv.setPercent(100);
        statusEv.setStatusString("done");
        statusEv.setType(CoreStatusEvent.STRING | CoreStatusEvent.PERCENT);
        notifyCoreStatusListeners(statusEv);
    }
    statusEv.setType(CoreStatusEvent.FINISHED);
    notifyCoreStatusListeners(statusEv);
}

From source file:dk.dma.vessel.track.store.AisStoreClient.java

public List<PastTrackPos> getPastTrack(int mmsi, Integer minDist, Duration age) {

    // Determine URL
    age = age != null ? age : Duration.parse(pastTrackTtl);
    minDist = minDist == null ? Integer.valueOf(pastTrackMinDist) : minDist;
    ZonedDateTime now = ZonedDateTime.now();
    String from = now.format(DateTimeFormatter.ISO_INSTANT);
    ZonedDateTime end = now.minus(age);
    String to = end.format(DateTimeFormatter.ISO_INSTANT);
    String interval = String.format("%s/%s", to, from);
    String url = String.format("%s?mmsi=%d&interval=%s", aisViewUrl, mmsi, interval);

    final List<PastTrackPos> track = new ArrayList<>();
    try {/*from  ww  w .  ja va  2s.  c  o m*/
        long t0 = System.currentTimeMillis();

        // TEST
        url = url + "&filter=" + URLEncoder.encode("(s.country not in (GBR)) & (s.region!=808)", "UTF-8");

        // Set up a few timeouts and fetch the attachment
        URLConnection con = new URL(url).openConnection();
        con.setConnectTimeout(10 * 1000); // 10 seconds
        con.setReadTimeout(60 * 1000); // 1 minute

        if (!StringUtils.isEmpty(aisAuthHeader)) {
            con.setRequestProperty("Authorization", aisAuthHeader);
        }

        try (InputStream in = con.getInputStream(); BufferedInputStream bin = new BufferedInputStream(in)) {
            AisReader aisReader = AisReaders.createReaderFromInputStream(bin);
            aisReader.registerPacketHandler(new Consumer<AisPacket>() {
                @Override
                public void accept(AisPacket p) {
                    AisMessage message = p.tryGetAisMessage();
                    if (message == null || !(message instanceof IVesselPositionMessage)) {
                        return;
                    }
                    VesselTarget target = new VesselTarget();
                    target.merge(p, message);
                    if (!target.checkValidPos()) {
                        return;
                    }
                    track.add(new PastTrackPos(target.getLat(), target.getLon(), target.getCog(),
                            target.getSog(), target.getLastPosReport()));
                }
            });
            aisReader.start();
            try {
                aisReader.join();
            } catch (InterruptedException e) {
                return null;
            }
        }
        LOG.info(String.format("Read %d past track positions in %d ms", track.size(),
                System.currentTimeMillis() - t0));
    } catch (IOException e) {
        LOG.error("Failed to make REST query: " + url);
        throw new InternalError("REST endpoint failed");
    }
    LOG.info("AisStore returned track with " + track.size() + " points");
    return PastTrack.downSample(track, minDist, age.toMillis());
}

From source file:org.tinygroup.commons.tools.HashCodeUtil.java

private static void reflectionAppend(Object object, Class clazz, HashCodeBuilder builder, boolean useTransients,
        String[] excludeFields) {
    if (isRegistered(object)) {
        return;//  w ww  .  j a v a2 s.  c o  m
    }
    try {
        register(object);
        Field[] fields = clazz.getDeclaredFields();
        List excludedFieldList = excludeFields != null ? Arrays.asList(excludeFields) : Collections.EMPTY_LIST;
        AccessibleObject.setAccessible(fields, true);
        for (int i = 0; i < fields.length; i++) {
            Field field = fields[i];
            if (!excludedFieldList.contains(field.getName()) && (field.getName().indexOf('$') == -1)
                    && (useTransients || !Modifier.isTransient(field.getModifiers()))
                    && (!Modifier.isStatic(field.getModifiers()))) {
                try {
                    Object fieldValue = field.get(object);
                    builder.append(fieldValue);
                } catch (IllegalAccessException e) {
                    // this can't happen. Would get a Security exception
                    // instead
                    // throw a runtime exception in case the impossible
                    // happens.
                    throw new InternalError("Unexpected IllegalAccessException");
                }
            }
        }
    } finally {
        unregister(object);
    }
}

From source file:edu.utah.further.dts.api.domain.concept.ConceptReport.java

/**
 * Return a deep copy of this object./*from   w w w .j  a  v  a  2s  . co  m*/
 *
 * @return a deep copy of this object
 * @see edu.utah.further.core.api.lang.PubliclyCloneable#copy()
 */
@Override
public ConceptReport copy() {
    try {
        // Could alternatively call CoreUtil.clone(), but reflection is slower
        // than direct invocation
        return (ConceptReport) super.clone();
    } catch (final CloneNotSupportedException e) {
        throw new InternalError("We are cloneable so we shouldn't be here!");
    }
}

From source file:com.epam.catgenome.manager.gene.parser.GffCodec.java

private GeneFeature createFeature(String line) {
    switch (type) {
    case GFF://from  w  ww. j a v a  2  s .com
    case COMPRESSED_GFF:
        return new GffFeature(line);
    case GTF:
    case COMPRESSED_GTF:
        return new GtfFeature(line);
    default:
        throw new InternalError("Unknown GENE type: " + type);
    }
}

From source file:com.igeekinc.indelible.indeliblefs.iscsi.IndelibleiSCSIMgmtServlet.java

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    Map<String, String[]> paramMap = req.getParameterMap();
    String[] keys = paramMap.get("cmd");
    if (keys.length != 1) {
        resp.sendError(200);/*  w ww.  j a v  a2 s  . com*/
    } else {
        try {
            String command = keys[0].toLowerCase().trim();
            JSONObject resultObject = null;
            if (command.equals("export"))
                resultObject = export(req, resp, paramMap);
            if (command.equals("unexport"))
                resultObject = unexport(req, resp, paramMap);
            if (command.equals("listexports"))
                resultObject = listExports();
            if (command.equals("serverinfo"))
                resultObject = serverInfo();
            if (resultObject != null) {
                resp.getWriter().print(resultObject.toString(5));
            } else {
                throw new InternalError("No result object created");
            }
        } catch (IndelibleMgmtException e) {
            Logger.getLogger(getClass()).error(new ErrorLogMessage("Caught exception"), e);
            doError(resp, e);
        } catch (Throwable t) {
            doError(resp, new IndelibleMgmtException(IndelibleMgmtException.kInternalError, t));
        }
    }
}

From source file:edu.ku.brc.af.prefs.AppPreferences.java

/**
 * @param factoryClassName/*from   ww w .  j a  va  2  s .  c o m*/
 * @param factoryNm
 * @return
 */
private AppPrefsIOIFace createFactoryIO(final String factoryNm) {
    this.saverClassName = System.getProperty(factoryNm, null);
    if (this.saverClassName == null) {
        throw new InternalError("System Property '" + factoryNm + "' must be set!"); //$NON-NLS-1$ //$NON-NLS-2$
    }

    AppPrefsIOIFace prefIO = null;
    try {
        prefIO = (AppPrefsIOIFace) Class.forName(this.saverClassName).newInstance();
        prefIO.setAppPrefsMgr(this);

    } catch (Exception e) {
        edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
        edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(AppPreferences.class, e);
        InternalError error = new InternalError(
                "Can't instantiate " + this.saverClassName + " factory for " + factoryNm); //$NON-NLS-1$ //$NON-NLS-2$
        error.initCause(e);
        throw error;
    }
    return prefIO;
}

From source file:com.clustercontrol.jobmanagement.view.action.StartJobAction.java

/**
 * ?/*from   w ww.  j  ava  2 s  .  c  o m*/
 *
 * @param managerName ???
 * @param sessionId ID
 * @param jobunitId ?ID
 * @param jobId ID
 * @param facilityId ID
 * @return ?
 *
 */
private Property getStartProperty(String managerName, String sessionId, String jobunitId, String jobId,
        String facilityId) {
    Locale locale = Locale.getDefault();
    //ID
    Property session = new Property(JobOperationConstant.SESSION, Messages.getString("session.id", locale),
            PropertyDefineConstant.EDITOR_TEXT);
    //ID
    Property jobUnit = new Property(JobOperationConstant.JOB_UNIT, Messages.getString("jobunit.id", locale),
            PropertyDefineConstant.EDITOR_TEXT);
    //ID
    Property job = new Property(JobOperationConstant.JOB, Messages.getString("job.id", locale),
            PropertyDefineConstant.EDITOR_TEXT);
    //ID
    Property facility = new Property(JobOperationConstant.FACILITY, Messages.getString("facility.id", locale),
            PropertyDefineConstant.EDITOR_TEXT);
    //
    Property control = new Property(JobOperationConstant.CONTROL, Messages.getString("control", locale),
            PropertyDefineConstant.EDITOR_SELECT);

    List<Integer> values = null;
    try {
        JobEndpointWrapper wrapper = JobEndpointWrapper.getWrapper(managerName);
        values = wrapper.getAvailableStartOperation(sessionId, jobunitId, jobId, facilityId);
    } catch (InvalidRole_Exception e) {
        MessageDialog.openInformation(null, Messages.getString("message"),
                Messages.getString("message.accesscontrol.16"));
        throw new InternalError("values is null.");
    } catch (Exception e) {
        m_log.warn("getStartProperty(), " + e.getMessage(), e);
        MessageDialog.openError(null, Messages.getString("failed"),
                Messages.getString("message.hinemos.failure.unexpected") + ", "
                        + HinemosMessage.replace(e.getMessage()));
        throw new InternalError("values is null.");
    }

    // type?String??
    List<String> valuesStr = new ArrayList<String>();
    for (Integer controlType : values) {
        valuesStr.add(OperationMessage.typeToString(controlType));
    }

    //?
    if (values.size() >= 1) {
        Object controlValues[][] = { valuesStr.toArray(), valuesStr.toArray() };
        control.setSelectValues(controlValues);
        control.setValue(valuesStr.get(0));
    } else {
        Object controlValues[][] = { { "" }, { "" } };
        control.setSelectValues(controlValues);
        control.setValue("");
    }

    session.setValue(sessionId);
    jobUnit.setValue(jobunitId);
    job.setValue(jobId);
    if (facilityId != null && facilityId.length() > 0) {
        facility.setValue(facilityId);
    } else {
        facility.setValue("");
    }

    //??/??
    session.setModify(PropertyDefineConstant.MODIFY_NG);
    jobUnit.setModify(PropertyDefineConstant.MODIFY_NG);
    job.setModify(PropertyDefineConstant.MODIFY_NG);
    facility.setModify(PropertyDefineConstant.MODIFY_NG);
    control.setModify(PropertyDefineConstant.MODIFY_OK);

    Property property = new Property(null, null, "");

    // ??
    property.removeChildren();
    property.addChildren(session);
    property.addChildren(jobUnit);
    property.addChildren(job);
    if (facilityId != null && facilityId.length() > 0) {
        property.addChildren(facility);
    }
    property.addChildren(control);

    return property;
}

From source file:org.tsho.dmc2.core.chart.LyapunovRenderer.java

public void render(Graphics2D g2, Rectangle2D dataArea, PlotRenderingInfo info) {

    boolean status;

    state = STATE_RUNNING;/*from  w  w w  . ja v  a2 s .  c om*/

    if (type == TYPE_VSTIME)
        status = renderVsTime(g2, dataArea);
    else if (type == TYPE_VSPAR)
        status = renderVsParameter(g2, dataArea);
    else if (type == TYPE_AREA)
        status = renderArea(g2, dataArea);
    else {
        throw new InternalError("Invalid plot type");
    }

    state = STATE_FINISHED;
}

From source file:edu.ku.brc.af.ui.forms.formatters.UIFieldFormatterMgr.java

/**
 * Returns the instance to the singleton
 * //from w  w  w .  ja  va  2 s  .co  m
 * @return the instance to the singleton
 */
public static UIFieldFormatterMgr getInstance() {
    if (instance != null) {
        return instance;
    }

    if (StringUtils.isEmpty(factoryName)) {
        return instance = new UIFieldFormatterMgr();
    }

    // else
    String factoryNameStr = AccessController.doPrivileged(new java.security.PrivilegedAction<String>() {
        public String run() {
            return System.getProperty(factoryName);
        }
    });

    if (StringUtils.isNotEmpty(factoryNameStr)) {
        try {
            instance = (UIFieldFormatterMgr) Class.forName(factoryNameStr).newInstance();
            instance.load();
            return instance;

        } catch (Exception e) {
            edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
            edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(UIFieldFormatterMgr.class, e);
            InternalError error = new InternalError(
                    "Can't instantiate UIFieldFormatterMgr factory " + factoryNameStr);
            error.initCause(e);
            throw error;
        }
    }
    // should not happen
    throw new RuntimeException("Can't instantiate UIFieldFormatterMgr factory [" + factoryNameStr + "]");
}