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:net.thackbarth.sparrow.FileReader.java

/**
 * This method reads the ID3-Tags from the given file and stores them
 * to the MusicTrack object./*from  w w w  . jav a2 s .  co  m*/
 *
 * @param fileToRead the file to read
 * @param rootFolder the root of the scan. It will be used to calculate
 *                   the correct file path.
 * @param track      the object to store the information from the file
 */
public boolean readFile(File fileToRead, File rootFolder, MusicTrack track) {
    boolean result = false;
    try {
        Mp3File mp3file = new Mp3File(fileToRead.getAbsolutePath());

        track.setFilePath(fileToRead.getAbsolutePath().substring(rootFolder.getAbsolutePath().length()));
        track.setFilePath(track.getFilePath().replace(File.separatorChar, '/'));
        track.setModificationDate(fileToRead.lastModified());

        copyTagField("Album", mp3file, track);
        copyTagField("Artist", mp3file, track);
        copyTagField("Genre", mp3file, track);
        copyTagField("GenreDescription", mp3file, track);
        copyTagField("Title", mp3file, track);
        copyTagField("Track", mp3file, track);

        Set<ConstraintViolation<MusicTrack>> violations = validator.validate(track);
        if (violations.isEmpty()) {
            // create Target Filename
            String newFileName = filenameGenerator.generateName(track);
            if ((newFileName == null) || (newFileName.isEmpty())) {
                throw new IllegalStateException(
                        "FilenameGenerator returns wrong value for " + fileToRead.getAbsolutePath());
            }
            track.setTargetFilePath(newFileName);
            track.setFilePathCorrect(track.getFilePath().equals(track.getTargetFilePath()));
            if (!track.isFilePathCorrect()) {
                int endPosition = fileToRead.getAbsolutePath().length() - track.getFilePath().length();
                String base = fileToRead.getAbsolutePath().substring(0, endPosition);
                String target = base.concat(track.getTargetFilePath());
                logger.info("Track must be moved to " + target + " -> " + track);
            }
            result = true;
        } else {
            logger.error("File is not valid: " + fileToRead.getAbsolutePath() + " - " + violations);
        }
    } catch (IOException e) {
        logger.error(EXCEPTION_MESSAGE_MP3, e);
    } catch (UnsupportedTagException e) {
        logger.error(EXCEPTION_MESSAGE_MP3, e);
    } catch (InvalidDataException e) {
        logger.error(EXCEPTION_MESSAGE_MP3, e);
    }
    return result;
}

From source file:org.mitre.swd.web.SimpleWebDiscoveryEndpoint.java

@RequestMapping("/.well-known/openid-configuration")
public ModelAndView providerConfiguration(ModelAndView modelAndView) {

    /*   /*from   w w  w. j  ava  2s  . c  om*/
     *
        version    string    Version of the provider response. "3.0" is the default.
       issuer    string    The https: URL with no query or fragment component that the OP asserts as its Issuer Identifier
       authorization_endpoint    string    URL of the OP's Authentication and Authorization Endpoint [OpenID.Messages]
       token_endpoint    string    URL of the OP's OAuth 2.0 Token Endpoint [OpenID.Messages]
       userinfo_endpoint    string    URL of the OP's UserInfo Endpoint [OpenID.Messages]
       refresh_session_endpoint    string    URL of the OP's Refresh Session Endpoint [OpenID.Session]
       end_session_endpoint    string    URL of the OP's End Session Endpoint [OpenID.Session]
       jwk_url    string    URL of the OP's JSON Web Key [JWK] document. Server's signing Key
       jwk_encryption_url    string    URL of the OP's JSON Web Key [JWK] document. Server's Encryption Key, if not present, its value is the same as the URL provided by jwk_url
       x509_url    string    URL of the OP's X.509 certificates in PEM format.
       x509_encryption_url    string    URL of the OP's X.509 certificates in PEM format. Server's Encryption Key, if not present its value is the same as the URL provided by x509_url
       registration_endpoint    string    URL of the OP's Dynamic Client Registration Endpoint [OpenID.Registration]
       scopes_supported    array    A JSON array containing a list of the OAuth 2.0 [OAuth2.0] scope values that this server supports. The server MUST support the openid scope value.
       response_types_supported    array    A JSON array containing a list of the OAuth 2.0 response_type that this server supports. The server MUST support the code, id_token, and the token id_token response_type.
       acrs_supported    array    A JSON array containing a list of the Authentication Context Class References that this server supports.
       user_id_types_supported    array    A JSON array containing a list of the user identifier types that this server supports. Valid types include pairwise and public.
       userinfo_algs_supported    array    A JSON array containing a list of the JWS [JWS] and JWE [JWE] signing and encryption algorithms [JWA] supported by the UserInfo Endpoint to encode the JWT [JWT].
       id_token_algs_supported    array    A JSON array containing a list of the JWS and JWE signing and encryption algorithms [JWA] supported by the Authorization Server for the ID Token to encode the JWT [JWT].
       request_object_algs_supported    array    A JSON array containing a list of the JWS and JWE signing and encryption algorithms [JWA] supported by the Authorization Server for the OpenID Request Object described in Section 2.1.2.1 of OpenID Connect Messages [OpenID.Messages] to encode the JWT [JWT]. Servers SHOULD support RS256.
       token_endpoint_auth_types_supported    array    A JSON array containing a list of authentication types supported by this Token Endpoint. The options are client_secret_post, client_secret_basic, client_secret_jwt, and private_key_jwt, as described in Section 2.2.1 of OpenID Connect Messages 1.0 [OpenID.Messages]. Other Authentication types may be defined by extension. If unspecified or omitted, the default is client_secret_basic HTTP Basic Authentication Scheme as specified in Section 2.3.1 of OAuth 2.0 [OAuth2.0].
       token_endpoint_auth_algs_supported    array    A JSON array containing a list of the JWS signing algorithms [JWA] supported by the Token Endpoint for the private_key_jwt method to encode the JWT [JWT]. Servers SHOULD support RS256.
     *
     */
    String baseUrl = config.getIssuer();

    if (!baseUrl.endsWith("/")) {
        baseUrl = baseUrl.concat("/");
    }

    Map<String, Object> m = new HashMap<String, Object>();
    m.put("version", "3.0");
    m.put("issuer", config.getIssuer());
    m.put("authorization_endpoint", baseUrl + "authorize");
    m.put("token_endpoint", baseUrl + "token");
    m.put("userinfo_endpoint", baseUrl + "userinfo");
    //m.put("refresh_session_endpoint", baseUrl + "/refresh_session");
    //m.put("end_session_endpoint", baseUrl + "/end_session");
    m.put("jwk_url", baseUrl + "jwk");
    m.put("x509_url", baseUrl + "x509");
    m.put("registration_endpoint", baseUrl + "register");
    m.put("scopes_supported", Lists.newArrayList("openid", "email", "profile", "address", "phone"));
    m.put("response_types_supported", Lists.newArrayList("code"));
    m.put("token_endpoint_auth_types_supported",
            Lists.newArrayList("client_secret_post", "client_secret_basic"));

    modelAndView.getModel().put("entity", m);
    // TODO: everything in the list up there

    modelAndView.setViewName("jsonOpenIdConfigurationView");

    return modelAndView;
}

From source file:com.web.mavenproject6.controller.VKController.java

private JSONObject execute(String apiMethod, Param... params) throws IOException, JSONException {
    if (accessToken != null || StringUtils.isEmpty(accessToken)) {
        return new JSONObject();
    }/*from   w w  w .ja  va 2s .c  o  m*/

    String paramString = "?".concat(accessToken);
    if (params != null) {
        for (Param p : params) {
            paramString = paramString.concat("&").concat(p.getName()).concat("=").concat(p.getValue());
        }
    }

    HttpClient client = new DefaultHttpClient();
    HttpGet method = new HttpGet(apiUrl.concat(apiMethod).concat(paramString));

    HttpResponse resp = client.execute(method);
    BufferedReader reader = new BufferedReader(new InputStreamReader(resp.getEntity().getContent()));
    JSONObject json = new JSONObject(reader.readLine());
    reader.close();
    return json;
}

From source file:com.angrystone.JpegCompressor.java

@Override
public PluginResult execute(String action, JSONArray args, String callbackId) {
    PluginResult.Status status = PluginResult.Status.OK;
    String filename = "/mnt/sdcard/DCIM/Camera/Convert_";
    String orifilename = "/mnt/sdcard/DCIM/Camera/";

    if (action.equals("compress")) {
        Integer quality = 100;//from   ww w.j ava 2s.c om

        try {
            orifilename = orifilename.concat(args.getString(0));
            filename = filename.concat(args.getString(0));
            quality = args.getInt(1);
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        OutputStream outputStream = null;
        File file = new File(filename);
        Bitmap bitmap = BitmapFactory.decodeFile(orifilename);

        try {
            outputStream = new FileOutputStream(file);
            bitmap.compress(Bitmap.CompressFormat.JPEG, quality, outputStream);
            try {
                outputStream.flush();
                outputStream.close();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    } else {
        status = PluginResult.Status.INVALID_ACTION;
    }
    return new PluginResult(status, filename);
}

From source file:com.denimgroup.threadfix.framework.impl.struts.StrutsEndpointMappings.java

private File getJavaFileByName(String fileName) {
    fileName = fileName.replace('.', '/');
    fileName = fileName.concat(".java");
    for (File f : javaFiles) {
        String filePath = f.getPath();
        if (filePath.contains("\\"))
            filePath = filePath.replace('\\', '/');
        if (filePath.endsWith(fileName))
            return f;
    }//from ww  w .ja  v  a2s . c o  m
    return null;
}

From source file:hudson.plugins.memegen.MemegeneratorResponseException.java

public boolean instanceCreate(Meme meme) {
    boolean ret = false;
    HashMap<String, String> vars = new HashMap();
    vars.put("username", username);
    vars.put("password", password);
    vars.put("text0", meme.getUpperText());
    vars.put("text1", meme.getLowerText());
    vars.put("generatorID", "" + meme.getGeneratorID());
    vars.put("imageID", "" + meme.getImageID());

    try {//  w ww .java  2  s . com
        URL url = buildURL("Instance_Create", vars);

        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        HttpURLConnection.setFollowRedirects(true);
        conn.setDoOutput(true);
        JSONObject obj = parseResponse(conn);
        JSONObject result = (JSONObject) obj.get("result");
        String memeUrl = (String) result.get("instanceImageUrl");
        if (memeUrl.matches("^http(.*)") == false) {
            memeUrl = APIURL + memeUrl;
        }
        //Debug the JSON to logs
        //System.err.println(obj.toJSONString()+", AND "+result.toJSONString());
        meme.setImageURL(memeUrl);
        ret = true;

    } catch (MalformedURLException me) {
        String log_warn_prefix = "Memegenerator API malformed URL: ";
        System.err.println(log_warn_prefix.concat(me.getMessage()));
    } catch (IOException ie) {
        String log_warn_prefix = "Memegenerator API IO exception: ";
        System.err.println(log_warn_prefix.concat(ie.getMessage()));
    } catch (ParseException pe) {
        String log_warn_prefix = "Memegenerator API malformed response: ";
        System.err.println(log_warn_prefix.concat(pe.getMessage()));
    } catch (MemegeneratorResponseException mre) {
        String log_warn_prefix = "Memegenerator API failure: ";
        System.err.println(log_warn_prefix.concat(mre.getMessage()));
    } catch (MemegeneratorJSONException mje) {
        String log_warn_prefix = "Memegenerator API malformed JSON: ";
        System.err.println(log_warn_prefix.concat(mje.getMessage()));
    }

    return ret;
}

From source file:com.blogspot.skam94.main.datatypes.FileItem.java

/**
 * newPath must contain the last ///from  www.  j  a v a2  s.  c om
 * @param newPath
 * @return
 */
public boolean move(String newPath) {
    if (newPath.equals(filePath)) {
        return true;
    }
    File newFile = new File(newPath.concat(fileName).concat(getExtWithDot()));
    try {
        FileUtils.moveFile(getFile(), newFile);
        filePath = newPath;
    } catch (IOException e) {
        e.printStackTrace();
        return false;
    }
    return true;
}

From source file:ch.entwine.weblounge.kernel.security.RoleBasedLoginSuccessHandler.java

/**
 * Add a timestamp parameter to the url location
 * // w  ww.  ja v  a2s.  c o  m
 * @param location
 *          the url
 * @return the page with a timestamp
 */
private String addTimeStamp(String location) {
    long timeStamp = new Date().getTime();
    if (location.contains("?")) {
        return location.concat("&_=" + timeStamp);
    } else {
        return location.concat("?_=" + timeStamp);
    }
}

From source file:org.n52.sos.soe.HarvestFeaturesWithObservations.java

private List<String> findNetworks()
        throws ClientProtocolException, IllegalStateException, IOException, XmlException {
    String url = HttpUtil.resolveServiceURL();

    XmlObject xo = HttpUtil// www  .  jav  a2  s . c  om
            .executeGetAndParseAsXml(url.concat("GetCapabilities?service=SOS&request=GetCapabilities&f=xml"));

    CapabilitiesDocument caps = (CapabilitiesDocument) xo;

    List<String> result = new ArrayList<>();

    for (Offering o : caps.getCapabilities().getContents().getContents().getOfferingArray()) {
        ObservationOfferingDocument off = ObservationOfferingDocument.Factory.parse(o.xmlText());
        result.add(off.getObservationOffering().getIdentifier());
    }

    return result;
}

From source file:com.microsoft.applicationinsights.web.extensibility.modules.WebRequestTrackingTelemetryModuleTests.java

private ServletRequest createServletRequest(String queryString, String pathVariable) {
    HttpServletRequest request = mock(HttpServletRequest.class);

    String uri = DEFAULT_REQUEST_URI;
    if (pathVariable != null) {
        uri = uri.concat(pathVariable);
    }// w w  w  . j av a  2 s. co m

    when(request.getRequestURI()).thenReturn(uri);
    when(request.getMethod()).thenReturn(HttpMethods.GET);
    when(request.getScheme()).thenReturn("http");
    when(request.getHeader("Host")).thenReturn("localhost:1234");
    when(request.getQueryString()).thenReturn(queryString);

    return request;
}