Skip to content
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
# Java
*.war
*.jar
*.class
*.class
Shevtsov/src/main/webapp/res/themes/manuscript/index.html
2 changes: 2 additions & 0 deletions Shevtsov/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*/taget/
*/classes/
80 changes: 80 additions & 0 deletions Shevtsov/BlogSources/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?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>com.example</groupId>
<artifactId>blogsources</artifactId>
<version>0.0.1</version>
<packaging>war</packaging>

<name>demo</name>
<description>web blog demo</description>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.7</java.version>
<spring.version>4.1.6.RELEASE</spring.version>
</properties>
<dependencies>
<dependency>
<groupId>com.example.blogsources</groupId>
<artifactId>URLMapping</artifactId>
<version>0.0.1</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<version>8.0.23</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<url>http://localhost:8080/manager/text</url>
<server>TomcatServer</server>
<path>/demo</path>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
package com.example.blogsources.Post;

import java.io.PrintStream;
import java.util.Date;

public abstract class AbstractPost implements Post {
private int id;
private int userId;
private String title;
private Date creationDate;
private Date updateDate;
protected String type = null;
protected String postContent = null;

public AbstractPost() {
}

public AbstractPost(int id, String title, int userId) {
this.id = id;
this.userId = userId;
this.title = title;
creationDate = new Date();
updateDate = creationDate;
setPostType();
}

@Override
public int getPostId() {
return id;
}

@Override
public Date getPostCreationDate() {
return creationDate;
}

@Override
public Date getPostLastUpdateDate() {
return updateDate;
}

public String getPostTitle() {
return title;
}

@Override
public void setPostLastUpdateDate(Date lastUpdateDate) {
updateDate = lastUpdateDate;
}

@Override
public String getPostType() {
return type;
}

protected abstract void setPostType();
protected void setPostContant(String postContant) {
this.postContent = postContant;
}

@Override
public abstract void displayPost(PrintStream out);

public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

public int getUserId() {
return userId;
}

public void setUserId(int userId) {
this.userId = userId;
}

public String getTitle() {
return title;
}

public void setTitle(String title) {
this.title = title;
}

public Date getCreationDate() {
return creationDate;
}

public void setCreationDate(Date creationDate) {
this.creationDate = creationDate;
}

public Date getUpdateDate() {
return updateDate;
}

public void setUpdateDate(Date updateDate) {
this.updateDate = updateDate;
}

public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}

public String getPostContent() {
return postContent;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.example.blogsources.Post.Exceptions;

public class IllegalPageTypeException extends PageExeptions {

public IllegalPageTypeException(String s) {
super(s);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.example.blogsources.Post.Exceptions;

public class NotExistsPageException extends PageExeptions {

public NotExistsPageException(String s) {
super(s);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.example.blogsources.Post.Exceptions;

public class PageExeptions extends RuntimeException{
PageExeptions (String s) {super(s);}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.example.blogsources.Post;

import java.io.PrintStream;

public class ImagePost extends AbstractPost {

public ImagePost(int id, String content, int userId) {
super(id,content,userId);
}

@Override
protected void setPostType() {
type = "image";
}

@Override
public void displayPost(PrintStream out) {out.println("There is I have to show a image - " + super.getPostTitle());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.example.blogsources.Post;

import java.io.PrintStream;
import java.util.Date;

public interface Post {
int getPostId();
String getPostTitle();
String getPostContent();
String getPostType();
void displayPost(PrintStream out);
Date getPostCreationDate();
Date getPostLastUpdateDate();
void setPostLastUpdateDate(Date lastUpdateDate);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.example.blogsources.Post;

import java.io.PrintStream;

public class RegularPost extends AbstractPost {

public RegularPost(int id, String content, int userId) {
super(id,content,userId);
}

public RegularPost() {
super();
setPostType();
}

@Override
protected void setPostType() {
type = "regular";
}

@Override
public void displayPost(PrintStream out) {
System.out.println("The Regular page was created" + super.getPostCreationDate() + "Content:S");
out.println(super.getPostTitle() + "\n" );
}
public void setPostContent (String content){
postContent = content;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.example.blogsources.Post;

public class URLMap {
public static final String PROTO = "http://";
public static final String HOST = "localhost";
public static final String PORT = ":8080/";
public static final String CONTEXT = "demo";
public static final String FULL_URL = PROTO + HOST + PORT + CONTEXT;
public static final String LOGIN = "/login";
public static final String FULL_LOGIN = FULL_URL + LOGIN;
public static final String LOGOUT = "/logout";
public static final String FULL_LOGOUT = FULL_URL + LOGOUT;
public static final String REGISTER = "/register";
public static final String FULL_REGISTER = FULL_URL + REGISTER;
public static final String ADDPOST = "/addPost";
public static final String FULL_ADDPOST = FULL_URL + ADDPOST;
public static final String WELCOME = "/welcome";
public static final String FULL_WELCOME = FULL_URL + WELCOME;
public static final String ABOUT = "/about";
public static final String FULL_ABOUT = FULL_URL + ABOUT;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.example.blogsources.Post;

import java.io.PrintStream;

public class URLPost extends AbstractPost {

public URLPost(int id, String content, int userId) {
super(id,content,userId);
}

@Override
protected void setPostType() {
type = "url";
}

@Override
public void displayPost(PrintStream out) {
out.println("There is I have to get and show data from the extended URL - " + super.getPostTitle());
}
}
Loading