This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.baeldung.web.hateoas; | |
import javax.servlet.http.HttpServletResponse; | |
import org.springframework.context.ApplicationListener; | |
import org.springframework.stereotype.Component; | |
import org.springframework.web.util.UriComponentsBuilder; | |
import com.google.common.base.Preconditions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<beans:beans | |
xmlns="http://www.springframework.org/schema/security" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xmlns:beans="http://www.springframework.org/schema/beans" | |
xmlns:sec="http://www.springframework.org/schema/security" | |
xsi:schemaLocation=" | |
http://www.springframework.org/schema/security | |
http://www.springframework.org/schema/security/spring-security-3.1.xsd | |
http://www.springframework.org/schema/beans |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class AbstractJpaDAO< T extends Serializable > { | |
private Class< T > clazz; | |
@PersistenceContext | |
EntityManager entityManager; | |
public void setClazz( final Class< T > clazzToSet ){ | |
this.clazz = clazzToSet; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public String authenticateAsAdmin(){ | |
return this.authenticate( "eparaschiv", "eparaschiv" ); | |
} | |
public String authenticate( String username, String password ){ | |
Response response = RestAssured.given(). | |
.param( UsernamePasswordAuthenticationFilter.SPRING_SECURITY_FORM_USERNAME_KEY, username ) | |
.param( UsernamePasswordAuthenticationFilter.SPRING_SECURITY_FORM_PASSWORD_KEY, password ) | |
.post( this.examplePaths.getLoginURL() ); | |
Preconditions.checkState( response.getStatusCode() == 302 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static String extractURIByRel(final String linkHeader, final String rel) { | |
if (linkHeader == null) { | |
return null; | |
} | |
String uriWithSpecifiedRel = null; | |
final String[] links = linkHeader.split(", "); | |
String linkRelation = null; | |
for (final String link : links) { | |
final int positionOfSeparator = link.indexOf(';'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<beans xmlns="http://www.springframework.org/schema/beans" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xmlns:context="http://www.springframework.org/schema/context" | |
xsi:schemaLocation=" | |
http://www.springframework.org/schema/beans | |
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd | |
http://www.springframework.org/schema/context | |
http://www.springframework.org/schema/context/spring-context-3.1.xsd"> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.macys.rest.common; | |
import java.util.HashSet; | |
import java.util.Set; | |
/** | |
* - link: http://thenoisychannel.com/2011/08/08/retiring-a-great-interview-problem/ <br> | |
* Given an input string and a dictionary of words, segment the input string into a space-separated sequence of dictionary words if possible. | |
* For example, if the input string is "applepie" and dictionary contains a | |
* standard set of English words, then we would return the string "apple pie" as output. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependency> | |
<groupId>commons-codec</groupId> | |
<artifactId>commons-codec</artifactId> | |
<version>1.6</version> | |
</dependency> | |
<dependency> | |
<groupId>org.apache.httpcomponents</groupId> | |
<artifactId>httpcore</artifactId> | |
<version>4.1.4</version> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component | |
public class RestTemplateFactory implements | |
FactoryBean< RestTemplate >, InitializingBean{ | |
private RestTemplate restTemplate; | |
public RestTemplate getObject(){ | |
return restTemplate; | |
} | |
public Class< RestTemplate > getObjectType(){ | |
return RestTemplate.class; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Bean | |
public static PropertySourcesPlaceholderConfigurer properties(){ | |
PropertySourcesPlaceholderConfigurer pspc = | |
new PropertySourcesPlaceholderConfigurer(); | |
Resource[] resources = new ClassPathResource[ ] | |
{ new ClassPathResource( "foo.properties" ) }; | |
pspc.setLocations( resources ); | |
pspc.setIgnoreUnresolvablePlaceholders( true ); | |
return pspc; | |
} |
NewerOlder