Example usage for java.util.logging Level CONFIG

List of usage examples for java.util.logging Level CONFIG

Introduction

In this page you can find the example usage for java.util.logging Level CONFIG.

Prototype

Level CONFIG

To view the source code for java.util.logging Level CONFIG.

Click Source Link

Document

CONFIG is a message level for static configuration messages.

Usage

From source file:com.google.enterprise.connector.sharepoint.client.SharepointClientContext.java

/**
 * Check the connectivity to a given URL by making HTTP head request.
 *
 * @param strURL The URL to be checked/* w  w  w .j  a v a 2s  . co m*/
 * @return the HTTP response code
 */
public int checkConnectivity(final String strURL, HttpMethodBase method) throws IOException {
    LOGGER.log(Level.CONFIG, "Connecting [ " + strURL + " ] ....");
    String username = this.username;
    final String host = Util.getHost(strURL);
    Credentials credentials = null;
    boolean kerberos = false;
    boolean ntlm = true; // We first try to use ntlm

    if (kdcServer != null && !kdcServer.equalsIgnoreCase(SPConstants.BLANK_STRING)) {
        credentials = new NTCredentials(username, password, host, domain);
        kerberos = true;
    } else if (!kerberos && null != domain && !domain.equals("")) {
        credentials = new NTCredentials(username, password, host, domain);
    } else {
        credentials = new UsernamePasswordCredentials(username, password);
        ntlm = false;
    }

    boolean isInputMethodNull = (null == method);
    if (isInputMethodNull) {
        method = new HeadMethod(strURL);
    }

    try {
        int responseCode = clientFactory.checkConnectivity(method, credentials);
        if (responseCode == 401 && ntlm && !kerberos) {
            LOGGER.log(Level.FINE, "Trying with HTTP Basic.");
            username = Util.getUserNameWithDomain(this.username, domain);
            credentials = new UsernamePasswordCredentials(username, password);
            responseCode = clientFactory.checkConnectivity(method, credentials);
        }
        if (responseCode != 200) {
            LOGGER.log(Level.WARNING, "responseCode: " + responseCode);
        }
        return responseCode;
    } finally {
        if (isInputMethodNull) {
            // Since method variable was local to this method
            // releasing connection here.
            method.releaseConnection();
        }
    }
}

From source file:diet.gridr.g5k.gui.GanttChart.java

/**
 * Method returning the selection panel for the Gantt chart
 *
 * @return the selection Panel for the Gantt chart
 *//*from w  ww  . j a v  a2 s. com*/
private JPanel getSelectionPanel() {
    if (selectionPanel == null) {
        selectionPanel = new JPanel();
        selectionPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 5, 10));
        selectionPanel.setLayout(new BoxLayout(selectionPanel, BoxLayout.X_AXIS));
        selectionLabel = new JLabel("Select the duration : ");
        selectionComboBox = new JComboBox(durationsStringArray);
        selectionComboBox.setSelectedIndex(visualizationDuration);
        selectionComboBox.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                visualizationDuration = selectionComboBox.getSelectedIndex();
                ganttChartLayout.show(cardPanel, (String) selectionComboBox.getSelectedItem());
            }
        });
        selectionPanel.add(selectionLabel);
        selectionPanel.add(selectionComboBox);
        selectionPanel.add(Box.createHorizontalGlue());
        LoggingManager.log(Level.CONFIG, LoggingManager.RESOURCESTOOL, this.getClass().getName(),
                "getSelectionPanel", "Selection Panel initialized");
    }

    return selectionPanel;
}

From source file:canreg.client.dataentry.Import.java

public static boolean importFiles(Task<Object, Void> task, Document doc,
        List<canreg.client.dataentry.Relation> map, File[] files, CanRegServerInterface server,
        ImportOptions io) throws SQLException, RemoteException, SecurityException, RecordLockedException {
    int numberOfLinesRead = 0;
    Writer reportWriter = new BufferedWriter(new OutputStreamWriter(System.out));
    if (io.getReportFileName() != null && io.getReportFileName().trim().length() > 0) {
        try {//from w ww  .j  av  a  2  s  .  co m
            reportWriter = new BufferedWriter(new FileWriter(io.getReportFileName()));
        } catch (IOException ex) {
            Logger.getLogger(Import.class.getName()).log(Level.WARNING, null, ex);
        }
    }
    boolean success = false;
    Set<String> noNeedToLookAtPatientVariables = new TreeSet<String>();
    noNeedToLookAtPatientVariables
            .add(canreg.common.Tools.toLowerCaseStandardized(io.getPatientIDVariableName()));
    noNeedToLookAtPatientVariables
            .add(canreg.common.Tools.toLowerCaseStandardized(io.getPatientRecordIDVariableName()));

    String[] lineElements;
    ResultCode worstResultCodeFound;
    //         CSVReader reader = null;
    CSVParser parser = null;
    CSVFormat format = CSVFormat.DEFAULT.withFirstRecordAsHeader().withDelimiter(io.getSeparators()[0]);

    int linesToRead = io.getMaxLines();

    try {
        // first we get the patients
        if (task != null) {
            task.firePropertyChange(PROGRESS, 0, 0);
            task.firePropertyChange(PATIENTS, 0, 0);
        }
        if (files[0] != null) {
            reportWriter
                    .write("Starting to import patients from " + files[0].getAbsolutePath() + Globals.newline);
            FileInputStream patientFIS = new FileInputStream(files[0]);
            InputStreamReader patientISR = new InputStreamReader(patientFIS, io.getFileCharsets()[0]);

            Logger.getLogger(Import.class.getName()).log(Level.CONFIG, "Name of the character encoding {0}",
                    patientISR.getEncoding());

            int numberOfRecordsInFile = canreg.common.Tools.numberOfLinesInFile(files[0].getAbsolutePath());

            numberOfLinesRead = 0;

            if (linesToRead > 0) {
                linesToRead = Math.min(numberOfRecordsInFile, linesToRead);
            } else {
                linesToRead = numberOfRecordsInFile;
            }
            parser = CSVParser.parse(files[0], io.getFileCharsets()[0], format);

            for (CSVRecord csvRecord : parser) {
                // We allow for null tasks...
                boolean savePatient = true;
                boolean deletePatient = false;
                int oldPatientDatabaseRecordID = -1;

                if (task != null) {
                    task.firePropertyChange(PROGRESS, ((numberOfLinesRead - 1) * 100 / linesToRead) / 3,
                            ((numberOfLinesRead) * 100 / linesToRead) / 3);
                    task.firePropertyChange(PATIENTS, ((numberOfLinesRead - 1) * 100 / linesToRead),
                            ((numberOfLinesRead) * 100 / linesToRead));
                }

                // Build patient part
                Patient patient = new Patient();
                for (int i = 0; i < map.size(); i++) {
                    Relation rel = map.get(i);
                    if (rel.getDatabaseTableVariableID() >= 0
                            && rel.getDatabaseTableName().equalsIgnoreCase("patient")) {
                        if (rel.getVariableType().equalsIgnoreCase("Number")) {
                            if (csvRecord.get(rel.getFileColumnNumber()).length() > 0) {
                                try {
                                    patient.setVariable(rel.getDatabaseVariableName(),
                                            Integer.parseInt(csvRecord.get(rel.getFileColumnNumber())));
                                } catch (NumberFormatException ex) {
                                    Logger.getLogger(Import.class.getName()).log(Level.SEVERE,
                                            "Number format error in line: " + (numberOfLinesRead + 1 + 1)
                                                    + ". ",
                                            ex);
                                    success = false;
                                }
                            }
                        } else {
                            patient.setVariable(rel.getDatabaseVariableName(),
                                    csvRecord.get(rel.getFileColumnNumber()));
                        }
                    }
                    if (task != null) {
                        task.firePropertyChange(RECORD, i - 1 / map.size() * 50, i / map.size() * 50);
                    }
                }
                // debugOut(patient.toString());

                // debugOut(tumour.toString());
                // add patient to the database
                Object patientID = patient.getVariable(io.getPatientRecordIDVariableName());
                Patient oldPatientRecord = null;
                try {
                    oldPatientRecord = CanRegClientApp.getApplication().getPatientRecord((String) patientID,
                            false);
                } catch (DistributedTableDescriptionException ex) {
                    Logger.getLogger(Import.class.getName()).log(Level.SEVERE, null, ex);
                } catch (RecordLockedException ex) {
                    Logger.getLogger(Import.class.getName()).log(Level.SEVERE, null, ex);
                } catch (RemoteException ex) {
                    Logger.getLogger(Import.class.getName()).log(Level.SEVERE, null, ex);
                } catch (SQLException ex) {
                    Logger.getLogger(Import.class.getName()).log(Level.SEVERE, null, ex);
                } catch (SecurityException ex) {
                    Logger.getLogger(Import.class.getName()).log(Level.SEVERE, null, ex);
                } catch (UnknownTableException ex) {
                    Logger.getLogger(Import.class.getName()).log(Level.SEVERE, null, ex);
                }

                if (oldPatientRecord != null) {
                    // deal with discrepancies                        
                    switch (io.getDiscrepancies()) {
                    case ImportOptions.REJECT:
                        savePatient = false;
                        break;
                    case ImportOptions.UPDATE:
                        String updateReport = updateRecord(oldPatientRecord, patient);
                        if (updateReport.length() > 0) {
                            reportWriter.write(patient.getVariable(io.getTumourIDVariablename())
                                    + Globals.newline + updateReport);
                        }
                        oldPatientDatabaseRecordID = (Integer) oldPatientRecord
                                .getVariable(Globals.PATIENT_TABLE_RECORD_ID_VARIABLE_NAME);
                        patient = oldPatientRecord;
                        savePatient = true;
                        break;
                    case ImportOptions.OVERWRITE:
                        // deleteTumour;
                        oldPatientDatabaseRecordID = (Integer) oldPatientRecord
                                .getVariable(Globals.PATIENT_TABLE_RECORD_ID_VARIABLE_NAME);
                        String overWriteReport = overwriteRecord(oldPatientRecord, patient);
                        if (overWriteReport.length() > 0) {
                            reportWriter.write(patient.getVariable(io.getTumourIDVariablename())
                                    + Globals.newline + overWriteReport);
                        }
                        patient = oldPatientRecord;
                        savePatient = true;
                        break;
                    }
                    // reportWriter.write(tumour.getVariable(io.getTumourIDVariablename()) + "Tumour already exists.\n");
                }

                if (task != null) {
                    task.firePropertyChange(RECORD, 50, 75);
                }

                if ((!io.isTestOnly())) {
                    if (deletePatient) {
                        server.deleteRecord(oldPatientDatabaseRecordID, Globals.PATIENT_TABLE_NAME);
                    }
                    if (savePatient) {
                        if (patient.getVariable(Globals.PATIENT_TABLE_RECORD_ID_VARIABLE_NAME) != null) {
                            server.editPatient(patient);
                        } else {
                            server.savePatient(patient);
                        }
                    }
                }

                if (task != null) {
                    task.firePropertyChange(RECORD, 100, 75);
                }

                numberOfLinesRead++;

                if (Thread.interrupted()) {
                    //We've been interrupted: no more importing.
                    reportWriter.flush();
                    throw new InterruptedException();
                }
            }
            parser.close();
            reportWriter.write("Finished reading patients." + Globals.newline + Globals.newline);
            reportWriter.flush();
        }
        if (task != null) {
            task.firePropertyChange(PATIENTS, 100, 100);
            task.firePropertyChange("progress", 33, 34);
        }

        // then we get the tumours            
        if (task != null) {
            task.firePropertyChange(TUMOURS, 0, 0);
        }

        if (files[1] != null) {
            reportWriter
                    .write("Starting to import tumours from " + files[1].getAbsolutePath() + Globals.newline);

            FileInputStream tumourFIS = new FileInputStream(files[1]);
            InputStreamReader tumourISR = new InputStreamReader(tumourFIS, io.getFileCharsets()[1]);

            Logger.getLogger(Import.class.getName()).log(Level.CONFIG, "Name of the character encoding {0}",
                    tumourISR.getEncoding());

            numberOfLinesRead = 0;

            int numberOfRecordsInFile = canreg.common.Tools.numberOfLinesInFile(files[1].getAbsolutePath());

            if (linesToRead > 0) {
                linesToRead = Math.min(numberOfRecordsInFile, linesToRead);
            } else {
                linesToRead = numberOfRecordsInFile;
            }

            format = CSVFormat.DEFAULT.withFirstRecordAsHeader().withDelimiter(io.getSeparators()[1]);

            parser = CSVParser.parse(files[1], io.getFileCharsets()[1], format);

            for (CSVRecord csvRecord : parser) {
                // We allow for null tasks...
                boolean saveTumour = true;
                boolean deleteTumour = false;

                if (task != null) {
                    task.firePropertyChange(PROGRESS, 33 + ((numberOfLinesRead - 1) * 100 / linesToRead) / 3,
                            33 + ((numberOfLinesRead) * 100 / linesToRead) / 3);
                    task.firePropertyChange(TUMOURS, ((numberOfLinesRead - 1) * 100 / linesToRead),
                            ((numberOfLinesRead) * 100 / linesToRead));
                }
                // Build tumour part
                Tumour tumour = new Tumour();
                for (int i = 0; i < map.size(); i++) {
                    Relation rel = map.get(i);
                    if (rel.getDatabaseTableVariableID() >= 0
                            && rel.getDatabaseTableName().equalsIgnoreCase("tumour")) {
                        if (rel.getVariableType().equalsIgnoreCase("Number")) {
                            if (csvRecord.get(rel.getFileColumnNumber()).length() > 0) {
                                try {
                                    tumour.setVariable(rel.getDatabaseVariableName(),
                                            Integer.parseInt(csvRecord.get(rel.getFileColumnNumber())));
                                } catch (NumberFormatException ex) {
                                    Logger.getLogger(Import.class.getName()).log(Level.SEVERE,
                                            "Number format error in line: " + (numberOfLinesRead + 1 + 1)
                                                    + ". ",
                                            ex);
                                    success = false;
                                }
                            }
                        } else {
                            tumour.setVariable(rel.getDatabaseVariableName(),
                                    csvRecord.get(rel.getFileColumnNumber()));
                        }
                    }
                    if (task != null) {
                        task.firePropertyChange(RECORD, i - 1 / map.size() * 50, i / map.size() * 50);
                    }
                }

                // see if this tumour exists in the database already
                // TODO: Implement this using arrays and getTumourRexords instead
                Tumour tumour2 = null;
                try {
                    tumour2 = CanRegClientApp.getApplication().getTumourRecordBasedOnTumourID(
                            (String) tumour.getVariable(io.getTumourIDVariablename()), false);
                } catch (DistributedTableDescriptionException ex) {
                    Logger.getLogger(Import.class.getName()).log(Level.SEVERE, null, ex);
                } catch (RecordLockedException ex) {
                    Logger.getLogger(Import.class.getName()).log(Level.SEVERE, null, ex);
                } catch (RemoteException ex) {
                    Logger.getLogger(Import.class.getName()).log(Level.SEVERE, null, ex);
                } catch (SQLException ex) {
                    Logger.getLogger(Import.class.getName()).log(Level.SEVERE, null, ex);
                } catch (SecurityException ex) {
                    Logger.getLogger(Import.class.getName()).log(Level.SEVERE, null, ex);
                } catch (UnknownTableException ex) {
                    Logger.getLogger(Import.class.getName()).log(Level.SEVERE, null, ex);
                }

                if (tumour2 != null) {
                    // deal with discrepancies
                    switch (io.getDiscrepancies()) {
                    case ImportOptions.REJECT:
                        saveTumour = false;
                        break;
                    case ImportOptions.UPDATE:
                        String updateReport = updateRecord(tumour2, tumour);
                        if (updateReport.length() > 0) {
                            reportWriter.write(tumour.getVariable(io.getTumourIDVariablename())
                                    + Globals.newline + updateReport);
                        }
                        tumour = tumour2;
                        saveTumour = true;
                        break;
                    case ImportOptions.OVERWRITE:
                        // deleteTumour;
                        deleteTumour = true;
                        saveTumour = true;
                        break;
                    }
                    // reportWriter.write(tumour.getVariable(io.getTumourIDVariablename()) + "Tumour already exists.\n");

                }

                Patient patient = null;
                try {
                    patient = CanRegClientApp.getApplication().getPatientRecord(
                            (String) tumour.getVariable(io.getPatientRecordIDTumourTableVariableName()), false);
                } catch (DistributedTableDescriptionException ex) {
                    Logger.getLogger(Import.class.getName()).log(Level.SEVERE, null, ex);
                } catch (RecordLockedException ex) {
                    Logger.getLogger(Import.class.getName()).log(Level.SEVERE, null, ex);
                } catch (RemoteException ex) {
                    Logger.getLogger(Import.class.getName()).log(Level.SEVERE, null, ex);
                } catch (SQLException ex) {
                    Logger.getLogger(Import.class.getName()).log(Level.SEVERE, null, ex);
                } catch (SecurityException ex) {
                    Logger.getLogger(Import.class.getName()).log(Level.SEVERE, null, ex);
                } catch (UnknownTableException ex) {
                    Logger.getLogger(Import.class.getName()).log(Level.SEVERE, null, ex);
                }

                if (patient != null) {
                    if (io.isDoChecks() && saveTumour) {
                        // run the edits...
                        String message = "";
                        LinkedList<CheckResult> checkResults = canreg.client.CanRegClientApp.getApplication()
                                .performChecks(patient, tumour);

                        Map<Globals.StandardVariableNames, CheckResult.ResultCode> mapOfVariablesAndWorstResultCodes = new EnumMap<Globals.StandardVariableNames, CheckResult.ResultCode>(
                                Globals.StandardVariableNames.class);
                        worstResultCodeFound = CheckResult.ResultCode.OK;
                        for (CheckResult result : checkResults) {
                            if (result.getResultCode() != CheckResult.ResultCode.OK
                                    && result.getResultCode() != CheckResult.ResultCode.NotDone) {
                                if (!result.getResultCode().equals(CheckResult.ResultCode.Missing)) {
                                    message += result + "\t";
                                    worstResultCodeFound = CheckResult.decideWorstResultCode(
                                            result.getResultCode(), worstResultCodeFound);
                                    for (Globals.StandardVariableNames standardVariableName : result
                                            .getVariablesInvolved()) {
                                        CheckResult.ResultCode worstResultCodeFoundForThisVariable = mapOfVariablesAndWorstResultCodes
                                                .get(standardVariableName);
                                        if (worstResultCodeFoundForThisVariable == null) {
                                            mapOfVariablesAndWorstResultCodes.put(standardVariableName,
                                                    result.getResultCode());
                                        } else if (CheckResult.compareResultSets(result.getResultCode(),
                                                worstResultCodeFoundForThisVariable) > 0) {
                                            mapOfVariablesAndWorstResultCodes.put(standardVariableName,
                                                    result.getResultCode());
                                        }
                                    }
                                }
                            }
                            // Logger.getLogger(Import.class.getName()).log(Level.INFO, result.toString());
                        }
                        // always generate ICD10...
                        // ConversionResult[] conversionResult = canreg.client.CanRegClientApp.getApplication().performConversions(Converter.ConversionName.ICDO3toICD10, patient, tumour);
                        // tumour.setVariable(io.getICD10VariableName(), conversionResult[0].getValue());

                        if (worstResultCodeFound != CheckResult.ResultCode.Invalid
                                && worstResultCodeFound != CheckResult.ResultCode.Missing) {
                            // generate ICD10 codes
                            ConversionResult[] conversionResult = canreg.client.CanRegClientApp.getApplication()
                                    .performConversions(Converter.ConversionName.ICDO3toICD10, patient, tumour);
                            tumour.setVariable(io.getICD10VariableName(), conversionResult[0].getValue());
                            // generate ICCC codes
                            ConversionResult[] conversionResultICCC = canreg.client.CanRegClientApp
                                    .getApplication()
                                    .performConversions(Converter.ConversionName.ICDO3toICCC3, patient, tumour);
                            tumour.setVariable(io.getICCCVariableName(), conversionResultICCC[0].getValue());
                        } else {
                            tumour.setVariable(io.getTumourRecordStatus(), "0");
                        }

                        if (worstResultCodeFound == CheckResult.ResultCode.OK) {
                            // message += "Cross-check conclusion: Valid";
                        } else {
                            reportWriter.write(tumour.getVariable(io.getTumourIDVariablename()) + "\t" + message
                                    + Globals.newline);
                            // System.out.println(tumour.getVariable(io.getTumourIDVariablename()) + " " + message);
                        }
                        tumour.setVariable(io.getTumourCheckStatus(),
                                CheckResult.toDatabaseVariable(worstResultCodeFound));

                    } else {
                        // try to generate ICD10, if missing, anyway
                        String icd10 = (String) tumour.getVariable(io.getICD10VariableName());
                        if (icd10 == null || icd10.trim().length() == 0) {
                            ConversionResult[] conversionResult = canreg.client.CanRegClientApp.getApplication()
                                    .performConversions(Converter.ConversionName.ICDO3toICD10, patient, tumour);
                            tumour.setVariable(io.getICD10VariableName(), conversionResult[0].getValue());
                        }
                        // try to generate ICCC3, if missing, anyway
                        String iccc = (String) tumour.getVariable(io.getICCCVariableName());
                        if (iccc == null || iccc.trim().length() == 0) {
                            ConversionResult[] conversionResult = canreg.client.CanRegClientApp.getApplication()
                                    .performConversions(Converter.ConversionName.ICDO3toICCC3, patient, tumour);
                            tumour.setVariable(io.getICCCVariableName(), conversionResult[0].getValue());
                        }
                    }
                } else {
                    reportWriter.write(tumour.getVariable(io.getTumourIDVariablename()) + "\t"
                            + "No patient matches this Tumour." + Globals.newline);
                    tumour.setVariable(io.getTumourRecordStatus(), "0");
                    tumour.setVariable(io.getTumourCheckStatus(),
                            CheckResult.toDatabaseVariable(ResultCode.Missing));
                }
                if (task != null) {
                    task.firePropertyChange(RECORD, 50, 75);
                }
                if (!io.isTestOnly()) {
                    if (deleteTumour) {
                        server.deleteRecord(
                                (Integer) tumour2.getVariable(Globals.TUMOUR_TABLE_RECORD_ID_VARIABLE_NAME),
                                Globals.TUMOUR_TABLE_NAME);
                    }
                    if (saveTumour) {
                        // if tumour has no record ID we save it
                        if (tumour.getVariable(Globals.TUMOUR_TABLE_RECORD_ID_VARIABLE_NAME) == null) {
                            server.saveTumour(tumour);
                        } // if not we edit it
                        else {
                            server.editTumour(tumour);
                        }
                    }
                }
                if (task != null) {
                    task.firePropertyChange(RECORD, 75, 100);
                }
                //Read next line of data

                numberOfLinesRead++;

                if (Thread.interrupted()) {
                    //We've been interrupted: no more importing.
                    reportWriter.flush();
                    throw new InterruptedException();
                }
            }
            parser.close();
            reportWriter.write("Finished reading tumours." + Globals.newline + Globals.newline);
            reportWriter.flush();
        }
        if (task != null) {
            task.firePropertyChange(TUMOURS, 100, 100);
        }
        // then at last we get the sources
        if (task != null) {
            task.firePropertyChange(SOURCES, 0, 0);
            task.firePropertyChange(PROGRESS, 66, 66);
        }
        if (files[2] != null) {
            reportWriter
                    .write("Starting to import sources from " + files[2].getAbsolutePath() + Globals.newline);

            FileInputStream sourceFIS = new FileInputStream(files[2]);
            InputStreamReader sourceISR = new InputStreamReader(sourceFIS, io.getFileCharsets()[2]);

            Logger.getLogger(Import.class.getName()).log(Level.CONFIG, "Name of the character encoding {0}",
                    sourceISR.getEncoding());

            numberOfLinesRead = 0;

            int numberOfRecordsInFile = canreg.common.Tools.numberOfLinesInFile(files[2].getAbsolutePath());

            if (linesToRead > 0) {
                linesToRead = Math.min(numberOfRecordsInFile, linesToRead);
            } else {
                linesToRead = numberOfRecordsInFile;
            }

            format = CSVFormat.DEFAULT.withFirstRecordAsHeader().withDelimiter(io.getSeparators()[2]);

            parser = CSVParser.parse(files[2], io.getFileCharsets()[2], format);

            for (CSVRecord csvRecord : parser) {
                // We allow for null tasks...
                if (task != null) {
                    task.firePropertyChange(PROGRESS, 67 + ((numberOfLinesRead - 1) * 100 / linesToRead) / 3,
                            67 + ((numberOfLinesRead) * 100 / linesToRead) / 3);
                    task.firePropertyChange(SOURCES, ((numberOfLinesRead - 1) * 100 / linesToRead),
                            ((numberOfLinesRead) * 100 / linesToRead));
                }

                // Build source part
                Source source = new Source();
                for (int i = 0; i < map.size(); i++) {
                    Relation rel = map.get(i);
                    if (rel.getDatabaseTableVariableID() >= 0
                            && rel.getDatabaseTableName().equalsIgnoreCase(Globals.SOURCE_TABLE_NAME)) {
                        if (rel.getVariableType().equalsIgnoreCase("Number")) {
                            if (csvRecord.get(rel.getFileColumnNumber()).length() > 0) {
                                try {
                                    source.setVariable(rel.getDatabaseVariableName(),
                                            Integer.parseInt(csvRecord.get(rel.getFileColumnNumber())));
                                } catch (NumberFormatException ex) {
                                    Logger.getLogger(Import.class.getName()).log(Level.SEVERE,
                                            "Number format error in line: " + (numberOfLinesRead + 1 + 1)
                                                    + ". ",
                                            ex);
                                    success = false;
                                }
                            }
                        } else {
                            source.setVariable(rel.getDatabaseVariableName(),
                                    csvRecord.get(rel.getFileColumnNumber()));
                        }
                    }
                    if (task != null) {
                        task.firePropertyChange(RECORD, i - 1 / map.size() * 50, i / map.size() * 50);
                    }
                }

                Tumour tumour = null;
                try {
                    tumour = CanRegClientApp.getApplication().getTumourRecordBasedOnTumourID(
                            (String) source.getVariable(io.getTumourIDSourceTableVariableName()), false);
                } catch (DistributedTableDescriptionException ex) {
                    Logger.getLogger(Import.class.getName()).log(Level.SEVERE, null, ex);
                } catch (RecordLockedException ex) {
                    Logger.getLogger(Import.class.getName()).log(Level.SEVERE, null, ex);
                } catch (RemoteException ex) {
                    Logger.getLogger(Import.class.getName()).log(Level.SEVERE, null, ex);
                } catch (SQLException ex) {
                    Logger.getLogger(Import.class.getName()).log(Level.SEVERE, null, ex);
                } catch (SecurityException ex) {
                    Logger.getLogger(Import.class.getName()).log(Level.SEVERE, null, ex);
                } catch (UnknownTableException ex) {
                    Logger.getLogger(Import.class.getName()).log(Level.SEVERE, null, ex);
                }
                if (task != null) {
                    task.firePropertyChange(RECORD, 50, 75);
                }
                boolean addSource = true;

                if (tumour != null) {
                    Set<Source> sources = tumour.getSources();
                    Object sourceRecordID = source.getVariable(io.getSourceIDVariablename());
                    // look for source in sources
                    for (Source oldSource : sources) {
                        if (oldSource.getVariable(io.getSourceIDVariablename()).equals(sourceRecordID)) {
                            // deal with discrepancies
                            switch (io.getDiscrepancies()) {
                            case ImportOptions.REJECT:
                                addSource = false;
                                break;
                            case ImportOptions.UPDATE:
                                String updateReport = updateRecord(oldSource, source);
                                if (updateReport.length() > 0) {
                                    reportWriter.write(tumour.getVariable(io.getTumourIDVariablename())
                                            + Globals.newline + updateReport);
                                }
                                source = oldSource;
                                addSource = false;
                                break;
                            case ImportOptions.OVERWRITE:
                                // deleteTumour;
                                sources.remove(oldSource);
                                addSource = true;
                                break;
                            }
                        }
                    }
                    if (addSource) {
                        sources.add(source);
                    }
                    tumour.setSources(sources);
                    if (!io.isTestOnly()) {
                        server.editTumour(tumour);
                    }
                } else {
                    Logger.getLogger(Import.class.getName()).log(Level.SEVERE, null,
                            "No tumour for source record.");
                }
                if (task != null) {
                    task.firePropertyChange(RECORD, 75, 100);
                }
                //Read next line of data

                numberOfLinesRead++;

                if (Thread.interrupted()) {
                    //We've been interrupted: no more importing.
                    reportWriter.flush();
                    throw new InterruptedException();
                }
            }
            reportWriter.write("Finished reading sources." + Globals.newline + Globals.newline);
            reportWriter.flush();
            parser.close();
        }
        if (task != null) {
            task.firePropertyChange(SOURCES, 100, 100);
            task.firePropertyChange(PROGRESS, 100, 100);
            while (!task.isProgressPropertyValid()) {
                // wait untill progress has been updated...
            }
        }
        reportWriter.write("Finished" + Globals.newline);
        reportWriter.flush();
        success = true;
    } catch (IOException ex) {
        Logger.getLogger(Import.class.getName()).log(Level.SEVERE,
                "Error in line: " + (numberOfLinesRead + 1 + 1) + ". ", ex);
        success = false;
    } catch (InterruptedException ex) {
        Logger.getLogger(Import.class.getName()).log(Level.INFO,
                "Interupted on line: " + (numberOfLinesRead + 1) + ". ", ex);
        success = true;
    } catch (IndexOutOfBoundsException ex) {
        Logger.getLogger(Import.class.getName()).log(Level.SEVERE,
                "String too short error in line: " + (numberOfLinesRead + 1 + 1) + ". ", ex);
        success = false;
    } finally {
        if (parser != null) {
            try {
                parser.close();
            } catch (IOException ex) {
                Logger.getLogger(Import.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        try {
            reportWriter.flush();
            reportWriter.close();
        } catch (IOException ex) {
            Logger.getLogger(Import.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    if (task != null) {
        task.firePropertyChange(PROGRESS, 100, 100);
        task.firePropertyChange("finished", null, null);
    }
    return success;
}

From source file:com.google.enterprise.connector.sharepoint.client.SharepointClientContext.java

/**
 * Detect SharePoint type from the URL//from   ww  w .  jav a2 s. com
 *
 * @param strURL
 * @return the SharePoint Type of the siteURL being passed
 */
public SPConstants.SPType checkSharePointType(String strURL) {
    LOGGER.log(Level.CONFIG, "Checking [ " + strURL + " ] for the SharePoint version.");

    strURL = Util.encodeURL(strURL);
    HttpMethodBase method = null;
    String version;
    try {
        method = new HeadMethod(strURL);
        checkConnectivity(strURL, method);
        version = clientFactory.getResponseHeader(method, "MicrosoftSharePointTeamServices");
        LOGGER.info("SharePoint Version: " + version);
    } catch (final Exception e) {
        LOGGER.log(Level.WARNING, "Unable to connect " + strURL, e);
        return null;
    } finally {
        if (method != null) {
            method.releaseConnection();
        }
    }
    if (version == null) {
        LOGGER.warning("Sharepoint version not found for the site [ " + strURL + " ]");
        return null;
    }

    /* Fix Details: ------------ SharePoint connector requires to know the
     * version of the SharePoint repository<br/> for following a)
     * MySite\Personal Site handling which is different in SP2003 & SP2007 Note:
     * current mysite handling fails for SP2010.<br/> However mysite URLs can be
     * discovered using the custom site discovery WS. b) Content Feed\Bulk
     * AuthZ: This is achieved through custom web services which is supported on
     * SP2007 Note: Checked that same web services work for SP2010 as well
     */

    if (version.trim().startsWith("6") || version.trim().startsWith("11")) {
        return SPType.SP2003;
    } else {
        // Return type as SP2007 for all SharePoint Versions starting
        // from MOSS 2007 and WSS 3.
        return SPType.SP2007;
    }
}

From source file:diet.gridr.g5k.gui.GanttChart.java

/**
 * Method creating the chart//  ww w. ja v a 2 s  .co m
 *
 * @param dataset dataset containing the data for the chart
 * @return a chart
 */
private JFreeChart createChart(XYZDataset dataset) {
    DateAxis xAxis = new DateAxis("Date");
    xAxis.setLowerMargin(0.0);
    xAxis.setUpperMargin(0.0);
    xAxis.setDateFormatOverride(new SimpleDateFormat(durationsFormatterArray[this.visualizationDuration]));
    xAxis.setRange(Calendar.getInstance().getTime(),
            new Date(System.currentTimeMillis() + HistoryUtil.durationsTimesArray[visualizationDuration]
                    - HistoryUtil.blockWidthsArray[visualizationDuration]));
    NumberAxis yAxis = new NumberAxis("Nodes");
    yAxis.setAutoRangeIncludesZero(false);
    yAxis.setInverted(true);
    yAxis.setLowerMargin(0.0);
    yAxis.setUpperMargin(0.0);
    yAxis.setRange(1, numberOfNodes);
    yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    XYBlockRenderer renderer = new XYBlockRenderer();
    LookupPaintScale paintScale = new LookupPaintScale();
    for (int i = 0; i < jobsList.get(visualizationDuration).size(); i++) {
        // String jobId = jobsList.get(visualizationDuration).get(i).getId().substring(0,jobsList.get(visualizationDuration).get(i).getId().indexOf("."));
        String jobId = jobsList.get(visualizationDuration).get(i).getParameterValue(GridJob.KEY_GRID_JOB_ID);
        int seed = Integer.parseInt(jobId);
        Random rng = new Random(seed);
        Color tempColor = Color.red;
        int red = tempColor.getRed();
        int green = tempColor.getGreen();
        int blue = tempColor.getBlue();
        int redRNG = rng.nextInt(255);
        int greenRNG = rng.nextInt(255);
        int blueRNG = rng.nextInt(255);
        if (red == redRNG && green == greenRNG && blue == blueRNG) {
            tempColor = new Color(rng.nextInt(255), rng.nextInt(255), rng.nextInt(255));
        } else {
            tempColor = new Color(redRNG, greenRNG, blueRNG);
        }
        if (seed == 0)
            tempColor = Color.red;
        paintScale.add(new Double(i), tempColor);
    }
    renderer.setBlockWidth(HistoryUtil.blockWidthsArray[visualizationDuration]);
    renderer.setBlockAnchor(RectangleAnchor.TOP_LEFT);
    renderer.setPaintScale(paintScale);
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    plot.setOrientation(PlotOrientation.VERTICAL);
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.black);
    plot.setRangeGridlinePaint(Color.black);
    JFreeChart chart = new JFreeChart("Gantt Chart activity for cluster " + siteName, plot);
    chart.removeLegend();
    chart.setBackgroundPaint(Color.white);
    LoggingManager.log(Level.CONFIG, LoggingManager.RESOURCESTOOL, this.getClass().getName(), "createChart",
            "Chart created");
    return chart;
}

From source file:de.mendelson.comm.as2.client.AS2Gui.java

/**
 * The client received a message from the server
 *///from   w ww .ja v  a2 s.  c o  m
@Override
public boolean processMessageFromServer(ClientServerMessage message) {
    if (message instanceof RefreshClientMessageOverviewList) {
        RefreshClientMessageOverviewList refreshRequest = (RefreshClientMessageOverviewList) message;
        if (refreshRequest.getOperation() == RefreshClientMessageOverviewList.OPERATION_PROCESSING_UPDATE) {
            this.refreshThread.serverRequestsOverviewRefresh();
        } else {
            //always perform update of a delete operation - even if the refresh has been disabled
            this.refreshThread.userRequestsOverviewRefresh();
        }
        return (true);
    } else if (message instanceof RefreshTablePartnerData) {
        this.refreshThread.requestPartnerRefresh();
        return (true);
    } else if (message instanceof ServerInfo) {
        ServerInfo serverInfo = (ServerInfo) message;
        this.getLogger().log(Level.CONFIG, serverInfo.getProductname());
        return (true);
    } else if (message instanceof RefreshClientCEMDisplay) {
        //return true for this message even if it is not processed here to prevent a
        //warning that the message was not processed
        return (true);
    }
    return (false);
}

From source file:com.google.enterprise.connector.otex.LivelinkConnectorType.java

/**
 * {@inheritDoc}/*from   ww w . j  a v  a  2  s .  co  m*/
 */
@Override
public ConfigureResponse getConfigForm(Locale locale) {
    if (LOGGER.isLoggable(Level.CONFIG))
        LOGGER.config("getConfigForm locale: " + locale);
    try {
        return new ConfigureResponse(null, new FormBuilder(getResources(locale)).getFormSnippet());
    } catch (Throwable t) {
        LOGGER.log(Level.SEVERE, "Failed to create config form", t);
        return getErrorResponse(getExceptionMessages(null, t));
    }
}

From source file:com.google.enterprise.connector.otex.LivelinkConnectorType.java

/**
 * {@inheritDoc}//from ww w  . j  av a 2s.c  om
 */
@Override
public ConfigureResponse getPopulatedConfigForm(Map<String, String> configData, Locale locale) {
    if (LOGGER.isLoggable(Level.CONFIG)) {
        LOGGER.config("getPopulatedConfigForm data: " + getMaskedMap(configData));
        LOGGER.config("getPopulatedConfigForm locale: " + locale);
    }
    try {
        return getResponse(null, getResources(locale), configData, new FormContext(configData));
    } catch (Throwable t) {
        LOGGER.log(Level.SEVERE, "Failed to create config form", t);
        return getErrorResponse(getExceptionMessages(null, t));
    }
}

From source file:com.google.enterprise.connector.otex.LivelinkConnectorType.java

/**
 * Helper method for <code>getPopulatedConfigForm</code> and
 * <code>validateConfig</code>.
 *
 * @param message A message to be included to the user along with the form
 * @param configData A map of name, value pairs (String, String)
 * of configuration data/*w w w  . jav a  2s  .c  om*/
 * @param formContext A context which may be configured by
 * the caller to affect the form generation
 */
private ConfigureResponse getResponse(String message, ResourceBundle bundle, Map<String, String> configData,
        FormContext formContext) {
    if (LOGGER.isLoggable(Level.CONFIG))
        LOGGER.config("Response data: " + getMaskedMap(configData));
    if (message != null || formContext != null) {
        FormBuilder form = new FormBuilder(bundle, configData, formContext);
        return new ConfigureResponse(message, form.getFormSnippet());
    } else if (configData != null) {
        return new ConfigureResponse(null, null, configData);
    } else {
        return null;
    }
}

From source file:diet.gridr.g5k.gui.GanttChart.java

/**
 * Method creating the dataset//from   w  ww .ja v a2 s . c  om
 *
 * @return the dataset
 */
private XYZDataset createDataset() {

    long numberOfBlocks = HistoryUtil.durationsTimesArray[visualizationDuration]
            / HistoryUtil.blockWidthsArray[visualizationDuration];
    double[] xvalues = new double[(int) (numberOfNodes * numberOfBlocks)];
    double[] yvalues = new double[(int) (numberOfNodes * numberOfBlocks)];
    double[] zvalues = new double[(int) (numberOfNodes * numberOfBlocks)];
    double[][] data = new double[][] { xvalues, yvalues, zvalues };
    Iterator<GridJob> iterJobs = jobsList.get(visualizationDuration).iterator();
    long now = Calendar.getInstance().getTimeInMillis();
    while (iterJobs.hasNext()) {
        GridJob thisJob = iterJobs.next();
        // get the maximum date between now and the start date of the job
        long startDate = (Long.parseLong(thisJob.getParameterValue(GridJob.KEY_GRID_JOB_SCHEDTIME)) - now > 0)
                ? (Long.parseLong(thisJob.getParameterValue(GridJob.KEY_GRID_JOB_SCHEDTIME)))
                : now;
        //getDateFromOARDate(thisJob.getParameterValue(GridJob.KEY_GRID_JOB_SCHEDTIME)).getTime()-now > 0 )?getDateFromOARDate(thisJob.getParameterValue(GridJob.KEY_GRID_JOB_SCHEDTIME)).getTime():now;
        long timeFromNow = startDate - now;
        long endDateInMillis = Long.parseLong(thisJob.getParameterValue(GridJob.KEY_GRID_JOB_STARTTIME));
        //getDateFromOARDate(thisJob.getParameterValue(GridJob.KEY_GRID_JOB_STARTTIME)).getTime();
        //                    getDateFromWallTime(thisJob.getParam(GridJob.GJOB_WALLTIME));
        long wt = Long.parseLong(thisJob.getParameterValue(GridJob.KEY_GRID_JOB_WALLTIME));
        //            try {
        //                     wt = Long.parseLong(thisJob.getParameterValue(GridJob.KEY_GRID_JOB_WALLTIME));
        //            }
        //            catch (Exception e) {
        //                
        //            }
        endDateInMillis += wt;
        long chartEnd = now + HistoryUtil.durationsTimesArray[visualizationDuration];
        long endDate = (endDateInMillis - chartEnd > 0) ? chartEnd : endDateInMillis;
        long durationOfTheJob = endDate - startDate;
        long numberOfBlocksOfTheJob = durationOfTheJob / HistoryUtil.blockWidthsArray[visualizationDuration];
        int startBlock = (int) (timeFromNow / HistoryUtil.blockWidthsArray[visualizationDuration]);
        boolean printed = true;
        // if (thisJob.jobHosts.equalsIgnoreCase("")){
        if (thisJob.getParameterValue(GridJob.KEY_GRID_JOB_HOSTS) == null) {
        } else {
            Iterator<Integer> iterNodes = getNodesList(thisJob).iterator();
            while (iterNodes.hasNext()) {
                int aNode = iterNodes.next();
                for (int aBlock = 0; aBlock < numberOfBlocksOfTheJob; aBlock++) {
                    // number Of time blocks
                    try {
                        int index = (int) ((aNode - 1) * (numberOfBlocks) + aBlock + startBlock);
                        xvalues[index] = now
                                + (startBlock + aBlock) * HistoryUtil.blockWidthsArray[visualizationDuration];
                        yvalues[index] = aNode;
                        if (thisJob.getParameterValue(GridJob.KEY_GRID_JOB_ID).startsWith("0.oar")) {
                            zvalues[index] = jobsList.get(visualizationDuration).indexOf(thisJob);
                            if (printed) {
                                printed = false;
                            }
                        }
                        zvalues[index] = jobsList.get(visualizationDuration).indexOf(thisJob);
                    } catch (Exception e) {
                        LoggingManager.log(Level.CONFIG, LoggingManager.RESOURCESTOOL,
                                this.getClass().getName(), "createDataset", e);
                    }
                }
            }
        }
    }
    DefaultXYZDataset dataset = new DefaultXYZDataset();
    dataset.addSeries("Series 1", data);
    LoggingManager.log(Level.CONFIG, LoggingManager.RESOURCESTOOL, this.getClass().getName(), "createDataset",
            "Dataset created");
    return dataset;
}