Skip to content
This repository was archived by the owner on Apr 5, 2022. It is now read-only.

Feature/retwisj reboot #4

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions retwisj-reboot/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
buildscript {
ext {
springBootVersion = '1.0.2.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'

jar {
baseName = 'retwisj-demo'
version = '0.0.1-SNAPSHOT'
}

repositories {
mavenCentral()
}

dependencies {
compile("org.springframework.boot:spring-boot-starter-web:${springBootVersion}")
compile("org.springframework.boot:spring-boot-starter-redis:${springBootVersion}")
testCompile("org.springframework.boot:spring-boot-starter-test:${springBootVersion}")
}

task wrapper(type: Wrapper) {
gradleVersion = '1.12'
}
74 changes: 74 additions & 0 deletions retwisj-reboot/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.example</groupId>
<artifactId>retwisj-demo</artifactId>
<version>0.0.1-SNAPSHOT</version>

<name>retwisj-reboot</name>
<description>retwisj demo project</description>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.0.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>

<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.13</version>
</dependency>

<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
<version>1.2.1.RELEASE</version>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
<version>2.2</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<start-class>org.example.retwisj.Application</start-class>
<java.version>1.7</java.version>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

</project>
89 changes: 89 additions & 0 deletions retwisj-reboot/src/main/java/org/example/retwisj/Application.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
* Copyright 2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.example.retwisj;

import java.util.Collections;
import java.util.Set;

import org.example.retwisj.web.CookieInterceptor;
import org.example.retwisj.web.TweetDateProcessor;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.thymeleaf.dialect.AbstractDialect;
import org.thymeleaf.dialect.IDialect;
import org.thymeleaf.processor.IProcessor;

/**
* @author Thomas Darimont
* @author Christoph Strobl
*/
@Configuration
@ComponentScan
@EnableAutoConfiguration
public class Application {

public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}

@Bean
public WebMvcConfigurerAdapter webMvcConfigurerAdapter() {
WebMvcConfigurerAdapter adapter = new WebMvcConfigurerAdapter() {

@Override
public void addInterceptors(InterceptorRegistry registry) {
super.addInterceptors(registry);
registry.addInterceptor(cookieInterceptor());
}
};

return adapter;
}

@Bean
CookieInterceptor cookieInterceptor() {
return new CookieInterceptor();
}

@Bean
public IDialect tweetDialect() {

return new AbstractDialect() {

@Override
public Set<IProcessor> getProcessors() {
return Collections.<IProcessor> singleton(tweetDateProcessor());
}

@Override
public String getPrefix() {
return "tweet";
}

};

}

@Bean
public TweetDateProcessor tweetDateProcessor() {
return new TweetDateProcessor();
}
}
118 changes: 118 additions & 0 deletions retwisj-reboot/src/main/java/org/example/retwisj/Post.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
/*
* Copyright 2011 the original uid or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.example.retwisj;


/**
* Class describing a post.
*
* @author Costin Leau
*/
public class Post {

private String content;
private String uid;
private String time = String.valueOf(System.currentTimeMillis());
private String replyPid;
private String replyUid;

/**
* Returns the content.
*
* @return Returns the content
*/
public String getContent() {
return content;
}

/**
* @param content The content to set.
*/
public void setContent(String content) {
this.content = content;
}


/**
* Returns the uid.
*
* @return Returns the uid
*/
public String getUid() {
return uid;
}

/**
* @param uid The uid to set.
*/
public void setUid(String author) {
this.uid = author;
}

/**
* Returns the time.
*
* @return Returns the time
*/
public String getTime() {
return time;
}

/**
* @param time The time to set.
*/
public void setTime(String time) {
this.time = time;
}

/**
* Returns the replyPid.
*
* @return Returns the replyPid
*/
public String getReplyPid() {
return replyPid;
}

/**
* @param replyPid The replyPid to set.
*/
public void setReplyPid(String replyPid) {
this.replyPid = replyPid;
}

/**
* Returns the replyUid.
*
* @return Returns the replyUid
*/
public String getReplyUid() {
return replyUid;
}

/**
* @param replyUid The replyUid to set.
*/
public void setReplyUid(String replyUid) {
this.replyUid = replyUid;
}

@Override
public String toString() {
return "Post [content=" + content + ", replyPid=" + replyPid + ", replyUid=" + replyUid
+ ", time=" + time + ", uid=" + uid + "]";
}
}
45 changes: 45 additions & 0 deletions retwisj-reboot/src/main/java/org/example/retwisj/Range.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright 2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.example.retwisj;

/**
* Basic object indicating a range of objects to retrieve. Default is 10 objects (starting at zero).
*
* @author Costin Leau
*/
public class Range {

private static final int SIZE = 9;
public int begin = 0;
public int end = SIZE;

public Range() {
};

public Range(int begin, int end) {
this.begin = begin;
this.end = end;
}

public Range(int pageNumber) {
this.begin = 0;
this.end = pageNumber * SIZE;
}

public int getPages() {
return (int) Math.round(Math.ceil(end / SIZE));
}
}
Loading