}
public void execute(JobExecutionContext ctx) throws JobExecutionException {
ContentletAPI conAPI = APILocator.getContentletAPI();
FieldAPI fieldAPI = APILocator.getFieldAPI();
PermissionAPI perAPI = APILocator.getPermissionAPI();
try {
List<Structure> allStructures = StructureFactory.getStructures();
for(Structure structure:allStructures){
boolean isCongigured = false;
String host = "";
String username = "";
String password = "";
int port = 0;
boolean isSSL = true;
try{
host = Config.getStringProperty("pop."+structure.getVelocityVarName()+".host");
username = Config.getStringProperty("pop."+structure.getVelocityVarName()+".login");
password = Config.getStringProperty("pop."+structure.getVelocityVarName()+".password");
port = Config.getIntProperty("pop."+structure.getVelocityVarName()+".port");
isSSL = Config.getBooleanProperty("pop."+structure.getVelocityVarName()+".ssl");
}catch (Exception e) {
}
if(UtilMethods.isSet(host)
&& UtilMethods.isSet(port)
&& UtilMethods.isSet(isSSL)
&& UtilMethods.isSet(username)
&& UtilMethods.isSet(password)){
isCongigured = true;
}
if(isCongigured){
String messageIdFieldVarNm = "";
String subjectFieldVarNm = "";
String bodyFieldVarNm = "";
String fromFieldVarNm = "";
String toFieldVarNm = "";
String ccFieldVarNm = "";
String bccFieldVarNm = "";
String dateFieldVarNm = "";
String referencesFieldVarNm = "";
String inReplyToFieldVarNm = "";
String attachment1FieldVarNm = "";
String attachment2FieldVarNm = "";
String attachment3FieldVarNm = "";
String attachment4FieldVarNm = "";
String attachment5FieldVarNm = "";
String attachment6FieldVarNm = "";
String attachment7FieldVarNm = "";
String attachment8FieldVarNm = "";
String attachment9FieldVarNm = "";
String attachment10FieldVarNm = "";
try{
messageIdFieldVarNm = Config.getStringProperty("pop."+structure.getVelocityVarName()+".messageId");
subjectFieldVarNm = Config.getStringProperty("pop."+structure.getVelocityVarName()+".subject");
bodyFieldVarNm = Config.getStringProperty("pop."+structure.getVelocityVarName()+".body");
fromFieldVarNm = Config.getStringProperty("pop."+structure.getVelocityVarName()+".from");
toFieldVarNm = Config.getStringProperty("pop."+structure.getVelocityVarName()+".to");
ccFieldVarNm = Config.getStringProperty("pop."+structure.getVelocityVarName()+".cc");
bccFieldVarNm = Config.getStringProperty("pop."+structure.getVelocityVarName()+".bcc");
dateFieldVarNm = Config.getStringProperty("pop."+structure.getVelocityVarName()+".date");
referencesFieldVarNm = Config.getStringProperty("pop."+structure.getVelocityVarName()+".references");
inReplyToFieldVarNm = Config.getStringProperty("pop."+structure.getVelocityVarName()+".inReplyTo");
attachment1FieldVarNm = Config.getStringProperty("pop."+structure.getVelocityVarName()+".attachment1");
attachment2FieldVarNm = Config.getStringProperty("pop."+structure.getVelocityVarName()+".attachment2");
attachment3FieldVarNm = Config.getStringProperty("pop."+structure.getVelocityVarName()+".attachment3");
attachment4FieldVarNm = Config.getStringProperty("pop."+structure.getVelocityVarName()+".attachment4");
attachment5FieldVarNm = Config.getStringProperty("pop."+structure.getVelocityVarName()+".attachment5");
attachment6FieldVarNm = Config.getStringProperty("pop."+structure.getVelocityVarName()+".attachment6");
attachment7FieldVarNm = Config.getStringProperty("pop."+structure.getVelocityVarName()+".attachment7");
attachment8FieldVarNm = Config.getStringProperty("pop."+structure.getVelocityVarName()+".attachment8");
attachment9FieldVarNm = Config.getStringProperty("pop."+structure.getVelocityVarName()+".attachment9");
attachment10FieldVarNm = Config.getStringProperty("pop."+structure.getVelocityVarName()+".attachment10");
}catch (Exception e) {
}
List<Field> fields = FieldsCache.getFieldsByStructureVariableName(structure.getVelocityVarName());
ContentletRelationships contRel;
ArrayList<Category> cats;
User systemUser = null;
try {
systemUser = APILocator.getUserAPI().getSystemUser();
} catch (DotDataException e) {
Logger.error(this, e.getMessage());
}
try {
List<Map<String,Object>> emails = EmailUtils.getEmails(host, port, isSSL, username, password);
for(Map<String,Object> email:emails){
Contentlet contentlet = new Contentlet();
contentlet.setStructureInode(structure.getInode());
for (Field field : fields){
if(fieldAPI.isElementConstant(field)){
continue;
}
Object value = null;
// using the standard headers/names from javax.mail.* to retrieve the email headers and field's values below
if(UtilMethods.isSet(messageIdFieldVarNm) && field.getVelocityVarName().equals(messageIdFieldVarNm)){