Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ninjaframework/ninja-rythm
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: evatechsoft/ninja-rythm
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 1 commit
  • 13 files changed
  • 1 contributor

Commits on Apr 19, 2015

  1. Copy the full SHA
    a08e940 View commit details
16 changes: 5 additions & 11 deletions ninja-rythm-demo/pom.xml
Original file line number Diff line number Diff line change
@@ -22,8 +22,8 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jettyVersion>9.0.5.v20130815</jettyVersion>
<ninjaVersion>2.0.0</ninjaVersion>
<jettyVersion>9.3.0.M2</jettyVersion>
<ninjaVersion>5.1.0</ninjaVersion>
<ninjaRythmVersion>0.0.1-SNAPSHOT</ninjaRythmVersion>
</properties>

@@ -51,21 +51,14 @@
<scanIntervalSeconds>1</scanIntervalSeconds>
<reload>automatic</reload>
<classesDirectory>
target/classes;../ninja-core/target/classes;../ninja-core-test/target/classes
target/classes
</classesDirectory>
<scanTargets>
<scanTarget>../ninja-core/target/classes</scanTarget>
<scanTarget>../ninja-core-test/target/classes</scanTarget>
</scanTargets>
<scanTargetPatterns>
<scanTargetPattern>
<directory>target/classes</directory>
<includes>
<include>**/*</include>
</includes>
<excludes>
<exclude>**/*.html</exclude>
</excludes>
</scanTargetPattern>
</scanTargetPatterns>
</configuration>
@@ -74,6 +67,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<configuration>
<skip>true</skip>
</configuration>
@@ -123,7 +117,7 @@
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>

138 changes: 138 additions & 0 deletions ninja-rythm-demo/pom.xml.versionsBackup
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
<!-- Copyright (C) 2012 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. -->

<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>ninja-rythm-demo</artifactId>
<packaging>war</packaging>

<name>Ninja demo application with Rythm</name>

<parent>
<groupId>org.ninjaframework</groupId>
<artifactId>ninja-rythm</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jettyVersion>9.0.5.v20130815</jettyVersion>
<ninjaVersion>5.1.0</ninjaVersion>
<ninjaRythmVersion>0.0.1-SNAPSHOT</ninjaRythmVersion>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.1</version>
<configuration>
<path>/</path>
<contextReloadable>true</contextReloadable>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jettyVersion}</version>
<configuration>
<webApp>
<contextPath>/</contextPath>
</webApp>
<stopKey>stop</stopKey>
<stopPort>8889</stopPort>
<scanIntervalSeconds>1</scanIntervalSeconds>
<reload>automatic</reload>
<classesDirectory>
target/classes;../ninja-core/target/classes;../ninja-core-test/target/classes
</classesDirectory>
<scanTargets>
<scanTarget>../ninja-core/target/classes</scanTarget>
<scanTarget>../ninja-core-test/target/classes</scanTarget>
</scanTargets>
<scanTargetPatterns>
<scanTargetPattern>
<directory>target/classes</directory>
<includes>
<include>**/*</include>
</includes>
<excludes>
<exclude>**/*.html</exclude>
</excludes>
</scanTargetPattern>
</scanTargetPatterns>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>

</plugins>

<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*</include>
</includes>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*</include>
</includes>
</resource>
</resources>

</build>

<dependencies>

<dependency>
<groupId>org.ninjaframework</groupId>
<artifactId>ninja-core</artifactId>
<version>${ninjaVersion}</version>
</dependency>
<dependency>
<groupId>org.ninjaframework</groupId>
<artifactId>ninja-servlet</artifactId>
<version>${ninjaVersion}</version>
</dependency>

<dependency>
<groupId>org.ninjaframework</groupId>
<artifactId>ninja-rythm-module</artifactId>
<version>${ninjaRythmVersion}</version>
</dependency>

<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.ninjaframework</groupId>
<artifactId>ninja-test-utilities</artifactId>
<version>${ninjaVersion}</version>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -27,7 +27,6 @@
import ninja.Result;
import ninja.Results;
import ninja.Router;
import ninja.cache.Cache;
import ninja.cache.NinjaCache;
import ninja.i18n.Lang;
import ninja.i18n.Messages;
@@ -42,7 +41,6 @@

import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.collect.Maps;
import com.google.inject.Inject;
import com.google.inject.Singleton;

@@ -101,7 +99,7 @@ public Result userDashboard(@PathParam("email") String email,
@PathParam("id") Integer id,
Context context) {

Map<String, Object> map = new HashMap<String, Object>();
Map<String, Object> map = new HashMap<>();
// generate tuples, convert integer to string here because Freemarker
// does it in locale
// dependent way with commas etc
92 changes: 48 additions & 44 deletions ninja-rythm-demo/src/main/java/controllers/UploadController.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
/**
* Copyright (C) 2013 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
* 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
* 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.
* 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 controllers;

import java.io.InputStream;
@@ -34,14 +33,16 @@
import com.google.common.io.ByteStreams;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import java.io.IOException;
import org.apache.commons.fileupload.FileUploadException;

@Singleton
public class UploadController {

/**
* This is the system wide logger. You can still use any config you like. Or
* create your own custom logger.
*
*
* But often this is just a simple solution:
*/
@Inject
@@ -63,10 +64,10 @@ public Result upload() {
}

/**
*
*
* This upload method expects a file and simply displays the file in the
* multipart upload again to the user (in the correct mime encoding).
*
*
* @param context
* @return
* @throws Exception
@@ -78,51 +79,54 @@ public Result uploadFinish(Context context) throws Exception {
Renderable renderable = new Renderable() {

@Override
public void render(Context context, Result result) throws Exception {
public void render(Context context, Result result) {

// make sure the context really is a multipart context...
if (context.isMultipart()) {
try {
// make sure the context really is a multipart context...
if (context.isMultipart()) {

// This is the iterator we can use to iterate over the
// contents
// of the request.
FileItemIterator fileItemIterator = context
.getFileItemIterator();
// This is the iterator we can use to iterate over the
// contents
// of the request.
FileItemIterator fileItemIterator = context
.getFileItemIterator();

while (fileItemIterator.hasNext()) {
while (fileItemIterator.hasNext()) {

FileItemStream item = fileItemIterator.next();
FileItemStream item = fileItemIterator.next();

String name = item.getFieldName();
InputStream stream = item.openStream();
String name = item.getFieldName();
InputStream stream = item.openStream();

String contentType = item.getContentType();
String contentType = item.getContentType();

if (contentType != null) {
result.contentType(contentType);
} else {
contentType = mimeTypes.getMimeType(name);
}
if (contentType != null) {
result.contentType(contentType);
} else {
contentType = mimeTypes.getMimeType(name);
}

ResponseStreams responseStreams = context
.finalizeHeaders(result);
ResponseStreams responseStreams = context
.finalizeHeaders(result);

if (item.isFormField()) {
System.out.println("Form field " + name
+ " with value " + Streams.asString(stream)
+ " detected.");
} else {
System.out.println("File field " + name
+ " with file name " + item.getName()
+ " detected.");
// Process the input stream
if (item.isFormField()) {
System.out.println("Form field " + name
+ " with value " + Streams.asString(stream)
+ " detected.");
} else {
System.out.println("File field " + name
+ " with file name " + item.getName()
+ " detected.");
// Process the input stream

ByteStreams.copy(stream,
responseStreams.getOutputStream());
ByteStreams.copy(stream,
responseStreams.getOutputStream());

}
}
}

}
} catch (FileUploadException | IOException fileUploadException) {
}

}
Loading