Skip to content

Commit 82460c2

Browse files
author
Joerg Huber
committed
Restructuring due to maven build.
1 parent e6e52e8 commit 82460c2

20 files changed

Lines changed: 2990 additions & 0 deletions
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/*
2+
* LogAuditor.java
3+
* Created: 04/03/2015
4+
*
5+
* Copyright 2015 Systemic Pty Ltd
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software distributed under the License
14+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
15+
* or implied.
16+
* See the License for the specific language governing permissions and limitations under the License.
17+
*/
18+
package systemic.sif3.demo.audit;
19+
20+
import java.io.PrintWriter;
21+
import java.io.StringWriter;
22+
import java.text.SimpleDateFormat;
23+
24+
import org.slf4j.Logger;
25+
import org.slf4j.LoggerFactory;
26+
27+
import sif3.common.interfaces.Auditor;
28+
import sif3.common.model.audit.AuditRecord;
29+
30+
/**
31+
* This is a demo implementation of an Audit Class. This particular implementation simply logs all the audit entries in a particular audit
32+
* file through the log4j configuration.
33+
*
34+
* @author Ben Carter & Joerg Huber
35+
*
36+
*/
37+
public class LogAuditor implements Auditor
38+
{
39+
private static final Logger logger = LoggerFactory.getLogger(LogAuditor.class);
40+
41+
@Override
42+
public void audit(AuditRecord auditRecord)
43+
{
44+
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss.SSS");
45+
StringWriter logEntry = new StringWriter();
46+
PrintWriter writer = new PrintWriter(logEntry);
47+
writer.println();
48+
writer.println("----------");
49+
writer.print("Request Date: ");
50+
writer.println(sdf.format(auditRecord.getRequestData().getTimestamp()));
51+
writer.print("Requested Operation: ");
52+
writer.println(auditRecord.getRequestData().getMethod());
53+
writer.print("Solution ID: ");
54+
writer.println(auditRecord.getSifData().getSolutionId());
55+
writer.print("App Key: ");
56+
writer.println(auditRecord.getSifData().getAppKey());
57+
writer.print("User Token: ");
58+
writer.println(auditRecord.getSifData().getUserToken());
59+
writer.print("Context: ");
60+
writer.println(auditRecord.getSifData().getContext());
61+
writer.print("Zone: ");
62+
writer.println(auditRecord.getSifData().getZone());
63+
writer.print("Environment ID: ");
64+
writer.println(auditRecord.getSifData().getEnvironmentId());
65+
writer.print("Session Token: ");
66+
writer.println(auditRecord.getSifData().getSessionToken());
67+
writer.print("URL: ");
68+
writer.println(auditRecord.getRequestData().getUrl());
69+
writer.println("Body: ");
70+
writer.println("--");
71+
writer.println(auditRecord.getRequestData().getPayload());
72+
writer.println("--");
73+
writer.print("HTTP Response Status:");
74+
writer.println(auditRecord.getResponseData().getHttpStatus());
75+
writer.println("Response:");
76+
writer.println("--");
77+
writer.println(auditRecord.getResponseData().getPayload());
78+
writer.println("--");
79+
writer.print("Response Date: ");
80+
writer.println(sdf.format(auditRecord.getResponseData().getTimestamp()));
81+
writer.println("----------");
82+
logger.info(logEntry.toString());
83+
}
84+
85+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* DemoProperties.java
3+
* Created: 30/04/2016
4+
*
5+
* Copyright 2016 Systemic Pty Ltd
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8+
* in compliance with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software distributed under the License
13+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14+
* or implied. See the License for the specific language governing permissions and limitations under
15+
* the License.
16+
*/
17+
package systemic.sif3.demo.hibernate;
18+
19+
import java.util.Properties;
20+
21+
import sif3.common.interfaces.HibernateProperties;
22+
23+
/**
24+
* This class demonstrates how hibernate properties can be set programmatically and injected to the SIF3 Framework.
25+
*
26+
* @author Joerg Huber
27+
*/
28+
public class DemoProperties implements HibernateProperties
29+
{
30+
private static Properties props = null;
31+
32+
public DemoProperties()
33+
{
34+
if (props == null)
35+
{
36+
props = new Properties();
37+
props.setProperty("hibernate.dialect", "sif3.common.persist.common.SQLiteDialect");
38+
props.setProperty("hibernate.connection.driver_class", "org.sqlite.JDBC");
39+
props.setProperty("hibernate.connection.url", "jdbc:sqlite:/DEV/lunaWorkspace/SIF3InfraREST/DB/Data/SIF3Infra.sqliteDB");
40+
props.setProperty("hibernate.connection.username", "");
41+
props.setProperty("hibernate.connection.password", "");
42+
}
43+
}
44+
45+
@Override
46+
public Properties getProperties()
47+
{
48+
return props;
49+
}
50+
51+
@Override
52+
public void setProperties(Properties properties)
53+
{
54+
props = properties;
55+
}
56+
57+
@Override
58+
public void addProperty(String key, String value)
59+
{
60+
if (props != null)
61+
{
62+
props.setProperty(key, value);
63+
}
64+
}
65+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* ModelObjectConstants.java
3+
* Created: 01/10/2013
4+
*
5+
* Copyright 2013 Systemic Pty Ltd
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software distributed under the License
14+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
15+
* or implied.
16+
* See the License for the specific language governing permissions and limitations under the License.
17+
*/
18+
19+
package systemic.sif3.demo.rest;
20+
21+
import sif.dd.au30.model.SchoolInfoCollectionType;
22+
import sif.dd.au30.model.SchoolInfoType;
23+
import sif.dd.au30.model.StudentDailyAttendanceCollectionType;
24+
import sif.dd.au30.model.StudentDailyAttendanceType;
25+
import sif.dd.au30.model.StudentPersonalCollectionType;
26+
import sif.dd.au30.model.StudentPersonalType;
27+
import sif.dd.au30.model.TeachingGroupCollectionType;
28+
import sif.dd.au30.model.TeachingGroupType;
29+
import sif3.common.conversion.ModelObjectInfo;
30+
31+
/**
32+
* @author Joerg Huber
33+
*
34+
*/
35+
public class ModelObjectConstants
36+
{
37+
public static final String UTF_8 = "UTF-8";
38+
39+
public static final ModelObjectInfo STUDENT_PERSONALS = new ModelObjectInfo("StudentPersonals", StudentPersonalCollectionType.class);
40+
public static final ModelObjectInfo STUDENT_PERSONAL = new ModelObjectInfo("StudentPersonal", StudentPersonalType.class);
41+
public static final ModelObjectInfo SCHOOL_INFOS = new ModelObjectInfo("SchoolInfos", SchoolInfoCollectionType.class);
42+
public static final ModelObjectInfo SCHOOL_INFO = new ModelObjectInfo("SchoolInfo", SchoolInfoType.class);
43+
public static final ModelObjectInfo STUDENT_DAILY_ATTENDANCES = new ModelObjectInfo("StudentDailyAttendances", StudentDailyAttendanceCollectionType.class);
44+
public static final ModelObjectInfo STUDENT_DAILY_ATTENDANCE = new ModelObjectInfo("StudentDailyAttendance", StudentDailyAttendanceType.class);
45+
public static final ModelObjectInfo TEACHING_GROUPS = new ModelObjectInfo("TeachingGroups", TeachingGroupCollectionType.class);
46+
public static final ModelObjectInfo TEACHING_GROUP = new ModelObjectInfo("TeachingGroups", TeachingGroupType.class);
47+
}
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
/*
2+
* AUDataModelConsumer.java
3+
* Created: 08/05/2014
4+
*
5+
* Copyright 2014 Systemic Pty Ltd
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software distributed under the License
14+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
15+
* or implied.
16+
* See the License for the specific language governing permissions and limitations under the License.
17+
*/
18+
19+
package systemic.sif3.demo.rest.consumer;
20+
21+
import org.apache.log4j.Logger;
22+
23+
import sif.dd.au30.conversion.DataModelMarshalFactory;
24+
import sif.dd.au30.conversion.DataModelUnmarshalFactory;
25+
import sif3.common.conversion.MarshalFactory;
26+
import sif3.common.conversion.UnmarshalFactory;
27+
import sif3.common.model.PagingInfo;
28+
import sif3.common.model.QueryCriteria;
29+
import sif3.common.model.delayed.DelayedResponseReceipt;
30+
import sif3.common.utils.JAXBUtils;
31+
import sif3.common.ws.CreateOperationStatus;
32+
import sif3.common.ws.ErrorDetails;
33+
import sif3.common.ws.OperationStatus;
34+
import sif3.common.ws.model.MultiOperationStatusList;
35+
import sif3.infra.rest.consumer.AbstractConsumer;
36+
37+
/**
38+
* @author Joerg Huber
39+
*
40+
*/
41+
public abstract class AUDataModelConsumer extends AbstractConsumer
42+
{
43+
protected final Logger logger = Logger.getLogger(getClass());
44+
45+
private static DataModelUnmarshalFactory unmarshaller = new DataModelUnmarshalFactory();
46+
private static DataModelMarshalFactory marshaller = new DataModelMarshalFactory();
47+
48+
public AUDataModelConsumer()
49+
{
50+
super();
51+
52+
//Initialise JAXB context for these classes. Make data processor behave better against race conditions.
53+
JAXBUtils.initCtx(getMultiObjectClassInfo().getObjectType());
54+
JAXBUtils.initCtx(getSingleObjectClassInfo().getObjectType());
55+
}
56+
57+
/*
58+
* (non-Javadoc)
59+
* @see sif3.common.interfaces.DataModelLink#getMarshaller()
60+
*/
61+
@Override
62+
public MarshalFactory getMarshaller()
63+
{
64+
return marshaller;
65+
}
66+
67+
@Override
68+
public UnmarshalFactory getUnmarshaller()
69+
{
70+
return unmarshaller;
71+
}
72+
73+
74+
@Override
75+
public void shutdown()
76+
{
77+
// nothing to do at the moment
78+
}
79+
80+
81+
// @Override
82+
// public ModelObjectInfo getSingleObjectClassInfo()
83+
// {
84+
// return null;
85+
// }
86+
//
87+
// @Override
88+
// public ModelObjectInfo getMultiObjectClassInfo()
89+
// {
90+
// return null;
91+
// }
92+
93+
/*----------------------------------------------------------------------------*/
94+
/*-- Abstract Consumer Methods: Dummy Implementation - Just log the values. --*/
95+
/*----------------------------------------------------------------------------*/
96+
97+
@Override
98+
public void processDelayedCreateMany(MultiOperationStatusList<CreateOperationStatus> statusList, DelayedResponseReceipt receipt)
99+
{
100+
logger.debug("Received DELAYED CREATE Response:\n"+statusList+"\nDelayed Receipt Details:\n"+receipt);
101+
}
102+
103+
@Override
104+
public void processDelayedUpdateMany(MultiOperationStatusList<OperationStatus> statusList, DelayedResponseReceipt receipt)
105+
{
106+
logger.debug("Received DELAYED UPDATE Response:\n"+statusList+"\nDelayed Receipt Details:\n"+receipt);
107+
}
108+
109+
@Override
110+
public void processDelayedDeleteMany(MultiOperationStatusList<OperationStatus> statusList, DelayedResponseReceipt receipt)
111+
{
112+
logger.debug("Received DELAYED DELETE Response:\n"+statusList+"\nDelayed Receipt Details:\n"+receipt);
113+
}
114+
115+
@Override
116+
public void processDelayedQuery(Object dataObject, PagingInfo pagingInfo, DelayedResponseReceipt receipt)
117+
{
118+
logger.debug("Received DELAYED QUERY Response:\n"+dataObject+"\nPagingInfo:\n"+pagingInfo+"\nDelayed Receipt Details:\n"+receipt);
119+
}
120+
121+
@Override
122+
public void processDelayedServicePath(Object dataObject, QueryCriteria queryCriteria, PagingInfo pagingInfo, DelayedResponseReceipt receipt)
123+
{
124+
logger.debug("Received DELAYED SERVICEPATH Response:\n"+dataObject+"\nQuery Criteria:\n"+queryCriteria+"\nPagingInfo:\n"+pagingInfo+"\nDelayed Receipt Details:\n"+receipt);
125+
}
126+
127+
@Override
128+
public void processDelayedError(ErrorDetails error, DelayedResponseReceipt receipt)
129+
{
130+
logger.debug("Received DELAYED ERROR Response:\n"+error+"\nDelayed Receipt Details:\n"+receipt);
131+
}
132+
}

0 commit comments

Comments
 (0)