Skip to content

Commit ad170a7

Browse files
committed
README updated and a couple of other rules added
1 parent e7c621e commit ad170a7

16 files changed

Lines changed: 204 additions & 158 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.settings
22
.DS_Store
33
.project
4+
.checkstyle
45
target
56
.classpath
67
target

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,19 @@ Note this points to the main buddycloud repository for the java server.
88

99
[![Build Status](https://travis-ci.org/buddycloud/buddycloud-server-java.png?branch=master)](https://travis-ci.org/buddycloud/buddycloud-server-java)
1010

11+
## Coding Standards
12+
13+
Checkstyle is used to confirm the preferred coding standards are used, these are based loosely on Google's OS Java guidelines. There is support in maven, the build should fail on the introduction of errors and there is also support for automated formatting in Eclipse. To setup do the following -
14+
15+
* Navigate to Eclipse->Preferences->Java ->Code Style->Formatter
16+
* Select 'import' and there is a file named 'eclipse_formatter.xml' in src/main/resources.
17+
* Import and set it as the active profile
18+
19+
N.B. Its also worth setting up the hooks that allow for formatting and organising of imports on save, to do this
20+
21+
* Navigate to Eclipse->Preferences->Java->Code Style->Save Actions
22+
* Select 'Format All Lines' and 'Organize Imports'
23+
1124
## Database install
1225

1326
The java server purposefully uses the same database schema as the buddycloud node.js server. See here for database installation instructions https://github.com/buddycloud/buddycloud-server/tree/develop/postgres.

pom.xml

Lines changed: 144 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
<scm>
1111
<url>https://github.com/buddycloud/buddycloud-server-java</url>
1212
</scm>
13-
13+
1414
<properties>
1515
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1616
<project.build.withDependencies>jar-with-dependencies</project.build.withDependencies>
1717
<maven.checkstyle.plugin.version>2.13</maven.checkstyle.plugin.version>
1818
<checkstyle.config.location>src/main/resources/checkstyle.xml</checkstyle.config.location>
1919
</properties>
20-
20+
2121
<dependencies>
2222
<dependency>
2323
<groupId>org.xbill</groupId>
@@ -163,141 +163,147 @@
163163
</pluginRepository>
164164
</pluginRepositories>
165165
<build>
166-
<plugins>
167-
<plugin>
168-
<!-- Extended Maven antrun plugin -->
169-
<!-- https://maven-antrun-extended-plugin.dev.java.net/ -->
170-
<groupId>org.jvnet.maven-antrun-extended-plugin</groupId>
171-
<artifactId>maven-antrun-extended-plugin</artifactId>
172-
<executions>
173-
<execution>
174-
<id>test-reports</id>
175-
<phase>test</phase>
176-
<configuration>
177-
<tasks unless="maven.test.skip">
178-
<junitreport todir="target/surefire-reports">
179-
<fileset dir="target/surefire-reports">
180-
<include name="**/*.xml" />
181-
</fileset>
182-
<report format="noframes"
183-
todir="target/surefire-reports" />
184-
</junitreport>
185-
</tasks>
186-
</configuration>
187-
<goals>
188-
<goal>run</goal>
189-
</goals>
190-
</execution>
191-
</executions>
192-
<dependencies>
193-
<dependency>
194-
<groupId>org.apache.ant</groupId>
195-
<artifactId>ant-junit</artifactId>
196-
<version>1.8.0</version>
197-
</dependency>
198-
<dependency>
199-
<groupId>org.apache.ant</groupId>
200-
<artifactId>ant-trax</artifactId>
201-
<version>1.8.0</version>
202-
</dependency>
203-
</dependencies>
204-
</plugin>
205-
<plugin>
206-
<groupId>org.apache.maven.plugins</groupId>
207-
<artifactId>maven-surefire-plugin</artifactId>
208-
<version>2.5</version>
209-
<configuration>
210-
<argLine>-Duser.timezone=UTC -XX:MaxPermSize=1024m -Xmx1024m</argLine>
211-
<skipTests>false</skipTests>
212-
<testFailureIgnore>true</testFailureIgnore>
213-
<forkMode>once</forkMode>
214-
<includes>
215-
<include>**/*Test.java</include>
216-
</includes>
217-
<useFile>false</useFile>
218-
</configuration>
219-
</plugin>
220-
<plugin>
221-
<groupId>org.apache.maven.plugins</groupId>
222-
<artifactId>maven-compiler-plugin</artifactId>
223-
<version>2.5.1</version>
224-
<configuration>
225-
<source>1.6</source>
226-
<target>1.6</target>
227-
</configuration>
228-
</plugin>
229-
<plugin>
230-
<artifactId>maven-assembly-plugin</artifactId>
231-
<configuration>
232-
<archive>
233-
<manifest>
234-
<mainClass>org.buddycloud.channelserver.Main</mainClass>
235-
</manifest>
236-
</archive>
237-
<descriptorRefs>
238-
<descriptorRef>${project.build.withDependencies}</descriptorRef>
239-
</descriptorRefs>
240-
</configuration>
241-
<executions>
242-
<execution>
243-
<id>jar-with-dependencies</id>
244-
<phase>package</phase>
245-
<goals>
246-
<goal>single</goal>
247-
</goals>
248-
</execution>
249-
</executions>
250-
</plugin>
251-
<plugin>
252-
<groupId>com.github.goldin</groupId>
253-
<artifactId>copy-maven-plugin</artifactId>
254-
<version>0.2.5</version>
255-
<executions>
256-
<execution>
257-
<id>create-archive</id>
258-
<phase>package</phase>
259-
<goals>
260-
<goal>copy</goal>
261-
</goals>
262-
<configuration>
263-
<resources>
264-
<resource>
265-
<targetPath>${project.build.directory}</targetPath>
266-
<file>target/${project.build.finalName}.jar</file>
267-
<destFileName>${project.artifactId}.jar</destFileName>
268-
</resource>
269-
<resource>
270-
<targetPath>${project.build.directory}</targetPath>
271-
<file>${project.build.directory}/${project.build.finalName}-${project.build.withDependencies}.jar</file>
272-
<destFileName>${project.artifactId}-${project.build.withDependencies}.jar</destFileName>
273-
</resource>
274-
</resources>
275-
</configuration>
276-
</execution>
277-
</executions>
278-
</plugin>
279-
<plugin>
280-
<groupId>org.apache.maven.plugins</groupId>
281-
<artifactId>maven-checkstyle-plugin</artifactId>
282-
<version>${maven.checkstyle.plugin.version}</version>
283-
<executions>
284-
<execution>
285-
<id>validate</id>
286-
<phase>validate</phase>
287-
<configuration>
288-
<configLocation>${checkstyle.config.location}</configLocation>
289-
<encoding>UTF-8</encoding>
290-
<consoleOutput>false</consoleOutput>
291-
<failOnViolation>true</failOnViolation>
292-
<failsOnError>true</failsOnError>
293-
<linkXRef>false</linkXRef>
294-
</configuration>
295-
<goals>
296-
<goal>check</goal>
297-
</goals>
298-
</execution>
299-
</executions>
300-
</plugin>
301-
</plugins>
166+
<pluginManagement>
167+
<plugins>
168+
<plugin>
169+
<!-- Extended Maven antrun plugin -->
170+
<!-- https://maven-antrun-extended-plugin.dev.java.net/ -->
171+
<groupId>org.jvnet.maven-antrun-extended-plugin</groupId>
172+
<artifactId>maven-antrun-extended-plugin</artifactId>
173+
<executions>
174+
<execution>
175+
<id>test-reports</id>
176+
<phase>test</phase>
177+
<configuration>
178+
<tasks unless="maven.test.skip">
179+
<junitreport
180+
todir="target/surefire-reports">
181+
<fileset
182+
dir="target/surefire-reports">
183+
<include name="**/*.xml" />
184+
</fileset>
185+
<report format="noframes"
186+
todir="target/surefire-reports" />
187+
</junitreport>
188+
</tasks>
189+
</configuration>
190+
<goals>
191+
<goal>run</goal>
192+
</goals>
193+
</execution>
194+
</executions>
195+
<dependencies>
196+
<dependency>
197+
<groupId>org.apache.ant</groupId>
198+
<artifactId>ant-junit</artifactId>
199+
<version>1.8.0</version>
200+
</dependency>
201+
<dependency>
202+
<groupId>org.apache.ant</groupId>
203+
<artifactId>ant-trax</artifactId>
204+
<version>1.8.0</version>
205+
</dependency>
206+
</dependencies>
207+
</plugin>
208+
<plugin>
209+
<groupId>org.apache.maven.plugins</groupId>
210+
<artifactId>maven-surefire-plugin</artifactId>
211+
<version>2.5</version>
212+
<configuration>
213+
<argLine>-Duser.timezone=UTC -XX:MaxPermSize=1024m -Xmx1024m</argLine>
214+
<skipTests>false</skipTests>
215+
<testFailureIgnore>true</testFailureIgnore>
216+
<forkMode>once</forkMode>
217+
<includes>
218+
<include>**/*Test.java</include>
219+
</includes>
220+
<useFile>false</useFile>
221+
</configuration>
222+
</plugin>
223+
<plugin>
224+
<groupId>org.apache.maven.plugins</groupId>
225+
<artifactId>maven-compiler-plugin</artifactId>
226+
<version>2.5.1</version>
227+
<configuration>
228+
<source>1.6</source>
229+
<target>1.6</target>
230+
</configuration>
231+
</plugin>
232+
<plugin>
233+
<artifactId>maven-assembly-plugin</artifactId>
234+
<configuration>
235+
<archive>
236+
<manifest>
237+
<mainClass>org.buddycloud.channelserver.Main</mainClass>
238+
</manifest>
239+
</archive>
240+
<descriptorRefs>
241+
<descriptorRef>${project.build.withDependencies}</descriptorRef>
242+
</descriptorRefs>
243+
</configuration>
244+
<executions>
245+
<execution>
246+
<id>jar-with-dependencies</id>
247+
<phase>package</phase>
248+
<goals>
249+
<goal>single</goal>
250+
</goals>
251+
</execution>
252+
</executions>
253+
</plugin>
254+
<plugin>
255+
<groupId>com.github.goldin</groupId>
256+
<artifactId>copy-maven-plugin</artifactId>
257+
<version>0.2.5</version>
258+
<executions>
259+
<execution>
260+
<id>create-archive</id>
261+
<phase>package</phase>
262+
<goals>
263+
<goal>copy</goal>
264+
</goals>
265+
<configuration>
266+
<resources>
267+
<resource>
268+
<targetPath>${project.build.directory}</targetPath>
269+
<file>target/${project.build.finalName}.jar</file>
270+
<destFileName>${project.artifactId}.jar</destFileName>
271+
</resource>
272+
<resource>
273+
<targetPath>${project.build.directory}</targetPath>
274+
<file>${project.build.directory}/${project.build.finalName}-${project.build.withDependencies}.jar</file>
275+
<destFileName>${project.artifactId}-${project.build.withDependencies}.jar</destFileName>
276+
</resource>
277+
</resources>
278+
</configuration>
279+
</execution>
280+
</executions>
281+
</plugin>
282+
<plugin>
283+
<groupId>org.apache.maven.plugins</groupId>
284+
<artifactId>maven-checkstyle-plugin</artifactId>
285+
<configuration>
286+
<failOnViolation>true</failOnViolation>
287+
<failsOnError>true</failsOnError>
288+
<encoding>UTF-8</encoding>
289+
<consoleOutput>false</consoleOutput>
290+
<linkXRef>false</linkXRef>
291+
<includes>**\/*.java</includes>
292+
<includeResources>false</includeResources>
293+
</configuration>
294+
<version>${maven.checkstyle.plugin.version}</version>
295+
<executions>
296+
<execution>
297+
<id>validate</id>
298+
<phase>validate</phase>
299+
<goals>
300+
<goal>check</goal>
301+
</goals>
302+
</execution>
303+
</executions>
304+
</plugin>
305+
</plugins>
306+
</pluginManagement>
302307
</build>
308+
303309
</project>

src/main/java/org/buddycloud/channelserver/channel/ChannelManagerImpl.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,12 @@ public void deleteRemoteData() throws NodeStoreException {
269269
ArrayList<String> nodes = this.getNodeList();
270270
for (String node : nodes) {
271271
try {
272-
if (true == node.equals(("/firehose")))
272+
if (true == node.equals(("/firehose"))) {
273273
return;
274-
if (false == this.isLocalNode(node))
274+
}
275+
if (false == this.isLocalNode(node)) {
275276
nodeStore.purgeNodeItems(node);
277+
}
276278
} catch (IllegalArgumentException e) {
277279
logger.error("Invalid remote node in datastore " + node, e);
278280
}

src/main/java/org/buddycloud/channelserver/channel/Conf.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,9 @@ private static HashMap<String, String> getDefaultConf(JID channelJID, String nod
141141

142142
private static void getConfigurationOverrides(JID channelJID, String node) {
143143

144-
if (null == node)
144+
if (null == node) {
145145
return;
146+
}
146147

147148
String accessModelKey = Configuration.CONFIGURATION_CHANNELS_DEFAULT_ACCESSMODEL.replace("default", node.replace("/", "."));
148149
if (null != projectConf.getProperty(accessModelKey)) {

src/main/java/org/buddycloud/channelserver/db/jdbc/ResultSetIterator.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,9 @@ public void remove() {
8787

8888
public void close() {
8989
try {
90-
if (false == resultSet.isClosed())
90+
if (false == resultSet.isClosed()) {
9191
resultSet.getStatement().close();
92+
}
9293
} catch (SQLException e) {
9394
logger.error("SQLException thrown while closing statement", e);
9495
}

src/main/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/discoitems/DiscoItemsGet.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ private void addItems() throws NodeStoreException {
5959
Element query = response.getElement().addElement("query");
6060
query.addNamespace("", JabberDiscoItems.NAMESPACE_URI);
6161
for (String node : nodes) {
62-
if (false == isLocalNode(node))
62+
if (false == isLocalNode(node)) {
6363
continue;
64+
}
6465
Element item = query.addElement("item");
6566
item.addAttribute("node", node);
6667
item.addAttribute("jid", jid);

0 commit comments

Comments
 (0)