Skip to content

Commit ba1cf30

Browse files
committed
added FTP archive implementations
1 parent a5432e5 commit ba1cf30

33 files changed

+960
-208
lines changed

pom.xml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
</scm>
3232
<developers>
3333
<developer>
34-
<id>janith</id>
34+
<id>janithb</id>
3535
<name>Janith Bandara</name>
3636
<organization>Audit4j</organization>
3737
<organizationUrl>http://audit4j.org</organizationUrl>
@@ -57,11 +57,22 @@
5757
<version>4.11</version>
5858
<scope>test</scope>
5959
</dependency>
60+
<dependency>
61+
<groupId>org.mockito</groupId>
62+
<artifactId>mockito-core</artifactId>
63+
<version>1.10.19</version>
64+
<scope>test</scope>
65+
</dependency>
6066
<dependency>
6167
<groupId>org.apache.commons</groupId>
6268
<artifactId>commons-lang3</artifactId>
6369
<version>3.3.2</version>
6470
</dependency>
71+
<dependency>
72+
<groupId>commons-net</groupId>
73+
<artifactId>commons-net</artifactId>
74+
<version>3.3</version>
75+
</dependency>
6576
<dependency>
6677
<groupId>com.esotericsoftware.yamlbeans</groupId>
6778
<artifactId>yamlbeans</artifactId>

src/main/java/org/audit4j/core/ConcurrentConfigurationContext.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,17 @@
2626
import org.audit4j.core.filter.AuditEventFilter;
2727
import org.audit4j.core.handler.Handler;
2828
import org.audit4j.core.layout.Layout;
29+
import org.audit4j.core.util.annotation.ThreadSafe;
2930

3031
import com.gs.collections.impl.map.mutable.ConcurrentHashMap;
3132

3233
/**
3334
* Configuration item store. All configuration items which are used by the
3435
* running components store here. Items loaded by the context.
3536
*
36-
* <p>Below Items store here:</p>
37+
* <p>
38+
* Below Items store here:
39+
* </p>
3740
* <ul>
3841
* <li>Available handlers.</li>
3942
* <li>Audit event filters.</li>
@@ -42,10 +45,9 @@
4245
* <li>Additional configuration properties.</li>
4346
* </ul>
4447
*
45-
* <p> #ThreadSafe# </p>
46-
*
4748
* @author <a href="mailto:[email protected]">Janith Bandara</a>
4849
*/
50+
@ThreadSafe
4951
public final class ConcurrentConfigurationContext {
5052

5153
/** The handlers. */
@@ -59,7 +61,7 @@ public final class ConcurrentConfigurationContext {
5961

6062
/** The Constant filters. */
6163
private final List<AuditAnnotationFilter> annotationFilters = new CopyOnWriteArrayList<AuditAnnotationFilter>();
62-
64+
6365
/** The layout. */
6466
private Layout layout;
6567

@@ -166,10 +168,9 @@ public void addFilter(AuditEventFilter filter) {
166168
filters.add(filter);
167169
}
168170

169-
170171
/**
171172
* Gets the annotation filters.
172-
*
173+
*
173174
* @return the annotation filters
174175
*/
175176
public List<AuditAnnotationFilter> getAnnotationFilters() {
@@ -178,12 +179,14 @@ public List<AuditAnnotationFilter> getAnnotationFilters() {
178179

179180
/**
180181
* Adds the annotation filter.
181-
*
182-
* @param annotationFilter the annotation filter
182+
*
183+
* @param annotationFilter
184+
* the annotation filter
183185
*/
184-
public void addAnnotationFilter(AuditAnnotationFilter annotationFilter){
186+
public void addAnnotationFilter(AuditAnnotationFilter annotationFilter) {
185187
annotationFilters.add(annotationFilter);
186188
}
189+
187190
/**
188191
* Gets the run status.
189192
*

src/main/java/org/audit4j/core/CoreConstants.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ public final class CoreConstants {
4141

4242
/** The Constant AUDIT_EXTENTION. */
4343
public static final String AUDIT_EXTENTION = ".audit";
44+
45+
/** The Constant AUDIT_ARCHIVE_EXTENTION. */
46+
public static final String AUDIT_ARCHIVE_EXTENTION = ".auditarchive";
4447

4548
/** The Constant SITE_URL. */
4649
public static final String SITE_URL = "http://audit4j.org";

src/main/java/org/audit4j/core/PreConfigurationContext.java

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
/**
3232
* Registry for internal initial resource configurations.
33-
*
33+
*
3434
* @author <a href="mailto:[email protected]">Janith Bandara</a>
3535
*
3636
* @since 2.3.0
@@ -50,14 +50,16 @@ public final class PreConfigurationContext {
5050
private static final List<AuditAnnotationFilter> preAnnotationFilters = new ArrayList<AuditAnnotationFilter>();
5151

5252
static {
53-
options.add("-scanAnnotated");
54-
commands.put("-scanAnnotated", new ScanAnnotatedCommand());
53+
ScanAnnotatedCommand scanAnnotated = new ScanAnnotatedCommand();
54+
options.add(scanAnnotated.getCommand());
55+
commands.put(scanAnnotated.getCommand(), scanAnnotated);
5556
}
5657

5758
/**
5859
* Gets the command by option name.
59-
*
60-
* @param optionName the option name
60+
*
61+
* @param optionName
62+
* the option name
6163
* @return the command by option name
6264
*/
6365
public static AbstractCommand getCommandByOptionName(String optionName) {
@@ -66,7 +68,7 @@ public static AbstractCommand getCommandByOptionName(String optionName) {
6668

6769
/**
6870
* Gets the options.
69-
*
71+
*
7072
* @return the options
7173
*/
7274
public static List<String> getOptions() {
@@ -75,7 +77,7 @@ public static List<String> getOptions() {
7577

7678
/**
7779
* Gets the commands.
78-
*
80+
*
7981
* @return the commands
8082
*/
8183
public static Map<String, AbstractCommand> getCommands() {
@@ -84,7 +86,7 @@ public static Map<String, AbstractCommand> getCommands() {
8486

8587
/**
8688
* Gets the prefilters.
87-
*
89+
*
8890
* @return the prefilters
8991
*/
9092
public static List<AuditEventFilter> getPrefilters() {
@@ -93,25 +95,27 @@ public static List<AuditEventFilter> getPrefilters() {
9395

9496
/**
9597
* Adds the filter.
96-
*
97-
* @param filter the filter
98+
*
99+
* @param filter
100+
* the filter
98101
*/
99102
public static void addFilter(AuditEventFilter filter) {
100103
preFilters.add(filter);
101104
}
102105

103106
/**
104107
* Adds the annotation filter.
105-
*
106-
* @param filter the filter
108+
*
109+
* @param filter
110+
* the filter
107111
*/
108112
public static void addAnnotationFilter(AuditAnnotationFilter filter) {
109113
preAnnotationFilters.add(filter);
110114
}
111115

112116
/**
113117
* Gets the preannotationfilters.
114-
*
118+
*
115119
* @return the preannotationfilters
116120
*/
117121
public static List<AuditAnnotationFilter> getPreannotationfilters() {

src/main/java/org/audit4j/core/command/AbstractCommand.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,33 @@ public Map<String, String> getOptions() {
4848
*
4949
* @param options the options
5050
*/
51-
public void setOptions(Map<String, String> options) {
51+
void setOptions(Map<String, String> options) {
5252
this.options = options;
5353
}
5454

5555
/**
5656
* Execute.
5757
*/
5858
public abstract void execute();
59+
60+
/**
61+
* Gets the command.
62+
*
63+
* @return the command
64+
*/
65+
public abstract String getCommand();
66+
67+
/**
68+
* Gets the command name.
69+
*
70+
* @return the command name
71+
*/
72+
public abstract String getCommandName();
73+
74+
/**
75+
* Gets the command description.
76+
*
77+
* @return the command description
78+
*/
79+
public abstract String getCommandDescription();
5980
}

src/main/java/org/audit4j/core/command/CommandProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public void process(Map<String, String> options) {
5151
try {
5252
command.init();
5353
} catch (InitializationException e) {
54-
Log.error("There is a problem in the : option you configured: ", entry.getKey(),
54+
Log.error("There is a problem in the option you configured: ", entry.getKey(),
5555
ErrorGuide.getGuide(ErrorGuide.OPTION_ERROR));
5656
}
5757
command.execute();

src/main/java/org/audit4j/core/command/impl/ScanAnnotatedCommand.java

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@
3131
import org.audit4j.core.filter.impl.ScanAnnotatedFilter;
3232

3333
/**
34-
* The Class ScanAnnotatedCommand.
35-
*
34+
* Scan Annotated Command.
35+
*
36+
* Scan annotations in initialization time and store the information. These
37+
* information will use later to speedup the event processing.
38+
*
3639
* @author <a href="mailto:[email protected]">Janith Bandara</a>
3740
*
3841
* @since 2.3.0
@@ -42,12 +45,30 @@ public class ScanAnnotatedCommand extends AbstractCommand {
4245
/** The db. */
4346
AnnotationDB db;
4447

45-
/* (non-Javadoc)
48+
@Override
49+
public String getCommand() {
50+
return "-scanAnnotated";
51+
}
52+
53+
@Override
54+
public String getCommandName() {
55+
return "Scan Annotated Command";
56+
}
57+
58+
@Override
59+
public String getCommandDescription() {
60+
return "Scan annotations in initialization time and store the information. "
61+
+ "These information will use later to speedup the event processing";
62+
}
63+
64+
/*
65+
* (non-Javadoc)
66+
*
4667
* @see org.audit4j.core.Initializable#init()
4768
*/
4869
@Override
4970
public void init() {
50-
String packageName = getOptions().get("-scanAnnotated");
71+
String packageName = getOptions().get(getCommand());
5172

5273
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
5374

@@ -77,7 +98,9 @@ public void init() {
7798

7899
}
79100

80-
/* (non-Javadoc)
101+
/*
102+
* (non-Javadoc)
103+
*
81104
* @see org.audit4j.core.command.AbstractCommand#execute()
82105
*/
83106
@Override
@@ -95,12 +118,13 @@ public void execute() {
95118
PreConfigurationContext.addAnnotationFilter(filter);
96119
}
97120

98-
/* (non-Javadoc)
121+
/*
122+
* (non-Javadoc)
123+
*
99124
* @see org.audit4j.core.Initializable#stop()
100125
*/
101126
@Override
102127
public void stop() {
103128
db = null;
104129
}
105-
106130
}

src/main/java/org/audit4j/core/filter/AuditEventFilter.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
*/
3232
public interface AuditEventFilter extends Serializable {
3333

34+
public POJOQuery<AuditEvent> query = new POJOQuery<>();
35+
3436
/**
3537
* Accepts.
3638
*

src/main/java/org/audit4j/core/filter/POJOQuery.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ public boolean operaterProceed() {
308308
* @return true, if successful
309309
*/
310310
public boolean evaluate() {
311+
atQuery = null;
311312
return result;
312313
}
313314
}

src/main/java/org/audit4j/core/handler/file/ArchiveJob.java

Lines changed: 0 additions & 62 deletions
This file was deleted.

0 commit comments

Comments
 (0)