Example usage for java.lang RuntimeException printStackTrace

List of usage examples for java.lang RuntimeException printStackTrace

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:piecework.exception.GeneralExceptionMapper.java

/**
 * @see javax.ws.rs.ext.ExceptionMapper#toResponse(java.lang.Throwable)
 *///from  w w  w  . j  a va  2  s  .  co m
public Response toResponse(RuntimeException exception) {
    if (exception instanceof AccessDeniedException) {
        AccessDeniedException accessDeniedException = AccessDeniedException.class.cast(exception);
        Explanation explanation = new Explanation();
        explanation.setMessage("Not authorized");
        explanation.setMessageDetail("You have not been granted the necessary permission to take this action.");
        return Response.status(Status.UNAUTHORIZED).entity(explanation).build();
    }

    String messageHeader = "Internal Server Error";
    String messageDetail = exception.getMessage();
    Status status = null;

    if (StringUtils.isEmpty(messageDetail))
        messageDetail = "The system is unable to complete your request at this time.";

    if (exception instanceof WebApplicationException) {
        WebApplicationException webApplicationException = WebApplicationException.class.cast(exception);
        Response response = webApplicationException.getResponse();
        int statusCode = response != null ? response.getStatus() : Status.INTERNAL_SERVER_ERROR.getStatusCode();
        status = Status.fromStatusCode(statusCode);
    }

    if (status != null)
        messageHeader = status.getReasonPhrase();
    else
        status = Status.INTERNAL_SERVER_ERROR;

    LOG.info("Uncaught exception. Sending exception message to client with status "
            + Status.INTERNAL_SERVER_ERROR + " and message " + messageDetail, exception);
    exception.printStackTrace();
    Explanation explanation = new Explanation();
    explanation.setMessage(messageHeader);
    explanation.setMessageDetail(messageDetail);

    List<MediaType> mediaTypes = messageContext.getHttpHeaders().getAcceptableMediaTypes();
    MediaType mediaType = mediaTypes != null && !mediaTypes.isEmpty() ? mediaTypes.iterator().next()
            : MediaType.TEXT_HTML_TYPE;

    if (!mediaType.equals(MediaType.TEXT_HTML_TYPE))
        return Response.status(status).entity(explanation).build();

    StreamingOutput streamingOutput = userInterfaceService.getExplanationAsStreaming(servletContext,
            explanation);
    return Response.status(status).entity(streamingOutput).type(MediaType.TEXT_HTML_TYPE).build();
}

From source file:com.healthcit.cacure.dao.CouchDBDao.java

private void doHttp(HttpUriRequest request, CouchJSONConverter converter) throws Exception {
    HttpClient httpclient = new DefaultHttpClient();
    // Execute the request
    HttpResponse response = httpclient.execute(request);
    // Get hold of the response entity
    HttpEntity entity = response.getEntity();

    // If the response does not enclose an entity, there is no need
    // to worry about connection release
    if (entity != null) {
        InputStream instream = null;
        try {//  w  ww.  jav  a 2s .  c om
            instream = entity.getContent();

            converter.setInputStream(instream);
            converter.convert();
        } catch (RuntimeException ex) {

            // In case of an unexpected exception you may want to abort
            // the HTTP request in order to shut down the underlying
            // connection and release it back to the connection manager.
            request.abort();
            throw ex;

        } finally {

            // Closing the input stream will trigger connection release
            try {
                instream.close();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }

        // When HttpClient instance is no longer needed,
        // shut down the connection manager to ensure
        // immediate deallocation of all system resources
        httpclient.getConnectionManager().shutdown();
    }
}

From source file:webServices.RestServiceImpl.java

@GET
@Path("/mapLayersInfo/{id}/{host}/{endpoint}/{qType}/{port}")
@Produces(MediaType.APPLICATION_XML)/* w w w .ja  v a  2 s .  c om*/
public List<MapInfo> getMapLayers(@PathParam("id") String id, @PathParam("host") String host,
        @PathParam("endpoint") String endpoint, @PathParam("qType") String qType, @PathParam("port") int port)
        throws EndpointCommunicationException {

    //Reset to default registry values
    endpointStore = new MapEndpointStore();

    //Get host info if the map is not saved in Registry
    if (!host.equalsIgnoreCase("none")) {
        endpointStore.setEndpointQuery(host, port, endpoint + "/" + qType);
    }

    //query registry to get the layers of the map with the specific id
    Vector<Vector<String>> results = endpointStore.openMapFromLink(id);

    int chartPosition = -1;

    //Pose queries to endpoints to get the KML files
    for (int i = 0; i < results.size(); i++) {
        Vector<String> temp = results.get(i);

        //End this loop at chart info separator
        if (temp.get(0).equalsIgnoreCase("@@@")) {
            chartPosition = i + 1;
            break;
        }

        String kmlFile = null;
        String hostName = null;
        String endpointName = null;
        String[] parts = null;
        String[] hostArr = null;

        //If an endpointURI exists, get the host and the name of it         
        if (temp.get(3) != null) {
            parts = temp.get(3).split("/");
            hostName = parts[2];
            port = 80;
            hostArr = hostName.split(":");
            if (hostArr.length > 1) {
                port = Integer.parseInt(hostArr[1]);
            }

            endpointName = "";
            for (int b = 3; b < parts.length - 1; b++) {
                //endpointName = parts[3] + "/" + parts[4];   
                endpointName += parts[b] + "/";
            }
            endpointName += parts[parts.length - 1];
        }

        /**
         * Query the respective endpoint to get the .kml file
         */
        if (parts != null && temp.get(1) != null) {
            if (!hostName.equalsIgnoreCase("data.ordnancesurvey.co.uk")) {
                //Strabon endpoint
                try {
                    //System.out.println("*** Query: " + temp.get(1));
                    //System.out.println("*** LayerName: " + temp.get(0));
                    //System.out.println("*** Host: " + hostName);
                    //System.out.println("*** Port: " + port);
                    //System.out.println("*** EndpointName: " + endpointName);
                    kmlFile = passQuery(temp.get(1), temp.get(0), hostName, port, endpointName);
                    //kmlFile = passQuery(query, name, host, port, endpointName.replaceAll("@@@", "/"));

                } catch (RuntimeException e) {
                    e.printStackTrace();
                }
            } else {
                //Ordnance Survey SPARQL endpoint
                try {
                    kmlFile = passQueryOS(temp.get(1), temp.get(0));
                } catch (RuntimeException e) {

                } catch (QueryResultParseException e) {
                    e.printStackTrace();
                } catch (TupleQueryResultHandlerException e) {
                    e.printStackTrace();
                } catch (QueryEvaluationException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

            temp.set(2, kmlFile);
            results.set(i, temp);

        }
    }

    //Wrap the results 
    ArrayList<MapInfo> mapInformation = new ArrayList<MapInfo>();

    for (int i = 0; i < results.size(); i++) {
        MapInfo info = new MapInfo();

        Vector<String> temp = results.get(i);
        //End this loop at chart info separator
        if (temp.get(0).equalsIgnoreCase("@@@")) {
            break;
        }

        info.init(temp);
        mapInformation.add(info);
    }

    //Pose queries to endpoints to get chart results and wrap results
    if (chartPosition != -1) {
        for (int i = chartPosition; i < results.size(); i++) {
            Vector<String> temp = results.get(i);

            String hostName = null;
            String endpointName = "";
            String[] parts = null;
            String[] hostArr = null;

            //Get the host and the name of the endpoint      
            parts = temp.get(3).split("/");
            hostName = parts[2];
            port = 80;
            hostArr = hostName.split(":");
            if (hostArr.length > 1) {
                port = Integer.parseInt(hostArr[1]);
            }

            for (int j = 3; j < parts.length - 1; j++) {
                endpointName = endpointName.concat(parts[j]);
                endpointName = endpointName.concat("/");
            }
            endpointName = endpointName.concat(parts[parts.length - 1]);

            Vector<String> resultsChart = new Vector<String>();
            String format = "";

            resultsChart = endpointStore.getDataForChart(hostName, endpointName, port, temp.get(2));

            for (int j = 0; j < resultsChart.size(); j++) {
                format = format.concat(resultsChart.get(j));
                format = format.concat("$");
            }

            MapInfo info = new MapInfo("chart", temp.get(2), temp.get(3), temp.get(1), format, temp.get(4),
                    temp.get(5), temp.get(6));
            mapInformation.add(info);
        }
    }

    return mapInformation;
}

From source file:junk.gui.HazardSpectrumApplication.java

public void init() {
    try {//from w  ww .j a va2s  . c  o  m

        // initialize the control pick list
        initControlList();
        //initialise the list to make selection whether to show ERF_GUIBean or ERF_RupSelectorGuiBean
        initProbOrDeterList();
        // initialize the GUI components
        jbInit();

        // initialize the various GUI beans
        initIMR_GuiBean();
        initSiteGuiBean();
        initImlProb_GuiBean();
        try {
            this.initERFSelector_GuiBean();
        } catch (RuntimeException e) {
            JOptionPane.showMessageDialog(this, "Connection to ERF failed", "Internet Connection Problem",
                    JOptionPane.OK_OPTION);
            return;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:org.sakaiproject.tool.assessment.ui.bean.author.AssessmentSettingsBean.java

public void setAssessment(AssessmentFacade assessment) {
    try {/*ww  w  .jav  a2 s.c om*/
        //1.  set the template info
        AssessmentService service = new AssessmentService();
        AssessmentTemplateIfc template = null;
        if (assessment.getAssessmentTemplateId() != null) {
            template = service.getAssessmentTemplate(assessment.getAssessmentTemplateId().toString());
        }
        if (template != null) {
            setNoTemplate(false);
            this.templateTitle = template.getTitle();
            this.templateDescription = template.getDescription();
            this.templateAuthors = template.getAssessmentMetaDataByLabel("author"); // see TemplateUploadListener line 142
        } else {
            setNoTemplate(true);
        }
        //2. set the assessment info
        this.assessment = assessment;
        // set the valueMap
        setValueMap(assessment.getAssessmentMetaDataMap());
        this.assessmentId = assessment.getAssessmentId();
        this.title = assessment.getTitle();
        this.creator = AgentFacade.getDisplayName(assessment.getCreatedBy());
        this.description = assessment.getDescription();
        // assessment meta data
        this.authors = assessment.getAssessmentMetaDataByLabel(AssessmentMetaDataIfc.AUTHORS);
        this.objectives = assessment.getAssessmentMetaDataByLabel(AssessmentMetaDataIfc.OBJECTIVES);
        this.keywords = assessment.getAssessmentMetaDataByLabel(AssessmentMetaDataIfc.KEYWORDS);
        this.rubrics = assessment.getAssessmentMetaDataByLabel(AssessmentMetaDataIfc.RUBRICS);
        this.bgColor = assessment.getAssessmentMetaDataByLabel(AssessmentMetaDataIfc.BGCOLOR);
        this.bgImage = assessment.getAssessmentMetaDataByLabel(AssessmentMetaDataIfc.BGIMAGE);
        if ((assessment.getAssessmentMetaDataByLabel(AssessmentMetaDataIfc.BGIMAGE) != null)
                && (!assessment.getAssessmentMetaDataByLabel(AssessmentMetaDataIfc.BGIMAGE).equals(""))) {
            this.bgImageSelect = "1";
            this.bgColorSelect = null;
        } else {
            this.bgImageSelect = null;
            this.bgColorSelect = "1";
        }

        // Get the extended time information for this assessment
        short extendedTimeCount = 1;
        String extendedTimeLabel = "extendedTime" + extendedTimeCount;
        this.extendedTimes = "";
        while ((assessment.getAssessmentMetaDataByLabel(extendedTimeLabel) != null)
                && (!assessment.getAssessmentMetaDataByLabel(extendedTimeLabel).equals(""))) {
            String extendedTimeValue = assessment.getAssessmentMetaDataByLabel(extendedTimeLabel);
            this.extendedTimes = this.extendedTimes.concat(extendedTimeValue + "^");
            extendedTimeCount++;
            extendedTimeLabel = "extendedTime" + extendedTimeCount;
        }

        // these are properties in AssessmentAccessControl
        AssessmentAccessControlIfc accessControl = null;
        accessControl = assessment.getAssessmentAccessControl();
        if (accessControl != null) {
            this.startDate = accessControl.getStartDate();
            this.dueDate = accessControl.getDueDate();
            this.retractDate = accessControl.getRetractDate();
            this.feedbackDate = accessControl.getFeedbackDate();
            // deal with releaseTo
            this.releaseTo = accessControl.getReleaseTo(); // list of String
            this.publishingTargets = getPublishingTargets();
            this.targetSelected = getTargetSelected(releaseTo);
            this.firstTargetSelected = getFirstTargetSelected(releaseTo);
            // SAK-1850 - when importing assessment forget to set releaseTo, we will catch it
            // and set it to host site
            if (!validateTarget(firstTargetSelected)) {
                releaseTo = AgentFacade.getCurrentSiteName();
                firstTargetSelected = AgentFacade.getCurrentSiteName();
                targetSelected = getTargetSelected(releaseTo);
            }
            groupsAuthorized = null;

            this.timeLimit = accessControl.getTimeLimit(); // in seconds
            if (timeLimit != null && timeLimit.intValue() > 0)
                setTimeLimitDisplay(timeLimit.intValue());
            else
                resetTimeLimitDisplay();
            if ((Integer.valueOf(1)).equals(accessControl.getTimedAssessment()))
                this.timedAssessment = true;
            if ((Integer.valueOf(1)).equals(accessControl.getAutoSubmit())) {
                this.autoSubmit = true;
            } else {
                this.autoSubmit = false;
            }
            if (accessControl.getAssessmentFormat() != null)
                this.assessmentFormat = accessControl.getAssessmentFormat().toString(); // question/part/assessment on separate page
            if (accessControl.getItemNavigation() != null)
                this.itemNavigation = accessControl.getItemNavigation().toString(); // linear or random
            if (accessControl.getItemNumbering() != null)
                this.itemNumbering = accessControl.getItemNumbering().toString();
            if (accessControl.getSubmissionsSaved() != null) // bad name, this is autoSaved
                this.submissionsSaved = accessControl.getSubmissionsSaved().toString();

            if (accessControl.getMarkForReview() != null
                    && (Integer.valueOf(1)).equals(accessControl.getMarkForReview())) {
                this.isMarkForReview = true;
            } else {
                this.isMarkForReview = false;
            }

            // default to unlimited if control value is null
            if (accessControl.getUnlimitedSubmissions() != null
                    && !accessControl.getUnlimitedSubmissions().booleanValue()) {
                this.unlimitedSubmissions = AssessmentAccessControlIfc.LIMITED_SUBMISSIONS.toString();
                this.submissionsAllowed = accessControl.getSubmissionsAllowed().toString();
            } else {
                this.unlimitedSubmissions = AssessmentAccessControlIfc.UNLIMITED_SUBMISSIONS.toString();
                this.submissionsAllowed = "";
            }
            if (accessControl.getLateHandling() != null)
                this.lateHandling = accessControl.getLateHandling().toString();
            if (accessControl.getSubmissionsSaved() != null)
                this.submissionsSaved = accessControl.getSubmissionsSaved().toString();
            this.submissionMessage = accessControl.getSubmissionMessage();
            this.username = accessControl.getUsername();
            this.password = accessControl.getPassword();
            this.finalPageUrl = accessControl.getFinalPageUrl();
        }

        // properties of AssesmentFeedback
        AssessmentFeedbackIfc feedback = assessment.getAssessmentFeedback();
        if (feedback != null) {
            if (feedback.getFeedbackDelivery() != null)
                this.feedbackDelivery = feedback.getFeedbackDelivery().toString();

            if (feedback.getFeedbackComponentOption() != null)
                this.feedbackComponentOption = feedback.getFeedbackComponentOption().toString();

            if (feedback.getFeedbackAuthoring() != null)
                this.feedbackAuthoring = feedback.getFeedbackAuthoring().toString();

            if ((Boolean.TRUE).equals(feedback.getShowQuestionText()))
                this.showQuestionText = true;
            else
                this.showQuestionText = false;

            if ((Boolean.TRUE).equals(feedback.getShowStudentResponse()))
                this.showStudentResponse = true;
            else
                this.showStudentResponse = false;

            if ((Boolean.TRUE).equals(feedback.getShowCorrectResponse()))
                this.showCorrectResponse = true;
            else
                this.showCorrectResponse = false;

            if ((Boolean.TRUE).equals(feedback.getShowStudentScore()))
                this.showStudentScore = true;
            else
                this.showStudentScore = false;

            if ((Boolean.TRUE).equals(feedback.getShowStudentQuestionScore()))
                this.showStudentQuestionScore = true;
            else
                this.showStudentQuestionScore = false;

            if ((Boolean.TRUE).equals(feedback.getShowQuestionLevelFeedback()))
                this.showQuestionLevelFeedback = true;
            else
                this.showQuestionLevelFeedback = false;

            if ((Boolean.TRUE).equals(feedback.getShowSelectionLevelFeedback()))
                this.showSelectionLevelFeedback = true;// must be MC
            else
                this.showSelectionLevelFeedback = false;

            if ((Boolean.TRUE).equals(feedback.getShowGraderComments()))
                this.showGraderComments = true;
            else
                this.showGraderComments = false;

            if ((Boolean.TRUE).equals(feedback.getShowStatistics()))
                this.showStatistics = true;
            else
                this.showStatistics = false;
        }

        // properties of EvaluationModel
        EvaluationModelIfc evaluation = assessment.getEvaluationModel();
        if (evaluation != null) {
            if (evaluation.getAnonymousGrading() != null)
                this.anonymousGrading = evaluation.getAnonymousGrading().toString().equals("1") ? true : false;
            if (evaluation.getToGradeBook() != null)
                this.toDefaultGradebook = evaluation.getToGradeBook().toString().equals("1") ? true : false;
            if (evaluation.getScoringType() != null)
                this.scoringType = evaluation.getScoringType().toString();

            String currentSiteId = AgentFacade.getCurrentSiteId();
            this.gradebookExists = gbsHelper.isGradebookExist(currentSiteId);

            this.extendedTimeTargets = initExtendedTimeTargets();

            /*
            GradebookService g = null;
            if (integrated)
            {
              g = (GradebookService) SpringBeanLocator.getInstance().
                getBean("org.sakaiproject.service.gradebook.GradebookService");
            }
                    
            this.gradebookExists = gbsHelper.gradebookExists(
               GradebookFacade.getGradebookUId(), g);
            */
        }

        // ip addresses
        this.ipAddresses = "";
        Set ipAddressSet = assessment.getSecuredIPAddressSet();
        if (ipAddressSet != null) {
            Iterator iter = ipAddressSet.iterator();
            while (iter.hasNext()) {
                SecuredIPAddressIfc ip = (SecuredIPAddressIfc) iter.next();
                if (ip.getIpAddress() != null)
                    this.ipAddresses = ip.getIpAddress() + "\n" + this.ipAddresses;
            }
        }
        // attachment
        this.attachmentList = assessment.getAssessmentAttachmentList();

        // secure delivery
        SecureDeliveryServiceAPI secureDeliveryService = SamigoApiFactory.getInstance()
                .getSecureDeliveryServiceAPI();
        this.secureDeliveryAvailable = secureDeliveryService.isSecureDeliveryAvaliable();
        this.secureDeliveryModuleSelections = getSecureDeliverModuleSelections();
        this.secureDeliveryModule = (String) assessment
                .getAssessmentMetaDataByLabel(SecureDeliveryServiceAPI.MODULE_KEY);
        this.secureDeliveryModuleExitPassword = secureDeliveryService.decryptPassword(this.secureDeliveryModule,
                (String) assessment.getAssessmentMetaDataByLabel(SecureDeliveryServiceAPI.EXITPWD_KEY));

        if (secureDeliveryModule == null || secureDeliveryModule.trim().length() == 0) {
            this.secureDeliveryModule = SecureDeliveryServiceAPI.NONE_ID;
        } else if (!secureDeliveryService.isSecureDeliveryModuleAvailable(secureDeliveryModule)) {
            log.warn("Assessment " + this.assessmentId + " requires secure delivery module "
                    + this.secureDeliveryModule
                    + " but the module is no longer available. Secure delivery module will revert to NONE");
            secureDeliveryModule = SecureDeliveryServiceAPI.NONE_ID;
        }
    } catch (RuntimeException ex) {
        ex.printStackTrace();
    }
}

From source file:gr.upatras.ece.nam.baker.repo.BakerRepositoryAPIImpl.java

@GET
@Path("/oauth2/login")
@Produces("text/html")
// @Produces("application/json")
public Response oauth2login(@QueryParam("code") String code) {

    // This one is the callback URL, which is called by the FIWARE OAUTH2 service
    logger.info(//from  w  w  w .j ava  2 s  .  c o  m
            "Received authorized request token code: " + code + ". Preparing AuthorizationCodeGrant header.");

    AuthorizationCodeGrant codeGrant = new AuthorizationCodeGrant(code, getCallbackURI());
    logger.info(
            "Requesting OAuth server accessTokenService to replace an authorized request token with an access token");
    ClientAccessToken accessToken = oAuthClientManagerRef.getAccessToken(codeGrant);
    if (accessToken == null) {
        String msg = "NO_OAUTH_ACCESS_TOKEN, Problem replacing your authorization key for OAuth access token,  please report to baker admin";
        logger.info(msg);
        return Response.status(Status.UNAUTHORIZED).entity(msg).build();
    }

    try {
        logger.info("OAUTH2 accessTokenService accessToken = " + accessToken.toString());
        String authHeader = oAuthClientManagerRef.createAuthorizationHeader(accessToken);
        logger.info("OAUTH2 accessTokenService authHeader = " + authHeader);
        logger.info("accessToken getTokenType= " + accessToken.getTokenType());
        logger.info("accessToken getTokenKey= " + accessToken.getTokenKey());
        logger.info("accessToken getRefreshToken= " + accessToken.getRefreshToken());
        logger.info("accessToken getExpiresIn= " + accessToken.getExpiresIn());

        Tenant t = FIWARECloudAccess.getFirstTenant(accessToken.getTokenKey());
        FIWAREUser fu = FIWAREUtils.getFIWAREUser(authHeader, accessToken);
        fu.setxOAuth2Token(accessToken.getTokenKey());
        fu.setTenantName(t.getName());
        fu.setTenantId(t.getId());
        fu.setCloudToken(FIWARECloudAccess.getAccessModel(t, accessToken.getTokenKey()).getToken().getId());

        // check if user exists in Baker database
        BakerUser u = bakerRepositoryRef.getUserByUsername(fu.getNickName());

        String roamPassword = UUID.randomUUID().toString(); // creating a temporary session password, to login
        if (u == null) {
            u = new BakerUser(); // create as new user
            u.setEmail(fu.getEmail());
            u.setUsername(fu.getNickName());
            ;
            u.setName(fu.getDisplayName());
            u.setOrganization("FI-WARE");
            u.setRole("SERVICE_PLATFORM_PROVIDER");
            u.setPassword(roamPassword);
            u.setCurrentSessionID(ws.getHttpServletRequest().getSession().getId());
            bakerRepositoryRef.addBakerUserToUsers(u);
        } else {
            u.setEmail(fu.getEmail());
            u.setName(fu.getDisplayName());
            u.setPassword(roamPassword);
            u.setOrganization("FI-WARE");
            u.setCurrentSessionID(ws.getHttpServletRequest().getSession().getId());
            u = bakerRepositoryRef.updateUserInfo(u.getId(), u);
        }

        UserSession userSession = new UserSession();
        userSession.setBakerUser(u);
        userSession.setPassword(roamPassword);
        userSession.setUsername(u.getUsername());
        userSession.setFIWAREUser(fu);

        Subject currentUser = SecurityUtils.getSubject();
        if (currentUser != null) {
            AuthenticationToken token = new UsernamePasswordToken(userSession.getUsername(),
                    userSession.getPassword());
            try {
                currentUser.login(token);

            } catch (AuthenticationException ae) {

                return Response.status(Status.UNAUTHORIZED).build();
            }
        }

        userSession.setPassword("");// trick so not to send in response
        ObjectMapper mapper = new ObjectMapper();

        // see https://developer.mozilla.org/en-US/docs/Web/API/Window.postMessage
        // there are CORS issues so to do this trich the popup window communicates with the parent window ia this script
        String comScript = "<script type='text/javascript'>function receiveMessage(event){"
                + "event.source.postMessage('" + mapper.writeValueAsString(userSession) + "', event.origin);"
                + "}" + "window.addEventListener('message', receiveMessage, false);" + "</script>";

        return Response.ok("<html><body><p>Succesful Login</p>" + comScript + "</body></html>"

        ).build();

    } catch (RuntimeException ex) {
        ex.printStackTrace();
        return Response.status(Status.UNAUTHORIZED).entity("USER Access problem").build();
    } catch (IOException e) {
        e.printStackTrace();
    }

    return Response.ok().build();

}

From source file:org.LexGrid.LexBIG.gui.LB_GUI.java

License:asdf

/**
 * Instantiates a new GUI with the given command arguments and the given
 * LexBIGService./*from  ww  w  . j  ava  2  s  .c  o  m*/
 * 
 * @param args
 *            Recognized arguments: -d, Disables admin options.
 * @param service
 *            The LexBIGService to invoke for GUI functions.
 * @throws LBInvocationException
 */
public LB_GUI(String[] args, LexBIGService service) throws LBInvocationException {
    isAdminEnabled = !(ArrayUtils.contains(args, "-d") || ArrayUtils.contains(args, "-D"));
    lbs_ = service != null ? service : LexBIGServiceImpl.defaultInstance();
    Display display = new Display();
    shell_ = new Shell(display);
    shell_.setText("LexBIG  " + Constants.version);
    init();

    setSizeFromPreviousRun();
    // shell_.setMaximized(true);
    shell_.open();
    try {
        while (!shell_.isDisposed()) {
            if (!display.readAndDispatch())
                display.sleep();
        }
    } catch (RuntimeException e) {
        System.err.println(e);
        e.printStackTrace();
        errorHandler.showError("ERROR", "Unhandled error, see log for details - exiting.");

    }
    display.dispose();
    System.exit(0);
}

From source file:com.newsrob.EntryManager.java

public void setMostRecentArticleAtomId(final String atomId) {
    try {/*from w  w  w  .  j a va 2s .c  om*/
        singleValueStore.putString("current_article", atomId.substring(33));
    } catch (RuntimeException re) {
        re.printStackTrace();
    }
}

From source file:org.sakaiproject.tool.assessment.ui.bean.questionpool.QuestionPoolBean.java

public void getCheckedPool() {
    try {/* ww w.ja v a 2  s .co  m*/
        QuestionPoolDataBean pool = new QuestionPoolDataBean();

        String qpid = (String) FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap()
                .get("qpid");
        if ((qpid != null) && (!qpid.equals("null"))) {
            pool.setId(new Long(qpid));
        } else {
            // This should not ococur.  It should always have an id.
            return;
        }

        // Get all data from the database
        QuestionPoolService delegate = new QuestionPoolService();

        // Does the user have permission to copy or move this pool?
        List<Long> poolsWithAccess = delegate.getPoolIdsByAgent(AgentFacade.getAgentString());
        if (!poolsWithAccess.contains(pool.getId())) {
            throw new IllegalArgumentException("User " + AgentFacade.getAgentString()
                    + " does not have access to question pool id " + pool.getId() + " for move or copy");
        }

        QuestionPoolFacade thepool = delegate.getPool(new Long(qpid), AgentFacade.getAgentString());
        tree.setCurrentId(thepool.getQuestionPoolId());

        pool.setDisplayName(thepool.getDisplayName());
        pool.setParentPoolId(thepool.getParentPoolId());
        pool.setDescription(thepool.getDescription());
        pool.setOwner(thepool.getOwnerDisplayName());
        //pool.setOwner(thepool.getOwnerId());
        pool.setObjectives(thepool.getObjectives());
        pool.setKeywords(thepool.getKeywords());
        pool.setOrganizationName(thepool.getOrganizationName());
        //          pool.setProperties((QuestionPoolData) thepool.getData());
        // TODO  which one should I use?
        //          pool.setNumberOfSubpools(
        //            new Integer(tree.getChildList(thepool.getQuestionPoolId()).size()).toString());
        pool.setNumberOfSubpools(thepool.getSubPoolSize().toString());
        pool.setNumberOfQuestions(thepool.getQuestionSize().toString());
        //pool.setDateCreated(thepool.getDateCreated());

        pool.setLastModified(new Date());

        this.setCurrentPool(pool);
    } catch (RuntimeException e) {
        e.printStackTrace();
        throw e;
    }

}

From source file:com.connectsdk.service.NetcastTVService.java

public String decToHex(String dec) {
    if (dec != null && dec.length() > 0) {
        try {/*from   ww  w. j a  v  a 2 s  .  c  om*/
            return decToHex(Long.parseLong(dec.trim()));
        } catch (RuntimeException e) {
            e.printStackTrace();
        }
    }
    return null;
}