private static String getActionIdentifier( final IAction actionBean, final String actionClassName, final String actionId ) { if ( actionBean != null ) { return actionBean.getClass().getName(); } else if ( !StringUtil.isEmpty( actionClassName ) ) { return actionClassName; } else if ( !StringUtil.isEmpty( actionId ) ) { return actionId; } return "?"; //$NON-NLS-1$ }
public String decrypt( String encryptedPassword ) throws PasswordServiceException { return StringUtil.isEmpty( encryptedPassword ) ? encryptedPassword : new String( Base64 .decodeBase64( encryptedPassword.getBytes() ) ); } }
public String encrypt( String password ) throws PasswordServiceException { return StringUtil.isEmpty( password ) ? password : new String( Base64.encodeBase64( password.getBytes() ) ); }
@Override public String encrypt( String password ) throws PasswordServiceException { if ( StringUtil.isEmpty( password ) ) { return password; } else { return encoder.encode( password ); } }
/** * Creates the {@link WorkItemLifecycleEvent} with all the required parameters. * * @param workItemUid a {@link String} containing unique identifier for the {@link WorkItemLifecycleEvent} * @param workItemDetails an {@link String} containing details of the {@link WorkItemLifecycleEvent} * @param workItemLifecyclePhase a {@link WorkItemLifecyclePhase} representing the lifecycle event * @param lifecycleDetails a {@link String} containing any additional details about the lifecycle event, such as * pertinent failure messages * @param sourceTimestamp a {@link Date} representing the time the lifecycle change occurred. */ public WorkItemLifecycleEvent( final String workItemUid, final String workItemDetails, final WorkItemLifecyclePhase workItemLifecyclePhase, final String lifecycleDetails, final Date sourceTimestamp ) { this.workItemUid = workItemUid; this.workItemDetails = workItemDetails; this.workItemLifecyclePhase = workItemLifecyclePhase; this.lifecycleDetails = lifecycleDetails; this.sourceTimestamp = sourceTimestamp; // if the workItemUid is null, generate it if ( StringUtil.isEmpty( this.workItemUid ) ) { this.workItemUid = UUID.randomUUID().toString(); } // Set sourceTimestamp to current date only if not already provided if ( this.sourceTimestamp == null ) { this.sourceTimestamp = new Date(); } // set the default values for host name and ip, they can be changed directly if needed this.sourceHostName = HOST_NAME; this.sourceHostIp = HOST_IP; }
/** * Returns a name for a work item which includes the input file name (derived from {@code inputFilePath}) and * {@code user} that executed it, in the following format: %input file name%-%user%, stripping any * invalid characters. * * This workItemName will be used for logging only * * @param inputFilePath the path of the input file of the action being invoked - optional * @param userName the user executing the action * @return a name for the work item */ public static String generateWorkItemName( final String inputFilePath, final String userName ) { if ( StringUtil.isEmpty( inputFilePath ) ) { logger.info( "Input file path is not provided." ); } if ( StringUtil.isEmpty( userName ) ) { logger.info( "User name is not provided." ); } String workItemName = String.format( "%s[%s]", Optional.ofNullable( inputFilePath ).orElse( StringUtils.EMPTY ), Optional.ofNullable( userName ).orElse( StringUtils.EMPTY ) ); if ( workItemName.length() > WORK_ITEM_LENGTH_LIMIT ) { logger.info( String.format( "Work item name exceeds max character limit of %d: %d", WORK_ITEM_LENGTH_LIMIT, workItemName.length() ) ); } return workItemName; }
@Override public String decrypt( String encryptedPassword ) throws PasswordServiceException { if ( StringUtil.isEmpty( encryptedPassword ) ) { return encryptedPassword; } else { if ( encryptedPassword.startsWith( prefix ) ) { // If it starts with "Encrypted " then decode using KettleTwoWayPasswordEncoder return encoder.decode( encryptedPassword ); } else { // If not, likely Base64 encoded so twy that return super.decrypt( encryptedPassword ); } } }
private static String lookupSetting( IApplicationContext applicationContext, String applicationContextName, String hibernateSettingsName, String pentahoXmlName ) { // 1- Look in applicationContext // 2- Look in PentahoSystem/hibernate-settings.xml // 3- Look in pentaho.xml String tmp = null; tmp = applicationContext.getProperty( applicationContextName, null ); if ( ( tmp != null ) && ( !StringUtil.isEmpty( tmp ) ) ) { return tmp.trim(); } if ( tmp == null ) { tmp = PentahoSystem.getSystemSetting( "hibernate/hibernate-settings.xml", hibernateSettingsName, null ); //$NON-NLS-1$ if ( ( tmp != null ) && ( !StringUtil.isEmpty( tmp ) ) ) { return tmp.trim(); } } if ( tmp == null ) { tmp = PentahoSystem.getSystemSetting( pentahoXmlName, null ); if ( ( tmp != null ) && ( !StringUtil.isEmpty( tmp ) ) ) { return tmp.trim(); } } return null; }
/** * @param params a {@link Map} containing action/work item related attributes, in particular {@code inputFile} and * {@code actionUser}, which are both used for the purpose of generating the uid. * @return a name for the work item * @see {@link #generateWorkItemName(String, String)} */ public static String generateWorkItemName( final Map<String, Serializable> params ) { if ( params == null ) { return generateWorkItemName( null, null ); } // at the time this method is called, the quartz specific map keys may not have been mapped to their // corresponding action keys (see KEY_MAP), fall back on the quartz key, if the action key cannot be found final String userName = Optional.ofNullable( (String) params.get( INVOKER_ACTIONUSER ) ).orElse( (String) params .get( QUARTZ_ACTIONUSER ) ); String inputFilePath = Optional.ofNullable( (String) params.get( INVOKER_STREAMPROVIDER_INPUT_FILE ) ) .orElse( (String) params.get( QUARTZ_STREAMPROVIDER_INPUT_FILE ) ); // if we still cannot find the inputFile, we have one last attempt: check for inline passing of input and output files, // represented by 'ActionAdapterQuartzJob-StreamProvider -> input file = <path><colon>output file=<path> if ( StringUtil.isEmpty( inputFilePath ) && isInlinePassingOfInputOnStreamProvider( params ) ) { inputFilePath = getInlineInputFileOnStreamProvider( params ); } return generateWorkItemName( inputFilePath, userName ); }
public List<CmisObject> getDescendants( String repositoryId, String folderId, TypesOfFileableObjects type, int depth, String filter, boolean includeAllowableActions, boolean includeRelationships ) throws InvalidArgumentException, ConstraintViolationException, FilterNotValidException, RuntimeException, UpdateConflictException, ObjectNotFoundException, OperationNotSupportedException, PermissionDeniedException, FolderNotValidException { Collection filters = null; if ( !StringUtil.isEmpty( filter ) ) { filters = getFilterCollection( filter ); } if ( !repositoryId.equals( BiPlatformRepositoryClient.PLATFORMORIG ) ) { throw new InvalidArgumentException(); } List<CmisObject> objects = new ArrayList<CmisObject>(); // get the element for the specified object Element objectElement = getFolderElement( folderId ); addChildren( objects, objectElement, type, filters, 0, 0, depth, 1 ); return objects; }
public String encodePassword( final String rawPass, final Object salt ) throws DataAccessException { Validate.notNull( rawPass, Messages.getInstance().getString( "DefaultPentahoPasswordEncoder.ERROR_0001_RAWPASS_CANNOT_BE_NULL" ) ); //$NON-NLS-1$ if ( StringUtil.isEmpty( rawPass ) ) { return rawPass; } CryptedSimpleCredentials cryptedCredentials; try { cryptedCredentials = new CryptedSimpleCredentials( new SimpleCredentials( "dummyUser", rawPass.toCharArray() ) ); return cryptedCredentials.getPassword(); } catch ( Exception e ) { throw new RuntimeException( e ); } }
public List<CmisObject> getChildren( String repositoryId, String folderId, TypesOfFileableObjects type, String filter, boolean includeAllowableActions, boolean includeRelationships, int maxItems, int skipCount ) throws InvalidArgumentException, ConstraintViolationException, FilterNotValidException, RuntimeException, UpdateConflictException, ObjectNotFoundException, OperationNotSupportedException, PermissionDeniedException, FolderNotValidException { Collection filters = null; if ( !StringUtil.isEmpty( filter ) ) { filters = getFilterCollection( filter ); } if ( !repositoryId.equals( BiPlatformRepositoryClient.PLATFORMORIG ) ) { throw new InvalidArgumentException(); } List<CmisObject> objects = new ArrayList<CmisObject>(); // get the element for the specified object Element objectElement = getFolderElement( folderId ); addChildren( objects, objectElement, type, filters, maxItems, skipCount, 1, 1 ); return objects; }
if ( !StringUtil.isEmpty( hostName ) ) {
public LocalFileModel( final String url, final HttpClientManager.HttpClientBuilderFacade clientBuilder, final String username, final String password, final String hostName, int port ) { if ( url == null ) { throw new NullPointerException(); } this.url = url; this.username = username; this.password = password; this.context = HttpClientContext.create(); if ( !StringUtil.isEmpty( hostName ) ) { // Preemptive Basic Authentication HttpHost target = new HttpHost( hostName, port, "http" ); // Create AuthCache instance AuthCache authCache = new BasicAuthCache(); // Generate BASIC scheme object and add it to the local // auth cache BasicScheme basicAuth = new BasicScheme(); authCache.put( target, basicAuth ); // Add AuthCache to the execution context this.context.setAuthCache( authCache ); } clientBuilder.setCookieSpec( CookieSpecs.DEFAULT ); clientBuilder.setMaxRedirects( 10 ); clientBuilder.allowCircularRedirects(); clientBuilder.allowRelativeRedirect(); }
!StringUtil.isEmpty( testWhileIdleValue ) ? Boolean.parseBoolean( testWhileIdleValue ) : false; boolean testOnBorrow = !StringUtil.isEmpty( testOnBorrowValue ) ? Boolean.parseBoolean( testOnBorrowValue ) : false; boolean testOnReturn = !StringUtil.isEmpty( testOnReturnValue ) ? Boolean.parseBoolean( testOnReturnValue ) : false; int maxActiveConnection = !StringUtil.isEmpty( maxActConn ) ? Integer.parseInt( maxActConn ) : -1; long waitTime = !StringUtil.isEmpty( wait ) ? Integer.parseInt( wait ) : -1; byte whenExhaustedActionType = !StringUtil.isEmpty( whenExhaustedAction ) ? Byte.parseByte( whenExhaustedAction ) : GenericObjectPool.WHEN_EXHAUSTED_BLOCK; int minIdleConnection = !StringUtil.isEmpty( minIdleConn ) ? Integer.parseInt( minIdleConn ) : -1; int maxIdleConnection = !StringUtil.isEmpty( maxdleConn ) ? Integer.parseInt( maxdleConn ) : -1;
if ( ( StringUtil.isEmpty( actionUser ) ) || ( actionUser.equals( "system session" ) ) ) { //$NON-NLS-1$
private FileSystem createWebFileSystem( final LayeredFileName genericRootName, final FileSystemOptions fileSystemOptions ) throws FileSystemException { final GenericFileName outerName = (GenericFileName) genericRootName.getOuterName(); String scheme = outerName.getScheme(); String hostName = outerName.getHostName(); int port = outerName.getPort(); String userName = outerName.getUserName(); String password = outerName.getPassword(); HttpClientManager.HttpClientBuilderFacade clientBuilder = HttpClientManager.getInstance().createBuilder(); if ( !StringUtil.isEmpty( hostName ) ) { clientBuilder.setProxy( hostName, port, scheme ); } if ( !StringUtil.isEmpty( userName ) ) { clientBuilder.setCredentials( userName, password ); } final PentahoSolutionsFileSystemConfigBuilder configBuilder = new PentahoSolutionsFileSystemConfigBuilder(); final int timeOut = configBuilder.getTimeOut( fileSystemOptions ); clientBuilder.setSocketTimeout( Math.max( 0, timeOut ) ); return new WebSolutionFileSystem( genericRootName, fileSystemOptions, new LocalFileModel( outerName.getURI(), clientBuilder, userName, password, hostName, port ) ); }