Example usage for org.apache.commons.lang ArrayUtils add

List of usage examples for org.apache.commons.lang ArrayUtils add

Introduction

In this page you can find the example usage for org.apache.commons.lang ArrayUtils add.

Prototype

public static short[] add(short[] array, short element) 

Source Link

Document

Copies the given array and adds the given element at the end of the new array.

Usage

From source file:org.talend.designer.runprocess.ProcessorUtilities.java

public static String[] getMainCommand(String processName, String processVersion, String contextName,
        int statisticPort, int tracePort, String... codeOptions) throws ProcessorException {
    IProcess currentProcess = null;/*from w w  w .  ja  va  2 s .co m*/
    ProcessItem selectedProcessItem = null;
    selectedProcessItem = ItemCacheManager.getProcessItem(processName, processVersion);
    if (selectedProcessItem != null) {
        IDesignerCoreService service = CorePlugin.getDefault().getDesignerCoreService();
        currentProcess = service.getProcessFromProcessItem(selectedProcessItem);
    }
    if (currentProcess == null) {
        return new String[] {};
    }
    IContext currentContext = getContext(currentProcess, contextName);
    IProcessor processor = getProcessor(currentProcess, selectedProcessItem.getProperty(), currentContext);
    String[] cmd = new String[] { processor.getCodePath().removeFirstSegments(1).toString().replace("/", ".") }; //$NON-NLS-1$ //$NON-NLS-2$
    if (codeOptions != null) {
        for (String string : codeOptions) {
            if (string != null) {
                cmd = (String[]) ArrayUtils.add(cmd, string);
            }
        }
    }
    if (needContextInCurrentGeneration && contextName != null && !contextName.equals("")) {
        cmd = (String[]) ArrayUtils.add(cmd, "--context=" + contextName); //$NON-NLS-1$
    }
    if (statisticPort != -1) {
        cmd = (String[]) ArrayUtils.add(cmd, "--stat_port=" + statisticPort); //$NON-NLS-1$
    }
    if (tracePort != -1) {
        cmd = (String[]) ArrayUtils.add(cmd, "--trace_port=" + tracePort); //$NON-NLS-1$
    }
    return cmd;
}

From source file:org.talend.repository.hadoopcluster.util.HCRepositoryUtil.java

public static void fillDefaultValuesOfHadoopCluster(HadoopClusterConnection connection) {
    String distribution = connection.getDistribution();
    String version = connection.getDfVersion();
    if (distribution == null) {
        return;//from w w w  .  j ava2s  .c om
    }

    String[] versionPrefix = new String[] { distribution };
    if (EHadoopDistributions.AMAZON_EMR.getName().equals(distribution)
            && (EHadoopVersion4Drivers.APACHE_1_0_3_EMR.getVersionValue().equals(version)
                    || EHadoopVersion4Drivers.APACHE_2_4_0_EMR.getVersionValue().equals(version)
                    || EHadoopVersion4Drivers.EMR_4_0_0.getVersionValue().equals(version))) {
        versionPrefix = (String[]) ArrayUtils.add(versionPrefix, version);
    }
    boolean isYarn = connection.isUseYarn();

    String defaultJTORRM = null;
    String defaultJTORRMPrincipal = null;
    if (isYarn) {
        defaultJTORRM = HadoopDefaultConfsManager.getInstance().getDefaultConfValue(
                (String[]) ArrayUtils.add(versionPrefix, EHadoopProperties.RESOURCE_MANAGER.getName()));
        defaultJTORRMPrincipal = HadoopDefaultConfsManager.getInstance()
                .getDefaultConfValue((String[]) ArrayUtils.add(versionPrefix,
                        EHadoopProperties.RESOURCE_MANAGER_PRINCIPAL.getName()));
    } else {
        defaultJTORRM = HadoopDefaultConfsManager.getInstance().getDefaultConfValue(
                (String[]) ArrayUtils.add(versionPrefix, EHadoopProperties.JOBTRACKER.getName()));
        defaultJTORRMPrincipal = HadoopDefaultConfsManager.getInstance().getDefaultConfValue(
                (String[]) ArrayUtils.add(versionPrefix, EHadoopProperties.JOBTRACKER_PRINCIPAL.getName()));
    }
    if (defaultJTORRM != null) {
        connection.setJobTrackerURI(defaultJTORRM);
    }
    String defaultRMS = HadoopDefaultConfsManager.getInstance().getDefaultConfValue(distribution,
            EHadoopProperties.RESOURCEMANAGER_SCHEDULER_ADDRESS.getName());
    if (defaultRMS != null) {
        connection.setRmScheduler(defaultRMS);
    }
    if (defaultJTORRMPrincipal != null) {
        connection.setJtOrRmPrincipal(defaultJTORRMPrincipal);
    }
    String defaultNN = HadoopDefaultConfsManager.getInstance().getDefaultConfValue(
            (String[]) ArrayUtils.add(versionPrefix, EHadoopProperties.NAMENODE_URI.getName()));
    if (defaultNN != null) {
        connection.setNameNodeURI(defaultNN);
    }
    String defaultNNP = HadoopDefaultConfsManager.getInstance().getDefaultConfValue(distribution,
            EHadoopProperties.NAMENODE_PRINCIPAL.getName());
    if (defaultNNP != null) {
        connection.setPrincipal(defaultNNP);
    }
    String defaultJobHistoryPrincipal = HadoopDefaultConfsManager.getInstance()
            .getDefaultConfValue(distribution, EHadoopProperties.JOBHISTORY_PRINCIPAL.getName());
    if (defaultJobHistoryPrincipal != null) {
        connection.setJobHistoryPrincipal(defaultJobHistoryPrincipal);
    }
    String defaultJH = HadoopDefaultConfsManager.getInstance().getDefaultConfValue(distribution,
            EHadoopProperties.JOBHISTORY_ADDRESS.getName());
    if (defaultJH != null) {
        connection.setJobHistory(defaultJH);
    }
    String defaultSD = HadoopDefaultConfsManager.getInstance().getDefaultConfValue(distribution,
            EHadoopProperties.STAGING_DIRECTORY.getName());
    if (defaultSD != null) {
        connection.setStagingDirectory(defaultSD);
    }
}

From source file:org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobJavaScriptsManager.java

@Override
public List<ExportFileResource> getExportResources(ExportFileResource[] process, String... codeOptions)
        throws ProcessorException {
    exportFileResource = process;/*from  www . j  a v  a  2 s.com*/
    for (int i = 0; i < process.length; i++) {
        ProcessItem processItem = (ProcessItem) process[i].getItem();
        String selectedJobVersion = processItem.getProperty().getVersion();
        selectedJobVersion = preExportResource(process, i, selectedJobVersion);

        IProcess jobProcess = null;

        // TODO: option doNotCompileCode is deprecated now.
        // code is just kept like this to avoid too big changes right now.
        if (!isOptionChoosed(ExportChoice.doNotCompileCode)) {
            if (contextName != null) {
                jobProcess = generateJobFiles(processItem, contextName, selectedJobVersion,
                        statisticPort != IProcessor.NO_STATISTICS
                                || isOptionChoosed(ExportChoice.addStatistics),
                        tracePort != IProcessor.NO_TRACES, isOptionChoosed(ExportChoice.applyToChildren),
                        progressMonitor);
            }
            analysisModules(processItem.getProperty().getId(), selectedJobVersion);
        } else {
            LastGenerationInfo.getInstance().setModulesNeededWithSubjobPerJob(processItem.getProperty().getId(),
                    processItem.getProperty().getVersion(), Collections.<ModuleNeeded>emptySet());
            LastGenerationInfo.getInstance().setLastMainJob(null);
        }
        List<URL> resources = new ArrayList<URL>();
        List<URL> childrenList = new ArrayList<URL>();
        if (CommonsPlugin.isHeadless()) {
            childrenList = posExportResource(process, exportChoice, contextName, launcher, statisticPort,
                    tracePort, i, jobProcess, processItem, selectedJobVersion, resources, codeOptions);
        } else {
            String log4jOption = getLog4jLevel() != null
                    ? TalendProcessArgumentConstant.CMD_ARG_LOG4J_LEVEL + getLog4jLevel().toLowerCase()
                    : null;
            String[] newCodeOptions = codeOptions;
            if (!ArrayUtils.contains(codeOptions, log4jOption)) {
                newCodeOptions = (String[]) ArrayUtils.add(codeOptions, log4jOption);
            }
            childrenList = posExportResource(process, exportChoice, contextName, launcher, statisticPort,
                    tracePort, i, jobProcess, processItem, selectedJobVersion, resources, newCodeOptions);
        }
        resources.addAll(childrenList);
        process[i].addResources(resources);
        // Gets job designer resouce
        // List<URL> srcList = getSource(processItem, exportChoice.get(ExportChoice.needSource));
        // process[i].addResources(JOB_SOURCE_FOLDER_NAME, srcList);
    }

    // Exports the system libs
    List<ExportFileResource> list = new ArrayList<ExportFileResource>(Arrays.asList(process));

    // Add the java system libraries
    ExportFileResource libResource = getCompiledLibExportFileResource(process);
    list.add(libResource);

    // Gets jobInfo.properties
    // only addClasspathJar not check in preferences ,then export the jobInfo.properties
    boolean addClasspathJar = false;
    IDesignerCoreUIService designerCoreUIService = CoreUIPlugin.getDefault().getDesignerCoreUIService();
    if (designerCoreUIService != null) {
        addClasspathJar = designerCoreUIService.getPreferenceStore()
                .getBoolean(IRepositoryPrefConstants.ADD_CLASSPATH_JAR);
    }
    if (!addClasspathJar) {
        if (!(process.length > 1)) {
            for (ExportFileResource pro : process) {
                ExportFileResource jobInfoResource = new ExportFileResource(null, PATH_SEPARATOR);
                if (CommonsPlugin.isHeadless()) {
                    jobInfoResource = new ExportFileResource();
                }
                list.add(jobInfoResource);
                List<URL> jobInfoList = getJobInfoFile(pro, contextName);
                jobInfoResource.addResources(jobInfoList);
            }
        }
    }

    if (PluginChecker.isRulesPluginLoaded()) {
        // hywang add for 6484,add final drl files or xls files to exported job script
        ExportFileResource ruleFileResource = new ExportFileResource(null, "Rules/rules/final"); //$NON-NLS-1$
        list.add(ruleFileResource);
        try {
            Map<String, List<URL>> map = initUrlForRulesFiles(process);
            Object[] keys = map.keySet().toArray();
            for (Object key : keys) {
                List<URL> talendDrlFiles = map.get(key.toString());
                ruleFileResource.addResources(key.toString(), talendDrlFiles);
            }
        } catch (CoreException e) {
            ExceptionHandler.process(e);
        } catch (MalformedURLException e) {
            ExceptionHandler.process(e);
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
        }
    }
    return list;

}

From source file:org.talend.repository.ui.wizards.metadata.connection.database.DatabaseForm.java

private void fillDefaultsWhenHiveVersionChanged() {
    if (isCreation) {
        String distribution = getConnection().getParameters()
                .get(ConnParameterKeys.CONN_PARA_KEY_HIVE_DISTRIBUTION);
        String version = getConnection().getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HIVE_VERSION);
        if (distribution == null) {
            return;
        }//from   w  ww.  j av a 2s. co m
        String[] versionPrefix = new String[] { distribution };
        if (HiveConnVersionInfo.AMAZON_EMR.getKey().equals(distribution)) {
            versionPrefix = (String[]) ArrayUtils.add(versionPrefix, version);
        }
        boolean useYarn = Boolean
                .valueOf(getConnection().getParameters().get(ConnParameterKeys.CONN_PARA_KEY_USE_YARN));
        String defaultNN = HadoopDefaultConfsManager.getInstance().getDefaultConfValue(
                (String[]) ArrayUtils.add(versionPrefix, EHadoopProperties.NAMENODE_URI.getName()));
        String nameNodeURLstr = getConnection().getParameters()
                .get(ConnParameterKeys.CONN_PARA_KEY_NAME_NODE_URL);
        String jobTrackerURLStr = getConnection().getParameters()
                .get(ConnParameterKeys.CONN_PARA_KEY_JOB_TRACKER_URL);
        if (StringUtils.isNotEmpty(nameNodeURLstr)) {
            nameNodeURLTxt.setText(nameNodeURLstr);
        } else if (defaultNN != null) {
            nameNodeURLTxt.setText(defaultNN);
        }
        String defaultJTORRM = null;
        if (useYarn) {
            defaultJTORRM = HadoopDefaultConfsManager.getInstance().getDefaultConfValue(
                    (String[]) ArrayUtils.add(versionPrefix, EHadoopProperties.RESOURCE_MANAGER.getName()));
        } else {
            defaultJTORRM = HadoopDefaultConfsManager.getInstance().getDefaultConfValue(
                    (String[]) ArrayUtils.add(versionPrefix, EHadoopProperties.JOBTRACKER.getName()));
        }
        if (StringUtils.isNotEmpty(jobTrackerURLStr)) {
            jobTrackerURLTxt.setText(jobTrackerURLStr);
        } else if (defaultJTORRM != null) {
            jobTrackerURLTxt.setText(defaultJTORRM);
        }
        String defaultPrincipal = HadoopDefaultConfsManager.getInstance().getDefaultConfValue(distribution,
                EHadoopCategory.HIVE.getName(), EHadoopProperties.HIVE_PRINCIPAL.getName());
        if (defaultPrincipal != null) {
            hivePrincipalTxt.setText(defaultPrincipal);
        }
        String defaultDatabase = HadoopDefaultConfsManager.getInstance().getDefaultConfValue(distribution,
                EHadoopCategory.HIVE.getName(), EHadoopProperties.DATABASE.getName());
        getConnection().setSID(defaultDatabase);
        sidOrDatabaseText.setText(defaultDatabase);
    }
}

From source file:org.talend.repository.ui.wizards.metadata.connection.database.DatabaseForm.java

private void fillDefaultsWhenHBaseVersionChanged() {
    if (isCreation) {
        String distribution = getConnection().getParameters()
                .get(ConnParameterKeys.CONN_PARA_KEY_HBASE_DISTRIBUTION);
        String version = getConnection().getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HBASE_VERSION);
        if (distribution == null) {
            return;
        }//  w w w .j ava2s  .  co m
        String[] versionPrefix = new String[] { distribution };
        if (EHBaseDistributions.AMAZON_EMR.getName().equals(distribution)) {
            versionPrefix = (String[]) ArrayUtils.add(versionPrefix, version);
        }
        String defaultPort = HadoopDefaultConfsManager.getInstance()
                .getDefaultConfValue((String[]) ArrayUtils.add(
                        ArrayUtils.add(versionPrefix, EHadoopCategory.HBASE.getName()),
                        EHadoopProperties.PORT.getName()));
        if (defaultPort != null && !isContextMode()) {
            getConnection().setPort(defaultPort);
            portText.setText(defaultPort);
        }
    }
}

From source file:org.uimafit.factory.ExternalResourceFactory.java

/**
 * Create a new dependency for the specified resource and bind it. This method is helpful for
 * UIMA components that do not use the uimaFIT {@link ExternalResource} annotation, because no
 * external resource dependencies can be automatically generated by uimaFIT for such components.
 *
 * @param aDesc/*from  w w  w. j a v  a2 s  .c om*/
 *            a description.
 * @param aKey
 *            the key to bind to.
 * @param aApi
 *            the resource API.
 */
public static void createDependency(ResourceSpecifier aDesc, String aKey, Class<?> aApi)
        throws InvalidXMLException {
    ExternalResourceDependency[] deps = getExternalResourceDependencies(aDesc);
    if (deps == null) {
        deps = new ExternalResourceDependency[] {};
    }

    // Check if the resource dependency is already present
    boolean found = false;
    for (ExternalResourceDependency dep : deps) {
        if (dep.getKey().equals(aKey)) {
            found = true;
            break;
        }
    }

    // If not, create one
    if (!found) {
        setExternalResourceDependencies(aDesc, (ExternalResourceDependency[]) ArrayUtils.add(deps,
                createExternalResourceDependency(aKey, aApi, false)));
    }
}

From source file:org.uimafit.factory.ExternalResourceFactory.java

/**
 * Create a new dependency for the specified resource and bind it. This method is helpful for
 * UIMA components that do not use the uimaFIT {@link ExternalResource} annotation, because no
 * external resource dependencies can be automatically generated by uimaFIT for such components.
 *
 * @param aDesc//  w  ww.  jav  a2s  . com
 *            a description.
 * @param aKey
 *            the key to bind to.
 * @param aImpl
 *            the resource implementation.
 * @param aUrl
 *            the resource URL.
 * @param aParams
 *            additional parameters supported by the resource.
 */
public static void createDependencyAndBind(AnalysisEngineDescription aDesc, String aKey,
        Class<? extends SharedResourceObject> aImpl, String aUrl, Object... aParams)
        throws InvalidXMLException {
    if (aDesc.getExternalResourceDependency(aKey) == null) {
        ExternalResourceDependency[] deps = aDesc.getExternalResourceDependencies();
        if (deps == null) {
            deps = new ExternalResourceDependency[] {};
        }
        aDesc.setExternalResourceDependencies((ExternalResourceDependency[]) ArrayUtils.add(deps,
                createExternalResourceDependency(aKey, aImpl, false)));
    }
    bindResource(aDesc, aKey, aImpl, aUrl, aParams);
}

From source file:org.wso2.carbon.identity.application.common.processors.RandomPasswordProcessor.java

private Property[] addUniqueIdProperty(Property[] properties) {

    if (ArrayUtils.isEmpty(properties)) {
        return new Property[0];
    }/*  w  ww .j  a v  a2s . c om*/

    String uuid = UUID.randomUUID().toString();
    Property uniqueIdProperty = new Property();
    uniqueIdProperty.setName(IdentityApplicationConstants.UNIQUE_ID_CONSTANT);
    uniqueIdProperty.setValue(uuid);
    if (log.isDebugEnabled()) {
        log.debug("Adding uniqueId property: " + uuid);
    }
    properties = (Property[]) ArrayUtils.add(properties, uniqueIdProperty);

    return properties;
}

From source file:org.wso2.carbon.identity.oauth2.dao.AccessTokenDAOImpl.java

@Override
public Set<AccessTokenDO> getAccessTokens(String consumerKey, AuthenticatedUser userName,
        String userStoreDomain, boolean includeExpired) throws IdentityOAuth2Exception {

    if (log.isDebugEnabled()) {
        log.debug("Retrieving access tokens for client: " + consumerKey + " user: " + userName.toString());
    }//from w ww .  ja v  a 2 s  . co  m

    boolean isUsernameCaseSensitive = IdentityUtil.isUserStoreInUsernameCaseSensitive(userName.toString());
    String tenantDomain = userName.getTenantDomain();
    String tenantAwareUsernameWithNoUserDomain = userName.getUserName();
    String userDomain = OAuth2Util.getSanitizedUserStoreDomain(userName.getUserStoreDomain());
    userStoreDomain = OAuth2Util.getSanitizedUserStoreDomain(userStoreDomain);

    Connection connection = IdentityDatabaseUtil.getDBConnection();
    PreparedStatement prepStmt = null;
    ResultSet resultSet = null;
    Map<String, AccessTokenDO> accessTokenDOMap = new HashMap<>();
    try {
        int tenantId = OAuth2Util.getTenantId(tenantDomain);
        String sql = SQLQueries.RETRIEVE_ACTIVE_ACCESS_TOKEN_BY_CLIENT_ID_USER;
        if (includeExpired) {
            sql = SQLQueries.RETRIEVE_ACTIVE_EXPIRED_ACCESS_TOKEN_BY_CLIENT_ID_USER;
        }

        sql = OAuth2Util.getTokenPartitionedSqlByUserStore(sql, userStoreDomain);

        if (!isUsernameCaseSensitive) {
            sql = sql.replace(AUTHZ_USER, LOWER_AUTHZ_USER);
        }

        prepStmt = connection.prepareStatement(sql);
        prepStmt.setString(1, getPersistenceProcessor().getProcessedClientId(consumerKey));
        if (isUsernameCaseSensitive) {
            prepStmt.setString(2, tenantAwareUsernameWithNoUserDomain);
        } else {
            prepStmt.setString(2, tenantAwareUsernameWithNoUserDomain.toLowerCase());
        }
        prepStmt.setInt(3, tenantId);
        prepStmt.setString(4, userDomain);
        resultSet = prepStmt.executeQuery();

        while (resultSet.next()) {
            String accessToken = null;
            if (isHashDisabled) {
                accessToken = getPersistenceProcessor()
                        .getPreprocessedAccessTokenIdentifier(resultSet.getString(1));
            }
            if (accessTokenDOMap.get(accessToken) == null) {
                String refreshToken = null;
                if (isHashDisabled) {
                    refreshToken = getPersistenceProcessor()
                            .getPreprocessedRefreshToken(resultSet.getString(2));
                }
                Timestamp issuedTime = resultSet.getTimestamp(3,
                        Calendar.getInstance(TimeZone.getTimeZone(UTC)));
                Timestamp refreshTokenIssuedTime = resultSet.getTimestamp(4,
                        Calendar.getInstance(TimeZone.getTimeZone(UTC)));
                long validityPeriodInMillis = resultSet.getLong(5);
                long refreshTokenValidityPeriodMillis = resultSet.getLong(6);
                String tokenType = resultSet.getString(7);
                String[] scope = OAuth2Util.buildScopeArray(resultSet.getString(8));
                String tokenId = resultSet.getString(9);
                String subjectIdentifier = resultSet.getString(10);

                AuthenticatedUser user = new AuthenticatedUser();
                user.setUserName(tenantAwareUsernameWithNoUserDomain);
                user.setTenantDomain(tenantDomain);
                user.setUserStoreDomain(userDomain);
                ServiceProvider serviceProvider;
                try {
                    serviceProvider = OAuth2ServiceComponentHolder.getApplicationMgtService()
                            .getServiceProviderByClientId(consumerKey, OAuthConstants.Scope.OAUTH2,
                                    tenantDomain);
                } catch (IdentityApplicationManagementException e) {
                    throw new IdentityOAuth2Exception(
                            "Error occurred while retrieving OAuth2 application data for " + "client id "
                                    + consumerKey,
                            e);
                }
                user.setAuthenticatedSubjectIdentifier(subjectIdentifier, serviceProvider);
                AccessTokenDO dataDO = new AccessTokenDO(consumerKey, user, scope, issuedTime,
                        refreshTokenIssuedTime, validityPeriodInMillis, refreshTokenValidityPeriodMillis,
                        tokenType);
                dataDO.setAccessToken(accessToken);
                dataDO.setRefreshToken(refreshToken);
                dataDO.setTokenId(tokenId);
                accessTokenDOMap.put(accessToken, dataDO);
            } else {
                String scope = resultSet.getString(8).trim();
                AccessTokenDO accessTokenDO = accessTokenDOMap.get(accessToken);
                accessTokenDO.setScope((String[]) ArrayUtils.add(accessTokenDO.getScope(), scope));
            }
        }
        connection.commit();
    } catch (SQLException e) {
        String errorMsg = "Error occurred while retrieving 'ACTIVE' access tokens for " + "Client ID : "
                + consumerKey + " and User ID : " + userName;
        if (includeExpired) {
            errorMsg = errorMsg.replace("ACTIVE", "ACTIVE or EXPIRED");
        }
        throw new IdentityOAuth2Exception(errorMsg, e);
    } finally {
        IdentityDatabaseUtil.closeAllConnections(connection, resultSet, prepStmt);
    }

    return new HashSet<>(accessTokenDOMap.values());
}

From source file:org.wso2.carbon.identity.oauth2.dao.AccessTokenDAOImpl.java

/**
 * Retrieves AccessTokenDOs of specified user store of the given tenant.
 *
 * @param tenantId/*  ww w.j a v a 2s  .  com*/
 * @param userStoreDomain
 * @return
 * @throws IdentityOAuth2Exception
 */
private Set<AccessTokenDO> getAccessTokensByTenant(int tenantId, String userStoreDomain)
        throws IdentityOAuth2Exception {

    Connection connection = IdentityDatabaseUtil.getDBConnection();
    PreparedStatement prepStmt = null;
    ResultSet resultSet = null;
    Map<String, AccessTokenDO> accessTokenDOMap = new HashMap<>();
    try {
        String sql = OAuth2Util.getTokenPartitionedSqlByUserStore(SQLQueries.LIST_ALL_TOKENS_IN_TENANT,
                userStoreDomain);

        prepStmt = connection.prepareStatement(sql);
        prepStmt.setInt(1, tenantId);
        resultSet = prepStmt.executeQuery();

        while (resultSet.next()) {
            String accessToken = null;
            if (isHashDisabled) {
                accessToken = getPersistenceProcessor()
                        .getPreprocessedAccessTokenIdentifier(resultSet.getString(1));
            }
            if (accessTokenDOMap.get(accessToken) == null) {
                String refreshToken = null;
                if (isHashDisabled) {
                    refreshToken = getPersistenceProcessor()
                            .getPreprocessedRefreshToken(resultSet.getString(2));
                }
                Timestamp issuedTime = resultSet.getTimestamp(3,
                        Calendar.getInstance(TimeZone.getTimeZone(UTC)));
                Timestamp refreshTokenIssuedTime = resultSet.getTimestamp(4,
                        Calendar.getInstance(TimeZone.getTimeZone(UTC)));
                long validityPeriodInMillis = resultSet.getLong(5);
                long refreshTokenValidityPeriodMillis = resultSet.getLong(6);
                String tokenType = resultSet.getString(7);
                String[] scope = OAuth2Util.buildScopeArray(resultSet.getString(8));
                String tokenId = resultSet.getString(9);
                String authzUser = resultSet.getString(10);
                userStoreDomain = resultSet.getString(11);
                String consumerKey = resultSet.getString(12);

                AuthenticatedUser user = new AuthenticatedUser();
                user.setUserName(authzUser);
                user.setTenantDomain(OAuth2Util.getTenantDomain(tenantId));
                user.setUserStoreDomain(userStoreDomain);
                AccessTokenDO dataDO = new AccessTokenDO(consumerKey, user, scope, issuedTime,
                        refreshTokenIssuedTime, validityPeriodInMillis, refreshTokenValidityPeriodMillis,
                        tokenType);
                dataDO.setAccessToken(accessToken);
                dataDO.setRefreshToken(refreshToken);
                dataDO.setTokenId(tokenId);
                dataDO.setTenantID(tenantId);
                accessTokenDOMap.put(accessToken, dataDO);
            } else {
                String scope = resultSet.getString(8).trim();
                AccessTokenDO accessTokenDO = accessTokenDOMap.get(accessToken);
                accessTokenDO.setScope((String[]) ArrayUtils.add(accessTokenDO.getScope(), scope));
            }
        }
        connection.commit();
    } catch (SQLException e) {
        String errorMsg = "Error occurred while retrieving 'ACTIVE or EXPIRED' access tokens for "
                + "user  tenant id : " + tenantId;
        throw new IdentityOAuth2Exception(errorMsg, e);
    } finally {
        IdentityDatabaseUtil.closeAllConnections(connection, resultSet, prepStmt);
    }

    return new HashSet<>(accessTokenDOMap.values());
}