try {
RequestContainer requestContainer = this.getRequestContainer();
SessionContainer session = requestContainer.getSessionContainer();
impManager = (IImportManager)session.getAttribute(ImportExportConstants.IMPORT_MANAGER);
impManager.openSession();
MetadataAssociations metaAss = impManager.getMetadataAssociation();
List expDsIds = request.getAttributeAsList("expConn");
Iterator iterExpConn = expDsIds.iterator();
while(iterExpConn.hasNext()){
String expDsIdStr= (String)iterExpConn.next();
String assDsIds = (String)request.getAttribute("connAssociated"+ expDsIdStr);
if(!assDsIds.equals("")) {
metaAss.insertCoupleDataSources(new Integer(expDsIdStr), new Integer(assDsIds));
Object existingDSObj = impManager.getExistingObject(new Integer(assDsIds), SbiDataSource.class);
Object exportedDSObj = impManager.getExportedObject(new Integer(expDsIdStr), SbiDataSource.class);
if (existingDSObj != null && exportedDSObj != null) {
SbiDataSource existingDataSource = (SbiDataSource)existingDSObj;
SbiDataSource exportedDataSource = (SbiDataSource)exportedDSObj;
impManager.getUserAssociation().recordDataSourceAssociation(exportedDataSource.getLabel(), existingDataSource.getLabel());
impManager.getUserAssociation().recordDataSourceAssociation(Integer.valueOf(exportedDataSource.getDsId()), Integer.valueOf(existingDataSource.getDsId()));
}
}
// else {
// logger.error("Exported data source " +expConnName+" is not associated to a current " +
// "system data source");
// List exportedDataSources = impManager.getExportedDataSources();
// Map currentDataSources = getCurrentDataSourcesInfo();
// response.setAttribute(ImportExportConstants.LIST_EXPORTED_DATA_SOURCES, exportedDataSources);
// response.setAttribute(ImportExportConstants.MAP_CURRENT_DATA_SOURCES, currentDataSources);
// response.setAttribute(ImportExportConstants.PUBLISHER_NAME, "ImportExportDataSourceAssociation");
// throw new EMFValidationError(EMFErrorSeverity.ERROR, "connAssociated"+ expConnName, "sbi.impexp.datasourceNotAssociated");
// }
}
impManager.checkExistingMetadata();
if (metaAss.isEmpty()) {
response.setAttribute(ImportExportConstants.PUBLISHER_NAME,
"ImportExportSkipExistingMetadataAssociation");
} else {
response.setAttribute(ImportExportConstants.PUBLISHER_NAME,
"ImportExportExistingMetadataAssociation");