Program: 160335
Project: 160335
Buggy source:
@Override public void triggerRevisionService(Long roid,Long soid) throws ServerException, UserException {
  DatabaseSession session=getBimServer().getDatabase().createSession();
  try {
    Revision revision=(Revision)session.get(StorePackage.eINSTANCE.getRevision(),roid,OldQuery.getDefault());
    if (revision == null) {
      throw new UserException("String_Node_Str" + roid);
    }
    NewService newService=session.get(StorePackage.eINSTANCE.getNewService(),soid,OldQuery.getDefault());
    if (revision.getServicesLinked().contains(newService)) {
      return;
    }
    String url=newService.getResourceUrl();
    SerializerPluginConfiguration serializer=newService.getSerializer();
    PackageMetaData pmd=getBimServer().getMetaDataManager().getPackageMetaData(revision.getProject().getSchema());
    Query query=DefaultQueries.all(pmd);
    Long topicId=download(Collections.singleton(roid),new JsonQueryObjectModelConverter(pmd).toJson(query).toString(),serializer.getOid(),false);
    CloseableHttpClient httpclient=HttpClients.createDefault();
    HttpPost httpPost=new HttpPost(url);
    LongAction<?> longAction=getBimServer().getLongActionManager().getLongAction(topicId);
    if (longAction == null) {
      throw new UserException("String_Node_Str" + topicId);
    }
    SCheckoutResult result;
    if (longAction instanceof LongStreamingDownloadAction) {
      LongStreamingDownloadAction longStreamingDownloadAction=(LongStreamingDownloadAction)longAction;
      if (longStreamingDownloadAction.getErrors().isEmpty()) {
        try {
          result=longStreamingDownloadAction.getCheckoutResult();
        }
 catch (        SerializerException e) {
          throw new UserException(e);
        }
      }
 else {
        LOGGER.error(longStreamingDownloadAction.getErrors().get(0));
        throw new ServerException(longStreamingDownloadAction.getErrors().get(0));
      }
    }
 else {
      LongDownloadOrCheckoutAction longDownloadAction=(LongDownloadOrCheckoutAction)longAction;
      try {
        longDownloadAction.waitForCompletion();
        if (longDownloadAction.getErrors().isEmpty()) {
          result=longDownloadAction.getCheckoutResult();
        }
 else {
          LOGGER.error(longDownloadAction.getErrors().get(0));
          throw new ServerException(longDownloadAction.getErrors().get(0));
        }
      }
 catch (      Exception e) {
        LOGGER.error("String_Node_Str",e);
        throw new ServerException(e);
      }
    }
    ByteArrayOutputStream baos=new ByteArrayOutputStream();
    LOGGER.info("String_Node_Str");
    DataSource datasource=result.getFile().getDataSource();
    if (datasource instanceof ExtendedDataSource) {
      ((ExtendedDataSource)datasource).writeToOutputStream(baos,null);
    }
    LOGGER.info("String_Node_Str");
    if (newService.getAccessToken() != null) {
      httpPost.setHeader("String_Node_Str","String_Node_Str" + newService.getAccessToken());
    }
    httpPost.setHeader("String_Node_Str",newService.getInput());
    httpPost.setHeader("String_Node_Str",newService.getOutput());
    httpPost.setEntity(new ByteArrayEntity(baos.toByteArray()));
    CloseableHttpResponse response=httpclient.execute(httpPost);
    LOGGER.info(response.getStatusLine().toString());
    if (response.getStatusLine().getStatusCode() == 401) {
      throw new UserException("String_Node_Str");
    }
 else     if (response.getStatusLine().getStatusCode() == 200) {
      Header[] headers=response.getHeaders("String_Node_Str");
      String filename="String_Node_Str";
      if (headers.length > 0) {
        String contentDisposition=headers[0].getValue();
        int indexOf=contentDisposition.indexOf("String_Node_Str") + 10;
        filename=contentDisposition.substring(indexOf,contentDisposition.indexOf("String_Node_Str",indexOf + 1));
      }
      Header dataTitleHeader=response.getFirstHeader("String_Node_Str");
      String dataTitle=newService.getName() + "String_Node_Str";
      if (dataTitleHeader != null) {
        dataTitle=dataTitleHeader.getValue();
      }
      byte[] responseBytes=ByteStreams.toByteArray(response.getEntity().getContent());
      LOGGER.info(new String(responseBytes,Charsets.UTF_8));
      Action action=newService.getAction();
      if (action instanceof StoreExtendedData) {
        SFile file=new SFile();
        file.setData(responseBytes);
        file.setFilename(filename);
        file.setSize(responseBytes.length);
        file.setMime(response.getHeaders("String_Node_Str")[0].getValue());
        Long fileId=uploadFile(file);
        SExtendedData extendedData=new SExtendedData();
        extendedData.setAdded(new Date());
        extendedData.setRevisionId(roid);
        extendedData.setTitle(dataTitle);
        extendedData.setSize(responseBytes.length);
        extendedData.setFileId(fileId);
        extendedData.setSchemaId(getExtendedDataSchemaByName(newService.getOutput()).getOid());
        addExtendedDataToRevision(roid,extendedData);
      }
 else       if (action instanceof CheckinRevision) {
        CheckinRevision checkinRevision=(CheckinRevision)action;
        Project targetProject=checkinRevision.getProject();
        String extension=filename.substring(filename.lastIndexOf("String_Node_Str") + 1);
        SDeserializerPluginConfiguration deserializer=getSuggestedDeserializerForExtension(extension,targetProject.getOid());
        Long checkingTopicId=initiateCheckin(targetProject.getOid(),deserializer.getOid());
        checkinInitiatedInternal(checkingTopicId,targetProject.getOid(),dataTitle,deserializer.getOid(),(long)responseBytes.length,filename,new DataHandler(new ByteArrayDataSource(responseBytes,"String_Node_Str")),false,true,newService.getOid());
      }
    }
 else {
      throw new UserException("String_Node_Str" + response.getStatusLine());
    }
  }
 catch (  Exception e) {
    handleException(e);
  }
 finally {
    session.close();
  }
}

Fixed version (ground truth):
@Override public void triggerRevisionService(Long roid,Long soid) throws ServerException, UserException {
  DatabaseSession session=getBimServer().getDatabase().createSession();
  try {
    Revision revision=(Revision)session.get(StorePackage.eINSTANCE.getRevision(),roid,OldQuery.getDefault());
    if (revision == null) {
      throw new UserException("String_Node_Str" + roid);
    }
    NewService newService=session.get(StorePackage.eINSTANCE.getNewService(),soid,OldQuery.getDefault());
    if (revision.getServicesLinked().contains(newService)) {
      return;
    }
    String url=newService.getResourceUrl();
    SerializerPluginConfiguration serializer=newService.getSerializer();
    PackageMetaData pmd=getBimServer().getMetaDataManager().getPackageMetaData(revision.getProject().getSchema());
    Query query=DefaultQueries.all(pmd);
    Long topicId=download(Collections.singleton(roid),new JsonQueryObjectModelConverter(pmd).toJson(query).toString(),serializer.getOid(),false);
    CloseableHttpClient httpclient=HttpClients.createDefault();
    HttpPost httpPost=new HttpPost(url);
    LongAction<?> longAction=getBimServer().getLongActionManager().getLongAction(topicId);
    if (longAction == null) {
      throw new UserException("String_Node_Str" + topicId);
    }
    SCheckoutResult result;
    if (longAction instanceof LongStreamingDownloadAction) {
      LongStreamingDownloadAction longStreamingDownloadAction=(LongStreamingDownloadAction)longAction;
      if (longStreamingDownloadAction.getErrors().isEmpty()) {
        try {
          result=longStreamingDownloadAction.getCheckoutResult();
        }
 catch (        SerializerException e) {
          throw new UserException(e);
        }
      }
 else {
        LOGGER.error(longStreamingDownloadAction.getErrors().get(0));
        throw new ServerException(longStreamingDownloadAction.getErrors().get(0));
      }
    }
 else {
      LongDownloadOrCheckoutAction longDownloadAction=(LongDownloadOrCheckoutAction)longAction;
      try {
        longDownloadAction.waitForCompletion();
        if (longDownloadAction.getErrors().isEmpty()) {
          result=longDownloadAction.getCheckoutResult();
        }
 else {
          LOGGER.error(longDownloadAction.getErrors().get(0));
          throw new ServerException(longDownloadAction.getErrors().get(0));
        }
      }
 catch (      Exception e) {
        LOGGER.error("String_Node_Str",e);
        throw new ServerException(e);
      }
    }
    ByteArrayOutputStream baos=new ByteArrayOutputStream();
    LOGGER.info("String_Node_Str");
    DataSource datasource=result.getFile().getDataSource();
    if (datasource instanceof ExtendedDataSource) {
      ((ExtendedDataSource)datasource).writeToOutputStream(baos,null);
    }
    LOGGER.info("String_Node_Str");
    if (newService.getAccessToken() != null) {
      httpPost.setHeader("String_Node_Str","String_Node_Str" + newService.getAccessToken());
    }
    httpPost.setHeader("String_Node_Str",newService.getInput());
    httpPost.setHeader("String_Node_Str",newService.getOutput());
    httpPost.setEntity(new ByteArrayEntity(baos.toByteArray()));
    CloseableHttpResponse response=httpclient.execute(httpPost);
    LOGGER.info(response.getStatusLine().toString());
    if (response.getStatusLine().getStatusCode() == 401) {
      throw new UserException("String_Node_Str");
    }
 else     if (response.getStatusLine().getStatusCode() == 200) {
      Header[] headers=response.getHeaders("String_Node_Str");
      String filename="String_Node_Str";
      if (headers.length > 0) {
        String contentDisposition=headers[0].getValue();
        int indexOf=contentDisposition.indexOf("String_Node_Str") + 10;
        filename=contentDisposition.substring(indexOf,contentDisposition.indexOf("String_Node_Str",indexOf + 1));
      }
      Header dataTitleHeader=response.getFirstHeader("String_Node_Str");
      String dataTitle=newService.getName() + "String_Node_Str";
      if (dataTitleHeader != null) {
        dataTitle=dataTitleHeader.getValue();
      }
      byte[] responseBytes=ByteStreams.toByteArray(response.getEntity().getContent());
      Action action=newService.getAction();
      if (action instanceof StoreExtendedData) {
        SFile file=new SFile();
        file.setData(responseBytes);
        file.setFilename(filename);
        file.setSize(responseBytes.length);
        file.setMime(response.getHeaders("String_Node_Str")[0].getValue());
        Long fileId=uploadFile(file);
        SExtendedData extendedData=new SExtendedData();
        extendedData.setAdded(new Date());
        extendedData.setRevisionId(roid);
        extendedData.setTitle(dataTitle);
        extendedData.setSize(responseBytes.length);
        extendedData.setFileId(fileId);
        extendedData.setSchemaId(getExtendedDataSchemaByName(newService.getOutput()).getOid());
        addExtendedDataToRevision(roid,extendedData);
      }
 else       if (action instanceof CheckinRevision) {
        CheckinRevision checkinRevision=(CheckinRevision)action;
        Project targetProject=checkinRevision.getProject();
        String extension=filename.substring(filename.lastIndexOf("String_Node_Str") + 1);
        SDeserializerPluginConfiguration deserializer=getSuggestedDeserializerForExtension(extension,targetProject.getOid());
        Long checkingTopicId=initiateCheckin(targetProject.getOid(),deserializer.getOid());
        checkinInitiatedInternal(checkingTopicId,targetProject.getOid(),dataTitle,deserializer.getOid(),(long)responseBytes.length,filename,new DataHandler(new ByteArrayDataSource(responseBytes,"String_Node_Str")),false,true,newService.getOid());
      }
    }
 else {
      throw new UserException("String_Node_Str" + response.getStatusLine());
    }
  }
 catch (  Exception e) {
    handleException(e);
  }
 finally {
    session.close();
  }
}