Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

updated readme files

  • Loading branch information...
commit 711cec07834a10139011405aab365f32d647cf1d 1 parent 8759d84
mic authored
Showing with 22,504 additions and 7 deletions.
  1. +4 −1 README.md
  2. +70 −0 README.md~
  3. +6 −0 blogracy-vuze/.settings/org.eclipse.jdt.core.prefs
  4. +5 −0 blogracy-vuze/.settings/org.eclipse.m2e.core.prefs
  5. +2 −3 blogracy-vuze/README.md
  6. +99 −0 blogracy-vuze/README.md~
  7. +1 −1  blogracy-vuze/mvn-install-vuze.sh
  8. +2 −0  blogracy-vuze/mvn-install-vuze.sh~
  9. +2 −2 blogracy-vuze/pom.xml
  10. +108 −0 blogracy-vuze/pom.xml~
  11. 0  blogracy-vuze/src/main/plugins/blogracy/plugin.properties
  12. +6 −0 blogracy-web/.settings/org.eclipse.jdt.core.prefs
  13. +5 −0 blogracy-web/.settings/org.eclipse.m2e.core.prefs
  14. +2 −0  blogracy-web/README.md
  15. +69 −0 blogracy-web/README.md~
  16. 0  build.sh
  17. +25 −0 old/src/main/config/blogracyPaths.properties
  18. +37 −0 old/src/main/config/blogracyUrl.config
  19. +27 −0 old/src/main/config/blogracyUser.properties
  20. +24 −0 old/src/main/config/blogracyVuze.properties
  21. +797 −0 old/src/main/java/it/unipr/aotlab/blogracy/Blogracy.java
  22. +164 −0 old/src/main/java/it/unipr/aotlab/blogracy/config/Configurations.java
  23. +36 −0 old/src/main/java/it/unipr/aotlab/blogracy/config/PathConfig.java
  24. +38 −0 old/src/main/java/it/unipr/aotlab/blogracy/config/UserConfig.java
  25. +34 −0 old/src/main/java/it/unipr/aotlab/blogracy/config/VuzeConfig.java
  26. +16 −0 old/src/main/java/it/unipr/aotlab/blogracy/controller/Controller.java
  27. +40 −0 old/src/main/java/it/unipr/aotlab/blogracy/errors/BlogracyError.java
  28. +50 −0 old/src/main/java/it/unipr/aotlab/blogracy/errors/InformationMissing.java
  29. +51 −0 old/src/main/java/it/unipr/aotlab/blogracy/errors/InformationNotYetAvailable.java
  30. +45 −0 old/src/main/java/it/unipr/aotlab/blogracy/errors/InvalidPluginStateException.java
  31. +37 −0 old/src/main/java/it/unipr/aotlab/blogracy/errors/MissingProfileError.java
  32. +28 −0 old/src/main/java/it/unipr/aotlab/blogracy/errors/NetworkConfigurationError.java
  33. +50 −0 old/src/main/java/it/unipr/aotlab/blogracy/errors/NetworkError.java
  34. +51 −0 old/src/main/java/it/unipr/aotlab/blogracy/errors/ServerConfigurationError.java
  35. +37 −0 old/src/main/java/it/unipr/aotlab/blogracy/errors/URLMappingError.java
  36. +100 −0 old/src/main/java/it/unipr/aotlab/blogracy/logging/Logger.java
  37. +37 −0 old/src/main/java/it/unipr/aotlab/blogracy/mime/MimeFinder.java
  38. +41 −0 old/src/main/java/it/unipr/aotlab/blogracy/mime/MimeFinderFactory.java
  39. +44 −0 old/src/main/java/it/unipr/aotlab/blogracy/mime/URLConnectionMimeFinder.java
  40. +47 −0 old/src/main/java/it/unipr/aotlab/blogracy/model/hashes/Hash.java
  41. +149 −0 old/src/main/java/it/unipr/aotlab/blogracy/model/hashes/Hashes.java
  42. +34 −0 old/src/main/java/it/unipr/aotlab/blogracy/model/messages/InputMessageFilter.java
  43. +46 −0 old/src/main/java/it/unipr/aotlab/blogracy/model/messages/Message.java
  44. +113 −0 old/src/main/java/it/unipr/aotlab/blogracy/model/messages/Messages.java
  45. +41 −0 old/src/main/java/it/unipr/aotlab/blogracy/model/messages/OutputMessageFilter.java
  46. +33 −0 old/src/main/java/it/unipr/aotlab/blogracy/model/tags/Tag.java
  47. +32 −0 old/src/main/java/it/unipr/aotlab/blogracy/model/tags/Tags.java
  48. +36 −0 old/src/main/java/it/unipr/aotlab/blogracy/model/users/Profile.java
  49. +61 −0 old/src/main/java/it/unipr/aotlab/blogracy/model/users/User.java
  50. +79 −0 old/src/main/java/it/unipr/aotlab/blogracy/model/users/UserImpl.java
  51. +111 −0 old/src/main/java/it/unipr/aotlab/blogracy/model/users/Users.java
  52. +14 −0 old/src/main/java/it/unipr/aotlab/blogracy/network/Network.java
  53. +42 −0 old/src/main/java/it/unipr/aotlab/blogracy/network/NetworkManager.java
  54. +1,672 −0 old/src/main/java/it/unipr/aotlab/blogracy/oldcode/Controller.java
  55. +70 −0 old/src/main/java/it/unipr/aotlab/blogracy/oldcode/DdbFile.java
  56. +68 −0 old/src/main/java/it/unipr/aotlab/blogracy/oldcode/DdbListenerRead.java
  57. +47 −0 old/src/main/java/it/unipr/aotlab/blogracy/oldcode/DdbListenerWrite.java
  58. +47 −0 old/src/main/java/it/unipr/aotlab/blogracy/oldcode/DownloadDetails.java
  59. +111 −0 old/src/main/java/it/unipr/aotlab/blogracy/oldcode/DownloadEventListener.java
  60. +378 −0 old/src/main/java/it/unipr/aotlab/blogracy/oldcode/Model.java
  61. +204 −0 old/src/main/java/it/unipr/aotlab/blogracy/oldcode/Rss.java
  62. +121 −0 old/src/main/java/it/unipr/aotlab/blogracy/services/DownloadService.java
  63. +123 −0 old/src/main/java/it/unipr/aotlab/blogracy/services/LookupService.java
  64. +138 −0 old/src/main/java/it/unipr/aotlab/blogracy/services/SeedService.java
  65. +100 −0 old/src/main/java/it/unipr/aotlab/blogracy/services/StoreService.java
  66. +109 −0 old/src/main/java/it/unipr/aotlab/blogracy/util/FileUtils.java
  67. +67 −0 old/src/main/java/it/unipr/aotlab/blogracy/web/misc/HttpResponseCode.java
  68. +63 −0 old/src/main/java/it/unipr/aotlab/blogracy/web/post/PostQuery.java
  69. +108 −0 old/src/main/java/it/unipr/aotlab/blogracy/web/post/PostQueryImpl.java
  70. +91 −0 old/src/main/java/it/unipr/aotlab/blogracy/web/post/PostQueryParser.java
  71. +178 −0 old/src/main/java/it/unipr/aotlab/blogracy/web/resolvers/AbstractRequestResolver.java
  72. +153 −0 old/src/main/java/it/unipr/aotlab/blogracy/web/resolvers/ErrorPageResolver.java
  73. +27 −0 old/src/main/java/it/unipr/aotlab/blogracy/web/resolvers/HTTPRequestType.java
  74. +201 −0 old/src/main/java/it/unipr/aotlab/blogracy/web/resolvers/MagnetResolver.java
  75. +72 −0 old/src/main/java/it/unipr/aotlab/blogracy/web/resolvers/MainResolver.java
  76. +158 −0 old/src/main/java/it/unipr/aotlab/blogracy/web/resolvers/MessagesResolver.java
  77. +64 −0 old/src/main/java/it/unipr/aotlab/blogracy/web/resolvers/MissingPageResolver.java
  78. +56 −0 old/src/main/java/it/unipr/aotlab/blogracy/web/resolvers/RequestResolver.java
  79. +40 −0 old/src/main/java/it/unipr/aotlab/blogracy/web/resolvers/RequestsUtilities.java
  80. +200 −0 old/src/main/java/it/unipr/aotlab/blogracy/web/resolvers/StaticFileResolver.java
  81. +89 −0 old/src/main/java/it/unipr/aotlab/blogracy/web/resolvers/UserResolver.java
  82. +149 −0 old/src/main/java/it/unipr/aotlab/blogracy/web/resolvers/VelocityRequestResolver.java
  83. +55 −0 old/src/main/java/it/unipr/aotlab/blogracy/web/url/ConfigurationTimeParameters.java
  84. +224 −0 old/src/main/java/it/unipr/aotlab/blogracy/web/url/Mapping.java
  85. +203 −0 old/src/main/java/it/unipr/aotlab/blogracy/web/url/URLMapper.java
  86. +34 −0 old/src/main/resources/messages/Messages.properties
  87. +2,467 −0 old/src/main/resources/static/css/bootstrap.css
  88. +41 −0 old/src/main/resources/static/css/style.css
  89. +113 −0 old/src/main/resources/static/scripts/bootstrap-alerts.js
  90. +9,300 −0 old/src/main/resources/static/scripts/jquery-1.7.js
  91. +4 −0 old/src/main/resources/static/scripts/jquery-1.7.min.js
  92. +919 −0 old/src/main/resources/static/scripts/jquery.form.js
  93. +7 −0 old/src/main/resources/static/scripts/main.js
  94. +192 −0 old/src/main/resources/templates/GET/index.vm
  95. +209 −0 old/src/main/resources/templates/GET/user.vm
  96. +1 −0  old/src/main/resources/templates/exp.vm
  97. +136 −0 old/src/test/java/it/unipr/aotlab/blogracy/web/resolvers/StaticFileResolverTest.java
  98. +70 −0 old/src/test/java/it/unipr/aotlab/blogracy/web/resolvers/StaticFileResolverTestCreationWithMapper.java
  99. +53 −0 ...est/java/it/unipr/aotlab/blogracy/web/resolvers/StaticFileResolverTestCreationWithMapperCapturingRegex.java
  100. +38 −0 old/src/test/java/it/unipr/aotlab/blogracy/web/resolvers/StaticFileResolverTestWrongMapperConf.java
  101. +209 −0 old/src/test/java/it/unipr/aotlab/blogracy/web/url/URLMapperTest.java
  102. +150 −0 old/src/test/java/it/unipr/aotlab/blogracy/web/url/URLMapperTestMixingParameters.java
  103. +121 −0 old/src/test/java/it/unipr/aotlab/blogracy/web/url/URLMapperTestStartingParameters.java
  104. +26 −0 old/src/test/resources/files/ExampleFile.java
View
5 README.md
@@ -52,7 +52,10 @@ Issue the following command:
./build.sh
```
-For more detailed information, read the instructions in the folder of each module.
+For more detailed information, read the instructions in the folder of each module:
+
+* [blogracy-vuze](tree/master/blogracy-vuze)
+* [blogracy-web](tree/master/blogracy-web)
## Authors ##
View
70 README.md~
@@ -0,0 +1,70 @@
+# Blogracy #
+
+## Introduction ##
+
+Blogracy is a simple peer-to-peer social networking system, built on top of Bittorrent.
+
+## Install ##
+
+The installation process is not yet streamlined. Essentially Blogracy is composed
+by two main modules:
+
+1. a Vuze plugin
+2. a web application
+
+The build system uses Maven. If you have a working maven
+installation things should be rather smooth.
+
+### Getting Blogracy ###
+
+The preferred way to obtain blogracy sources is with git. Blogracy main
+repository is hosted at git://github.com/rik0/blogracy.git. However,
+if you intend to contribute to blogracy, we strongly encourage you to make a
+fork and then pull request the modifications.
+
+#### Fork ####
+
+1. Create a fork through GitHub repository
+2. The fork repository will be at git@github.com:\<USERNAME\>/blogracy.git
+ where \<USERNAME\> is your actual username
+3. Clone the new git fork:
+
+```
+git clone git@github.com:<USERNAME>/blogracy.git
+```
+
+If you are using Eclipse, issue the command directly in the workspace or
+move the sources afterwards.
+
+#### Read-Only ####
+
+To get the sources "read only" simply:
+
+```
+git://github.com/rik0/blogracy.git
+```
+
+### Compile and Run ###
+
+Issue the following command:
+
+```
+./build.sh
+```
+
+For more detailed information, read the instructions in the folder of each module:
+
+* blogracy-vuze
+* blogracy-web
+
+## Authors ##
+
+The code of the present versions is mostly written by Enrico Franchi and Michele Tomaiuolo.
+
+The project is currently maintained by Enrico Franchi and Michele Tomaiuolo.
+
+## Contributors ##
+
+* Enrico Franchi (efranchi@ce.unipr.it) [ core ]
+* Michele Tomaiuolo (tomamic@ce.unipr.it) [ core ]
+* Alan Nonnato () [ old core ]
View
6 blogracy-vuze/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,6 @@
+#Mon May 21 09:46:15 CEST 2012
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.6
View
5 blogracy-vuze/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,5 @@
+#Mon May 21 09:46:10 CEST 2012
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
View
5 blogracy-vuze/README.md
@@ -15,9 +15,8 @@ This information regards the first module, the Vuze plugin.
Vuze is not packaged for Maven right now. This may change in the future.
Right now, it is necessary to:
-1. Download Vuze jar (and sources) from main Vuze site: http://dev.vuze.com/
- A link which is working at the present time is:
- http://sourceforge.net/projects/azureus/files/vuze/Vuze_4702/Vuze_4702.jar/download
+1. Download the latest AzureusXYZ.jar from main Vuze site: http://dev.vuze.com/
+ Rename the downloaded file to Azureus2.jar, as suggested on the Vuze site
2. In the same directory where the files have been downloaded, execute
the "mvn-install-vuze.sh" script.
View
99 blogracy-vuze/README.md~
@@ -0,0 +1,99 @@
+# Blogracy #
+
+## Introduction ##
+
+Blogracy is a simple peer-to-peer social networking system, built on top of Bittorrent.
+Essentially Blogracy is composed by two main modules:
+
+1. a Vuze plugin
+2. a web application
+
+This information regards the first module, the Vuze plugin.
+
+### Getting Vuze ###
+
+Vuze is not packaged for Maven right now. This may change in the future.
+Right now, it is necessary to:
+
+1. Download Vuze jar (and sources) from main Vuze site: http://dev.vuze.com/
+ A link which is working at the present time is:
+ http://sourceforge.net/projects/azureus/files/vuze/Vuze_4702/Vuze_4702.jar/download
+2. In the same directory where the files have been downloaded, execute
+ the "mvn-install-vuze.sh" script.
+
+### Compile ###
+
+To compile the sub-project, it is sufficient to issue
+
+```
+mvn compile
+```
+
+in the sub-project folder. This compiles all the Java sources.
+The classes, the resource files (those in src/resources) and the
+configuration files (in src/config) are copied in the "target" folder.
+
+The following command, instead, creates a JAR archive in the "target" folder,
+including Vuze classes and all other dependencies.
+
+```
+mvn package
+```
+
+### Maven and the IDE ###
+
+Maven pom files are simply a description of a project. Such description can
+be easily interpreted by an IDE and can be used to build the project.
+
+Suppose that Blogracy sources have been cloned to "~/src/blogracy/".
+The first step, in the "~/src/blogracy/blogracy-vuze/" folder, is just:
+
+```
+mvn eclipse:eclipse
+```
+
+that updates the eclipse project with stuff coming from maven.
+Repeat this step when something changes in the pom file.
+
+Then, start Eclipse using blogracy as workspace:
+
+```
+eclipse -data ~/src/blogracy/
+```
+
+In Eclipse, choose "Import Existing Maven Project" from the "File" menu,
+and indicate the "~/src/blogracy/blogracy-vuze/" folder.
+
+Feel free to read more documentation regarding integrating Eclipse with
+Maven. There is also an excellent plugin that can be installed in Eclipse.
+We however found that this first project setup phase is easier this way.
+
+With IntelliJ things mostly work out of the box.
+
+## Run ##
+
+Either run:
+
+```
+java -jar target/blogracy-vuze-1.0-SNAPSHOT-jar-with-dependencies.jar
+```
+
+or:
+
+```
+mvn exec:exec
+```
+
+We do not use GUI or SWT. Consequently we run the Vuze console version.
+We do not depend from STW, as a consequence.
+
+Alternatively, you can put the blogracy-vuze...jar file into the plugins folder
+of Vuze, and start Vuze normally. This way, you may also need to start ActiveMQ
+by hand, separately.
+
+### Executing Blogracy inside the IDE ###
+
+Use the information above to create the appropriate configuration in the IDE.
+The Blogracy class implements a static "main" method for starting ActiveMQ,
+Vuze and Blogracy-Vuze plugin.
+
View
2  blogracy-vuze/mvn-install-vuze.sh
@@ -1,2 +1,2 @@
#!/bin/bash
-mvn install:install-file -DgroupId=vuze -DartifactId=vuze -Dpackaging=jar -Dversion=4702 -DgeneratePom=true -Dfile=Vuze_4702.jar
+mvn install:install-file -DgroupId=vuze -DartifactId=azureus -Dpackaging=jar -Dversion=2 -DgeneratePom=true -Dfile=Azureus2.jar
View
2  blogracy-vuze/mvn-install-vuze.sh~
@@ -0,0 +1,2 @@
+#!/bin/bash
+mvn install:install-file -DgroupId=vuze -DartifactId=vuze -Dpackaging=jar -Dversion=2 -DgeneratePom=true -Dfile=Azureus2.jar
View
4 blogracy-vuze/pom.xml
@@ -91,8 +91,8 @@
</dependency-->
<dependency>
<groupId>vuze</groupId>
- <artifactId>vuze</artifactId>
- <version>4702</version>
+ <artifactId>azureus</artifactId>
+ <version>2</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
View
108 blogracy-vuze/pom.xml~
@@ -0,0 +1,108 @@
+<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>
+ <groupId>net.blogracy</groupId>
+ <artifactId>blogracy-vuze</artifactId>
+ <packaging>jar</packaging>
+ <version>1.0-SNAPSHOT</version>
+ <name>blogracy-vuze</name>
+ <url>http://maven.apache.org</url>
+
+ <build>
+ <resources>
+ <resource>
+ <directory>src/main/plugins</directory>
+ <targetPath>../plugins/</targetPath>
+ </resource>
+ <resource>
+ <directory>src/main/java/net/blogracy/chat/resources</directory>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.3.2</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>1.2.1</version>
+ <configuration>
+ <executable>java</executable>
+ <workingDirectory>target/</workingDirectory>
+ <arguments>
+ <argument>-Dazureus.config.path=.</argument>
+ <argument>-classpath</argument>
+ <classpath/>
+ <argument>net.blogracy.Blogracy</argument>
+ </arguments>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass>net.blogracy.Blogracy</mainClass>
+ </manifest>
+ </archive>
+ <descriptorRefs>
+ <descriptorRef>jar-with-dependencies</descriptorRef>
+ </descriptorRefs>
+ <includeProjectDependencies>true</includeProjectDependencies>
+ </configuration>
+ <executions>
+ <execution>
+ <id>make-assembly</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.9</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-cli</groupId>
+ <artifactId>commons-cli</artifactId>
+ <version>1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.6.4</version>
+ </dependency>
+ <!--dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <version>1.0.0</version>
+ </dependency-->
+ <dependency>
+ <groupId>vuze</groupId>
+ <artifactId>vuze</artifactId>
+ <version>4702</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-core</artifactId>
+ <version>5.5.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.json</groupId>
+ <artifactId>json</artifactId>
+ <version>20090211</version>
+ </dependency>
+ </dependencies>
+</project>
View
0  blogracy-vuze/src/main/plugins/blogracy/plugin.properties 100755 → 100644
File mode changed
View
6 blogracy-web/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,6 @@
+#Thu May 03 23:21:54 CEST 2012
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.6
View
5 blogracy-web/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,5 @@
+#Thu May 03 23:21:49 CEST 2012
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
View
2  blogracy-web/README.md
@@ -62,6 +62,8 @@ mvn jetty:run
Alternatively, you can deploy the webapp into any Java web container.
+Blogracy web interface is available at: htpp://localhost:8080
+
### Executing Blogracy inside the IDE ###
Use the information above to create the appropriate configuration in the IDE.
View
69 blogracy-web/README.md~
@@ -0,0 +1,69 @@
+# Blogracy #
+
+## Introduction ##
+
+Blogracy is a simple peer-to-peer social networking system, built on top of Bittorrent.
+Essentially Blogracy is composed by two main modules:
+
+1. a Vuze plugin
+2. a web application
+
+This information regards the second module, the Web application.
+
+### Compile ###
+
+To compile this sub-project, it is sufficient to issue
+
+```
+mvn compile
+```
+
+in the sub-project folder. This compiles all the Java sources.
+The classes, the resource files (those in src/resources) and the
+configuration files (in src/config) are copied in the "target" folder.
+
+### Maven and the IDE ###
+
+Maven pom files are simply a description of a project. Such description can
+be easily interpreted by an IDE and can be used to build the project.
+
+Suppose that Blogracy sources have been cloned to "~/src/blogracy/".
+The first step, in the "~/src/blogracy/blogracy-web/" folder, is just:
+
+```
+mvn eclipse:eclipse
+```
+
+that updates the eclipse project with stuff coming from maven.
+Repeat this step when something changes in the pom file.
+
+Then, start Eclipse using blogracy as workspace:
+
+```
+eclipse -data ~/src/blogracy/
+```
+
+In Eclipse, choose "Import Existing Maven Project" from the "File" menu,
+and indicate the "~/src/blogracy/blogracy-web/" folder.
+
+Feel free to read more documentation regarding integrating Eclipse with
+Maven. There is also an excellent plugin that can be installed in Eclipse.
+We however found that this first project setup phase is easier this way.
+
+With IntelliJ things mostly work out of the box.
+
+## Run ##
+
+Issue the following command:
+
+```
+mvn jetty:run
+```
+
+Alternatively, you can deploy the webapp into any Java web container.
+
+Blogracy web interface is available at: htpp://localhost:8080
+
+### Executing Blogracy inside the IDE ###
+
+Use the information above to create the appropriate configuration in the IDE.
View
0  build.sh 100755 → 100644
File mode changed
View
25 old/src/main/config/blogracyPaths.properties
@@ -0,0 +1,25 @@
+#
+# Copyright (c) 2012 Enrico Franchi, Michele Tomaiuolo and University of Parma.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+
+blogracy.paths.root = ${project.build.outputDirectory}
+blogracy.paths.templates = ${project.build.outputDirectory}/templates
+blogracy.paths.cached = ${project.build.outputDirectory}/cache
View
37 old/src/main/config/blogracyUrl.config
@@ -0,0 +1,37 @@
+[
+ {
+ "regexpString": "^/$",
+ "classString": "it.unipr.aotlab.blogracy.web.resolvers.MainResolver",
+ "startingParameters": []
+ },
+ {
+ "regexpString": "^/main$",
+ "classString": "it.unipr.aotlab.blogracy.web.resolvers.MainResolver",
+ "startingParameters": []
+ },
+ {
+ "regexpString": "^/user/([^/]*)$",
+ "classString": "it.unipr.aotlab.blogracy.web.resolvers.UserResolver",
+ "startingParameters": []
+ },
+ {
+ "regexpString": "^/magnet/([^/]*)$",
+ "classString": "it.unipr.aotlab.blogracy.web.resolvers.MagnetResolver",
+ "startingParameters": ["${project.build.outputDirectory}/cache"]
+ },
+ {
+ "regexpString": "^/messages$",
+ "classString": "it.unipr.aotlab.blogracy.web.resolvers.MessagesResolver",
+ "startingParameters": []
+ },
+ {
+ "regexpString": "^/css/(?:.*)$",
+ "classString": "it.unipr.aotlab.blogracy.web.resolvers.StaticFileResolver",
+ "startingParameters": ["${project.build.outputDirectory}/static"]
+ },
+ {
+ "regexpString": "^/scripts/(?:.*)$",
+ "classString": "it.unipr.aotlab.blogracy.web.resolvers.StaticFileResolver",
+ "startingParameters": ["${project.build.outputDirectory}/static"]
+ }
+]
View
27 old/src/main/config/blogracyUser.properties
@@ -0,0 +1,27 @@
+#
+# Copyright (c) 2012 Enrico Franchi, Michele Tomaiuolo and University of Parma.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+
+blogracy.user.user = W3W7TSICZWSCUK4R7C7HMQ633GRL6YPU mic
+blogracy.user.friends.1 = BLANNBXOHECW2MWHVN5AU5X4KCDDIQJZ rik0
+blogracy.user.friends.2 = QG3PKBZU2F6CZ7AWBT6AP3BRXG6NFKI6 uno
+blogracy.user.friends.3 = GDG7OPX7FJMWV74IYR2VMDPIHW5KPU2G due
+blogracy.user.friends.4 = CGVGVXDXGSBLYS4VX75S5E3S7PDDCBAZ tre
View
24 old/src/main/config/blogracyVuze.properties
@@ -0,0 +1,24 @@
+#
+# Copyright (c) 2012 Enrico Franchi, Michele Tomaiuolo and University of Parma.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+
+blogracy.vuze.port = 32674
+blogracy.vuze.broker = tcp://localhost:61616
View
797 old/src/main/java/it/unipr/aotlab/blogracy/Blogracy.java
@@ -0,0 +1,797 @@
+/*
+ * Copyright (c) 2011 Enrico Franchi, Michele Tomaiuolo and University of Parma.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package it.unipr.aotlab.blogracy;
+
+import it.unipr.aotlab.blogracy.config.Configurations;
+import it.unipr.aotlab.blogracy.errors.ServerConfigurationError;
+import it.unipr.aotlab.blogracy.errors.URLMappingError;
+import it.unipr.aotlab.blogracy.logging.Logger;
+import it.unipr.aotlab.blogracy.model.hashes.Hashes;
+import it.unipr.aotlab.blogracy.model.users.User;
+import it.unipr.aotlab.blogracy.services.DownloadService;
+import it.unipr.aotlab.blogracy.services.LookupService;
+import it.unipr.aotlab.blogracy.services.SeedService;
+import it.unipr.aotlab.blogracy.services.StoreService;
+import it.unipr.aotlab.blogracy.util.FileUtils;
+import it.unipr.aotlab.blogracy.web.misc.HttpResponseCode;
+import it.unipr.aotlab.blogracy.web.resolvers.ErrorPageResolver;
+import it.unipr.aotlab.blogracy.web.resolvers.RequestResolver;
+import it.unipr.aotlab.blogracy.web.url.URLMapper;
+
+import org.apache.activemq.ActiveMQConnection;
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.broker.BrokerService;
+import org.apache.log4j.BasicConfigurator;
+import org.apache.log4j.Level;
+import org.apache.velocity.app.Velocity;
+import org.apache.velocity.runtime.RuntimeServices;
+import org.apache.velocity.runtime.log.LogChute;
+import org.gudy.azureus2.core3.config.COConfigurationManager;
+import org.gudy.azureus2.core3.config.impl.ConfigurationDefaults;
+import org.gudy.azureus2.plugins.PluginException;
+import org.gudy.azureus2.plugins.PluginInterface;
+import org.gudy.azureus2.plugins.ddb.DistributedDatabase;
+import org.gudy.azureus2.plugins.ddb.DistributedDatabaseEvent;
+import org.gudy.azureus2.plugins.ddb.DistributedDatabaseException;
+import org.gudy.azureus2.plugins.ddb.DistributedDatabaseKey;
+import org.gudy.azureus2.plugins.ddb.DistributedDatabaseListener;
+import org.gudy.azureus2.plugins.ddb.DistributedDatabaseValue;
+import org.gudy.azureus2.plugins.download.Download;
+import org.gudy.azureus2.plugins.download.DownloadCompletionListener;
+import org.gudy.azureus2.plugins.download.DownloadException;
+import org.gudy.azureus2.plugins.torrent.Torrent;
+import org.gudy.azureus2.plugins.torrent.TorrentException;
+import org.gudy.azureus2.plugins.tracker.web.TrackerWebPageRequest;
+import org.gudy.azureus2.plugins.tracker.web.TrackerWebPageResponse;
+import org.gudy.azureus2.plugins.ui.config.ConfigSection;
+import org.gudy.azureus2.plugins.ui.config.HyperlinkParameter;
+import org.gudy.azureus2.plugins.ui.model.BasicPluginConfigModel;
+import org.gudy.azureus2.plugins.utils.resourcedownloader.ResourceDownloader;
+import org.gudy.azureus2.plugins.utils.resourcedownloader.ResourceDownloaderException;
+import org.gudy.azureus2.ui.webplugin.WebPlugin;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.nio.channels.FileChannel;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Properties;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.DeliveryMode;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+import org.gudy.azureus2.core3.util.SHA1Hasher;
+import org.gudy.azureus2.core3.util.Base32;
+
+import com.sun.syndication.feed.synd.SyndContent;
+import com.sun.syndication.feed.synd.SyndContentImpl;
+import com.sun.syndication.feed.synd.SyndEnclosure;
+import com.sun.syndication.feed.synd.SyndEnclosureImpl;
+import com.sun.syndication.feed.synd.SyndEntry;
+import com.sun.syndication.feed.synd.SyndEntryImpl;
+import com.sun.syndication.feed.synd.SyndFeed;
+import com.sun.syndication.feed.synd.SyndFeedImpl;
+import com.sun.syndication.feed.synd.SyndLink;
+import com.sun.syndication.feed.synd.SyndLinkImpl;
+import com.sun.syndication.io.FeedException;
+import com.sun.syndication.io.SyndFeedInput;
+import com.sun.syndication.io.SyndFeedOutput;
+import com.sun.syndication.io.XmlReader;
+
+
+public class Blogracy extends WebPlugin {
+
+ private BrokerService broker;
+ private ConnectionFactory connectionFactory;
+ private Connection connection;
+
+ private Session lookupSession;
+ private Destination lookupQueue;
+ private MessageProducer lookupProducer;
+ private MessageConsumer lookupConsumer;
+
+ private Session downloadSession;
+ private Destination downloadQueue;
+ private MessageProducer downloadProducer;
+ private MessageConsumer downloadConsumer;
+
+ private URLMapper mapper = new URLMapper();
+
+ private HyperlinkParameter testParam;
+ static private Blogracy singleton;
+
+ static private final String URL_CONFIG_NAME = "blogracyUrl.config";
+
+ static class Accesses {
+ static String ALL = "all";
+ static String LOCAL = "local";
+
+ static String wantsLocal(boolean local) {
+ return local ? Accesses.LOCAL : Accesses.ALL;
+ }
+ }
+
+ static private PluginInterface plugin;
+
+ // Misc Keys
+ private static final String MESSAGES_BLOGRACY_URL_KEY = "blogracy.url";
+
+ // blogracy.internal. keys
+ private static final String INTERNAL_CONFIG_ACCESS_KEY = "blogracy.internal.config.access";
+ private static final String INTERNAL_CONFIG_PORT_KEY = "blogracy.internal.config.port";
+ private static final String INTERNAL_TEST_URL_KEY = "blogracy.internal.test.url";
+ private static final String INTERNAL_MIGRATED_KEY = "blogracy.internal.migrated";
+
+ // blogracy default keys
+ private static final String PLUGIN_DEFAULT_DEVICE_BLOGRACY_PORT = "Plugin.default.device.blogracy.port";
+ private static final String PLUGIN_DEFAULT_DEVICE_BLOGRACY_LOCALONLY = "Plugin.default.device.blogracy.localonly";
+ private static final String PLUGIN_DEFAULT_DEVICE_BLOGRACY_ENABLE = "Plugin.default.device.blogracy.enable";
+
+ private static Properties defaults = new Properties();
+
+ public static final String DSNS_PLUGIN_CHANNEL_NAME = "DSNS";
+
+ //final static int DEFAULT_PORT = 32674;
+ final static String DEFAULT_ACCESS = Accesses.ALL;
+
+ private static boolean loaded;
+
+
+ static {
+ ConfigurationDefaults cd = ConfigurationDefaults.getInstance();
+ cd.addParameter(INTERNAL_MIGRATED_KEY, Boolean.TRUE);
+ cd.addParameter(PLUGIN_DEFAULT_DEVICE_BLOGRACY_LOCALONLY, Boolean.TRUE);
+ cd.addParameter(PLUGIN_DEFAULT_DEVICE_BLOGRACY_ENABLE, Boolean.TRUE);
+ }
+
+ public static Blogracy getSingleton() {
+ return (singleton);
+ }
+
+ @Override
+ protected void initStage(int num) {
+ if (num == 1) {
+ BasicPluginConfigModel config = getConfigModel();
+ testParam = config.addHyperlinkParameter2(INTERNAL_TEST_URL_KEY, "");
+ testParam.setEnabled(isPluginEnabled());
+ testParam.setLabelKey(MESSAGES_BLOGRACY_URL_KEY);
+ }
+ }
+
+ /**
+ * This method is effectively called when a new instance of this plugin
+ * should be created.
+ * <p/>
+ * We found this feature not documented. Perhaps we should not rely
+ * on that. We also ensure that Blogracy is a singleton.
+ *
+ * @param pluginInterface is the same old access point for plugins
+ */
+ public static void load(PluginInterface pluginInterface) {
+
+ if (singletonShouldReturnImmediately()) return;
+ File rootDir = createRootDirectoryIfMissingAndGetPath();
+
+ if (COConfigurationManager.getBooleanParameter(INTERNAL_MIGRATED_KEY)) {
+ configureIfMigratedKey(rootDir);
+ } else {
+ configureIfNotMigrateKey(rootDir);
+ }
+
+
+ }
+
+ private static void configureIfNotMigrateKey(final File rootDir) {
+ final int DEFAULT_PORT = Configurations.getVuzeConfig().getPort();
+ final Integer blogracyPort = COConfigurationManager.getIntParameter(
+ PLUGIN_DEFAULT_DEVICE_BLOGRACY_PORT,
+ DEFAULT_PORT
+ );
+ if (blogracyPort != DEFAULT_PORT) {
+ COConfigurationManager.setParameter(
+ INTERNAL_CONFIG_PORT_KEY,
+ blogracyPort
+ );
+ }
+
+ boolean local = COConfigurationManager.getBooleanParameter(
+ PLUGIN_DEFAULT_DEVICE_BLOGRACY_LOCALONLY
+ );
+ final String blogracyAccess = Accesses.wantsLocal(local);
+ if (!blogracyAccess.equals(DEFAULT_ACCESS)) {
+ COConfigurationManager.setParameter(
+ INTERNAL_CONFIG_ACCESS_KEY,
+ blogracyAccess
+ );
+ }
+ COConfigurationManager.setParameter(
+ INTERNAL_MIGRATED_KEY,
+ Boolean.TRUE
+ );
+
+ final boolean blogracyEnable =
+ COConfigurationManager.getBooleanParameter(
+ PLUGIN_DEFAULT_DEVICE_BLOGRACY_ENABLE
+ );
+ setDefaultsProperties(
+ blogracyPort,
+ blogracyAccess,
+ rootDir,
+ blogracyEnable
+ );
+ }
+
+ private static void configureIfMigratedKey(final File root_dir) {
+ final int DEFAULT_PORT = Configurations.getVuzeConfig().getPort();
+ final Integer blogracy_port = COConfigurationManager.getIntParameter(
+ INTERNAL_CONFIG_PORT_KEY,
+ DEFAULT_PORT
+ );
+ final String blogracy_access =
+ COConfigurationManager.getStringParameter(
+ INTERNAL_CONFIG_ACCESS_KEY,
+ DEFAULT_ACCESS
+ );
+ final boolean blogracyEnable =
+ COConfigurationManager.getBooleanParameter(
+ PLUGIN_DEFAULT_DEVICE_BLOGRACY_ENABLE
+ );
+ setDefaultsProperties(
+ blogracy_port,
+ blogracy_access,
+ root_dir,
+ blogracyEnable
+ );
+ }
+
+ private static boolean singletonShouldReturnImmediately() {
+ synchronized (Blogracy.class) {
+ if (loaded) {
+ return true;
+ } else {
+ loaded = true;
+ }
+ }
+ return false;
+ }
+
+ private static void setDefaultsProperties(
+ final Integer blogracyPort,
+ final String blogracyAccess,
+ final File rootDir,
+ final boolean blogracyEnable) {
+ defaults.put(WebPlugin.PR_ENABLE, blogracyEnable);
+ defaults.put(WebPlugin.PR_DISABLABLE, Boolean.TRUE);
+ defaults.put(WebPlugin.PR_PORT, blogracyPort);
+ defaults.put(WebPlugin.PR_ACCESS, blogracyAccess);
+ defaults.put(WebPlugin.PR_ROOT_DIR, rootDir.getAbsolutePath());
+ defaults.put(WebPlugin.PR_ENABLE_KEEP_ALIVE, Boolean.TRUE);
+ defaults.put(WebPlugin.PR_HIDE_RESOURCE_CONFIG, Boolean.TRUE);
+ defaults.put(WebPlugin.PR_PAIRING_SID, Configurations.BLOGRACY);
+
+ defaults.put(WebPlugin.PR_CONFIG_MODEL_PARAMS,
+ new String[]{
+ ConfigSection.SECTION_ROOT,
+ Configurations.BLOGRACY
+ }
+ );
+ }
+
+ private static File createRootDirectoryIfMissingAndGetPath() {
+ File root_dir = new File(
+ Configurations.getPathConfig()
+ .getRootDirectoryPath()
+ );
+ return createDirIfMissing(root_dir);
+ }
+
+ private static File createDirIfMissing(File dir) {
+ if (!dir.exists()) {
+ boolean createdDir = dir.mkdir();
+ assert (createdDir);
+ }
+ return dir;
+ }
+
+ public Blogracy() {
+ super(defaults);
+ }
+
+ public String getURL() {
+ return (getProtocol() + "://127.0.0.1:" + getPort() + "/");
+ }
+
+
+ @Override
+ public boolean generateSupport(
+ TrackerWebPageRequest request,
+ TrackerWebPageResponse response)
+ throws IOException {
+ String url = request.getURL();
+ try {
+ final RequestResolver resolver = mapper.getResolver(url);
+ resolver.resolve(request, response);
+ } catch (URLMappingError urlMappingError) {
+ final ErrorPageResolver errorPageResolver = new ErrorPageResolver(
+ urlMappingError
+ );
+ Logger.error(urlMappingError.getMessage());
+ // urlMappingError.printStackTrace();
+ errorPageResolver.resolve(request, response);
+ } catch (ServerConfigurationError serverConfigurationError) {
+ final ErrorPageResolver errorPageResolver = new ErrorPageResolver(
+ serverConfigurationError,
+ HttpResponseCode.HTTP_INTERNAL_ERROR
+ );
+ Logger.error(serverConfigurationError.getMessage());
+ serverConfigurationError.printStackTrace();
+ errorPageResolver.resolve(request, response);
+ } catch (RuntimeException genericException) {
+ final ErrorPageResolver errorPageResolver = new ErrorPageResolver(
+ genericException,
+ HttpResponseCode.HTTP_INTERNAL_ERROR
+ );
+ Logger.error(genericException.getMessage());
+ genericException.printStackTrace();
+ try {
+ errorPageResolver.resolve(request, response);
+ } catch (RuntimeException e) {
+ e.printStackTrace();
+ throw e;
+ }
+ }
+ return true;
+ }
+
+
+ @Override
+ protected void
+ setupServer() {
+ super.setupServer();
+
+ if (testParam != null) {
+ testParam.setEnabled(isPluginEnabled());
+ testParam.setHyperlink(getURL());
+ }
+ }
+
+ @Override
+ protected boolean
+ isPluginEnabled() {
+ return true;
+ }
+
+ @Override
+ public void initialize(PluginInterface pluginInterface)
+ throws PluginException {
+ initializePluginInterface(pluginInterface);
+ initializeLogger();
+ initializeURLMapper();
+ initVelocity();
+ initializeSingleton();
+ createQueues();
+ super.initialize(pluginInterface);
+ }
+
+ private void initVelocity() {
+ Properties velocityProperties = new Properties();
+ // TODO: here we are not using the deployed files!
+ velocityProperties.setProperty(
+ Velocity.FILE_RESOURCE_LOADER_PATH,
+ Configurations.getPathConfig().getTemplatesDirectoryPath()
+ );
+ Velocity.setProperty(Velocity.FILE_RESOURCE_LOADER_CACHE, false);
+ Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM, new LogChute() {
+ @Override
+ public void init(final RuntimeServices rs) throws Exception {
+ // do nothing
+ }
+
+ @Override
+ public void log(final int level, final String message) {
+ switch (level) {
+ case DEBUG_ID:
+ case TRACE_ID:
+ case INFO_ID:
+ Logger.info(message);
+ break;
+ case WARN_ID:
+ Logger.warn(message);
+ break;
+ case ERROR_ID:
+ Logger.error(message);
+ break;
+ }
+ }
+
+ @Override
+ public void log(
+ final int level,
+ final String message,
+ final Throwable t) {
+ final String fullMessage = message + t.getMessage();
+ log(level, message);
+ }
+
+ @Override
+ public boolean isLevelEnabled(final int level) {
+ return true;
+ }
+ });
+ Velocity.init(velocityProperties);
+ }
+
+ private void initializeSingleton() {
+ singleton = this;
+ }
+
+ private void initializePluginInterface(
+ final PluginInterface pluginInterface) {
+ plugin = pluginInterface;
+ }
+
+ private void initializeLogger() {
+ Logger.initialize(plugin, DSNS_PLUGIN_CHANNEL_NAME);
+ }
+
+ private void initializeURLMapper() throws PluginException {
+ try {
+ ClassLoader classLoader = ClassLoader.getSystemClassLoader();
+ mapper.configure(
+ new InputStreamReader(
+ classLoader.getResourceAsStream(URL_CONFIG_NAME)
+ )
+ );
+ } catch (ServerConfigurationError serverConfigurationError) {
+ throw new PluginException(serverConfigurationError);
+ }
+ }
+
+ // TODO: probably to move to Network and implementing classes
+ public Download addDownload(final String fileHash,
+ final String downloadDirectory,
+ final String fileName) {
+ Download download = null;
+ try {
+ URL magnetURI = new URL("magnet:?xt=urn:btih:" + fileHash);
+ download = addDownload(magnetURI, downloadDirectory, fileName);
+ } catch (MalformedURLException e1) {
+ Logger.error("Error generating MagnetURI for: " + fileHash);
+ }
+ return download;
+ }
+
+ // TODO: probably to move to Network and implementing classes
+ public Download addDownload(final URL magnetURI,
+ final String downloadDirectory,
+ final String fileName) {
+ // add magnet-uri to download manager
+ Download download = null;
+ try {
+ ResourceDownloader rdl =
+ plugin.getUtilities()
+ .getResourceDownloaderFactory().create(magnetURI);
+ InputStream is = rdl.download();
+ Torrent torrent =
+ plugin.getTorrentManager()
+ .createFromBEncodedInputStream(is);
+ download = plugin.getDownloadManager().addDownload(
+ torrent,
+ null,
+ new File(downloadDirectory)
+ );
+ if (download != null && fileName != null) download.renameDownload(fileName);
+ Logger.info(magnetURI + " added to download list");
+ } catch (ResourceDownloaderException e1) {
+ Logger.error("Resource download exception for: " + magnetURI);
+ } catch (TorrentException e1) {
+ Logger.error("Torrent exception for: " + magnetURI);
+ } catch (DownloadException e1) {
+ Logger.error("Download exception for: " + magnetURI);
+ }
+ return download;
+ }
+
+ // TODO: unused, remove?
+ static String getHashFromMagnetURI(String uri) {
+ String hash = null;
+ int btih = uri.indexOf("xt=urn:btih:");
+ if (btih >= 0) {
+ hash = uri.substring(btih + "xt=urn:btih:".length());
+ int amp = hash.indexOf('&');
+ if (amp >= 0) hash = hash.substring(0, amp);
+ }
+ return hash;
+ }
+
+ public static boolean checkNewFeed(File newFile, File oldFile) {
+ boolean newer = true;
+ if (oldFile.exists() && oldFile.getName().endsWith(".rss")) {
+ SyndFeed oldFeed = null;
+ SyndFeed newFeed = null;
+ try {
+ oldFeed = new SyndFeedInput().build(new XmlReader(oldFile));
+ newFeed = new SyndFeedInput().build(new XmlReader(newFile));
+ } catch (IllegalArgumentException e) {
+ e.printStackTrace();
+ } catch (FeedException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ if (newFeed != null || newFeed.getEntries().size() > 0) {
+ if (oldFeed != null && oldFeed.getEntries().size() > 0) {
+ SyndEntry newEntry = (SyndEntry) newFeed.getEntries().get(0);
+ SyndEntry oldEntry = (SyndEntry) oldFeed.getEntries().get(0);
+ if (oldEntry.getPublishedDate().getTime() > newEntry.getPublishedDate().getTime()) {
+ newer = false;
+ }
+ }
+ if (newer) {
+ // verifySignature(newFeed);
+ }
+ } else {
+ newer = false;
+ }
+ }
+ return newer;
+ }
+
+ // TODO: probably to move to Network and implementing classes
+ public void addIndirectDownload(final String key,
+ final String downloadDirectory,
+ final String fileName) {
+ final long TIMEOUT = 5 * 60 * 1000; // 5 mins
+ DistributedDatabase ddb = plugin.getDistributedDatabase();
+ try {
+ ddb.read(
+ new DistributedDatabaseListener() {
+ public void event(DistributedDatabaseEvent event) {
+ final int type = event.getType();
+ System.out.println("re!" + type + ' ' + key);
+ if (type == DistributedDatabaseEvent.ET_OPERATION_COMPLETE) {
+ // ...
+ } else if (type == DistributedDatabaseEvent.ET_OPERATION_TIMEOUT) {
+ // ...
+ } else if (type == DistributedDatabaseEvent.ET_VALUE_READ) {
+ try {
+ String value = (String) event.getValue().getValue(String.class);
+ System.out.println("db!" + value + ' ' + fileName);
+ URL magnetURI = new URL(value);
+ Download download = addDownload(magnetURI, downloadDirectory, null);
+ if (download != null) {
+ download.addCompletionListener(new DownloadCompletionListener() {
+ @Override
+ public void onCompletion(Download download) {
+ File newFile = new File(download.getSavePath() /*+ File.separator + download.getName()*/);
+ File oldFile = new File(downloadDirectory + File.separator + fileName);
+ System.out.println("dl!" + newFile.getAbsolutePath() + ' ' + oldFile.getAbsolutePath());
+ if (checkNewFeed(newFile, oldFile)) {
+ FileUtils.copyFile(newFile, oldFile);
+ }
+ }
+ });
+ }
+ } catch (MalformedURLException e1) {
+ Logger.error("Error retrieving a value " +
+ "from the DDB: " + key);
+ } catch (DistributedDatabaseException e) {
+ Logger.error("Error retrieving a value " +
+ "from the DDB: " + key);
+ }
+ }
+ }
+ },
+ ddb.createKey(key),
+ TIMEOUT,
+ DistributedDatabase.OP_EXHAUSTIVE_READ
+ );
+ } catch (DistributedDatabaseException e) {
+ Logger.error("Problem reading from the DDB");
+ }
+ }
+
+ public URL shareFile(File file) {
+ URL torrentMagnetURI = null;
+ try {
+ File folder = new File(Configurations.getPathConfig().getCachedFilesDirectoryPath());
+ // the announce-url should not be needed...
+ Torrent torrent = plugin.getTorrentManager().createFromDataFile(
+ file,
+ new URL("udp://tracker.openbittorrent.com:80")
+ );
+ torrent.setComplete(folder);
+ //File torrentFile = new File(file.getAbsolutePath() + ".torrent");
+ //if (torrentFile.exists()) torrentFile.delete();
+ //torrent.writeToFile(torrentFile);
+
+ torrentMagnetURI = torrent.getMagnetURI();
+
+ String name = getHashFromMagnetURI(torrentMagnetURI.toString());
+ int index = file.getName().lastIndexOf('.');
+ if (0 < index && index <= file.getName().length() - 2 ) {
+ name = name + file.getName().substring(index);
+ }
+
+ Download download = plugin.getDownloadManager().addDownload(
+ torrent,
+ null, //torrentFile,
+ folder
+ );
+ if (download != null) download.renameDownload(name);
+
+ System.out.println("file: " + file.getName() + " name: " + name
+ + " uri: " + getHashFromMagnetURI(torrentMagnetURI.toString()));
+
+ } catch (MalformedURLException e) {
+ Logger.error("MalformedURL Exception while sharing file " + file.getName());
+ } catch (TorrentException e) {
+ Logger.error("Torrent Exception while sharing file " + file.getName());
+ e.printStackTrace();
+ } catch (DownloadException e) {
+ Logger.error("Download Exception while sharing file " + file.getName());
+ e.printStackTrace();
+ }
+ return torrentMagnetURI;
+ }
+
+ public URL shareMessage(String message) {
+ URL torrentMagnetURI = null;
+ try {
+ String folder = Configurations.getPathConfig().getCachedFilesDirectoryPath();
+ String hash = Hashes.newHash(message).getPrintableValue();
+ String fullFileName = folder + File.separator + hash + ".txt";
+
+ java.io.FileWriter w = new java.io.FileWriter(fullFileName);
+ w.write(message);
+ w.close();
+
+ torrentMagnetURI = shareFile(new File(fullFileName));
+ //updateFeed(user, magnetUri, message);
+ } catch (IOException e) {
+ Logger.error("IO Exception while sharing a message");
+ e.printStackTrace();
+ }
+ return torrentMagnetURI;
+ }
+
+ public SyndFeed getFeed(User user) {
+ System.out.println("Getting feed: " + user.getHash().getPrintableValue());
+ SyndFeed feed = null;
+ try {
+ String folder = Configurations.getPathConfig().getCachedFilesDirectoryPath();
+ File feedFile = new File(folder + File.separator + user.getHash().getPrintableValue() + ".rss");
+ feed = new SyndFeedInput().build(new XmlReader(feedFile));
+ System.out.println("Feed loaded");
+ } catch (Exception e) {
+ feed = new SyndFeedImpl();
+ feed.setFeedType("rss_2.0");
+ feed.setTitle(user.getHash().getPrintableValue());
+ feed.setLink("http://www.blogracy.net");
+ feed.setDescription("This feed has been created using ROME (Java syndication utilities");
+ feed.setEntries(new ArrayList());
+ System.out.println("Feed created");
+ }
+ return feed;
+ }
+
+ public void addFeedEntry(User user, URL uri, String text, URL attachment) {
+ try {
+ SyndFeed feed = getFeed(user);
+
+ SyndEntry entry = new SyndEntryImpl();
+ entry.setTitle("No Title");
+ entry.setLink(uri.toString());
+ entry.setPublishedDate(new Date());
+ SyndContent description = new SyndContentImpl();
+ description.setType("text/plain");
+ description.setValue(text);
+ entry.setDescription(description);
+ entry.setLink(uri.toString());
+ /*
+ SyndLink link = new SyndLinkImpl();
+ link.setHref(uri.toString());
+ link.setTitle(uri.toString());
+ ArrayList links = new ArrayList();
+ links.add(link);
+ entry.setLinks(links);
+ */
+ if (attachment != null) {
+ SyndEnclosure enclosure = new SyndEnclosureImpl();
+ enclosure.setUrl(attachment.toString());
+ ArrayList enclosures = new ArrayList();
+ enclosures.add(enclosure);
+ entry.setEnclosures(enclosures);
+ }
+
+ feed.getEntries().add(0, entry);
+ String folder = Configurations.getPathConfig().getCachedFilesDirectoryPath();
+ File feedFile = new File(folder + File.separator + user.getHash().getPrintableValue() + ".rss");
+ new SyndFeedOutput().output(feed, new PrintWriter(feedFile));
+ // TODO: sign feedFile
+
+ URL feedUri = shareFile(feedFile);
+
+ // create a copy of latest feed, named after its author
+ new SyndFeedOutput().output(feed, new PrintWriter(feedFile));
+
+ DistributedDatabase ddb = plugin.getDistributedDatabase();
+ DistributedDatabaseKey key = ddb.createKey(user.getHash().getPrintableValue());
+ DistributedDatabaseValue value = ddb.createValue(feedUri.toString());
+ System.out.println("kv!" + key.getKey() + ' ' + value.getValue(String.class));
+
+ ddb.write(new DistributedDatabaseListener() {
+ @Override
+ public void event(DistributedDatabaseEvent event) {
+ System.out.println("we!" + event);
+ }
+ }, key, new DistributedDatabaseValue[] {value});
+ } catch (Exception e) { e.printStackTrace(); }
+ }
+
+ void createQueues() {
+ BasicConfigurator.configure();
+ org.apache.log4j.Logger.getLogger("org.apache").setLevel(Level.INFO);
+
+ final PluginInterface plugin = this.plugin;
+ final boolean TRANSACTED = false;
+ String brokerUrl = Configurations.getVuzeConfig().getBroker();
+ if (brokerUrl == null) brokerUrl = ActiveMQConnection.DEFAULT_BROKER_URL;
+ try {
+ connectionFactory = new ActiveMQConnectionFactory(brokerUrl);
+ connection = connectionFactory.createConnection();
+ connection.start();
+
+ new StoreService(connection, plugin);
+ new LookupService(connection, plugin);
+
+ new SeedService(connection, plugin);
+ new DownloadService(connection, plugin);
+
+ //Destination download = session.createQueue("download");
+ //Destination seed = session.createQueue("seed");
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+}
+
View
164 old/src/main/java/it/unipr/aotlab/blogracy/config/Configurations.java
@@ -0,0 +1,164 @@
+/*
+ * Copyright (c) 2012 Enrico Franchi, Michele Tomaiuolo and University of Parma.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+package it.unipr.aotlab.blogracy.config;
+
+import it.unipr.aotlab.blogracy.model.hashes.Hashes;
+import it.unipr.aotlab.blogracy.model.users.User;
+import it.unipr.aotlab.blogracy.model.users.Users;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+/**
+ * User: enrico
+ * Package: it.unipr.aotlab.blogracy.config
+ * Date: 1/24/12
+ * Time: 11:37 AM
+ */
+public class Configurations {
+
+ public static final String BLOGRACY = "blogracy";
+ private static final String PATHS_FILE = "blogracyPaths.properties";
+ private static final String BLOGRACY_PATHS_STATIC = "blogracy.paths.static";
+ private static final String BLOGRACY_PATHS_CACHED = "blogracy.paths.cached";
+ private static final String BLOGRACY_PATHS_TEMPLATES = "blogracy.paths.templates";
+ private static final String BLOGRACY_PATHS_ROOT = "blogracy.paths.root";
+ private static final String VUZE_FILE = "blogracyVuze.properties";
+ private static final String BLOGRACY_VUZE_PORT = "blogracy.vuze.port";
+ private static final String BLOGRACY_VUZE_BROKER = "blogracy.vuze.broker";
+ private static final String USER_FILE = "blogracyUser.properties";
+ private static final String BLOGRACY_USER_USER = "blogracy.user.user";
+ private static final String BLOGRACY_USER_FRIENDS = "blogracy.user.friends";
+
+ static private Properties loadProperties(String file) throws IOException {
+ ClassLoader loader = ClassLoader.getSystemClassLoader();
+ InputStream is = loader.getResourceAsStream(file);
+
+ if (is != null) {
+ Properties properties = new Properties();
+ properties.load(is);
+ return properties;
+ } else {
+ return new Properties();
+ }
+ }
+
+ static public PathConfig getPathConfig() {
+ try {
+
+ return new PathConfig() {
+ // TODO: this should absolutely come from the outside!
+ Properties pathProperties = loadProperties(PATHS_FILE);
+
+ @Override
+ public String getStaticFilesDirectoryPath() {
+ return pathProperties.getProperty(BLOGRACY_PATHS_STATIC);
+ }
+
+ @Override
+ public String getCachedFilesDirectoryPath() {
+ return pathProperties.getProperty(BLOGRACY_PATHS_CACHED);
+ }
+
+ @Override
+ public String getTemplatesDirectoryPath() {
+ return pathProperties.getProperty(BLOGRACY_PATHS_TEMPLATES);
+ }
+
+ @Override
+ public String getRootDirectoryPath() {
+ return pathProperties.getProperty(BLOGRACY_PATHS_ROOT);
+ }
+ };
+ } catch (IOException e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ static public VuzeConfig getVuzeConfig() {
+ try {
+ return new VuzeConfig() {
+ // TODO: this should absolutely come from the outside!
+ Properties userProperties = loadProperties(VUZE_FILE);
+
+ @Override
+ public int getPort() {
+ String port = userProperties.getProperty(BLOGRACY_VUZE_PORT);
+ return Integer.parseInt(port);
+ }
+
+ @Override
+ public String getBroker() {
+ String broker = userProperties.getProperty(BLOGRACY_VUZE_BROKER);
+ return broker;
+ }
+ };
+ } catch (IOException e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ static public UserConfig getUserConfig() {
+ try {
+ return new UserConfig() {
+ // TODO: this should absolutely come from the outside!
+ Properties userProperties = loadProperties(USER_FILE);
+
+ @Override
+ public User getUser() {
+ String userRow = userProperties.getProperty(BLOGRACY_USER_USER);
+ return loadUser(userRow);
+ }
+
+ @Override
+ public List<User> getFriends() {
+ ArrayList<User> friends = new ArrayList<User>();
+ int i = 1;
+ String friendRow = userProperties.getProperty(BLOGRACY_USER_FRIENDS + '.' + i);
+ while (friendRow != null) {
+ friends.add(loadUser(friendRow));
+ ++i;
+ friendRow = userProperties.getProperty(BLOGRACY_USER_FRIENDS + '.' + i);
+ }
+ return friends;
+ }
+
+ private User loadUser(String text) {
+ String[] hashAndNick = text.split(" ", 2);
+ User user = Users.newUser(Hashes.fromString(hashAndNick[0]));
+ if (hashAndNick.length == 2) user.setLocalNick(hashAndNick[1]);
+ else user.setLocalNick(hashAndNick[0]);
+ return user;
+ }
+ };
+ } catch (IOException e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+}
View
36 old/src/main/java/it/unipr/aotlab/blogracy/config/PathConfig.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2012 Enrico Franchi, Michele Tomaiuolo and University of Parma.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+package it.unipr.aotlab.blogracy.config;
+
+/**
+ * User: enrico
+ * Package: it.unipr.aotlab.blogracy.config
+ * Date: 1/30/12
+ * Time: 11:31 AM
+ */
+public interface PathConfig {
+ public String getStaticFilesDirectoryPath();
+ public String getCachedFilesDirectoryPath();
+ public String getTemplatesDirectoryPath();
+ public String getRootDirectoryPath();
+}
View
38 old/src/main/java/it/unipr/aotlab/blogracy/config/UserConfig.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2012 Enrico Franchi, Michele Tomaiuolo and University of Parma.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+package it.unipr.aotlab.blogracy.config;
+
+import java.util.List;
+
+import it.unipr.aotlab.blogracy.model.users.User;
+
+/**
+ * User: enrico
+ * Package: it.unipr.aotlab.blogracy.config
+ * Date: 1/30/12
+ * Time: 11:31 AM
+ */
+public interface UserConfig {
+ public User getUser();
+ public List<User> getFriends();
+}
View
34 old/src/main/java/it/unipr/aotlab/blogracy/config/VuzeConfig.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2012 Enrico Franchi, Michele Tomaiuolo and University of Parma.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+package it.unipr.aotlab.blogracy.config;
+
+/**
+ * User: enrico
+ * Package: it.unipr.aotlab.blogracy.config
+ * Date: 1/30/12
+ * Time: 11:31 AM
+ */
+public interface VuzeConfig {
+ public int getPort();
+ public String getBroker();
+}
View
16 old/src/main/java/it/unipr/aotlab/blogracy/controller/Controller.java
@@ -0,0 +1,16 @@
+package it.unipr.aotlab.blogracy.controller;
+
+import it.unipr.aotlab.blogracy.model.messages.Message;
+import it.unipr.aotlab.blogracy.model.users.User;
+
+/**
+ * User: enrico
+ * Package: it.unipr.aotlab.blogracy.controller
+ * Date: 10/27/11
+ * Time: 1:32 PM
+ */
+public interface Controller {
+ void sendMessage(Message m);
+ boolean follow(User u);
+ boolean unfollow(User u);
+}
View
40 old/src/main/java/it/unipr/aotlab/blogracy/errors/BlogracyError.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2011 Enrico Franchi and University of Parma.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+package it.unipr.aotlab.blogracy.errors;
+
+public class BlogracyError extends Exception {
+ public BlogracyError() {
+ }
+
+ public BlogracyError(String s) {
+ super(s);
+ }
+
+ public BlogracyError(String s, Throwable throwable) {
+ super(s, throwable);
+ }
+
+ public BlogracyError(Throwable throwable) {
+ super(throwable);
+ }
+}
View
50 old/src/main/java/it/unipr/aotlab/blogracy/errors/InformationMissing.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2011 Enrico Franchi, Michele Tomaiuolo and University of Parma.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+package it.unipr.aotlab.blogracy.errors;
+
+/**
+ * User: enrico
+ * Package: it.unipr.aotlab.blogracy.errors
+ * Date: 10/27/11
+ * Time: 12:45 PM
+ */
+
+/**
+ * A InformationMissing exception is thrown if the required information is not currently in memory.
+ */
+public class InformationMissing extends BlogracyError {
+ public InformationMissing() {
+ }
+
+ public InformationMissing(final String s) {
+ super(s);
+ }
+
+ public InformationMissing(final String s, final Throwable throwable) {
+ super(s, throwable);
+ }
+
+ public InformationMissing(final Throwable throwable) {
+ super(throwable);
+ }
+}
View
51 old/src/main/java/it/unipr/aotlab/blogracy/errors/InformationNotYetAvailable.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2011 Enrico Franchi, Michele Tomaiuolo and University of Parma.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+package it.unipr.aotlab.blogracy.errors;
+
+/**
+ * User: enrico
+ * Package: it.unipr.aotlab.blogracy.errors
+ * Date: 10/27/11
+ * Time: 1:17 PM
+ */
+
+/**
+ * This exception is thrown when the required information was required to the network,
+ * but is not yet available
+ */
+public class InformationNotYetAvailable extends InformationMissing {
+ public InformationNotYetAvailable() {
+ }
+
+ public InformationNotYetAvailable(final String s) {
+ super(s);
+ }
+
+ public InformationNotYetAvailable(final String s, final Throwable throwable) {
+ super(s, throwable);
+ }
+
+ public InformationNotYetAvailable(final Throwable throwable) {
+ super(throwable);
+ }
+}
View
45 old/src/main/java/it/unipr/aotlab/blogracy/errors/InvalidPluginStateException.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2011 Enrico Franchi and University of Parma.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+package it.unipr.aotlab.blogracy.errors;
+
+/**
+ * This exception should be used to indicate that some object from the platform was called before
+ * the system was fully initialized.
+ */
+public class InvalidPluginStateException extends BlogracyError {
+
+ public InvalidPluginStateException() {
+ }
+
+ public InvalidPluginStateException(final String s) {
+ super(s);
+ }
+
+ public InvalidPluginStateException(final String s, final Throwable throwable) {
+ super(s, throwable);
+ }
+
+ public InvalidPluginStateException(final Throwable throwable) {
+ super(throwable);
+ }
+}
View
37 old/src/main/java/it/unipr/aotlab/blogracy/errors/MissingProfileError.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2011 Enrico Franchi, Michele Tomaiuolo and University of Parma.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+package it.unipr.aotlab.blogracy.errors;
+
+/**
+ * User: enrico
+ * Package: it.unipr.aotlab.blogracy.errors
+ * Date: 10/27/11
+ * Time: 12:59 PM
+ */
+
+/**
+ * The required profile is not existent
+ */
+public class MissingProfileError extends BlogracyError {
+
+}
View
28 old/src/main/java/it/unipr/aotlab/blogracy/errors/NetworkConfigurationError.java
@@ -0,0 +1,28 @@
+package it.unipr.aotlab.blogracy.errors;
+
+/**
+ * Enrico Franchi, 2011 (c)
+ * <p/>
+ * This program or module is released under the terms of the MIT license.
+ * <p/>
+ * User: enrico
+ * Date: 10/27/11
+ * Time: 4:46 PM
+ */
+public class NetworkConfigurationError extends NetworkError {
+ public NetworkConfigurationError() {
+ super();
+ }
+
+ public NetworkConfigurationError(String s) {
+ super(s);
+ }
+
+ public NetworkConfigurationError(String s, Throwable throwable) {
+ super(s, throwable);
+ }
+
+ public NetworkConfigurationError(Throwable throwable) {
+ super(throwable);
+ }
+}
View
50 old/src/main/java/it/unipr/aotlab/blogracy/errors/NetworkError.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2011 Enrico Franchi, Michele Tomaiuolo and University of Parma.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+package it.unipr.aotlab.blogracy.errors;
+
+/**
+ * User: enrico
+ * Package: it.unipr.aotlab.blogracy.errors
+ * Date: 10/27/11
+ * Time: 1:01 PM
+ */
+
+/**
+ * Some information could not be retrieved from the DHT
+ */
+public class NetworkError extends BlogracyError {
+ public NetworkError() {
+ }
+
+ public NetworkError(String s) {
+ super(s);
+ }
+
+ public NetworkError(String s, Throwable throwable) {
+ super(s, throwable);
+ }
+
+ public NetworkError(Throwable throwable) {
+ super(throwable);
+ }
+}
View
51 old/src/main/java/it/unipr/aotlab/blogracy/errors/ServerConfigurationError.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2011 Enrico Franchi, Michele Tomaiuolo and University of Parma.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+package it.unipr.aotlab.blogracy.errors;
+
+/**
+ * User: enrico
+ * Package: it.unipr.aotlab.blogracy.errors
+ * Date: 11/11/11
+ * Time: 10:59 PM
+ */
+
+/**
+ * A ServerConfigurationError is thrown (usually) at configuration time if
+ * something is not right about the specified configuration.
+ */
+public class ServerConfigurationError extends BlogracyError {
+ public ServerConfigurationError() {
+ }
+
+ public ServerConfigurationError(final String s) {
+ super(s);
+ }
+
+ public ServerConfigurationError(final String s, final Throwable throwable) {
+ super(s, throwable);
+ }
+
+ public ServerConfigurationError(final Throwable throwable) {
+ super(throwable);
+ }
+}
View
37 old/src/main/java/it/unipr/aotlab/blogracy/errors/URLMappingError.java
@@ -0,0 +1,37 @@
+package it.unipr.aotlab.blogracy.errors;
+
+/**
+ * Enrico Franchi, 2011 (c)
+ * <p/>
+ * This program or module is released under the terms of the MIT license.
+ * <p/>
+ * User: enrico
+ * Date: 11/2/11
+ * Time: 6:30 PM
+ */
+public class URLMappingError extends BlogracyError {
+ private int httpErrorStatus;
+
+ public URLMappingError(int httpErrorStatus) {
+ this.httpErrorStatus = httpErrorStatus;
+ }
+
+ public URLMappingError(int httpErrorStatus, String s) {
+ super(s);
+ this.httpErrorStatus = httpErrorStatus;
+ }
+
+ public URLMappingError(int httpErrorStatus, String s, Throwable throwable) {
+ super(s, throwable);
+ this.httpErrorStatus = httpErrorStatus;
+ }
+
+ public URLMappingError(int httpErrorStatus, Throwable throwable) {
+ super(throwable);
+ this.httpErrorStatus = httpErrorStatus;
+ }
+
+ public int getHttpErrorStatus() {
+ return httpErrorStatus;
+ }
+}
View
100 old/src/main/java/it/unipr/aotlab/blogracy/logging/Logger.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2011 Enrico Franchi and University of Parma.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package it.unipr.aotlab.blogracy.logging;
+
+import org.gudy.azureus2.plugins.PluginInterface;
+import org.gudy.azureus2.plugins.logging.LoggerChannel;
+
+/**
+ * Use the static methods of this class for all the logging. It does the right thing!
+ */
+public class Logger {
+
+ interface SimpleChannel {
+ void info(String msg);
+
+ void warn(String msg);
+
+ void error(String msg);
+ }
+
+ static LoggerChannel loggerChannel = null;
+ static org.gudy.azureus2.plugins.logging.Logger logger = null;
+ static SimpleChannel simpleChannel = new SimpleChannel() {
+ java.util.logging.Logger defaultLogger =
+ java.util.logging.Logger.getAnonymousLogger();
+
+ @Override
+ public void info(String s) {
+ defaultLogger.info(s);
+ }
+
+ @Override
+ public void warn(String s) {
+ defaultLogger.warning(s);
+ }
+
+ @Override
+ public void error(String s) {
+ defaultLogger.severe(s);
+ }
+ };
+
+ /**
+ * Initializes the default logger so that it can be used afterwards.
+ * @param pluginInterface is used to get Vuze logger
+ * @param pluginChannelName is the name of the channel for this plugin
+ */
+ public static void initialize(PluginInterface pluginInterface,
+ String pluginChannelName) {
+ logger = pluginInterface.getLogger();
+ loggerChannel = logger.getTimeStampedChannel(pluginChannelName);
+ simpleChannel = new SimpleChannel() {
+ @Override
+ public void info(String msg) {
+ loggerChannel.logAlert(LoggerChannel.LT_INFORMATION, msg);
+ }
+
+ @Override
+ public void warn(String msg) {
+ loggerChannel.logAlert(LoggerChannel.LT_WARNING, msg);
+ }
+
+ @Override
+ public void error(String msg) {
+ loggerChannel.logAlert(LoggerChannel.LT_ERROR, msg);
+ }
+ };
+ }
+
+ public static void info(String msg) {
+ simpleChannel.info(msg);
+ }
+
+ public static void warn(String msg) {
+ simpleChannel.warn(msg);
+ }
+
+ public static void error(String msg) {
+ simpleChannel.error(msg);
+ }
+}
View
37 old/src/main/java/it/unipr/aotlab/blogracy/mime/MimeFinder.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2011 Enrico Franchi, Michele Tomaiuolo and University of Parma.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+package it.unipr.aotlab.blogracy.mime;
+
+import java.io.File;
+
+/**
+ * User: enrico
+ * Package: it.unipr.aotlab.blogracy.mime
+ * Date: 11/11/11