public BeanInjectionInfo(Class<?> clazz) { LOG.logDebug("Collect bean injection info for " + clazz); try { this.clazz = clazz; clazzAnnotation = clazz.getAnnotation(InjectionSupported.class); if (clazzAnnotation == null) { throw new RuntimeException("Injection not supported in " + clazz); } Group gr0 = new Group(""); groupsList.add(gr0); groupsMap.put(gr0.getName(), gr0); for (String group : clazzAnnotation.groups()) { Group gr = new Group(group); groupsList.add(gr); groupsMap.put(gr.getName(), gr); } BeanLevelInfo root = new BeanLevelInfo(); root.leafClass = clazz; root.init(this); properties = Collections.unmodifiableMap(properties); groupsList = Collections.unmodifiableList(groupsList); groupsMap = null; } catch (Throwable ex) { LOG.logError( "Error bean injection info collection for " + clazz + ": " + ex.getMessage(), ex); throw ex; } }
public void close() throws KettleException { try { if (!getQueryResult().isDone()) { this.qr.setDone(true); this.qr = null; } if (this.sObjects != null) { this.sObjects = null; } if (this.binding != null) { this.binding = null; } if (this.loginResult != null) { this.loginResult = null; } if (this.userInfo != null) { this.userInfo = null; } if (this.getDeletedList != null) { getDeletedList.clear(); getDeletedList = null; } if (log.isDetailed()) { log.logDetailed(BaseMessages.getString(PKG, "SalesforceInput.Log.ConnectionClosed")); } } catch (Exception e) { throw new KettleException( BaseMessages.getString(PKG, "SalesforceInput.Error.ClosingConnection"), e); } }
private void parseDocument() { // get a factory SAXParserFactory spf = SAXParserFactory.newInstance(); try { // get a new instance of parser SAXParser sp = spf.newSAXParser(); // parse the file and also register this class for call backs sp.parse(sourceFile, this); } catch (SAXException se) { log.logError(Const.getStackTracker(se)); } catch (ParserConfigurationException pce) { log.logError(Const.getStackTracker(pce)); } catch (IOException ie) { log.logError(Const.getStackTracker(ie)); } }
protected int getDataForRow(TableItem item, Object[] row) { int nrErrors = 0; // Display the correct line item... // String strNr; lineNr++; try { strNr = wFields.getNumberColumn().getValueMeta().getString(new Long(lineNr)); } catch (Exception e) { strNr = Integer.toString(lineNr); } item.setText(0, strNr); for (int c = 0; c < rowMeta.size(); c++) { ValueMetaInterface v = rowMeta.getValueMeta(c); String show; try { show = v.getString(row[c]); if (v.isBinary() && show != null && show.length() > MAX_BINARY_STRING_PREVIEW_SIZE) { // We want to limit the size of the strings during preview to keep all SWT widgets happy. // show = show.substring(0, MAX_BINARY_STRING_PREVIEW_SIZE); } } catch (KettleValueException e) { nrErrors++; if (nrErrors < 25) { log.logError(Const.getStackTracker(e)); } show = null; } catch (ArrayIndexOutOfBoundsException e) { nrErrors++; if (nrErrors < 25) { log.logError(Const.getStackTracker(e)); } show = null; } if (show != null) { item.setText(c + 1, show); } } return nrErrors; }
protected String calculateString( String packageName, String key, Object[] parameters, Class<?> resourceClass) { String string = null; // First try the standard locale, in the local package try { string = findString(packageName, langChoice.getDefaultLocale(), key, parameters, resourceClass); } catch (MissingResourceException e) { } ; if (string != null) return string; // Then try to find it in the i18n package, in the system messages of the preferred language. try { string = findString( SYSTEM_BUNDLE_PACKAGE, langChoice.getDefaultLocale(), key, parameters, resourceClass); } catch (MissingResourceException e) { } ; if (string != null) return string; // Then try the failover locale, in the local package try { string = findString(packageName, langChoice.getFailoverLocale(), key, parameters, resourceClass); } catch (MissingResourceException e) { } ; if (string != null) return string; // Then try to find it in the i18n package, in the system messages of the failover language. try { string = findString( SYSTEM_BUNDLE_PACKAGE, langChoice.getFailoverLocale(), key, parameters, resourceClass); } catch (MissingResourceException e) { } ; if (string != null) return string; string = "!" + key + "!"; String message = "Message not found in the preferred and failover locale: key=[" + key + "], package=" + packageName; log.logDetailed(Const.getStackTracker(new KettleException(message))); return string; }
/** Construct a new Salesforce Connection */ public SalesforceConnection( LogChannelInterface logInterface, String url, String username, String password) throws KettleException { this.log = logInterface; this.url = url; setUsername(username); setPassword(password); setTimeOut(0); this.binding = null; this.loginResult = null; this.userInfo = null; this.sql = null; this.serverTimestamp = null; this.qr = null; this.condition = null; this.startDate = null; this.endDate = null; this.sObjects = null; this.recordsFilter = SalesforceConnectionUtils.RECORDS_FILTER_ALL; this.fieldsList = null; this.queryResultSize = 0; this.recordsCount = 0; setUsingCompression(false); rollbackAllChangesOnError(false); // check target URL if (Const.isEmpty(getURL())) { throw new KettleException( BaseMessages.getString(PKG, "SalesforceInput.TargetURLMissing.Error")); } // check username if (Const.isEmpty(getUsername())) { throw new KettleException( BaseMessages.getString(PKG, "SalesforceInput.UsernameMissing.Error")); } if (log.isDetailed()) { logInterface.logDetailed(BaseMessages.getString(PKG, "SalesforceInput.Log.NewConnection")); } }
public Repository connectRepository(String repositoryName, String username, String password) throws KettleException { // Verify that the repository exists on the slave server... // RepositoriesMeta repositoriesMeta = new RepositoriesMeta(); repositoriesMeta.getLog().setLogLevel(log.getLogLevel()); try { repositoriesMeta.readData(); } catch (Exception e) { throw new KettleException( "Unable to get a list of repositories to locate repository '" + repositoryName + "'"); } return connectRepository(repositoriesMeta, repositoryName, username, password); }
protected String findString( String packageName, Locale locale, String key, Object[] parameters, Class<?> resourceClass) throws MissingResourceException { try { ResourceBundle bundle = getBundle(locale, packageName + "." + BUNDLE_NAME, resourceClass); String unformattedString = bundle.getString(key); String string = MessageFormat.format(unformattedString, parameters); return string; } catch (IllegalArgumentException e) { String message = "Format problem with key=[" + key + "], locale=[" + locale + "], package=" + packageName + " : " + e.toString(); log.logError(message); log.logError(Const.getStackTracker(e)); throw new MissingResourceException(message, packageName, key); } }
public Repository connectRepository( RepositoriesMeta repositoriesMeta, String repositoryName, String username, String password) throws KettleException { RepositoryMeta repositoryMeta = repositoriesMeta.findRepository(repositoryName); if (repositoryMeta == null) { log.logBasic("I couldn't find the repository with name '" + repositoryName + "'"); return null; } Repository rep = PluginRegistry.getInstance() .loadClass(RepositoryPluginType.class, repositoryMeta, Repository.class); rep.init(repositoryMeta); try { rep.connect(username, password); log.logBasic("Connected to " + repositoryName + " as " + username); setRepository(rep); return rep; } catch (Exception e) { log.logBasic("Unable to connect to the repository with name '" + repositoryName + "'"); return null; } }
@Override public void callExtensionPoint(LogChannelInterface log, Object object) throws KettleException { if (!(object instanceof CommandLineOption[])) { return; } CommandLineOption[] options = (CommandLineOption[]) object; StringBuilder optionRepname = getCommandLineOption(options, "rep").getArgument(); StringBuilder optionFilename = getCommandLineOption(options, "file").getArgument(); StringBuilder optionUsername = getCommandLineOption(options, "user").getArgument(); StringBuilder optionPassword = getCommandLineOption(options, "pass").getArgument(); if (!Utils.isEmpty(optionRepname) && Utils.isEmpty(optionFilename)) { RepositoryMeta repositoryMeta = repositoryConnectController.getRepositoryMetaByName(optionRepname.toString()); if (repositoryMeta != null && !Utils.isEmpty(optionUsername) && !Utils.isEmpty(optionPassword)) { repositoryConnectController.connectToRepository( repositoryMeta, optionUsername.toString(), optionPassword.toString()); } else if (repositoryMeta != null) { repositoryConnectController.connectToRepository(repositoryMeta, null, null); } if (!repositoryConnectController.isConnected()) { String msg = BaseMessages.getString(PKG, "Repository.NoConnected.Message"); log.logError(msg); // "No repositories defined on this system." MessageBox mb = new MessageBox(getSpoon().getShell(), SWT.OK | SWT.ICON_ERROR); mb.setMessage( BaseMessages.getString( PKG, "Repository.NoConnected.Message", optionRepname.toString())); mb.setText(BaseMessages.getString(PKG, "Repository.NoConnected.Message.Title")); mb.open(); } } else if (Utils.isEmpty(optionFilename)) { RepositoryMeta repositoryMeta = repositoryConnectController.getDefaultRepositoryMeta(); if (repositoryMeta != null) { if (repositoryMeta.getId().equals("KettleFileRepository")) { repositoryConnectController.connectToRepository(repositoryMeta); } else { new RepositoryDialog(getSpoon().getShell(), repositoryConnectController) .openLogin(repositoryMeta); } } } }
public void getUsedArguments( JobMeta jobMeta, String[] commandLineArguments, IMetaStore metaStore) { for (JobEntryCopy jobEntryCopy : jobMeta.jobcopies) { if (jobEntryCopy.isTransformation()) { JobEntryTrans jobEntryTrans = (JobEntryTrans) jobEntryCopy.getEntry(); try { TransMeta transMeta = jobEntryTrans.getTransMeta(repository, metaStore, jobMeta); Map<String, String> map = transMeta.getUsedArguments(commandLineArguments); for (String key : map.keySet()) { String value = map.get(key); if (!arguments.containsKey(key)) { arguments.put(key, value); } } } catch (KettleException ke) { log.logBasic(ke.getMessage(), ke); } } } }
// Event Handlers public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { // set the _counter level position[_counter + 1] += 1; _counter++; try { if (!rootFound) { XMLInputSaxFieldPosition el = null; try { el = (XMLInputSaxFieldPosition) pathToRootElement.get(counter); } catch (IndexOutOfBoundsException e) { throw new SAXException(e); } if ((counter == _counter) && qName.equalsIgnoreCase(el.getName())) { if (el.getType() == XMLInputSaxFieldPosition.XML_ELEMENT_ATT) { String att1 = attributes.getValue(el.getAttribute()); // must throw exception String att2 = el.getAttributeValue(); if (att1.equals(att2)) { _pathToRootElement.add( new XMLInputSaxFieldPosition( qName, el.getAttribute(), el.getAttributeValue())); // to test with clone if (counter == pathToRootElement.size() - 1) { for (int i = 0; i < attributes.getLength(); i++) { XMLInputSaxFieldPosition tempP = new XMLInputSaxFieldPosition( attributes.getQName(i), XMLInputSaxFieldPosition.XML_ATTRIBUTE, i + 1); _pathToRootElement.add(tempP); XMLInputSaxFieldPosition[] path = new XMLInputSaxFieldPosition[_pathToRootElement.size()]; _pathToRootElement.toArray(path); _pathToRootElement.remove(_pathToRootElement.size() - 1); XMLInputSaxField tempF = new XMLInputSaxField(tempP.getName(), path); if (!fields.contains(tempF)) { fields.add(tempF); } } } counterUp(); } else { _pathToRootElement.add( new XMLInputSaxFieldPosition( qName, XMLInputSaxFieldPosition.XML_ELEMENT_POS, position[_counter] + 1)); } } else { _pathToRootElement.add( new XMLInputSaxFieldPosition( qName, XMLInputSaxFieldPosition.XML_ELEMENT_POS, position[_counter] + 1)); counterUp(); } } else { _pathToRootElement.add( new XMLInputSaxFieldPosition( qName, XMLInputSaxFieldPosition.XML_ELEMENT_POS, position[_counter] + 1)); } } else { XMLInputSaxField temp = null; if (attributes.getValue(meta.getDefiningAttribute(qName)) == null) { _pathToRootElement.add( new XMLInputSaxFieldPosition( qName, XMLInputSaxFieldPosition.XML_ELEMENT_POS, position[_counter] + 1)); XMLInputSaxFieldPosition[] path = new XMLInputSaxFieldPosition[_pathToRootElement.size()]; _pathToRootElement.toArray(path); temp = new XMLInputSaxField(naming(path), path); } else { String attribute = meta.getDefiningAttribute(qName); _pathToRootElement.add( new XMLInputSaxFieldPosition(qName, attribute, attributes.getValue(attribute))); XMLInputSaxFieldPosition[] path = new XMLInputSaxFieldPosition[_pathToRootElement.size()]; _pathToRootElement.toArray(path); temp = new XMLInputSaxField(naming(path), path); } if (!fields.contains(temp)) { fields.add(temp); } } } catch (KettleValueException e) { log.logError(Const.getStackTracker(e)); throw new SAXException( _counter + "," + counter + ((XMLInputSaxFieldPosition) _pathToRootElement.get(_pathToRootElement.size() - 1)) .toString(), e); } }
public boolean validate() { boolean retval = false; FileObject xmlfile = null; FileObject DTDfile = null; ByteArrayInputStream ba = null; try { if (xmlfilename != null && ((getDTDFilename() != null && !isInternDTD()) || (isInternDTD()))) { xmlfile = KettleVFS.getFileObject(getXMLFilename()); if (xmlfile.exists()) { URL xmlFile = new File(KettleVFS.getFilename(xmlfile)).toURI().toURL(); StringBuffer xmlStringbuffer = new StringBuffer(""); BufferedReader xmlBufferedReader = null; InputStreamReader is = null; try { // open XML File is = new InputStreamReader(xmlFile.openStream()); xmlBufferedReader = new BufferedReader(is); char[] buffertXML = new char[1024]; int LenXML = -1; while ((LenXML = xmlBufferedReader.read(buffertXML)) != -1) { xmlStringbuffer.append(buffertXML, 0, LenXML); } } finally { if (is != null) { is.close(); } if (xmlBufferedReader != null) { xmlBufferedReader.close(); } } // Prepare parsing ... DocumentBuilderFactory DocBuilderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder DocBuilder = DocBuilderFactory.newDocumentBuilder(); // Let's try to get XML document encoding DocBuilderFactory.setValidating(false); ba = new ByteArrayInputStream(xmlStringbuffer.toString().getBytes("UTF-8")); Document xmlDocDTD = DocBuilder.parse(ba); if (ba != null) { ba.close(); } String encoding = null; if (xmlDocDTD.getXmlEncoding() == null) { encoding = "UTF-8"; } else { encoding = xmlDocDTD.getXmlEncoding(); } int xmlStartDTD = xmlStringbuffer.indexOf("<!DOCTYPE"); if (isInternDTD()) { // DTD find in the XML document if (xmlStartDTD != -1) { log.logBasic( BaseMessages.getString( PKG, "JobEntryDTDValidator.ERRORDTDFound.Label", getXMLFilename())); } else { setErrorMessage( BaseMessages.getString( PKG, "JobEntryDTDValidator.ERRORDTDNotFound.Label", getXMLFilename())); } } else { // DTD in external document // If we find an intern declaration, we remove it DTDfile = KettleVFS.getFileObject(getDTDFilename()); if (DTDfile.exists()) { if (xmlStartDTD != -1) { int EndDTD = xmlStringbuffer.indexOf(">", xmlStartDTD); // String DocTypeDTD = xmlStringbuffer.substring(xmlStartDTD, EndDTD + 1); xmlStringbuffer.replace(xmlStartDTD, EndDTD + 1, ""); } String xmlRootnodeDTD = xmlDocDTD.getDocumentElement().getNodeName(); String RefDTD = "<?xml version='" + xmlDocDTD.getXmlVersion() + "' encoding='" + encoding + "'?>\n<!DOCTYPE " + xmlRootnodeDTD + " SYSTEM '" + KettleVFS.getFilename(DTDfile) + "'>\n"; int xmloffsetDTD = xmlStringbuffer.indexOf("<" + xmlRootnodeDTD); xmlStringbuffer.replace(0, xmloffsetDTD, RefDTD); } else { log.logError( BaseMessages.getString(PKG, "JobEntryDTDValidator.ERRORDTDFileNotExists.Subject"), BaseMessages.getString( PKG, "JobEntryDTDValidator.ERRORDTDFileNotExists.Msg", getDTDFilename())); } } if (!(isInternDTD() && xmlStartDTD == -1 || (!isInternDTD() && !DTDfile.exists()))) { // Let's parse now ... MyErrorHandler error = new MyErrorHandler(); DocBuilderFactory.setValidating(true); DocBuilder = DocBuilderFactory.newDocumentBuilder(); DocBuilder.setErrorHandler(error); ba = new ByteArrayInputStream(xmlStringbuffer.toString().getBytes(encoding)); xmlDocDTD = DocBuilder.parse(ba); if (error.errorMessage == null) { log.logBasic( BaseMessages.getString(PKG, "JobEntryDTDValidator.DTDValidatorOK.Subject"), BaseMessages.getString( PKG, "JobEntryDTDValidator.DTDValidatorOK.Label", getXMLFilename())); // Everything is OK retval = true; } else { // Invalid DTD setNrErrors(error.nrErrors); setErrorMessage( BaseMessages.getString( PKG, "JobEntryDTDValidator.DTDValidatorKO", getXMLFilename(), error.nrErrors, error.errorMessage)); } } } else { if (!xmlfile.exists()) { setErrorMessage( BaseMessages.getString( PKG, "JobEntryDTDValidator.FileDoesNotExist.Label", getXMLFilename())); } } } else { setErrorMessage(BaseMessages.getString(PKG, "JobEntryDTDValidator.AllFilesNotNull.Label")); } } catch (Exception e) { setErrorMessage( BaseMessages.getString( PKG, "JobEntryDTDValidator.ErrorDTDValidator.Label", getXMLFilename(), getDTDFilename(), e.getMessage())); } finally { try { if (xmlfile != null) { xmlfile.close(); } if (DTDfile != null) { DTDfile.close(); } if (ba != null) { ba.close(); } } catch (IOException e) { // Ignore close errors } } return retval; }
@Override public void setLabel(String labelText) { log.logBasic(labelText); }
@Override public void showError(String title, String message, Exception e) { log.logError(message, e); }
@Override public void addLog(String line) { log.logBasic(line); }
public void query(boolean specifyQuery) throws KettleException { if (getBinding() == null) { throw new KettleException( BaseMessages.getString(PKG, "SalesforceInput.Exception.CanNotGetBiding")); } try { if (!specifyQuery) { // check if we can query this Object DescribeSObjectResult describeSObjectResult = getBinding().describeSObject(getModule()); if (describeSObjectResult == null) { throw new KettleException( BaseMessages.getString(PKG, "SalesforceInput.ErrorGettingObject")); } if (!describeSObjectResult.isQueryable()) { throw new KettleException( BaseMessages.getString(PKG, "SalesforceInputDialog.ObjectNotQueryable", module)); } if (this.recordsFilter == SalesforceConnectionUtils.RECORDS_FILTER_UPDATED || this.recordsFilter == SalesforceConnectionUtils.RECORDS_FILTER_DELETED) { // The object must be replicateable if (!describeSObjectResult.isReplicateable()) { throw new KettleException( BaseMessages.getString( PKG, "SalesforceInput.Error.ObjectNotReplicateable", getModule())); } } } if (getSQL() != null && log.isDetailed()) { log.logDetailed( BaseMessages.getString(PKG, "SalesforceInput.Log.SQLString") + " : " + getSQL()); } switch (this.recordsFilter) { case SalesforceConnectionUtils.RECORDS_FILTER_UPDATED: // Updated records ... GetUpdatedResult updatedRecords = getBinding().getUpdated(getModule(), this.startDate, this.endDate); if (updatedRecords.getIds() != null) { int nr = updatedRecords.getIds().length; if (nr > 0) { String[] ids = updatedRecords.getIds(); // We can pass a maximum of 2000 object IDs if (nr > SalesforceConnectionUtils.MAX_UPDATED_OBJECTS_IDS) { this.sObjects = new SObject[nr]; List<String> list = new ArrayList<String>(); int desPos = 0; for (int i = 0; i < nr; i++) { list.add(updatedRecords.getIds(i)); if (i % SalesforceConnectionUtils.MAX_UPDATED_OBJECTS_IDS == 0 || i == nr - 1) { SObject[] s = getBinding() .retrieve( this.fieldsList, getModule(), list.toArray(new String[list.size()])); System.arraycopy(s, 0, this.sObjects, desPos, s.length); desPos += s.length; s = null; list = new ArrayList<String>(); } } } else { this.sObjects = getBinding().retrieve(this.fieldsList, getModule(), ids); } if (this.sObjects != null) { this.queryResultSize = this.sObjects.length; } } } break; case SalesforceConnectionUtils.RECORDS_FILTER_DELETED: // Deleted records ... GetDeletedResult deletedRecordsResult = getBinding().getDeleted(getModule(), this.startDate, this.endDate); DeletedRecord[] deletedRecords = deletedRecordsResult.getDeletedRecords(); if (log.isDebug()) { log.logDebug( toString(), BaseMessages.getString( PKG, "SalesforceConnection.DeletedRecordsFound", String.valueOf(deletedRecords == null ? 0 : deletedRecords.length))); } if (deletedRecords != null && deletedRecords.length > 0) { getDeletedList = new HashMap<String, Date>(); for (DeletedRecord dr : deletedRecords) { getDeletedList.put(dr.getId(), dr.getDeletedDate().getTime()); } this.qr = getBinding().queryAll(getSQL()); this.sObjects = getQueryResult().getRecords(); if (this.sObjects != null) { this.queryResultSize = this.sObjects.length; } } break; default: // return query result this.qr = isQueryAll() ? getBinding().queryAll(getSQL()) : getBinding().query(getSQL()); this.sObjects = getQueryResult().getRecords(); this.queryResultSize = getQueryResult().getSize(); break; } if (this.sObjects != null) { this.recordsCount = this.sObjects.length; } } catch (Exception e) { log.logError(Const.getStackTracker(e)); throw new KettleException( BaseMessages.getString(PKG, "SalesforceConnection.Exception.Query"), e); } }
public void connect() throws KettleException { try { this.binding = (SoapBindingStub) new SforceServiceLocator().getSoap(); if (log.isDetailed()) { log.logDetailed( BaseMessages.getString( PKG, "SalesforceInput.Log.LoginURL", binding._getProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY))); } // Set timeout if (getTimeOut() > 0) { this.binding.setTimeout(getTimeOut()); if (log.isDebug()) { log.logDebug( BaseMessages.getString(PKG, "SalesforceInput.Log.SettingTimeout", "" + this.timeout)); } } // Set URL this.binding._setProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY, getURL()); // Do we need compression? if (isUsingCompression()) { this.binding._setProperty(HTTPConstants.MC_ACCEPT_GZIP, useCompression); this.binding._setProperty(HTTPConstants.MC_GZIP_REQUEST, useCompression); } if (isRollbackAllChangesOnError()) { // Set the SOAP header to rollback all changes // unless all records are processed successfully. AllOrNoneHeader allOrNoneHeader = new AllOrNoneHeader(); allOrNoneHeader.setAllOrNone(true); this.binding.setHeader( new SforceServiceLocator().getServiceName().getNamespaceURI(), "AllOrNoneHeader", allOrNoneHeader); } // Attempt the login giving the user feedback if (log.isDetailed()) { log.logDetailed(BaseMessages.getString(PKG, "SalesforceInput.Log.LoginNow")); log.logDetailed("----------------------------------------->"); log.logDetailed(BaseMessages.getString(PKG, "SalesforceInput.Log.LoginURL", getURL())); log.logDetailed( BaseMessages.getString(PKG, "SalesforceInput.Log.LoginUsername", getUsername())); if (getModule() != null) { log.logDetailed( BaseMessages.getString(PKG, "SalesforceInput.Log.LoginModule", getModule())); } if (getCondition() != null) { log.logDetailed( BaseMessages.getString(PKG, "SalesforceInput.Log.LoginCondition", getCondition())); } log.logDetailed("<-----------------------------------------"); } // Login this.loginResult = getBinding().login(getUsername(), getPassword()); if (log.isDebug()) { log.logDebug( BaseMessages.getString(PKG, "SalesforceInput.Log.SessionId") + " : " + this.loginResult.getSessionId()); log.logDebug( BaseMessages.getString(PKG, "SalesforceInput.Log.NewServerURL") + " : " + this.loginResult.getServerUrl()); } // set the session header for subsequent call authentication this.binding._setProperty( SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY, this.loginResult.getServerUrl()); // Create a new session header object and set the session id to that // returned by the login SessionHeader sh = new SessionHeader(); sh.setSessionId(loginResult.getSessionId()); this.binding.setHeader( new SforceServiceLocator().getServiceName().getNamespaceURI(), "SessionHeader", sh); // Return the user Infos this.userInfo = this.binding.getUserInfo(); if (log.isDebug()) { log.logDebug( BaseMessages.getString(PKG, "SalesforceInput.Log.UserInfos") + " : " + this.userInfo.getUserFullName()); log.logDebug("----------------------------------------->"); log.logDebug( BaseMessages.getString(PKG, "SalesforceInput.Log.UserName") + " : " + this.userInfo.getUserFullName()); log.logDebug( BaseMessages.getString(PKG, "SalesforceInput.Log.UserEmail") + " : " + this.userInfo.getUserEmail()); log.logDebug( BaseMessages.getString(PKG, "SalesforceInput.Log.UserLanguage") + " : " + this.userInfo.getUserLanguage()); log.logDebug( BaseMessages.getString(PKG, "SalesforceInput.Log.UserOrganization") + " : " + this.userInfo.getOrganizationName()); log.logDebug("<-----------------------------------------"); } this.serverTimestamp = getBinding().getServerTimestamp().getTimestamp().getTime(); if (log.isDebug()) { BaseMessages.getString(PKG, "SalesforceInput.Log.ServerTimestamp", getServerTimestamp()); } if (log.isDetailed()) { log.logDetailed(BaseMessages.getString(PKG, "SalesforceInput.Log.Connected")); } } catch (LoginFault ex) { // The LoginFault derives from AxisFault ExceptionCode exCode = ex.getExceptionCode(); if (exCode == ExceptionCode.FUNCTIONALITY_NOT_ENABLED || exCode == ExceptionCode.INVALID_CLIENT || exCode == ExceptionCode.INVALID_LOGIN || exCode == ExceptionCode.LOGIN_DURING_RESTRICTED_DOMAIN || exCode == ExceptionCode.LOGIN_DURING_RESTRICTED_TIME || exCode == ExceptionCode.ORG_LOCKED || exCode == ExceptionCode.PASSWORD_LOCKOUT || exCode == ExceptionCode.SERVER_UNAVAILABLE || exCode == ExceptionCode.TRIAL_EXPIRED || exCode == ExceptionCode.UNSUPPORTED_CLIENT) { throw new KettleException( BaseMessages.getString(PKG, "SalesforceInput.Error.InvalidUsernameOrPassword")); } throw new KettleException( BaseMessages.getString(PKG, "SalesforceInput.Error.Connection"), ex); } catch (Exception e) { throw new KettleException(BaseMessages.getString(PKG, "SalesforceInput.Error.Connection"), e); } }
@Override public synchronized void importAll( RepositoryImportFeedbackInterface feedback, String fileDirectory, String[] filenames, RepositoryDirectoryInterface baseDirectory, boolean overwrite, boolean continueOnError, String versionComment) { this.baseDirectory = baseDirectory; this.overwrite = overwrite; this.continueOnError = continueOnError; this.versionComment = versionComment; String importPathCompatibility = System.getProperty(Const.KETTLE_COMPATIBILITY_IMPORT_PATH_ADDITION_ON_VARIABLES, "N"); this.needToCheckPathForVariables = "N".equalsIgnoreCase(importPathCompatibility); askReplace = Props.getInstance().askAboutReplacingDatabaseConnections(); if (askReplace) { if (feedback instanceof HasOverwritePrompter) { Props.getInstance().setProperty(IMPORT_ASK_ABOUT_REPLACE_CS, "Y"); Props.getInstance().setProperty(IMPORT_ASK_ABOUT_REPLACE_DB, "Y"); Props.getInstance().setProperty(IMPORT_ASK_ABOUT_REPLACE_PS, "Y"); Props.getInstance().setProperty(IMPORT_ASK_ABOUT_REPLACE_SS, "Y"); this.overwritePrompter = ((HasOverwritePrompter) feedback).getOverwritePrompter(); } else { this.overwritePrompter = new OverwritePrompter() { @Override public boolean overwritePrompt(String arg0, String arg1, String arg2) { throw new RuntimeException( BaseMessages.getString(PKG, "RepositoryImporter.CannotPrompt.Label")); } }; } } else { final boolean replaceExisting = Props.getInstance().replaceExistingDatabaseConnections(); this.overwritePrompter = new OverwritePrompter() { @Override public boolean overwritePrompt(String arg0, String arg1, String arg2) { return replaceExisting; } }; } referencingObjects = new ArrayList<RepositoryObject>(); feedback.setLabel(BaseMessages.getString(PKG, "RepositoryImporter.ImportXML.Label")); try { loadSharedObjects(); RepositoryImportLocation.setRepositoryImportLocation(baseDirectory); for (int ii = 0; ii < filenames.length; ++ii) { final String filename = (!Const.isEmpty(fileDirectory)) ? fileDirectory + Const.FILE_SEPARATOR + filenames[ii] : filenames[ii]; if (log.isBasic()) { log.logBasic("Import objects from XML file [" + filename + "]"); } feedback.addLog(BaseMessages.getString(PKG, "RepositoryImporter.WhichFile.Log", filename)); // To where? feedback.setLabel(BaseMessages.getString(PKG, "RepositoryImporter.WhichDir.Label")); // Read it using SAX... // try { RepositoryExportSaxParser parser = new RepositoryExportSaxParser(filename, feedback); parser.parse(this); } catch (Exception e) { addException(e); feedback.showError( BaseMessages.getString(PKG, "RepositoryImporter.ErrorGeneral.Title"), BaseMessages.getString(PKG, "RepositoryImporter.ErrorGeneral.Message"), e); } } // Correct those jobs and transformations that contain references to other objects. for (RepositoryObject repoObject : referencingObjects) { switch (repoObject.getObjectType()) { case TRANSFORMATION: TransMeta transMeta = rep.loadTransformation(repoObject.getObjectId(), null); saveTransformationToRepo(transMeta, feedback); break; case JOB: JobMeta jobMeta = rep.loadJob(repoObject.getObjectId(), null); saveJobToRepo(jobMeta, feedback); break; default: throw new KettleException( BaseMessages.getString(PKG, "RepositoryImporter.ErrorDetectFileType")); } } feedback.addLog(BaseMessages.getString(PKG, "RepositoryImporter.ImportFinished.Log")); } catch (Exception e) { addException(e); feedback.showError( BaseMessages.getString(PKG, "RepositoryImporter.ErrorGeneral.Title"), BaseMessages.getString(PKG, "RepositoryImporter.ErrorGeneral.Message"), e); } finally { // set the repository import location to null when done! RepositoryImportLocation.setRepositoryImportLocation(null); } }