Example usage for java.rmi RemoteException getMessage

List of usage examples for java.rmi RemoteException getMessage

Introduction

In this page you can find the example usage for java.rmi RemoteException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message, including the message from the cause, if any, of this exception.

Usage

From source file:com.collabnet.ccf.teamforge.TFWriter.java

private TrackerDO updateTrackerMetaData(GenericArtifact ga, String trackerId, Connection connection) {
    Map<String, SortedSet<String>> fieldsToBeChanged = new HashMap<String, SortedSet<String>>();
    // retrieve all fields that should be changed
    List<GenericArtifactField> fields = ga.getAllGenericArtifactFields();
    for (GenericArtifactField genericArtifactField : fields) {
        String fieldName = genericArtifactField.getFieldName();
        Object fieldValue = genericArtifactField.getFieldValue();
        SortedSet<String> values = fieldsToBeChanged.get(fieldName);
        if (values == null) {
            values = new TreeSet<String>();
            fieldsToBeChanged.put(fieldName, values);
        }/*from  www  .  ja  v  a 2 s  .  c  om*/
        if (fieldValue != null) {
            values.add(fieldValue.toString());
        }
    }
    TrackerDO result = null;
    try {
        result = trackerHandler.updateTrackerMetaData(ga, trackerId, fieldsToBeChanged, connection);
    } catch (RemoteException e) {
        String cause = "Could not update meta data of tracker " + trackerId + e.getMessage();
        log.error(cause, e);
        ga.setErrorCode(GenericArtifact.ERROR_META_DATA_WRITE);
        throw new CCFRuntimeException(cause, e);
    }
    if (result != null) {
        log.info("Successfully updated meta data of tracker " + result.getId());
    }
    return result;
}

From source file:com.collabnet.ccf.teamforge.TFWriter.java

private PlanningFolderDO createPlanningFolder(GenericArtifact ga, String project, Connection connection) {

    String targetSystemTimezone = ga.getTargetSystemTimezone();
    String parentId = project;// w  ww .j  a  v a  2s.c om
    String targetParentArtifactId = ga.getDepParentTargetArtifactId();

    if (targetParentArtifactId != null && !targetParentArtifactId.equals(GenericArtifact.VALUE_NONE)
            && !targetParentArtifactId.equals(GenericArtifact.VALUE_UNKNOWN)) {
        parentId = targetParentArtifactId;
    }

    String title = GenericArtifactHelper
            .getStringMandatoryGAField(TFArtifactMetaData.TFFields.title.getFieldName(), ga);

    String description = GenericArtifactHelper
            .getStringMandatoryGAField(TFArtifactMetaData.TFFields.description.getFieldName(), ga);

    Date startDate = null;
    Date endDate = null;

    GenericArtifactField startDateField = GenericArtifactHelper
            .getMandatoryGAField(TFArtifactMetaData.TFFields.startDate.getFieldName(), ga);

    if (startDateField != null) {
        GregorianCalendar gc = (GregorianCalendar) startDateField.getFieldValue();
        if (gc != null) {
            Date dateValue = gc.getTime();
            if (DateUtil.isAbsoluteDateInTimezone(dateValue, "GMT")) {
                startDate = DateUtil.convertGMTToTimezoneAbsoluteDate(dateValue, targetSystemTimezone);
            } else {
                startDate = dateValue;
            }
        }
    }

    GenericArtifactField endDateField = GenericArtifactHelper
            .getMandatoryGAField(TFArtifactMetaData.TFFields.endDate.getFieldName(), ga);

    if (endDateField != null) {
        GregorianCalendar gc = (GregorianCalendar) endDateField.getFieldValue();
        if (gc != null) {
            Date dateValue = gc.getTime();
            if (DateUtil.isAbsoluteDateInTimezone(dateValue, "GMT")) {
                endDate = DateUtil.convertGMTToTimezoneAbsoluteDate(dateValue, targetSystemTimezone);
            } else {
                endDate = dateValue;
            }
        }
    }

    int capacity = 0;
    String status = null;
    String releaseId = null;
    if (connection.supports54()) {
        capacity = GenericArtifactHelper
                .getIntMandatoryGAField(TFArtifactMetaData.TFFields.capacity.getFieldName(), ga);
        status = GenericArtifactHelper
                .getStringMandatoryGAField(TFArtifactMetaData.TFFields.status.getFieldName(), ga);
        releaseId = GenericArtifactHelper
                .getStringMandatoryGAField(TFArtifactMetaData.TFFields.releaseId.getFieldName(), ga);
    }

    //To support display effort in field added in TF 7.0
    String trackerUnitId = null;
    if (connection.supports62()) {
        trackerUnitId = GenericArtifactHelper
                .getStringMandatoryGAField(TFArtifactMetaData.TFFields.trackerUnitId.getFieldName(), ga);

    }

    //For points capacity field added in TF 7.1
    int pointsCapacity = 0;
    if (connection.supports63()) {
        pointsCapacity = GenericArtifactHelper
                .getIntMandatoryGAField(TFArtifactMetaData.TFFields.pointsCapacity.getFieldName(), ga);
    }

    PlanningFolderDO planningFolder = null;

    try {
        if (translateTechnicalReleaseIds) {
            releaseId = TFTrackerHandler.convertReleaseIdForProject(connection, releaseId, project,
                    isReleaseIdFieldsContainFileReleasePackageName() ? getPackageReleaseSeparatorString()
                            : null);
        }
        String trackerUnitIdValue = !StringUtils.isEmpty(trackerUnitId) ? trackerUnitId : "Hours";
        trackerUnitId = TFTrackerHandler.getTrackerUnitId(connection, trackerUnitIdValue, project);
        planningFolder = connection.getPlanningClient().createPlanningFolder(parentId, title, description,
                startDate, endDate, status, capacity, pointsCapacity, releaseId, trackerUnitId, null);
    } catch (RemoteException e) {
        String cause = "Could not create planning folder: " + e.getMessage();
        log.error(cause, e);
        ga.setErrorCode(GenericArtifact.ERROR_EXTERNAL_SYSTEM_WRITE);
        throw new CCFRuntimeException(cause, e);
    }
    log.info("Created planning folder " + planningFolder.getId() + " in project " + project + " with parent "
            + parentId + " other system id: " + ga.getSourceArtifactId() + " in repository: "
            + ga.getSourceRepositoryId());

    return planningFolder;
}

From source file:com.collabnet.ccf.teamforge.TFWriter.java

/**
 * Creates the artifact represented by the GenericArtifact object on the
 * target TF system//from   w ww . java  2 s  .c  om
 * 
 * @param ga
 *            - the GenericArtifact object
 * @param tracker
 *            - The target TF tracker ID
 * @param connection
 *            - The Connection object for the target TF system
 * @return - the newly created artifact's ArtifactSoapDO object
 */
private ArtifactDO createArtifact(GenericArtifact ga, String tracker, Connection connection) {
    ArrayList<String> flexFieldNames = new ArrayList<String>();
    ArrayList<String> flexFieldTypes = new ArrayList<String>();
    ArrayList<Object> flexFieldValues = new ArrayList<Object>();

    List<GenericArtifactField> gaFields = ga
            .getAllGenericArtifactFieldsWithSameFieldType(GenericArtifactField.VALUE_FIELD_TYPE_FLEX_FIELD);
    String targetSystemTimezone = ga.getTargetSystemTimezone();
    if (gaFields != null) {
        for (GenericArtifactField gaField : gaFields) {
            String fieldName = gaField.getFieldName();
            if (COMMENT_TEXT.equals(fieldName)) {
                continue;
            }
            String trackerFieldValueType = TFArtifactMetaData
                    .getTFFieldValueTypeForGAFieldType(gaField.getFieldValueType());
            flexFieldNames.add(fieldName);
            flexFieldTypes.add(trackerFieldValueType);
            Object value = null;
            FieldValueTypeValue fieldType = gaField.getFieldValueType();
            if (trackerFieldValueType.equals(TrackerFieldSoapDO.FIELD_VALUE_TYPE_DATE)) {
                if (fieldType == FieldValueTypeValue.DATE) {
                    GregorianCalendar gc = (GregorianCalendar) gaField.getFieldValue();
                    if (gc != null) {
                        Date dateValue = gc.getTime();
                        if (DateUtil.isAbsoluteDateInTimezone(dateValue, "GMT")) {
                            value = DateUtil.convertGMTToTimezoneAbsoluteDate(dateValue, targetSystemTimezone);
                        } else {
                            value = dateValue;
                        }
                    }
                } else if (fieldType == FieldValueTypeValue.DATETIME) {
                    value = gaField.getFieldValue();
                }
            } else {
                value = gaField.getFieldValue();
            }
            flexFieldValues.add(value);
        }
    }

    String folderId = GenericArtifactHelper
            .getStringMandatoryGAField(TFArtifactMetaData.TFFields.folderId.getFieldName(), ga);
    String description = GenericArtifactHelper
            .getStringMandatoryGAField(TFArtifactMetaData.TFFields.description.getFieldName(), ga);
    String category = GenericArtifactHelper
            .getStringMandatoryGAField(TFArtifactMetaData.TFFields.category.getFieldName(), ga);
    String group = GenericArtifactHelper
            .getStringMandatoryGAField(TFArtifactMetaData.TFFields.group.getFieldName(), ga);
    String status = GenericArtifactHelper
            .getStringMandatoryGAField(TFArtifactMetaData.TFFields.status.getFieldName(), ga);
    String statusClass = GenericArtifactHelper
            .getStringMandatoryGAField(TFArtifactMetaData.TFFields.statusClass.getFieldName(), ga);
    String customer = GenericArtifactHelper
            .getStringMandatoryGAField(TFArtifactMetaData.TFFields.customer.getFieldName(), ga);
    int priority = GenericArtifactHelper
            .getIntMandatoryGAField(TFArtifactMetaData.TFFields.priority.getFieldName(), ga);

    int estimatedEffort = 0;
    int actualEffort = 0;
    int remainingEffort = 0;
    String planningFolder = null;
    Boolean autosumming = false;

    estimatedEffort = GenericArtifactHelper
            .getIntMandatoryGAField(TFArtifactMetaData.TFFields.estimatedHours.getFieldName(), ga);
    actualEffort = GenericArtifactHelper
            .getIntMandatoryGAField(TFArtifactMetaData.TFFields.actualHours.getFieldName(), ga);
    if (connection.supports53()) {
        remainingEffort = GenericArtifactHelper
                .getIntMandatoryGAField(TFArtifactMetaData.TFFields.remainingEffort.getFieldName(), ga);

        planningFolder = GenericArtifactHelper
                .getStringMandatoryGAField(TFArtifactMetaData.TFFields.planningFolder.getFieldName(), ga);

        autosumming = GenericArtifactHelper
                .getBooleanMandatoryGAField(TFArtifactMetaData.TFFields.autosumming.getFieldName(), ga);
    }

    int points = 0;
    if (connection.supports54()) {
        points = GenericArtifactHelper.getIntMandatoryGAField(TFArtifactMetaData.TFFields.points.getFieldName(),
                ga);

    }

    Date closeDate = GenericArtifactHelper
            .getDateMandatoryGAField(TFArtifactMetaData.TFFields.closeDate.getFieldName(), ga);
    String assignedTo = GenericArtifactHelper
            .getStringMandatoryGAField(TFArtifactMetaData.TFFields.assignedTo.getFieldName(), ga);
    String reportedReleaseId = GenericArtifactHelper
            .getStringMandatoryGAField(TFArtifactMetaData.TFFields.reportedReleaseId.getFieldName(), ga);
    String resolvedReleaseId = GenericArtifactHelper
            .getStringMandatoryGAField(TFArtifactMetaData.TFFields.resolvedReleaseId.getFieldName(), ga);
    String title = GenericArtifactHelper
            .getStringMandatoryGAField(TFArtifactMetaData.TFFields.title.getFieldName(), ga);
    String[] comments = this.getComments(ga);
    ArtifactDO result = null;
    try {
        if (this.translateTechnicalReleaseIds) {
            reportedReleaseId = TFTrackerHandler.convertReleaseId(connection, reportedReleaseId, folderId,
                    isReleaseIdFieldsContainFileReleasePackageName() ? getPackageReleaseSeparatorString()
                            : null);
            resolvedReleaseId = TFTrackerHandler.convertReleaseId(connection, resolvedReleaseId, folderId,
                    isReleaseIdFieldsContainFileReleasePackageName() ? getPackageReleaseSeparatorString()
                            : null);
        }

        // now we have to deal with the parent dependencies
        String parentId = ga.getDepParentTargetArtifactId();
        boolean associateWithParent = false;
        if (parentId != null && !parentId.equals(GenericArtifact.VALUE_UNKNOWN)
                && !parentId.equals(GenericArtifact.VALUE_NONE)) {
            // parent is a planning folder
            if (parentId.startsWith("plan")) {
                planningFolder = parentId;
            } else {
                associateWithParent = true;
                if (planningFolder == null) {
                    ArtifactDO parentArtifact = connection.getTrackerClient().getArtifactData(parentId);
                    planningFolder = parentArtifact.getPlanningFolderId();
                }

            }
        }

        result = trackerHandler.createArtifact(connection, folderId, description, category, group, status,
                statusClass, customer, priority, estimatedEffort, actualEffort, closeDate, assignedTo,
                reportedReleaseId, resolvedReleaseId, flexFieldNames, flexFieldValues, flexFieldTypes, title,
                comments, remainingEffort, autosumming, planningFolder, points);

        // now create parent dependency
        if (associateWithParent) {
            trackerHandler.createArtifactDependency(connection, parentId, result.getId(),
                    "CCF created parent-child dependency");
        }

        log.info("New artifact " + result.getId() + " is created with the change from "
                + ga.getSourceArtifactId());
    } catch (RemoteException e) {
        String cause = "While trying to create an artifact within TF, an error occured";
        log.error(cause, e);
        ga.setErrorCode(GenericArtifact.ERROR_EXTERNAL_SYSTEM_WRITE);
        throw new CCFRuntimeException(cause, e);
    } catch (PlanningFolderRuleViolationException e) {
        String cause = "While trying to create an artifact within TF, a planning folder rule violation occured: "
                + e.getMessage();
        log.error(cause, e);
        ga.setErrorCode(GenericArtifact.ERROR_EXTERNAL_SYSTEM_WRITE);
        throw new CCFRuntimeException(cause, e);
    }
    return result;
}

From source file:com.collabnet.ccf.teamforge.TFWriter.java

/**
 * Creates the artifact represented by the GenericArtifact object on the
 * target TF system/*from   ww  w.  j  av a 2  s.  com*/
 * 
 * @param ga
 * @param tracker
 * @param forceOverride
 * @param connection
 * @return - returns the updated artifact's ArtifactSoapDO object
 */
private ArtifactDO updateArtifact(GenericArtifact ga, String tracker, Connection connection) {
    String id = ga.getTargetArtifactId();
    ArrayList<String> flexFieldNames = new ArrayList<String>();
    ArrayList<String> flexFieldTypes = new ArrayList<String>();
    ArrayList<Object> flexFieldValues = new ArrayList<Object>();
    Set<String> overriddenFlexFields = new HashSet<String>();
    List<GenericArtifactField> gaFields = ga
            .getAllGenericArtifactFieldsWithSameFieldType(GenericArtifactField.VALUE_FIELD_TYPE_FLEX_FIELD);
    String targetSystemTimezone = ga.getTargetSystemTimezone();
    if (gaFields != null) {
        for (GenericArtifactField gaField : gaFields) {
            String fieldName = gaField.getFieldName();
            if (COMMENT_TEXT.equals(fieldName)) {
                continue;
            }
            if (gaField.getFieldValueHasChanged()) {
                overriddenFlexFields.add(fieldName);
            } else {
                continue;
            }
            String trackerFieldValueType = TFArtifactMetaData
                    .getTFFieldValueTypeForGAFieldType(gaField.getFieldValueType());
            flexFieldNames.add(fieldName);
            flexFieldTypes.add(trackerFieldValueType);
            Object value = null;
            FieldValueTypeValue fieldType = gaField.getFieldValueType();
            if (trackerFieldValueType.equals(TrackerFieldSoapDO.FIELD_VALUE_TYPE_DATE)) {
                if (fieldType == FieldValueTypeValue.DATE) {
                    GregorianCalendar gc = (GregorianCalendar) gaField.getFieldValue();
                    if (gc != null) {
                        Date dateValue = gc.getTime();
                        if (DateUtil.isAbsoluteDateInTimezone(dateValue, "GMT")) {
                            value = DateUtil.convertGMTToTimezoneAbsoluteDate(dateValue, targetSystemTimezone);
                        } else {
                            value = dateValue;
                        }
                    }
                } else if (fieldType == FieldValueTypeValue.DATETIME) {
                    value = gaField.getFieldValue();
                }
            } else {
                value = gaField.getFieldValue();
            }
            flexFieldValues.add(value);
        }
    }

    GenericArtifactField folderId = GenericArtifactHelper
            .getMandatoryGAField(TFArtifactMetaData.TFFields.folderId.getFieldName(), ga);
    GenericArtifactField description = GenericArtifactHelper
            .getMandatoryGAField(TFArtifactMetaData.TFFields.description.getFieldName(), ga);
    GenericArtifactField category = GenericArtifactHelper
            .getMandatoryGAField(TFArtifactMetaData.TFFields.category.getFieldName(), ga);
    GenericArtifactField group = GenericArtifactHelper
            .getMandatoryGAField(TFArtifactMetaData.TFFields.group.getFieldName(), ga);
    GenericArtifactField status = GenericArtifactHelper
            .getMandatoryGAField(TFArtifactMetaData.TFFields.status.getFieldName(), ga);
    GenericArtifactField statusClass = GenericArtifactHelper
            .getMandatoryGAField(TFArtifactMetaData.TFFields.statusClass.getFieldName(), ga);
    GenericArtifactField customer = GenericArtifactHelper
            .getMandatoryGAField(TFArtifactMetaData.TFFields.customer.getFieldName(), ga);
    GenericArtifactField priority = GenericArtifactHelper
            .getMandatoryGAField(TFArtifactMetaData.TFFields.priority.getFieldName(), ga);

    GenericArtifactField estimatedEffort = null;
    GenericArtifactField actualEffort = null;
    GenericArtifactField remainingEffort = null;
    GenericArtifactField planningFolder = null;
    GenericArtifactField autosumming = null;

    estimatedEffort = GenericArtifactHelper
            .getMandatoryGAField(TFArtifactMetaData.TFFields.estimatedHours.getFieldName(), ga);
    actualEffort = GenericArtifactHelper
            .getMandatoryGAField(TFArtifactMetaData.TFFields.actualHours.getFieldName(), ga);

    if (connection.supports53()) {
        remainingEffort = GenericArtifactHelper
                .getMandatoryGAField(TFArtifactMetaData.TFFields.remainingEffort.getFieldName(), ga);
        planningFolder = GenericArtifactHelper
                .getMandatoryGAField(TFArtifactMetaData.TFFields.planningFolder.getFieldName(), ga);
        autosumming = GenericArtifactHelper
                .getMandatoryGAField(TFArtifactMetaData.TFFields.autosumming.getFieldName(), ga);
    }

    GenericArtifactField storyPoints = null;
    if (connection.supports54()) {
        storyPoints = GenericArtifactHelper
                .getMandatoryGAField(TFArtifactMetaData.TFFields.points.getFieldName(), ga);
    }

    GenericArtifactField closeDate = GenericArtifactHelper
            .getMandatoryGAField(TFArtifactMetaData.TFFields.closeDate.getFieldName(), ga);
    GenericArtifactField assignedTo = GenericArtifactHelper
            .getMandatoryGAField(TFArtifactMetaData.TFFields.assignedTo.getFieldName(), ga);
    GenericArtifactField reportedReleaseId = GenericArtifactHelper
            .getMandatoryGAField(TFArtifactMetaData.TFFields.reportedReleaseId.getFieldName(), ga);
    GenericArtifactField resolvedReleaseId = GenericArtifactHelper
            .getMandatoryGAField(TFArtifactMetaData.TFFields.resolvedReleaseId.getFieldName(), ga);
    GenericArtifactField title = GenericArtifactHelper
            .getMandatoryGAField(TFArtifactMetaData.TFFields.title.getFieldName(), ga);

    String[] comments = this.getComments(ga);
    ArtifactDO result = null;
    try {
        // now we have to deal with the parent dependencies
        String newParentId = ga.getDepParentTargetArtifactId();
        boolean associateWithParent = false;
        boolean deleteOldParentAssociation = false;
        String currentParentId = null;

        if (newParentId != null && !newParentId.equals(GenericArtifact.VALUE_UNKNOWN)) {
            // now find out current parent id
            ArtifactDependencyRow[] parents = trackerHandler.getArtifactParentDependencies(connection, id);
            if (parents.length != 0) {
                // only take first entry of this record
                ArtifactDependencyRow parent = parents[0];
                currentParentId = parent.getOriginId();
            }

            if (newParentId.equals(GenericArtifact.VALUE_NONE)) {
                // we have to set the planning folder to null
                planningFolder = TFToGenericArtifactConverter.createGenericArtifactField(
                        TFArtifactMetaData.TFFields.planningFolder, null, ga, null, false);

                // we have to deassociate the old parent
                if (currentParentId != null) {
                    deleteOldParentAssociation = true;
                }
            }

            else if (newParentId.startsWith("plan")) {
                // we have to set the planning folder to the new parent
                planningFolder = TFToGenericArtifactConverter.createGenericArtifactField(
                        TFArtifactMetaData.TFFields.planningFolder, newParentId, ga, null, false);

                // we have to deassociate the old parent
                if (currentParentId != null) {
                    deleteOldParentAssociation = true;
                }
            }

            else if (!newParentId.equals(currentParentId)) {
                // new parent is a tracker item
                // we have to deassociate the old parent
                if (currentParentId != null) {
                    deleteOldParentAssociation = true;
                }
                associateWithParent = true;
                // we have to change the planning folder if there was no
                // special value requested for this
                if (connection.supports53()
                        && (planningFolder == null || !planningFolder.getFieldValueHasChanged())) {
                    ArtifactDO parentArtifact = trackerHandler.getTrackerItem(connection, newParentId);
                    planningFolder = TFToGenericArtifactConverter.createGenericArtifactField(
                            TFArtifactMetaData.TFFields.planningFolder, parentArtifact.getPlanningFolderId(),
                            ga, null, false);
                }
            }
        }

        result = trackerHandler.updateArtifact(ga, connection, folderId, description, category, group, status,
                statusClass, customer, priority, estimatedEffort, actualEffort, closeDate, assignedTo,
                reportedReleaseId, resolvedReleaseId, flexFieldNames, flexFieldValues, flexFieldTypes,
                overriddenFlexFields, title, id, comments, translateTechnicalReleaseIds, remainingEffort,
                autosumming, storyPoints, planningFolder, deleteOldParentAssociation, currentParentId,
                associateWithParent, newParentId,
                isReleaseIdFieldsContainFileReleasePackageName() ? getPackageReleaseSeparatorString() : null);

        if (result != null) {
            log.info("Artifact " + id + " is updated successfully");
        }
    } catch (RemoteException e) {
        String cause = "While trying to update an artifact within TF, an error occured";
        log.error(cause, e);
        ga.setErrorCode(GenericArtifact.ERROR_EXTERNAL_SYSTEM_WRITE);
        throw new CCFRuntimeException(cause, e);
    } catch (PlanningFolderRuleViolationException e) {
        String cause = "While trying to update an artifact within TF, a planning folder rule violation occured: "
                + e.getMessage();
        log.error(cause, e);
        ga.setErrorCode(GenericArtifact.ERROR_EXTERNAL_SYSTEM_WRITE);
        throw new CCFRuntimeException(cause, e);
    }
    return result;
}

From source file:io.snappydata.hydra.cluster.SnappyTest.java

/**
 * Task(ENDTASK) for cleaning up snappy processes, because they are not stopped by Hydra in case of Test failure.
 *//*from  w  w  w.j  a va 2s .  co  m*/
public static void HydraTask_cleanUpSnappyProcessesOnFailure() {
    Process pr = null;
    ProcessBuilder pb = null;
    File logFile = null, log = null, nukeRunOutput = null;
    try {
        List<String> pidList = new ArrayList();
        HostDescription hd = TestConfig.getInstance().getMasterDescription().getVmDescription()
                .getHostDescription();
        pidList = snappyTest.getPidList();
        log = new File(".");
        String nukerun = log.getCanonicalPath() + File.separator + "snappyNukeRun.sh";
        logFile = new File(nukerun);
        String nukeRunOutputString = log.getCanonicalPath() + File.separator + "nukeRunOutput.log";
        nukeRunOutput = new File(nukeRunOutputString);
        FileWriter fw = new FileWriter(logFile.getAbsoluteFile(), true);
        BufferedWriter bw = new BufferedWriter(fw);
        for (String pidString : pidList) {
            int pid = Integer.parseInt(pidString);
            bw.write("/bin/kill -KILL " + pid);
            bw.newLine();
            try {
                RemoteTestModule.Master.removePID(hd, pid);
            } catch (RemoteException e) {
                String s = "Failed to remove PID from nukerun script: " + pid;
                throw new HydraRuntimeException(s, e);
            }
        }
        bw.close();
        fw.close();
        logFile.setExecutable(true);
        pb = new ProcessBuilder(nukerun);
        pb.redirectErrorStream(true);
        pb.redirectOutput(ProcessBuilder.Redirect.appendTo(nukeRunOutput));
        pr = pb.start();
        pr.waitFor();
    } catch (IOException e) {
        throw new TestException("IOException occurred while retriving logFile path " + log + "\nError Message:"
                + e.getMessage());
    } catch (InterruptedException e) {
        String s = "Exception occurred while waiting for the process execution : " + pr;
        throw new TestException(s, e);
    }
}

From source file:org.apache.manifoldcf.crawler.connectors.meridio.MeridioConnector.java

/** Close the connection.  Call this before discarding the repository connector.
*///from  w  ww  .j a  v  a 2s  .  c o  m
@Override
public void disconnect() throws ManifoldCFException {
    Logging.connectors.debug("Meridio: Entering 'disconnect' method");

    try {
        if (meridio_ != null) {
            meridio_.logout();
        }
    } catch (org.apache.axis.AxisFault e) {
        long currentTime = System.currentTimeMillis();
        if (e.getFaultCode().equals(new javax.xml.namespace.QName("http://xml.apache.org/axis/", "HTTP"))) {
            org.w3c.dom.Element elem = e.lookupFaultDetail(
                    new javax.xml.namespace.QName("http://xml.apache.org/axis/", "HttpErrorCode"));
            if (elem != null) {
                elem.normalize();
                String httpErrorCode = elem.getFirstChild().getNodeValue().trim();
                Logging.connectors.warn(
                        "Unexpected http error code " + httpErrorCode + " logging out: " + e.getMessage());
                return;
            }
            Logging.connectors.warn("Unknown http error occurred while logging out: " + e.getMessage());
            return;
        }
        if (e.getFaultCode().equals(new javax.xml.namespace.QName("http://schemas.xmlsoap.org/soap/envelope/",
                "Server.userException"))) {
            String exceptionName = e.getFaultString();
            if (exceptionName.equals("java.lang.InterruptedException"))
                throw new ManifoldCFException("Interrupted", ManifoldCFException.INTERRUPTED);
        }
        if (e.getFaultCode()
                .equals(new javax.xml.namespace.QName("http://schemas.xmlsoap.org/soap/envelope/", "Server"))) {
            if (e.getFaultString().indexOf(" 23031#") != -1) {
                // This means that the session has expired, so reset it and retry
                meridio_ = null;
                return;
            }
        }

        Logging.connectors.warn("Meridio: Got an unknown remote exception logging out - axis fault = "
                + e.getFaultCode().getLocalPart() + ", detail = " + e.getFaultString(), e);
        return;
    } catch (RemoteException remoteException) {
        Logging.connectors.warn(
                "Meridio: A remote exception occurred while " + "logging out: " + remoteException.getMessage(),
                remoteException);
    } finally {
        super.disconnect();
        meridio_ = null;
        urlBase = null;
        urlVersionBase = null;
        DmwsURL = null;
        RmwsURL = null;
        mySSLFactory = null;
        Logging.connectors.debug("Meridio: Exiting 'disconnect' method");
    }
}

From source file:org.apache.manifoldcf.crawler.connectors.meridio.MeridioConnector.java

/** Queue "seed" documents.  Seed documents are the starting places for crawling activity.  Documents
* are seeded when this method calls appropriate methods in the passed in ISeedingActivity object.
*
* This method can choose to find repository changes that happen only during the specified time interval.
* The seeds recorded by this method will be viewed by the framework based on what the
* getConnectorModel() method returns.//from w w  w.j a  v  a 2s  . c  o m
*
* It is not a big problem if the connector chooses to create more seeds than are
* strictly necessary; it is merely a question of overall work required.
*
* The end time and seeding version string passed to this method may be interpreted for greatest efficiency.
* For continuous crawling jobs, this method will
* be called once, when the job starts, and at various periodic intervals as the job executes.
*
* When a job's specification is changed, the framework automatically resets the seeding version string to null.  The
* seeding version string may also be set to null on each job run, depending on the connector model returned by
* getConnectorModel().
*
* Note that it is always ok to send MORE documents rather than less to this method.
* The connector will be connected before this method can be called.
*@param activities is the interface this method should use to perform whatever framework actions are desired.
*@param spec is a document specification (that comes from the job).
*@param seedTime is the end of the time range of documents to consider, exclusive.
*@param lastSeedVersionString is the last seeding version string for this job, or null if the job has no previous seeding version string.
*@param jobMode is an integer describing how the job is being run, whether continuous or once-only.
*@return an updated seeding version string, to be stored with the job.
*/
@Override
public String addSeedDocuments(ISeedingActivity activities, Specification spec, String lastSeedVersion,
        long seedTime, int jobMode) throws ManifoldCFException, ServiceInterruption {
    Logging.connectors.debug("Meridio: Entering 'addSeedDocuments' method");
    long startTime;
    if (lastSeedVersion == null)
        startTime = 0L;
    else {
        // Unpack seed time from seed version string
        startTime = new Long(lastSeedVersion).longValue();
    }
    // Adjust start time so that we don't miss documents that squeeze in with earlier timestamps after we've already scanned that interval.
    // Chose an interval of 15 minutes, but I've never seen this effect take place over a time interval even 1/10 of that.
    long timeAdjust = 15L * 60000L;
    if (startTime > timeAdjust)
        startTime -= timeAdjust;
    else
        startTime = 0L;

    while (true) {
        getSession();

        try {
            DMSearchResults searchResults;
            int numResultsReturnedByStream = 0;

            while (true) {
                searchResults = documentSpecificationSearch(spec, startTime, seedTime,
                        numResultsReturnedByStream + 1, maxHitsToReturn);

                for (int i = 0; i < searchResults.returnedHitsCount; i++) {
                    long documentId = searchResults.dsDM.getSEARCHRESULTS_DOCUMENTS()[i].getDocId();

                    String strDocumentId = new Long(documentId).toString();
                    activities.addSeedDocument(strDocumentId);
                }

                numResultsReturnedByStream += searchResults.returnedHitsCount;
                if (numResultsReturnedByStream == searchResults.totalHitsCount)
                    break;
            }
            return new Long(seedTime).toString();
        } catch (org.apache.axis.AxisFault e) {
            long currentTime = System.currentTimeMillis();
            if (e.getFaultCode().equals(new javax.xml.namespace.QName("http://xml.apache.org/axis/", "HTTP"))) {
                org.w3c.dom.Element elem = e.lookupFaultDetail(
                        new javax.xml.namespace.QName("http://xml.apache.org/axis/", "HttpErrorCode"));
                if (elem != null) {
                    elem.normalize();
                    String httpErrorCode = elem.getFirstChild().getNodeValue().trim();
                    throw new ManifoldCFException("Unexpected http error code " + httpErrorCode
                            + " accessing Meridio: " + e.getMessage(), e);
                }
                throw new ManifoldCFException(
                        "Unknown http error occurred while performing search: " + e.getMessage(), e);
            }
            if (e.getFaultCode().equals(new javax.xml.namespace.QName(
                    "http://schemas.xmlsoap.org/soap/envelope/", "Server.userException"))) {
                String exceptionName = e.getFaultString();
                if (exceptionName.equals("java.lang.InterruptedException"))
                    throw new ManifoldCFException("Interrupted", ManifoldCFException.INTERRUPTED);
            }
            if (e.getFaultCode().equals(
                    new javax.xml.namespace.QName("http://schemas.xmlsoap.org/soap/envelope/", "Server"))) {
                if (e.getFaultString().indexOf(" 23031#") != -1) {
                    // This means that the session has expired, so reset it and retry
                    meridio_ = null;
                    continue;
                }
            }
            if (Logging.connectors.isDebugEnabled())
                Logging.connectors.debug(
                        "Meridio: Got an unknown remote exception while performing search - axis fault = "
                                + e.getFaultCode().getLocalPart() + ", detail = " + e.getFaultString()
                                + " - retrying",
                        e);
            throw new ServiceInterruption("Remote procedure exception: " + e.getMessage(), e,
                    currentTime + 300000L, currentTime + 3 * 60 * 60000L, -1, false);
        } catch (RemoteException remoteException) {
            throw new ManifoldCFException("Meridio: A Remote Exception occurred while "
                    + "performing a search: " + remoteException.getMessage(), remoteException);
        } catch (MeridioDataSetException meridioDataSetException) {
            throw new ManifoldCFException("Meridio: A problem occurred manipulating the Web " + "Service XML: "
                    + meridioDataSetException.getMessage(), meridioDataSetException);
        }
    }

}

From source file:org.apache.manifoldcf.crawler.connectors.meridio.MeridioConnector.java

/** Returns the categories set up in the Meridio system; these are used by the UI for two
* purposes//  w  ww  .j  ava 2  s .  co m
*
*              1)      To populate the "SearchCategory"
*                              Use "getPROP_title()" on the list of CATEGORIES object in
*                              the return ArrayList
*              2)  To assist with population of the metadata values to return. The
*                      available metadata depends on the chosen category
*
*@return Sorted array of strings containing the category names
*/
public String[] getMeridioCategories() throws ManifoldCFException, ServiceInterruption {
    Logging.connectors.debug("Entering 'getMeridioCategories' method");

    while (true) {
        getSession();
        ArrayList returnCategories = new ArrayList();

        try {
            CATEGORIES[] categories = meridio_.getCategories().getCATEGORIES();
            for (int i = 0; i < categories.length; i++) {
                if (categories[i].getPROP_categoryId() == 4 || // Global Document Category
                        categories[i].getPROP_categoryId() == 5 || // Mail Message
                        categories[i].getPROP_categoryId() > 100) // Custom Document Category
                {
                    if (!categories[i].getPROP_title().equals("<None>")) {
                        Logging.connectors.debug("Adding category <" + categories[i].getPROP_title() + ">");
                        returnCategories.add(categories[i].getPROP_title());
                    }
                }
            }

            String[] returnStringArray = new String[returnCategories.size()];
            Iterator it = returnCategories.iterator();
            for (int i = 0; it.hasNext(); i++) {
                returnStringArray[i] = (String) it.next();
            }

            java.util.Arrays.sort(returnStringArray);

            Logging.connectors.debug("Exiting 'getMeridioCategories' method");

            return returnStringArray;
        } catch (org.apache.axis.AxisFault e) {
            long currentTime = System.currentTimeMillis();
            if (e.getFaultCode().equals(new javax.xml.namespace.QName("http://xml.apache.org/axis/", "HTTP"))) {
                org.w3c.dom.Element elem = e.lookupFaultDetail(
                        new javax.xml.namespace.QName("http://xml.apache.org/axis/", "HttpErrorCode"));
                if (elem != null) {
                    elem.normalize();
                    String httpErrorCode = elem.getFirstChild().getNodeValue().trim();
                    throw new ManifoldCFException("Unexpected http error code " + httpErrorCode
                            + " getting categories: " + e.getMessage());
                }
                throw new ManifoldCFException(
                        "Unknown http error occurred while getting categories: " + e.getMessage(), e);
            }
            if (e.getFaultCode().equals(new javax.xml.namespace.QName(
                    "http://schemas.xmlsoap.org/soap/envelope/", "Server.userException"))) {
                String exceptionName = e.getFaultString();
                if (exceptionName.equals("java.lang.InterruptedException"))
                    throw new ManifoldCFException("Interrupted", ManifoldCFException.INTERRUPTED);
            }
            if (e.getFaultCode().equals(
                    new javax.xml.namespace.QName("http://schemas.xmlsoap.org/soap/envelope/", "Server"))) {
                if (e.getFaultString().indexOf(" 23031#") != -1) {
                    // This means that the session has expired, so reset it and retry
                    meridio_ = null;
                    continue;
                }
            }

            throw new ManifoldCFException(
                    "Meridio: Got an unknown remote exception getting categories - axis fault = "
                            + e.getFaultCode().getLocalPart() + ", detail = " + e.getFaultString(),
                    e);
        } catch (RemoteException remoteException) {
            throw new ManifoldCFException("Meridio: A Remote Exception occurred while "
                    + "retrieving the Meridio categories: " + remoteException.getMessage(), remoteException);
        } catch (MeridioDataSetException meridioDataSetException) {
            throw new ManifoldCFException(
                    "Meridio: DataSet Exception occurred retrieving the Meridio categories: "
                            + meridioDataSetException.getMessage(),
                    meridioDataSetException);
        }
    }
}

From source file:org.apache.manifoldcf.crawler.connectors.meridio.MeridioConnector.java

public MeridioClassContents[] getClassOrFolderContents(int classOrFolderId)
        throws ManifoldCFException, ServiceInterruption {
    Logging.connectors.debug("Entering 'getClassOrFolderContents' method");

    while (true) {
        getSession();//  ww  w  .j  a  v  a2  s.  c om
        ArrayList meridioContainers = new ArrayList();

        try {
            RMDataSet ds = meridio_.getClassContents(classOrFolderId, false, false, false);
            if (ds == null) {
                Logging.connectors.debug("No classes or folders in returned DataSet");
                return new MeridioClassContents[] {};
            }

            Rm2vClass[] classes = ds.getRm2vClass();
            Rm2vFolder[] folders = ds.getRm2vFolder();

            for (int i = 0; i < classes.length; i++) {
                if (classes[i].getHomePage() == null || classes[i].getHomePage().length() == 0) // Not a federated link
                {
                    MeridioClassContents classContents = new MeridioClassContents();

                    classContents.containerType = MeridioClassContents.CLASS;
                    classContents.classOrFolderId = classes[i].getId();
                    classContents.classOrFolderName = classes[i].getName();

                    meridioContainers.add(classContents);
                }
            }

            for (int i = 0; i < folders.length; i++) {
                MeridioClassContents classContents = new MeridioClassContents();

                classContents.containerType = MeridioClassContents.FOLDER;
                classContents.classOrFolderId = folders[i].getId();
                classContents.classOrFolderName = folders[i].getName();

                meridioContainers.add(classContents);
            }

            MeridioClassContents[] classArray = new MeridioClassContents[meridioContainers.size()];
            Iterator it = meridioContainers.iterator();
            for (int i = 0; it.hasNext(); i++) {
                classArray[i] = (MeridioClassContents) it.next();
            }
            Logging.connectors.debug("Exiting 'getClassOrFolderContents' method");

            return classArray;
        } catch (org.apache.axis.AxisFault e) {
            long currentTime = System.currentTimeMillis();
            if (e.getFaultCode().equals(new javax.xml.namespace.QName("http://xml.apache.org/axis/", "HTTP"))) {
                org.w3c.dom.Element elem = e.lookupFaultDetail(
                        new javax.xml.namespace.QName("http://xml.apache.org/axis/", "HttpErrorCode"));
                if (elem != null) {
                    elem.normalize();
                    String httpErrorCode = elem.getFirstChild().getNodeValue().trim();
                    throw new ManifoldCFException("Unexpected http error code " + httpErrorCode
                            + " getting class or folder contents: " + e.getMessage());
                }
                throw new ManifoldCFException(
                        "Unknown http error occurred while getting class or folder contents: " + e.getMessage(),
                        e);
            }
            if (e.getFaultCode().equals(new javax.xml.namespace.QName(
                    "http://schemas.xmlsoap.org/soap/envelope/", "Server.userException"))) {
                String exceptionName = e.getFaultString();
                if (exceptionName.equals("java.lang.InterruptedException"))
                    throw new ManifoldCFException("Interrupted", ManifoldCFException.INTERRUPTED);
            }
            if (e.getFaultCode().equals(
                    new javax.xml.namespace.QName("http://schemas.xmlsoap.org/soap/envelope/", "Server"))) {
                if (e.getFaultString().indexOf(" 23031#") != -1) {
                    // This means that the session has expired, so reset it and retry
                    meridio_ = null;
                    continue;
                }
            }

            throw new ManifoldCFException(
                    "Meridio: Got an unknown remote exception getting class or folder contents - axis fault = "
                            + e.getFaultCode().getLocalPart() + ", detail = " + e.getFaultString(),
                    e);
        } catch (RemoteException remoteException) {
            throw new ManifoldCFException("Meridio: A Remote Exception occurred while "
                    + "retrieving class or folder contents: " + remoteException.getMessage(), remoteException);
        } catch (MeridioDataSetException meridioDataSetException) {
            throw new ManifoldCFException("Meridio: A problem occurred manipulating the Web " + "Service XML: "
                    + meridioDataSetException.getMessage(), meridioDataSetException);
        }
    }
}

From source file:org.apache.manifoldcf.crawler.connectors.meridio.MeridioConnector.java

/** Set up the session with Meridio */
protected void getSession() throws ManifoldCFException, ServiceInterruption {
    if (meridio_ == null) {
        // Do the first part (which used to be in connect() itself)
        try {//from ww w . j av a2s  . c o  m
            /*=================================================================
            * Construct the URL strings from the parameters
            *================================================================*/
            String DMWSProtocol = params.getParameter("DMWSServerProtocol");
            String DMWSPort = params.getParameter("DMWSServerPort");
            if (DMWSPort == null || DMWSPort.length() == 0)
                DMWSPort = "";
            else
                DMWSPort = ":" + DMWSPort;

            String Url = DMWSProtocol + "://" + params.getParameter("DMWSServerName") + DMWSPort
                    + params.getParameter("DMWSLocation");

            Logging.connectors.debug("Meridio: Document Management Web Service (DMWS) URL is [" + Url + "]");
            DmwsURL = new URL(Url);

            String RMWSProtocol = params.getParameter("RMWSServerProtocol");
            String RMWSPort = params.getParameter("RMWSServerPort");
            if (RMWSPort == null || RMWSPort.length() == 0)
                RMWSPort = "";
            else
                RMWSPort = ":" + RMWSPort;

            Url = RMWSProtocol + "://" + params.getParameter("RMWSServerName") + RMWSPort
                    + params.getParameter("RMWSLocation");

            Logging.connectors.debug("Meridio: Record Management Web Service (RMWS) URL is [" + Url + "]");
            RmwsURL = new URL(Url);

            // Set up ssl if indicated
            String keystoreData = params.getParameter("MeridioKeystore");

            if (keystoreData != null)
                mySSLFactory = KeystoreManagerFactory.make("", keystoreData).getSecureSocketFactory();
            else
                mySSLFactory = null;

            // Put together the url base
            String clientProtocol = params.getParameter("MeridioWebClientProtocol");
            String clientPort = params.getParameter("MeridioWebClientServerPort");
            if (clientPort == null || clientPort.length() == 0)
                clientPort = "";
            else
                clientPort = ":" + clientPort;
            urlVersionBase = clientProtocol + "://" + params.getParameter("MeridioWebClientServerName")
                    + clientPort + params.getParameter("MeridioWebClientDocDownloadLocation");
            urlBase = urlVersionBase + "?launchMode=1&launchAs=0&documentId=";

        } catch (MalformedURLException malformedURLException) {
            throw new ManifoldCFException(
                    "Meridio: Could not construct the URL for either " + "the DM or RM Meridio Web Service",
                    malformedURLException, ManifoldCFException.REPOSITORY_CONNECTION_ERROR);
        }

        // Do the second part (where we actually try to connect to the system)
        try {
            /*=================================================================
            * Now try and login to Meridio; the wrapper's constructor can be
            * used as it calls the Meridio login method
            *================================================================*/
            meridio_ = new MeridioWrapper(Logging.connectors, DmwsURL, RmwsURL, null,
                    params.getParameter("DMWSProxyHost"), params.getParameter("DMWSProxyPort"),
                    params.getParameter("RMWSProxyHost"), params.getParameter("RMWSProxyPort"), null,

                    null, params.getParameter("UserName"), params.getObfuscatedParameter("Password"),
                    InetAddress.getLocalHost().getHostName(), mySSLFactory,
                    org.apache.manifoldcf.connectorcommon.common.CommonsHTTPSender.class, "client-config.wsdd");
        } catch (NumberFormatException e) {
            throw new ManifoldCFException("Meridio: bad number: " + e.getMessage(), e);
        } catch (UnknownHostException unknownHostException) {
            throw new ManifoldCFException("Meridio: A Unknown Host Exception occurred while "
                    + "connecting - is a network software and hardware configuration: "
                    + unknownHostException.getMessage(), unknownHostException);
        } catch (org.apache.axis.AxisFault e) {
            long currentTime = System.currentTimeMillis();
            if (e.getFaultCode().equals(new javax.xml.namespace.QName("http://xml.apache.org/axis/", "HTTP"))) {
                org.w3c.dom.Element elem = e.lookupFaultDetail(
                        new javax.xml.namespace.QName("http://xml.apache.org/axis/", "HttpErrorCode"));
                if (elem != null) {
                    elem.normalize();
                    String httpErrorCode = elem.getFirstChild().getNodeValue().trim();
                    throw new ManifoldCFException("Unexpected http error code " + httpErrorCode
                            + " accessing Meridio: " + e.getMessage(), e);
                }
                throw new ManifoldCFException("Unknown http error occurred while connecting: " + e.getMessage(),
                        e);
            }
            if (e.getFaultCode().equals(new javax.xml.namespace.QName(
                    "http://schemas.xmlsoap.org/soap/envelope/", "Server.userException"))) {
                String exceptionName = e.getFaultString();
                if (exceptionName.equals("java.lang.InterruptedException"))
                    throw new ManifoldCFException("Interrupted", ManifoldCFException.INTERRUPTED);
            }
            if (Logging.connectors.isDebugEnabled())
                Logging.connectors.debug("Meridio: Got an unknown remote exception connecting - axis fault = "
                        + e.getFaultCode().getLocalPart() + ", detail = " + e.getFaultString() + " - retrying",
                        e);
            throw new ServiceInterruption("Remote procedure exception: " + e.getMessage(), e,
                    currentTime + 300000L, currentTime + 3 * 60 * 60000L, -1, false);
        } catch (RemoteException remoteException) {
            throw new ManifoldCFException("Meridio: An unknown remote exception occurred while "
                    + "connecting: " + remoteException.getMessage(), remoteException);
        }

    }
}