Example usage for java.lang Boolean getBoolean

List of usage examples for java.lang Boolean getBoolean

Introduction

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

Prototype

public static boolean getBoolean(String name) 

Source Link

Document

Returns true if and only if the system property named by the argument exists and is equal to, ignoring case, the string "true" .

Usage

From source file:org.artifactory.spring.ArtifactoryApplicationContext.java

@Override
public void destroy() {
    setReady(false);/*from w ww.  j  ava 2  s .c om*/
    ArtifactoryContextThreadBinder.bind(this);
    ArtifactoryHome.bind(getArtifactoryHome());
    try {
        try {
            if (reloadableBeans != null && !reloadableBeans.isEmpty()) {
                // TODO[By Gidi] find better way to update the ArtifactoryStateManager on beforeDestroy event
                beanForType(ArtifactoryStateManager.class).beforeDestroy();
                log.debug("Destroying beans: {}", reloadableBeans);
                for (int i = reloadableBeans.size() - 1; i >= 0; i--) {
                    ReloadableBean bean = reloadableBeans.get(i);
                    String beanIfc = getInterfaceName(bean);
                    log.info("Destroying {}", beanIfc);
                    try {
                        bean.destroy();
                    } catch (Exception e) {
                        if (log.isDebugEnabled() || Boolean.getBoolean(ConstantValues.test.getPropertyName())) {
                            log.error("Exception while destroying bean '" + beanIfc + "'.", e);
                        } else {
                            log.error("Exception while destroying {} ({}).", beanIfc, e.getMessage());
                        }
                    }
                    log.debug("Destroyed {}", beanIfc);
                }
            }
        } finally {
            super.destroy();
        }
    } finally {
        ArtifactoryContextThreadBinder.unbind();
        ArtifactoryHome.unbind();
    }
}

From source file:org.ngrinder.infra.AgentConfig.java

public boolean isSilentMode() {
    final PropertiesWrapper properties = getCommonProperties();
    if (properties == null) {
        return Boolean.getBoolean(System.getProperty(PROP_COMMON_SILENT_MODE, "false"));
    } else {//from   w  w  w.  j  av  a  2s  . c  o  m
        return properties.getPropertyBoolean(PROP_COMMON_SILENT_MODE);
    }
}

From source file:hermes.impl.DefaultXMLHelper.java

public Message createMessage(MessageFactory hermes, XMLMessage message)
        throws JMSException, IOException, ClassNotFoundException, DecoderException {
    try {//from   w  w  w . j ava  2  s .c  o  m
        Message rval = hermes.createMessage();

        if (message instanceof XMLTextMessage) {
            rval = hermes.createTextMessage();

            XMLTextMessage textMessage = (XMLTextMessage) message;
            TextMessage textRval = (TextMessage) rval;

            if (BASE64_CODEC.equals(textMessage.getCodec())) {
                byte[] bytes = base64EncoderTL.get().decode(textMessage.getText().getBytes());
                textRval.setText(new String(bytes, "ASCII"));
            } else {
                textRval.setText(textMessage.getText());
            }
        } else if (message instanceof XMLMapMessage) {
            rval = hermes.createMapMessage();

            XMLMapMessage mapMessage = (XMLMapMessage) message;
            MapMessage mapRval = (MapMessage) rval;

            for (Iterator iter = mapMessage.getBodyProperty().iterator(); iter.hasNext();) {
                final Property property = (Property) iter.next();

                if (property.getValue() == null) {
                    mapRval.setObject(property.getName(), null);
                } else if (property.getType().equals(String.class.getName())) {
                    mapRval.setString(property.getName(), property.getValue());
                } else if (property.getType().equals(Long.class.getName())) {
                    mapRval.setLong(property.getName(), Long.parseLong(property.getValue()));
                } else if (property.getType().equals(Double.class.getName())) {
                    mapRval.setDouble(property.getName(), Double.parseDouble(property.getValue()));
                } else if (property.getType().equals(Boolean.class.getName())) {
                    mapRval.setBoolean(property.getName(), Boolean.getBoolean(property.getValue()));
                } else if (property.getType().equals(Character.class.getName())) {
                    mapRval.setChar(property.getName(), property.getValue().charAt(0));
                } else if (property.getType().equals(Short.class.getName())) {
                    mapRval.setShort(property.getName(), Short.parseShort(property.getValue()));
                } else if (property.getType().equals(Integer.class.getName())) {
                    mapRval.setInt(property.getName(), Integer.parseInt(property.getValue()));
                }
            }
        } else if (message instanceof XMLBytesMessage) {
            rval = hermes.createBytesMessage();

            XMLBytesMessage bytesMessage = (XMLBytesMessage) message;
            BytesMessage bytesRval = (BytesMessage) rval;

            bytesRval.writeBytes(base64EncoderTL.get().decode(bytesMessage.getBytes().getBytes()));
        } else if (message instanceof XMLObjectMessage) {
            rval = hermes.createObjectMessage();

            XMLObjectMessage objectMessage = (XMLObjectMessage) message;
            ObjectMessage objectRval = (ObjectMessage) rval;
            ByteArrayInputStream bistream = new ByteArrayInputStream(
                    base64EncoderTL.get().decode(objectMessage.getObject().getBytes()));

            ObjectInputStream oistream = new ObjectInputStream(bistream);

            objectRval.setObject((Serializable) oistream.readObject());
        }

        //
        // JMS Header properties

        try {
            rval.setJMSDeliveryMode(message.getJMSDeliveryMode());
        } catch (JMSException ex) {
            log.error("unable to set JMSDeliveryMode to " + message.getJMSDeliveryMode() + ": "
                    + ex.getMessage());
        }

        try {
            rval.setJMSMessageID(message.getJMSMessageID());
        } catch (JMSException ex) {
            log.error("unable to set JMSMessageID: " + ex.getMessage(), ex);
        }

        try {
            if (message.getJMSExpiration() != null) {
                rval.setJMSExpiration(message.getJMSExpiration());
            }
        } catch (JMSException ex) {
            log.error("unable to set JMSExpiration: " + ex.getMessage(), ex);
        }

        try {
            if (message.getJMSPriority() != null) {
                rval.setJMSPriority(message.getJMSPriority());
            }
        } catch (JMSException ex) {
            log.error("unable to set JMSPriority: " + ex.getMessage(), ex);
        }

        try {
            if (message.getJMSTimestamp() != null) {
                rval.setJMSTimestamp(message.getJMSTimestamp());
            }
        } catch (JMSException ex) {
            log.error("unable to set JMSTimestamp:" + ex.getMessage(), ex);
        }

        if (message.getJMSCorrelationID() != null) {
            rval.setJMSCorrelationID(message.getJMSCorrelationID());
        }

        if (message.getJMSReplyTo() != null && !message.getJMSReplyTo().equals("null")) {
            rval.setJMSReplyTo(hermes.getDestination(message.getJMSReplyTo(),
                    Domain.getDomain(message.getJMSReplyToDomain())));
        }

        if (message.getJMSType() != null) {
            rval.setJMSType(message.getJMSType());
        }

        if (message.getJMSDestination() != null) {
            if (message.isFromQueue()) {
                rval.setJMSDestination(hermes.getDestination(message.getJMSDestination(), Domain.QUEUE));
            } else {
                rval.setJMSDestination(hermes.getDestination(message.getJMSDestination(), Domain.TOPIC));
            }
        }

        for (Iterator iter = message.getHeaderProperty().iterator(); iter.hasNext();) {
            Property property = (Property) iter.next();

            if (property.getValue() == null) {
                rval.setObjectProperty(property.getName(), null);
            } else if (property.getType().equals(String.class.getName())) {
                rval.setStringProperty(property.getName(), StringEscapeUtils.unescapeXml(property.getValue()));
            } else if (property.getType().equals(Long.class.getName())) {
                rval.setLongProperty(property.getName(), Long.parseLong(property.getValue()));
            } else if (property.getType().equals(Double.class.getName())) {
                rval.setDoubleProperty(property.getName(), Double.parseDouble(property.getValue()));
            } else if (property.getType().equals(Boolean.class.getName())) {
                rval.setBooleanProperty(property.getName(), Boolean.parseBoolean(property.getValue()));
            } else if (property.getType().equals(Short.class.getName())) {
                rval.setShortProperty(property.getName(), Short.parseShort(property.getValue()));
            } else if (property.getType().equals(Integer.class.getName())) {
                rval.setIntProperty(property.getName(), Integer.parseInt(property.getValue()));
            }
        }

        return rval;
    } catch (NamingException e) {
        throw new HermesException(e);
    }

}

From source file:org.dataone.proto.trove.mn.rest.v1.ObjectController.java

/**
 *
 *//*w  ww . ja v a 2  s  . c  o m*/
@RequestMapping(value = { "/v1/object", "/v1/object/" }, method = RequestMethod.GET)
public ModelAndView search(HttpServletRequest request, HttpServletResponse response)
        throws NotAuthorized, InvalidRequest, NotImplemented, ServiceFailure, InvalidToken {
    debugRequest(request);

    Session cert = new Session();
    Integer start = 0;
    Integer count = 1000;
    ObjectFormatIdentifier format = null;
    String startTime = null;
    String endTime = null;
    Boolean replica = null;
    DateTime startDate = null;
    DateTime endDate = null;
    if (request.getParameterMap().keySet().contains("start")) {
        String[] values = (String[]) request.getParameterMap().get("start");
        start = Integer.parseInt(values[0]);
    }
    if (request.getParameterMap().keySet().contains("count")) {
        String[] values = (String[]) request.getParameterMap().get("count");
        count = Integer.parseInt(values[0]);
    }
    if (request.getParameterMap().keySet().contains("replicaStatus")) {
        String[] values = (String[]) request.getParameterMap().get("replicaStatus");
        replica = Boolean.getBoolean(values[0]);

    }
    if (request.getParameterMap().keySet().contains("format")) {
        String[] values = (String[]) request.getParameterMap().get("format");
        format = new ObjectFormatIdentifier();
        format.setValue(values[0]);
    }
    if (request.getParameterMap().keySet().contains("startTime")) {
        String[] values = (String[]) request.getParameterMap().get("startTime");
        startTime = values[0];
    }
    if (request.getParameterMap().keySet().contains("endTime")) {
        String[] values = (String[]) request.getParameterMap().get("endTime");
        endTime = values[0];
    }
    LogEntry logEntry = new LogEntry();
    d1Log.add(logEntry);
    //d1Log.put("search", "start = " + start + " count = " + count + " format = " + (format == null ? "null" : format.getValue()) + " startTime = " + startTime + " endTime = " + endTime);
    logger.info("start = " + start + " count = " + count + " format = "
            + (format == null ? "null" : format.getValue()) + " startTime = " + startTime + " endTime = "
            + endTime);
    if (!((startTime == null) && (endTime == null))) {
        if (startTime == null) {
            startTime = "1900-01-01T00:00:00Z";
        }
        if (endTime == null) {
            endTime = new DateTime().toString();
        }
        startDate = new DateTime(startTime, DateTimeZone.UTC);
        endDate = new DateTime(endTime, DateTimeZone.UTC);
    }
    ObjectList objectList = mnRead.listObjects(cert, (startDate == null ? null : startDate.toDate()),
            (endDate == null ? null : endDate.toDate()), format, replica, start, count);
    return new ModelAndView("xmlObjectListViewResolver", "org.dataone.service.types.v1.ObjectList", objectList);
}

From source file:org.sakaiproject.tool.assessment.ui.listener.author.ConfirmPublishAssessmentListener.java

public void processAction(ActionEvent ae) throws AbortProcessingException {
    FacesContext context = FacesContext.getCurrentInstance();
    ExternalContext extContext = context.getExternalContext();
    AssessmentSettingsBean assessmentSettings = (AssessmentSettingsBean) ContextUtil
            .lookupBean("assessmentSettings");
    AssessmentBean assessmentBean = (AssessmentBean) ContextUtil.lookupBean("assessmentBean");
    AuthorBean author = (AuthorBean) ContextUtil.lookupBean("author");
    //#1 - permission checking before proceeding - daisyf
    String assessmentId = String.valueOf(assessmentSettings.getAssessmentId());
    SaveAssessmentSettings s = new SaveAssessmentSettings();
    AssessmentService assessmentService = new AssessmentService();
    AssessmentFacade assessment = assessmentService.getAssessment(assessmentId);

    // Check permissions
    AuthorizationBean authzBean = (AuthorizationBean) ContextUtil.lookupBean("authorization");
    if (!authzBean.isUserAllowedToPublishAssessment(assessmentId, assessment.getCreatedBy(), false)) {
        String err = (String) ContextUtil.getLocalizedString(
                "org.sakaiproject.tool.assessment.bundle.AuthorMessages", "denied_publish_assessment_error");
        context.addMessage(null, new FacesMessage(err));
        assessmentSettings.setOutcomePublish("editAssessmentSettings");
        author.setIsErrorInSettings(true);
        return;/*w ww . j a  v a  2  s .c  o  m*/
    }

    assessmentBean.setAssessment(assessment);

    // Only if the assessment already have question, this page will be excuted
    assessmentSettings.setHasQuestions(true);

    //proceed to look for error, save assessment setting and confirm publish
    //#2a - look for error: check if core assessment title is unique
    boolean error = false;

    String assessmentName = TextFormat.convertPlaintextToFormattedTextNoHighUnicode(log,
            assessmentSettings.getTitle());
    if (assessmentName != null && (assessmentName.trim()).equals("")) {
        String nameEmpty_err = ContextUtil.getLocalizedString(
                "org.sakaiproject.tool.assessment.bundle.AssessmentSettingsMessages", "assessmentName_empty");
        context.addMessage(null, new FacesMessage(nameEmpty_err));
        error = true;
    }
    if (!assessmentService.assessmentTitleIsUnique(assessmentId, assessmentName, false)) {
        String nameUnique_err = ContextUtil.getLocalizedString(
                "org.sakaiproject.tool.assessment.bundle.AssessmentSettingsMessages", "assessmentName_error");
        context.addMessage(null, new FacesMessage(nameUnique_err));
        error = true;
    }

    // check if start date is valid
    if (!assessmentSettings.getIsValidStartDate()) {
        String startDateErr = ContextUtil.getLocalizedString(
                "org.sakaiproject.tool.assessment.bundle.GeneralMessages", "invalid_start_date");
        context.addMessage(null, new FacesMessage(startDateErr));
        error = true;
    }
    // check if due date is valid
    if (!assessmentSettings.getIsValidDueDate()) {
        String dueDateErr = ContextUtil.getLocalizedString(
                "org.sakaiproject.tool.assessment.bundle.GeneralMessages", "invalid_due_date");
        context.addMessage(null, new FacesMessage(dueDateErr));
        error = true;
    }
    // check if late submission date is valid
    if (!assessmentSettings.getIsValidRetractDate()) {
        String retractDateErr = ContextUtil.getLocalizedString(
                "org.sakaiproject.tool.assessment.bundle.GeneralMessages", "invalid_retrack_date");
        context.addMessage(null, new FacesMessage(retractDateErr));
        error = true;
    }

    Date startDate = assessmentSettings.getStartDate();
    Date dueDate = assessmentSettings.getDueDate();
    Date retractDate = assessmentSettings.getRetractDate();
    boolean isRetractEarlierThanAvaliable = false;
    if ((dueDate != null && startDate != null && dueDate.before(startDate))
            || (dueDate != null && startDate == null && dueDate.before(new Date()))) {
        String dateError1 = ContextUtil.getLocalizedString(
                "org.sakaiproject.tool.assessment.bundle.AssessmentSettingsMessages",
                "due_earlier_than_avaliable");
        context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_WARN, dateError1, null));
        error = true;
        assessmentSettings.setStartDate(new Date());
    }
    if (assessmentSettings.getLateHandling() != null && AssessmentAccessControlIfc.ACCEPT_LATE_SUBMISSION
            .toString().equals(assessmentSettings.getLateHandling())) {
        if ((retractDate != null && startDate != null && retractDate.before(startDate))
                || (retractDate != null && startDate == null && retractDate.before(new Date()))) {
            String dateError2 = ContextUtil.getLocalizedString(
                    "org.sakaiproject.tool.assessment.bundle.AssessmentSettingsMessages",
                    "retract_earlier_than_avaliable");
            context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_WARN, dateError2, null));
            error = true;
            isRetractEarlierThanAvaliable = true;
            assessmentSettings.setStartDate(new Date());
        }
        if (!isRetractEarlierThanAvaliable
                && (retractDate != null && dueDate != null && retractDate.before(dueDate))) {
            String dateError3 = ContextUtil.getLocalizedString(
                    "org.sakaiproject.tool.assessment.bundle.AssessmentSettingsMessages",
                    "retract_earlier_than_due");
            context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_WARN, dateError3, null));
            error = true;
        }
    }

    // SAM-1088
    // if late submissions not allowed and late submission date is null, set late submission date to due date
    if (assessmentSettings.getLateHandling() != null
            && AssessmentAccessControlIfc.NOT_ACCEPT_LATE_SUBMISSION.toString()
                    .equals(assessmentSettings.getLateHandling())
            && retractDate == null && dueDate != null && assessmentSettings.getAutoSubmit()) {
        boolean autoSubmitEnabled = ServerConfigurationService.getBoolean("samigo.autoSubmit.enabled", false);
        if (autoSubmitEnabled) {
            retractDate = dueDate;
            assessmentSettings.setRetractDate(dueDate);
        }
    }
    // if auto-submit is enabled, make sure late submission date is set
    if (assessmentSettings.getAutoSubmit() && retractDate == null) {
        boolean autoSubmitEnabled = ServerConfigurationService.getBoolean("samigo.autoSubmit.enabled", false);
        if (autoSubmitEnabled) {
            String dateError4 = ContextUtil.getLocalizedString(
                    "org.sakaiproject.tool.assessment.bundle.AssessmentSettingsMessages",
                    "retract_required_with_auto_submit");
            context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_WARN, dateError4, null));
            error = true;
        }
    }

    if (!isFromActionSelect) {
        if (assessmentSettings.getReleaseTo().equals(AssessmentAccessControl.RELEASE_TO_SELECTED_GROUPS)) {
            String[] groupsAuthorized = assessmentSettings.getGroupsAuthorized(); //getGroupsAuthorized();
            if (groupsAuthorized == null || groupsAuthorized.length == 0) {
                String releaseGroupError = ContextUtil.getLocalizedString(
                        "org.sakaiproject.tool.assessment.bundle.GeneralMessages", "choose_one_group");
                context.addMessage(null, new FacesMessage(releaseGroupError));
                error = true;
                assessmentSettings.setNoGroupSelectedError(true);
            } else {
                assessmentSettings.setNoGroupSelectedError(false);
            }
        }

        //#2c - validate if this is a time assessment, is there a time entry?
        Object time = assessmentSettings.getValueMap().get("hasTimeAssessment");
        boolean isTime = false;
        if (time != null) {
            // Because different flow might get different type, we test it before cast.
            if (time instanceof java.lang.String) {
                isTime = Boolean.getBoolean((String) time);
            } else if (time instanceof java.lang.Boolean) {
                isTime = ((Boolean) time).booleanValue();
            }
        }

        if ((isTime) && ((assessmentSettings.getTimeLimit().intValue()) == 0)) {
            String time_err = ContextUtil.getLocalizedString(
                    "org.sakaiproject.tool.assessment.bundle.AssessmentSettingsMessages", "timeSelect_error");
            context.addMessage(null, new FacesMessage(time_err));
            error = true;
        }
        boolean ipErr = false;
        String ipString = assessmentSettings.getIpAddresses().trim();
        String[] arraysIp = (ipString.split("\n"));
        //System.out.println("arraysIp.length: "+arraysIp.length);
        for (int a = 0; a < arraysIp.length; a++) {
            String currentString = arraysIp[a];
            if (!currentString.trim().equals("")) {
                if (a < (arraysIp.length - 1))
                    currentString = currentString.substring(0, currentString.length() - 1);
                if (!s.isIpValid(currentString)) {
                    ipErr = true;
                    break;
                }
            }

        }
        if (ipErr) {
            error = true;
            String ip_err = ContextUtil.getLocalizedString(
                    "org.sakaiproject.tool.assessment.bundle.AssessmentSettingsMessages", "ip_error");
            context.addMessage(null, new FacesMessage(ip_err));
        }

        String unlimitedSubmissions = assessmentSettings.getUnlimitedSubmissions();
        if (unlimitedSubmissions != null
                && unlimitedSubmissions.equals(AssessmentAccessControlIfc.LIMITED_SUBMISSIONS.toString())) {
            String submissionsAllowed = assessmentSettings.getSubmissionsAllowed().trim();
            try {
                int submissionAllowed = Integer.parseInt(submissionsAllowed);
                if (submissionAllowed < 1) {
                    throw new RuntimeException();
                }
            } catch (RuntimeException e) {
                error = true;
                String submission_err = ContextUtil.getLocalizedString(
                        "org.sakaiproject.tool.assessment.bundle.AssessmentSettingsMessages",
                        "submissions_allowed_error");
                context.addMessage(null, new FacesMessage(submission_err));
            }
        }

        String scoringType = assessmentSettings.getScoringType();
        if ((scoringType).equals(EvaluationModelIfc.AVERAGE_SCORE.toString())
                && "0".equals(assessmentSettings.getUnlimitedSubmissions())) {
            try {
                String submissionsAllowed = assessmentSettings.getSubmissionsAllowed().trim();
                int submissionAllowed = Integer.parseInt(submissionsAllowed);
                if (submissionAllowed < 2) {
                    throw new RuntimeException();
                }
            } catch (RuntimeException e) {
                error = true;
                String submission_err = ContextUtil.getLocalizedString(
                        "org.sakaiproject.tool.assessment.bundle.AssessmentSettingsMessages",
                        "averag_grading_single_submission");
                context.addMessage(null, new FacesMessage(submission_err));
            }
        }

        //check feedback - if at specific time then time should be defined.
        if ((assessmentSettings.getFeedbackDelivery()).equals("2")
                && ((assessmentSettings.getFeedbackDateString() == null)
                        || (assessmentSettings.getFeedbackDateString().equals("")))) {
            error = true;
            String date_err = ContextUtil.getLocalizedString(
                    "org.sakaiproject.tool.assessment.bundle.AssessmentSettingsMessages", "date_error");
            context.addMessage(null, new FacesMessage(date_err));
        }
    } else {
        if (assessmentSettings.getReleaseTo().equals(AssessmentAccessControl.RELEASE_TO_SELECTED_GROUPS)) {
            String[] groupsAuthorized = assessmentSettings.getGroupsAuthorized(); //populate groupsAuthorized;
            if (groupsAuthorized == null || groupsAuthorized.length == 0) {
                String releaseGroupError = ContextUtil.getLocalizedString(
                        "org.sakaiproject.tool.assessment.bundle.GeneralMessages", "choose_release_to");
                context.addMessage(null, new FacesMessage(releaseGroupError));
                error = true;
                assessmentSettings.setNoGroupSelectedError(true);
            } else {
                assessmentSettings.setNoGroupSelectedError(false);
            }
        }
    }

    //Gradebook right now only excep if total score >0 check if total score<=0 then throw error.
    if (assessmentSettings.getToDefaultGradebook()) {
        if (assessmentBean.getTotalScore() <= 0) {
            String gb_err = (String) ContextUtil.getLocalizedString(
                    "org.sakaiproject.tool.assessment.bundle.AuthorMessages", "gradebook_exception_min_points");
            context.addMessage(null, new FacesMessage(gb_err));
            error = true;
        }
    }

    //#2b - check if gradebook exist, if so, if assessment title already exists in GB
    GradebookExternalAssessmentService g = null;
    if (integrated) {
        g = (GradebookExternalAssessmentService) SpringBeanLocator.getInstance()
                .getBean("org.sakaiproject.service.gradebook.GradebookExternalAssessmentService");
    }
    try {
        if (assessmentSettings.getToDefaultGradebook()
                && gbsHelper.isAssignmentDefined(assessmentSettings.getTitle(), g)) {
            String gbConflict_err = ContextUtil.getLocalizedString(
                    "org.sakaiproject.tool.assessment.bundle.AssessmentSettingsMessages", "gbConflict_error");
            context.addMessage(null, new FacesMessage(gbConflict_err));
            error = true;
        }
    } catch (Exception e) {
        log.warn("external assessment in GB has the same title:" + e.getMessage());
    }

    if (!isFromActionSelect) {
        // To convertFormattedTextToPlaintext for the fields that have been through convertPlaintextToFormattedTextNoHighUnicode
        assessmentSettings
                .setTitle(FormattedText.convertFormattedTextToPlaintext(assessmentSettings.getTitle()));
        assessmentSettings
                .setAuthors(FormattedText.convertFormattedTextToPlaintext(assessmentSettings.getAuthors()));
        assessmentSettings.setFinalPageUrl(
                FormattedText.convertFormattedTextToPlaintext(assessmentSettings.getFinalPageUrl()));
        assessmentSettings
                .setBgColor(FormattedText.convertFormattedTextToPlaintext(assessmentSettings.getBgColor()));
        assessmentSettings
                .setBgImage(FormattedText.convertFormattedTextToPlaintext(assessmentSettings.getBgImage()));
        assessmentSettings
                .setKeywords(FormattedText.convertFormattedTextToPlaintext(assessmentSettings.getKeywords()));
        assessmentSettings.setObjectives(
                FormattedText.convertFormattedTextToPlaintext(assessmentSettings.getObjectives()));
        assessmentSettings
                .setRubrics(FormattedText.convertFormattedTextToPlaintext(assessmentSettings.getRubrics()));
        assessmentSettings
                .setUsername(FormattedText.convertFormattedTextToPlaintext(assessmentSettings.getUsername()));
        assessmentSettings
                .setPassword(FormattedText.convertFormattedTextToPlaintext(assessmentSettings.getPassword()));
    }

    if (error) {
        assessmentSettings.setOutcomePublish("editAssessmentSettings");
        author.setIsErrorInSettings(true);
        return;
    }

    //#3 now u can proceed to save core assessment
    if (!isFromActionSelect) {
        assessment = s.save(assessmentSettings, true);

        //unEscape the TextFormat.convertPlaintextToFormattedTextNoHighUnicode in s.save()
        assessment.setTitle(FormattedText.convertFormattedTextToPlaintext(assessment.getTitle()));
        assessmentSettings.setAssessment(assessment);
    }

    //  we need a publishedUrl, this is the url used by anonymous user
    String releaseTo = assessment.getAssessmentAccessControl().getReleaseTo();
    if (releaseTo != null) {
        // generate an alias to the pub assessment
        String alias = AgentFacade.getAgentString() + (new Date()).getTime();
        assessmentSettings.setAlias(alias);
        //log.info("servletPath=" + extContext.getRequestServletPath());
        String server = ((javax.servlet.http.HttpServletRequest) extContext.getRequest()).getRequestURL()
                .toString();
        int index = server.indexOf(extContext.getRequestContextPath() + "/"); // "/samigo-app/"
        server = server.substring(0, index);
        //log.info("servletPath=" + server);
        String url = server + extContext.getRequestContextPath();
        assessmentSettings.setPublishedUrl(url + "/servlet/Login?id=" + alias);
    }

    //#4 - before going to confirm publishing, check if the title is unique
    PublishedAssessmentService publishedService = new PublishedAssessmentService();
    if (!publishedService.publishedAssessmentTitleIsUnique(assessmentId, assessmentName)) {
        String err = ContextUtil.getLocalizedString(
                "org.sakaiproject.tool.assessment.bundle.AssessmentSettingsMessages",
                "published_assessment_title_not_unique_error");
        context.addMessage(null, new FacesMessage(err));
        assessmentSettings.setOutcomePublish("editAssessmentSettings");
        author.setIsErrorInSettings(true);
        return;
    }

    //#4 - regenerate the core assessment list in autor bean again
    // sortString can be of these value:title,releaseTo,dueDate,startDate
    // get the managed bean, author and reset the list.
    // Yes, we need to do that just in case the user change those delivery
    // dates and turning an inactive pub to active pub and then go back to assessment list page
    ArrayList assessmentList = assessmentService
            .getBasicInfoOfAllActiveAssessments(author.getCoreAssessmentOrderBy(), author.isCoreAscending());
    // get the managed bean, author and set the list
    author.setAssessments(assessmentList);

    PublishRepublishNotificationBean publishRepublishNotification = (PublishRepublishNotificationBean) ContextUtil
            .lookupBean("publishRepublishNotification");
    publishRepublishNotification.setSendNotification(false);
    publishRepublishNotification.setPrePopulateText(ContextUtil.getLocalizedString(
            "org.sakaiproject.tool.assessment.bundle.AssessmentSettingsMessages", "pre_populate_text_publish"));
    assessmentSettings.setOutcomePublish("saveSettingsAndConfirmPublish"); // finally goto confirm
    SetFromPageAsAuthorSettingsListener setFromPageAsAuthorSettingsListener = new SetFromPageAsAuthorSettingsListener();
    setFromPageAsAuthorSettingsListener.processAction(null);
}

From source file:org.wso2.carbon.governance.lcm.internal.LifeCycleServiceImpl.java

private LCStateBean getCheckListItems(Resource artifactResource, String artifactLC, String[] roleNames,
        UserRegistry registry) throws RegistryException {

    String artifactLCState = artifactResource.getProperty("registry.lifecycle." + artifactLC + ".state");

    LCStateBean lifeCycleStateBean = new LCStateBean();
    if (artifactLCState == null) {
        return lifeCycleStateBean;
    }//from w  w w. j  ava  2  s.  co  m
    lifeCycleStateBean.setLifeCycleName(artifactLC);
    lifeCycleStateBean.setLifeCycleState(artifactLCState);

    List<LifeCycleCheckListItemBean> checkListItemList = new ArrayList<>();
    List<LifeCycleApprovalBean> lifeCycleApprovalBeanList = new ArrayList<>();

    String[] aspectActions = registry.getAspectActions(artifactResource.getPath(), artifactLC);
    if (aspectActions != null && aspectActions.length > 0) {
        LifeCycleActionsBean lifecycleActionsEntry = new LifeCycleActionsBean();
        lifecycleActionsEntry.setLifecycle(artifactLC);
        lifecycleActionsEntry.setActions(aspectActions);
        lifeCycleStateBean.setLifeCycleActionsBean(lifecycleActionsEntry);
    }

    Properties lifecycleProps = artifactResource.getProperties();

    List<String> permissionList = new ArrayList();
    List<String> approvePermissionList = new ArrayList();

    Map<String, List<LifeCycleInputBean>> lifeCycleInputBeanMap = new HashMap();

    Set propertyKeys = lifecycleProps.keySet();

    for (Object propertyObj : propertyKeys) {
        String propertyKey = (String) propertyObj;
        String checkListPrefix = "registry.custom_lifecycle.checklist.";
        String permissionSuffix = ".item.permission";

        String votePrefix = "registry.custom_lifecycle.votes.";
        String votePermissionSuffix = ".vote.permission";
        if (propertyKey.startsWith(checkListPrefix) && propertyKey.endsWith(permissionSuffix)
                && propertyKey.contains(GovernanceConstants.LIFECYCLE_PROPERTY_SEPERATOR + artifactLC
                        + GovernanceConstants.LIFECYCLE_PROPERTY_SEPERATOR)) {
            for (String role : roleNames) {
                List<String> propValues = (List<String>) lifecycleProps.get(propertyKey);
                for (String propValue : propValues) {
                    String key = propertyKey.replace(checkListPrefix, "").replace(permissionSuffix, "");
                    if (propValue.equals(role)) {
                        permissionList.add(key);
                    } else if (propValue.startsWith(checkListPrefix) && propValue.endsWith(permissionSuffix)) {
                        permissionList.add(key);
                    }
                }
            }
        }
        if (propertyKey.startsWith(votePrefix) && propertyKey.endsWith(votePermissionSuffix)
                && propertyKey.contains(GovernanceConstants.LIFECYCLE_PROPERTY_SEPERATOR + artifactLC
                        + GovernanceConstants.LIFECYCLE_PROPERTY_SEPERATOR)) {
            for (String role : roleNames) {
                List<String> propValues = (List<String>) lifecycleProps.get(propertyKey);
                for (String propValue : propValues) {
                    String key = propertyKey.replace(votePrefix, "").replace(votePermissionSuffix, "");
                    if (propValue.equals(role)) {
                        approvePermissionList.add(key);
                    } else if (propValue.startsWith(votePrefix) && propValue.endsWith(votePermissionSuffix)) {
                        approvePermissionList.add(key);
                    }
                }
            }
        }
    }
    String lifecyleInputs = REGISTRY_CUSTOM_LIFECYCLE_INPUTS;
    for (Object key : lifecycleProps.keySet()) {
        if (key.toString().startsWith(lifecyleInputs + artifactLC + "." + artifactLCState)) {
            List<String> propValues = (List<String>) lifecycleProps.get(key);
            LifeCycleInputBean lifeCycleInputBean = new LifeCycleInputBean();
            lifeCycleInputBean.setName(propValues.get(1));
            lifeCycleInputBean.setRequired(Boolean.getBoolean(propValues.get(2)));
            lifeCycleInputBean.setLabel(propValues.get(3));
            lifeCycleInputBean.setPlaceHolder(propValues.get(4));
            lifeCycleInputBean.setTooltip(propValues.get(5));
            lifeCycleInputBean.setRegex(propValues.get(6));
            List<LifeCycleInputBean> lifeCycleInputBeanList = lifeCycleInputBeanMap.get(propValues.get(0));
            if (lifeCycleInputBeanList == null) {
                lifeCycleInputBeanList = new ArrayList<LifeCycleInputBean>();
            }
            lifeCycleInputBeanList.add(lifeCycleInputBean);
            lifeCycleInputBeanMap.put(propValues.get(0), lifeCycleInputBeanList);
        }
    }

    for (Object propertyObj : propertyKeys) {
        String propertyKey = (String) propertyObj;

        String checkListPrefix = "registry.custom_lifecycle.checklist.";
        String checkListSuffix = ".item";

        String prefixVote = "registry.custom_lifecycle.votes.";
        String suffixVote = ".vote";

        if (propertyKey.startsWith(checkListPrefix) && propertyKey.endsWith(checkListSuffix)
                && propertyKey.contains(GovernanceConstants.LIFECYCLE_PROPERTY_SEPERATOR + artifactLC
                        + GovernanceConstants.LIFECYCLE_PROPERTY_SEPERATOR)) {
            List<String> propValues = (List<String>) lifecycleProps.get(propertyKey);
            LifeCycleCheckListItemBean checkListItem = new LifeCycleCheckListItemBean();
            if (propValues != null && propValues.size() > 2) {
                for (String param : propValues) {
                    if ((param.startsWith("status:"))) {
                        checkListItem.setStatus(param.substring(7));
                    } else if ((param.startsWith("name:"))) {
                        checkListItem.setName(param.substring(5));
                    } else if ((param.startsWith("value:"))) {
                        checkListItem.setValue(Boolean.parseBoolean(param.substring(6)));
                    } else if ((param.startsWith("order:"))) {
                        checkListItem.setOrder(Integer.parseInt(param.substring(6)));
                    }
                }
            }
            String key = propertyKey.replace(checkListPrefix, "").replace(checkListSuffix, "");
            if (permissionList.contains(key)) {
                checkListItem.setVisible("true");
            }

            checkListItemList.add(checkListItem);
        } else if (propertyKey.startsWith(prefixVote) && propertyKey.endsWith(suffixVote)
                && propertyKey.contains(GovernanceConstants.LIFECYCLE_PROPERTY_SEPERATOR + artifactLC
                        + GovernanceConstants.LIFECYCLE_PROPERTY_SEPERATOR)) {
            List<String> propValues = (List<String>) lifecycleProps.get(propertyKey);
            LifeCycleApprovalBean approveItem = new LifeCycleApprovalBean();
            approveItem.setVisible("false");
            if (propValues != null && propValues.size() > 2) {
                for (String param : propValues) {
                    if ((param.startsWith("name:"))) {
                        approveItem.setName(param.substring(5));
                    }
                    if ((param.startsWith("users:"))) {
                        boolean userVoted = false;
                        String users = param.replace("users:", "");
                        String[] votedUsers = users.split(",");
                        userVoted = Arrays.asList(votedUsers).contains(registry.getUserName());
                        approveItem.setValue(userVoted);
                    }
                    if ((param.startsWith("votes:"))) {
                        approveItem.setRequiredVote(Integer.parseInt(param.substring(6)));
                    }
                    if ((param.startsWith("current:"))) {
                        approveItem.setCurrentVote(Integer.parseInt(param.substring(8)));
                    }
                    if ((param.startsWith("order:"))) {
                        approveItem.setOrder(Integer.parseInt(param.substring(6)));
                    }
                }
            }
            String key = propertyKey.replace(prefixVote, "").replace(suffixVote, "");

            if (approvePermissionList.contains(key)) {
                approveItem.setVisible("true");
            }
            if (lifeCycleStateBean.getLifeCycleActionsBean() != null) {
                LifeCycleActionsBean lifeCycleActionsBean = lifeCycleStateBean.getLifeCycleActionsBean();
                List<String> lcActionList = Arrays.asList(lifeCycleActionsBean.getActions());
                if (lcActionList.contains(approveItem.getName()) && ("true").equals(approveItem.getVisible())) {
                    lifeCycleApprovalBeanList.add(approveItem);
                }
                if (approveItem.getCurrentVote() < approveItem.getRequiredVote()) {
                    String[] newActions = (String[]) ArrayUtils.removeElement(lifeCycleActionsBean.getActions(),
                            approveItem.getName());
                    lifeCycleActionsBean.setActions(newActions);
                }
                lifeCycleStateBean.setLifeCycleActionsBean(lifeCycleActionsBean);
            }
        }

    }
    lifeCycleStateBean.setLifeCycleApprovalBeanList(lifeCycleApprovalBeanList);
    lifeCycleStateBean.setLifeCycleCheckListItemBeans(checkListItemList);
    lifeCycleStateBean.setLifeCycleInputBeanMap(lifeCycleInputBeanMap);

    return lifeCycleStateBean;
}

From source file:org.hippoecm.repository.LocalHippoRepository.java

private boolean isContentBootstrapEnabled() {
    return Boolean.getBoolean(SYSTEM_BOOTSTRAP_PROPERTY);
}

From source file:wjhk.jupload2.upload.FileUploadThreadFTP.java

/**
 * Will set the binary/ascii value based on the parameters to the applet.
 * This could be done by file extension too but it is not implemented.
 * //from  w w  w .  ja  v  a2  s .c o  m
 * @param index The index of the file that we want to upload, in the array
 *            of files to upload.
 * @throws IOException if an error occurs while setting mode data
 */
private void setTransferType(@SuppressWarnings("unused") int index) throws IOException {
    // FileData file
    try {
        String binVal = this.uploadPolicy.getString("binary");

        // read the value given from the user
        if (Boolean.getBoolean(binVal))
            this.ftp.setFileType(FTP.BINARY_FILE_TYPE);
        else
            this.ftp.setFileType(FTP.ASCII_FILE_TYPE);

    } catch (MissingResourceException e) {
        // should set based on extension (not implemented)
        this.ftp.setFileType(FTP.BINARY_FILE_TYPE);
    }

    // now do the same for the passive/active parameter
    try {
        String pasVal = this.uploadPolicy.getString("passive");

        if (Boolean.getBoolean(pasVal)) {
            this.ftp.enterRemotePassiveMode();
            this.ftp.enterLocalPassiveMode();
        } else {
            this.ftp.enterLocalActiveMode();
            this.ftp.enterRemoteActiveMode(InetAddress.getByName(this.host), Integer.parseInt(this.port));
        }
    } catch (MissingResourceException e) {
        this.ftp.enterRemotePassiveMode();
        this.ftp.enterLocalPassiveMode();
    }
}

From source file:org.opennms.ng.services.collectd.CollectableService.java

private BasePersister createPersister(ServiceParameters params, RrdRepository repository) {
    if (Boolean.getBoolean("org.opennms.rrd.storeByGroup")) {
        return new GroupPersister(params, repository);
    } else {//from  www. jav a 2  s.  c o  m
        return new OneToOnePersister(params, repository);
    }
}

From source file:it.tidalwave.imageio.test.ImageReaderTestSupport.java

/*******************************************************************************************************************
 * /*from   www.  ja va  2s .  co  m*/
 * 
 ******************************************************************************************************************/
protected void assertRaster(final @Nonnull BufferedImage image, final @Nonnull String path,
        final @Nonnull String expectedRasterMD5, final @Nonnull String suffix)
        throws IOException, NoSuchAlgorithmException {
    final File targetDirectory = new File("target/converted-images/");
    final File tiffFile = new File(targetDirectory, path.replace("https://", "").replace("http://", "") + suffix
            + "-" + System.getProperty("java.version") + ".tiff");

    if (Boolean.getBoolean("jrawio.dumpImageAsTIFF")) {
        tiffFile.getParentFile().mkdirs();
        logger.info("***************** Writing %s...", tiffFile.getAbsolutePath());
        System.err.printf(">>>> Writing %s...\n", tiffFile.getAbsolutePath());
        ImageIO.write(image, "TIFF", tiffFile);
    }

    final Raster raster = image.getData();

    if (Boolean.getBoolean("jrawio.dumpRasterAsText")) {
        final File textDumpFile = new File(
                tiffFile.getAbsolutePath() + "-" + System.getProperty("java.version") + ".txt");
        dumpRasterAsText(raster, textDumpFile);
    }

    if (expectedRasterMD5 != null) // we temporarily accept null since there's no value for thumbnails
    {
        final MessageDigest md5 = md5(raster);

        // Comparisons are broken with JDK 1.5.0, don't make tests fail under Hudson.
        // See http://jrawio.tidalwave.it/issues/browse/JRW-162
        //        if (System.getProperty("java.version").contains("1.5.0"))
        //          {
        //            logger.warning("Not testing raster's MD5 on Java 5 because of JRW-162");
        //          }
        //        else
        //          {
        assertEquals(expectedRasterMD5, asString(md5.digest()));
        //          }
    }
}