private void validate(
      File file,
      Collection<Exception> exceptions,
      Collection<MavenProjectProblem> problems,
      Collection<MavenId> unresolvedArtifacts)
      throws RemoteException {
    for (Exception each : exceptions) {
      Maven3ServerGlobals.getLogger().info(each);

      if (each instanceof InvalidProjectModelException) {
        ModelValidationResult modelValidationResult =
            ((InvalidProjectModelException) each).getValidationResult();
        if (modelValidationResult != null) {
          for (Object eachValidationProblem : modelValidationResult.getMessages()) {
            problems.add(
                MavenProjectProblem.createStructureProblem(
                    file.getPath(), (String) eachValidationProblem));
          }
        } else {
          problems.add(
              MavenProjectProblem.createStructureProblem(
                  file.getPath(), each.getCause().getMessage()));
        }
      } else if (each instanceof ProjectBuildingException) {
        String causeMessage =
            each.getCause() != null ? each.getCause().getMessage() : each.getMessage();
        problems.add(MavenProjectProblem.createStructureProblem(file.getPath(), causeMessage));
      } else {
        problems.add(MavenProjectProblem.createStructureProblem(file.getPath(), each.getMessage()));
      }
    }
    unresolvedArtifacts.addAll(retrieveUnresolvedArtifactIds());
  }
 private static Collection<String> collectProfilesIds(List<Profile> profiles) {
   Collection<String> result = new THashSet<String>();
   for (Profile each : profiles) {
     if (each.getId() != null) {
       result.add(each.getId());
     }
   }
   return result;
 }