Example usage for java.lang String concat

List of usage examples for java.lang String concat

Introduction

In this page you can find the example usage for java.lang String concat.

Prototype

public String concat(String str) 

Source Link

Document

Concatenates the specified string to the end of this string.

Usage

From source file:com.khepry.utilities.GenericUtilities.java

public static String replaceTildePrefixWithUserHome(String path, String prefix) {
    String result = "";
    // if the prefix is non-null and not blank and starts with a tilde (~)
    if (prefix != null && !prefix.equals("") && prefix.startsWith("~")) {
        // replace the tilde with the user's home folder
        prefix = prefix.replace("~", System.getProperty("user.home"));
    }/*from   w w  w . j  a  v a2 s.  c  o m*/
    // if the prefix is blank or the path starts with a tilde (~)
    if (prefix == null || prefix.equals("") || path.startsWith("~")) {
        // if the path starts with a tilde (~), replace it with the user's home folder
        // otherwise, simply use the path from the incoming path parameter
        result = path.startsWith("~") ? path.replace("~", System.getProperty("user.home")) : path;
    }
    // otherwise,
    else {
        // if the path starts with a slash or backslash or contains a colon, use the path as provided
        // otherwise, pre-pend any non-null prefix to the path from the incoming path parameter
        result = (path.startsWith("/") || path.startsWith("\\") || path.indexOf(":") > -1) ? path
                : prefix != null ? prefix.concat(path) : path;
    }
    // System.out.println("replaceTildePrefixWithUserHome:: Path: " + path + ", Prefix: " + prefix + ", Result: " + result);
    return result;
}

From source file:com.microsoftopentechnologies.windowsazurestorage.helper.CredentialMigration.java

public static void upgradeStorageConfig() throws Exception {

    File sourceFile = new File(Utils.getWorkDirectory(), Constants.LEGACY_STORAGE_CONFIG_FILE);
    try {/* ww  w  .j  a va2 s  . co  m*/
        //check if we need to upgrade (i.e. if we have prior version of 0.3.2 storage plugin)
        if (!sourceFile.exists()) {
            return;
        }

        LOGGER.log(Level.INFO, sourceFile + " exists, upgrade will start now...");

        File backUp = backupFile(sourceFile.getCanonicalPath());
        List<StorageAccountInfo> oldStorages = getOldStorageConfig(sourceFile);

        if (oldStorages.size() > 0) {
            for (StorageAccountInfo sa : oldStorages) {
                String storageAccount = sa.getStorageAccName();
                String storageAccountKey = sa.getStorageAccountKey();
                String storageBlobURL = sa.getBlobEndPointURL();

                AzureCredentials.StorageAccountCredential u = new AzureCredentials.StorageAccountCredential(
                        storageAccount, storageAccountKey, storageBlobURL);
                AzureCredentials cred = CredentialsMatchers.firstOrNull(
                        CredentialsProvider.lookupCredentials(AzureCredentials.class, Jenkins.getInstance(),
                                ACL.SYSTEM, Collections.<DomainRequirement>emptyList()),
                        CredentialsMatchers.withId(u.getId()));
                if (cred != null) {
                    return;
                }

                LOGGER.log(Level.INFO,
                        "Moving Storage Account names and their keys to credential store, a creddential Id will be created for each pair of account name and key.");

                // no matching, so make our own.
                AzureCredentials tempCred = new AzureCredentials(CredentialsScope.GLOBAL,
                        Utils.getMD5(storageAccount.concat(storageAccountKey)),
                        "credential for " + storageAccount, storageAccount, storageAccountKey, storageBlobURL);
                final SecurityContext securityContext = ACL.impersonate(ACL.SYSTEM);

                try {
                    CredentialsStore s = CredentialsProvider.lookupStores(Jenkins.getInstance()).iterator()
                            .next();
                    try {
                        s.addCredentials(Domain.global(), tempCred);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }

                } finally {

                    SecurityContextHolder.setContext(securityContext);

                } // end finally

            } //end for

        } // end if

        LOGGER.log(Level.INFO, "Migrated successfully, deleting legacy config files...");
        removeFile(sourceFile.getCanonicalPath());
        removeFile(backUp.getCanonicalPath());

    } catch (Exception e) {
        e.printStackTrace();
    }

    return;

}

From source file:fr.natoine.model_annotation.AnnotationStatus.java

public String toCSS() {
    String css = ".annotation_" + label.replaceAll(" ", "_");
    css = css.concat("\n");
    css = css.concat("{ \n");
    if (color != null) {
        css = css.concat("border: 2px solid " + color + " ;\n");
        css = css.concat("background-color : " + color + " ;\n");
    } else {/*from   w w  w  .  j a  va2 s  .c  o m*/
        css = css.concat("border: 2px solid yellow ;\n");
        css = css.concat("background-color : yellow ;\n");
    }
    css = css.concat("\n }");
    return css;
}

From source file:fr.natoine.model_annotation.Annotation.java

public String toRDF(String _url_resource, String _url_agent, String _rdf_toinsert) {
    ArrayList<Agent> _authors = new ArrayList<Agent>();
    String rdf = "";
    if (status != null)
        rdf = rdf.concat("<jeu2debat:").concat(status.getRDFLabel()).concat(" rdf:about=\"")
                .concat(_url_resource).concat("?id=").concat(getId().toString()).concat("\" >");
    else/*from w w w .j  a  va2 s  . co  m*/
        rdf = rdf.concat("<annotea:Annotation rdf:about=\"").concat(_url_resource).concat("?id=")
                .concat(getId().toString()).concat("\" >");
    //annotates
    rdf = rdf.concat(annotated(_url_resource));
    //context, slections
    Collection<Resource> _annotateds = annotated;
    if (_annotateds != null && _annotateds.size() > 0) {
        rdf = rdf.concat("<annotea:context>");
        for (Resource _annotated : _annotateds) {
            rdf = rdf.concat(_annotated.toRDF(_url_resource, _url_agent, ""));
        }
        rdf = rdf.concat("</annotea:context>");
    }
    //body, ressources ajoutes
    Collection<Resource> _addeds = added;
    if (_addeds != null && _addeds.size() > 0) {
        rdf = rdf.concat("<annotea:body>");
        for (Resource _added : _addeds) {
            rdf = rdf.concat(_added.toRDF(_url_resource, _url_agent, ""));
            if (_added instanceof TagAgent) {
                if (((TagAgent) _added).getLabel().contains("isAuthor"))
                    _authors.add(((TagAgent) _added).getAgent());
            }
        }
        rdf = rdf.concat("</annotea:body>");
    }
    //autheurs
    if (_authors.size() > 0) {
        rdf = rdf.concat("<annotea:author>");
        for (Agent _author : _authors) {
            rdf = rdf.concat(_author.toRDF(_url_agent, ""));
        }
        rdf = rdf.concat("</annotea:author>");
    }
    if (_rdf_toinsert != null && _rdf_toinsert.length() > 0)
        rdf = rdf.concat(_rdf_toinsert);
    //fin
    if (status != null)
        rdf = rdf.concat("</jeu2debat:").concat(status.getRDFLabel()).concat(">");
    else
        rdf = rdf.concat("</annotea:Annotation>");
    return rdf;
}

From source file:fr.natoine.model_annotation.Annotation.java

private String annotated(String _url_resource) {
    String rdf = "";
    if (annotated != null && annotated.size() > 0) {
        rdf = rdf.concat("<annotea:annotates>");
        ArrayList<Resource> filtred_annotated = new ArrayList<Resource>();
        for (Resource resource : annotated) {
            if (resource instanceof Selection) {
                Resource origin = ((Selection) resource).getSelectionOrigin();
                if (!filtred_annotated.contains(origin)) {
                    rdf = rdf.concat(origin.toSeeAlso(_url_resource));
                    filtred_annotated.add(origin);
                }/* www.jav  a 2  s . co m*/
            } else {
                if (!filtred_annotated.contains(resource)) {
                    rdf = rdf.concat(resource.toSeeAlso(_url_resource));
                    filtred_annotated.add(resource);
                }
            }
        }
        rdf = rdf.concat("</annotea:annotates>");
    }
    return rdf;
}

From source file:jeplus.TRNSYSConfig.java

/**
 * Get Bin Directory// w  ww  .  j a va 2  s  . c  om
 */
@JsonIgnore
public String getResolvedTRNSYSBinDir() {
    String dir = RelativeDirUtil.checkAbsolutePath(TRNSYSBinDir, UserBaseDir);
    dir = dir.concat(dir.endsWith(File.separator) ? "" : File.separator);
    return dir;
}

From source file:br.ufrn.fonoweb.service.ArquivoService.java

public String getEncodedFileName(String originalFile, byte[] contents) {
    MessageDigest md = null;/*w w w .j a v  a  2  s .com*/
    String result = null;
    try {
        md = MessageDigest.getInstance("SHA-256");
        md.update(contents);
        result = new BigInteger(1, md.digest()).toString(16);
    } catch (NoSuchAlgorithmException ex) {
        Logger.getLogger(ArquivoService.class.getName()).log(Level.SEVERE, null, ex);
        return null;
    }
    result = result.concat(".").concat(FilenameUtils.getExtension(originalFile));
    return result;
}

From source file:es.juntadeandalucia.panelGestion.presentacion.controlador.impl.ConfigurationController.java

private String makeURLconnection(DataBaseVO dbVo) {
    String res = "";
    res = res.concat("jdbc:" + dbVo.getTipoBaseDatos() + "://" + dbVo.getHost() + ":" + dbVo.getPuerto() + "/"
            + dbVo.getBaseDatos());/*  ww  w.  ja  v a  2 s  .  c o  m*/
    try {
        descomposeURLtoParameterConnection(res);
    } catch (Exception oops) {
        log.info("Error en la cadena de conexion");
        res = "error";
    }
    return res;
}

From source file:fr.natoine.model_annotation.Annotation.java

public String toRDF(String _url_resource, String _rdf_toinsert) {
    //ArrayList<Agent> _authors = new ArrayList<Agent>();
    String rdf = "";
    if (status != null)
        rdf = rdf.concat("<jeu2debat:").concat(status.getRDFLabel()).concat(" rdf:about=\"")
                .concat(_url_resource).concat("?id=").concat(getId().toString()).concat("\" >");
    else/*from  w w  w. j  av a2s . co  m*/
        rdf = rdf.concat("<annotea:Annotation rdf:about=\"").concat(_url_resource).concat("?id=")
                .concat(getId().toString()).concat("\" >");
    //annotates
    rdf = rdf.concat(annotated(_url_resource));
    //context, ressources annotes
    Collection<Resource> _annotateds = annotated;
    if (_annotateds != null && _annotateds.size() > 0) {
        rdf = rdf.concat("<annotea:context>");
        for (Resource _annotated : _annotateds) {
            rdf = rdf.concat(_annotated.toRDF(_url_resource, ""));
        }
        rdf = rdf.concat("</annotea:context>");
    }
    //body, ressources ajoutes
    Collection<Resource> _addeds = added;
    if (_addeds != null && _addeds.size() > 0) {
        rdf = rdf.concat("<annotea:body>");
        for (Resource _added : _addeds) {
            rdf = rdf.concat(_added.toRDF(_url_resource, ""));
            /*if(_added instanceof TagAgent)
            {
               if(((TagAgent)_added).getLabel().contains("isAuthor")) _authors.add(((TagAgent)_added).getAgent());
            }*/
        }
        rdf = rdf.concat("</annotea:body>");
    }
    //autheurs
    /*if(_authors.size()>0)
    {
       String _url_rdf_agent = _url_resource ;
       _url_rdf_agent = _url_rdf_agent.substring(0 , _url_rdf_agent.lastIndexOf("/") + 1);
       _url_rdf_agent = _url_rdf_agent.concat("ServletViewRDFAgents");
       rdf = rdf.concat("<annotea:author>");
       for(Agent _author : _authors)
       {
    rdf = rdf.concat(_author.toRDF(_url_rdf_agent));
       }
       rdf = rdf.concat("</annotea:author>");
    }*/
    if (_rdf_toinsert != null && _rdf_toinsert.length() > 0)
        rdf = rdf.concat(_rdf_toinsert);
    //fin
    if (status != null)
        rdf = rdf.concat("</jeu2debat:").concat(status.getRDFLabel()).concat(">");
    else
        rdf = rdf.concat("</annotea:Annotation>");
    return rdf;
}

From source file:ch.icclab.cyclops.client.CloudStackAuth.java

/**
 * Perform construction of URL based on command provided, with some parameters as hashmap(key, value)
 *
 * @return constructed URL string/*from  www .ja  v a2 s . c  o m*/
 */
private String constructURL() {
    logger.trace("Constructing CloudStack API URL");

    // construct standard header
    Map<String, String> header = constructHeader();

    // now create url
    String queryString = Joiner.on("&").withKeyValueSeparator("=").join(header);

    try {
        // sign the normalised query string
        String signature = signRequest(queryString.toLowerCase());

        // add signature to our query string
        queryString = queryString.concat("&signature=".concat(signature));

        // return signed string
        return apiConnection.getCloudStackURL().concat("?".concat(queryString));

    } catch (NoSuchAlgorithmException e) {
        logger.error("Couldn't find encryption algorithm for signing CloudStack API URL");
        e.printStackTrace();
    } catch (InvalidKeyException e) {
        logger.error("Invalid Secret Key provided when trying to sign CloudStack API URL");
        e.printStackTrace();
    } catch (UnsupportedEncodingException e) {
        logger.error("Unsupported Encoding used when trying to sign CloudStack API URL");
        e.printStackTrace();
    }

    // return empty string if something went wrong
    return "";
}