Example usage for java.util Properties putAll

List of usage examples for java.util Properties putAll

Introduction

In this page you can find the example usage for java.util Properties putAll.

Prototype

@Override
    public synchronized void putAll(Map<?, ?> t) 

Source Link

Usage

From source file:org.apache.james.transport.mailets.remote.delivery.RemoteDeliveryConfiguration.java

public Properties createFinalJavaxProperties() {
    Properties props = new Properties();
    props.put("mail.debug", "false");
    // Reactivated: javamail 1.3.2 should no more have problems with "250 OK" messages
    // (WAS "false": Prevents problems encountered with 250 OK Messages)
    props.put("mail.smtp.ehlo", "true");
    // By setting this property to true the transport is allowed to send 8 bit data to the server (if it supports
    // the 8bitmime extension).
    props.setProperty("mail.smtp.allow8bitmime", "true");
    props.put("mail.smtp.timeout", String.valueOf(smtpTimeout));
    props.put("mail.smtp.connectiontimeout", String.valueOf(connectionTimeout));
    props.put("mail.smtp.sendpartial", String.valueOf(sendPartial));
    props.put("mail.smtp.localhost", heloNameProvider.getHeloName());
    props.put("mail.smtp.starttls.enable", String.valueOf(startTLS));
    props.put("mail.smtp.ssl.enable", String.valueOf(isSSLEnable));
    if (isBindUsed()) {
        // undocumented JavaMail 1.2 feature, smtp transport will use
        // our socket factory, which will also set the local address
        props.put("mail.smtp.socketFactory.class", RemoteDeliverySocketFactory.class.getClass());
        // Don't fallback to the standard socket factory on error, do throw an exception
        props.put("mail.smtp.socketFactory.fallback", "false");
    }/*from   w ww .  j ava2  s.  c  o m*/
    if (authUser != null) {
        props.put("mail.smtp.auth", "true");
    }
    props.putAll(javaxAdditionalProperties);
    return props;
}

From source file:edu.isi.wings.portal.classes.Config.java

public Properties getProperties(Domain domain) {
    Properties props = new Properties();
    if (domain != null) {
        props = domain.getProperties();/*  w  ww .  jav a  2  s . c  o m*/
        if (domain.isLegacy())
            return props;

        props.setProperty("ont.dir.url", this.ontdirurl);
        if (!domain.getUseSharedTripleStore())
            props.setProperty("ont.dir.map",
                    "file:" + domain.getDomainDirectory() + File.separator + "ontology");

        props.setProperty("ont.data.url", this.getDataOntologyUrl());
        props.setProperty("ont.component.url", this.getComponentOntologyUrl());
        props.setProperty("ont.workflow.url", this.getWorkflowOntologyUrl());
        props.setProperty("ont.execution.url", this.getExecutionOntologyUrl());
        if (domain.getUseSharedTripleStore())
            props.setProperty("tdb.repository.dir", this.getTripleStoreDir());

        ExeEngine pengine = engines.get(domain.getPlanEngine());
        ExeEngine sengine = engines.get(domain.getStepEngine());
        props.putAll(pengine.getProperties());
        props.putAll(sengine.getProperties());
    } else {
        props.setProperty("tdb.repository.dir", this.getTripleStoreDir());
    }
    props.setProperty("dot.path", this.getDotFile());

    if (this.getResourceOntologyUrl() == null)
        this.setResourceOntologyUrl(ontdirurl + "/resource.owl");
    props.setProperty("ont.resource.url", this.getResourceOntologyUrl());
    props.setProperty("lib.resource.url", this.getExportCommunityUrl() + "/resource/library.owl");
    props.setProperty("lib.provenance.url", this.getExportCommunityUrl() + "/provenance/library.owl");

    if (this.viewerId != null)
        props.setProperty("viewer.id", this.viewerId);
    if (this.userId != null)
        props.setProperty("user.id", this.userId);

    return props;
}

From source file:edu.ku.brc.specify.tasks.ReportsBaseTask.java

/**
 * Prints a Label / Reports from a command
 * @param cmdAction the command/*from w  w  w  . j av a2s  .  c  o  m*/
 */
protected void printReport(final CommandAction cmdAction) {
    // Get the original set of params
    Properties params = cmdAction.getProperties();
    if (params == null) {
        params = new Properties();
    }

    // No add the additional params
    String paramList = cmdAction.getPropertyAsString("params");
    if (StringUtils.isNotEmpty(paramList)) {
        params.putAll(UIHelper.parseProperties(paramList));
    }

    String impStr = params.getProperty("isimport");
    String rsDropStr = params.getProperty("hasrsdropparam");
    RecordSet spRep = (RecordSet) params.get("spreport");
    if (spRep != null) {
        //SpReport was clicked. Just Run it
        CommandAction runner = new CommandAction(REPORTS, RUN_REPORT, cmdAction);
        CommandDispatcher.dispatch(runner);
        return;
    }

    boolean canRunWithoutRS = spRep != null
            || (impStr != null && impStr.equals("1") && rsDropStr != null && rsDropStr.equals("0"));
    if (cmdAction.getData() instanceof RecordSetIFace || canRunWithoutRS) {
        RecordSetIFace recordSet = cmdAction.getData() instanceof RecordSetIFace
                ? (RecordSetIFace) cmdAction.getData()
                : null;

        // XXX For the Demo and until I revist a generalized way of associating a default set of reports and labels
        // to To things. One way to get here with a null title is to click on the Labels btn from the search results
        if (recordSet != null && recordSet.getDbTableId() != null && recordSet.getDbTableId() == 1
                && cmdAction.getPropertyAsString("title") == null) {
            cmdAction.setProperty("file", "fish_label.jrxml");
            cmdAction.setProperty("title", "Fish Labels");

        } else if (recordSet != null && recordSet.getDbTableId() != null && recordSet.getDbTableId() == 52
                && cmdAction.getPropertyAsString("title") == null) {
            // XXX For the Demo and until I revist a generalized way of associating a default set of reports and labels
            // to To things. One way to get here with a null title is to click on the Labels btn from the search results
            cmdAction.setProperty("file", "LoanInvoice.jrxml");
            cmdAction.setProperty("title", "Loan Invoice");
        }

        if (recordSet == null || checkForALotOfLabels(recordSet)) {
            String labelFileName = cmdAction.getPropertyAsString("file");

            if (StringUtils.isEmpty(labelFileName)) {
                labelFileName = askForLabelName();
            }

            if (StringUtils.isNotEmpty(labelFileName)) {
                Taskable originatingTask = (Taskable) cmdAction.getProperty(NavBoxAction.ORGINATING_TASK);
                //System.out.println("************** "+(new File("/home/rods/Specify/reportsCache_Linux/fish_label.jrxml").lastModified()));
                doLabels(labelFileName, cmdAction.getPropertyAsString("title"), recordSet, params,
                        originatingTask == null ? this : originatingTask,
                        (ImageIcon) cmdAction.getProperty("icon"));
            }
        }

    } else if (cmdAction.getData() instanceof JRDataSource) {
        String labelFileName = cmdAction.getPropertyAsString("file");

        if (StringUtils.isEmpty(labelFileName)) {
            labelFileName = askForLabelName();
        }

        if (StringUtils.isNotEmpty(labelFileName)) {
            Taskable originatingTask = (Taskable) cmdAction.getProperty(NavBoxAction.ORGINATING_TASK);
            doLabels(labelFileName, cmdAction.getPropertyAsString("title"), cmdAction.getData(), params,
                    originatingTask, (ImageIcon) cmdAction.getProperty("icon"));
        }

    } else {
        String tableIDStr = cmdAction.getPropertyAsString("tableid");
        if (StringUtils.isNotEmpty(tableIDStr) && StringUtils.isNumeric(tableIDStr)) {
            RecordSetIFace recordSet = RecordSetTask.askForRecordSet(Integer.parseInt(tableIDStr));
            if (recordSet != null) {
                doLabels(cmdAction.getPropertyAsString("file"), cmdAction.getPropertyAsString("title"),
                        recordSet, params, this, (ImageIcon) cmdAction.getProperty("icon"));
            } else {
                UIRegistry.displayLocalizedStatusBarText("RecordSetTask.NoRecordsets");
            }
        }

    }

}

From source file:edu.isi.wings.portal.classes.config.Config.java

public Properties getProperties(Domain domain) {
    Properties props = new Properties();
    if (domain != null) {
        props = domain.getProperties();//w  w w. jav a  2s.co  m
        if (domain.isLegacy())
            return props;

        props.setProperty("ont.dir.url", this.ontdirurl);
        if (!domain.getUseSharedTripleStore())
            props.setProperty("ont.dir.map",
                    "file:" + domain.getDomainDirectory() + File.separator + "ontology");

        props.setProperty("ont.data.url", this.getDataOntologyUrl());
        props.setProperty("ont.component.url", this.getComponentOntologyUrl());
        props.setProperty("ont.workflow.url", this.getWorkflowOntologyUrl());
        props.setProperty("ont.execution.url", this.getExecutionOntologyUrl());
        if (domain.getUseSharedTripleStore())
            props.setProperty("tdb.repository.dir", this.getTripleStoreDir());

        ExeEngine pengine = engines.get(domain.getPlanEngine());
        ExeEngine sengine = engines.get(domain.getStepEngine());
        props.putAll(pengine.getProperties());
        props.putAll(sengine.getProperties());
    } else {
        props.setProperty("tdb.repository.dir", this.getTripleStoreDir());
    }
    props.setProperty("dot.path", this.getDotFile());

    if (this.getResourceOntologyUrl() == null)
        this.setResourceOntologyUrl(ontdirurl + "/resource.owl");
    props.setProperty("ont.resource.url", this.getResourceOntologyUrl());

    props.setProperty("lib.resource.url", this.getExportCommunityUrl() + "/resource/library.owl");

    if (domain != null && !domain.getUseSharedTripleStore())
        props.setProperty("lib.resource.map", "file:" + domain.getDomainDirectory() + File.separator
                + "ontology" + File.separator + "resource" + File.separator + "library.owl");

    props.setProperty("lib.provenance.url", this.getExportCommunityUrl() + "/provenance/library.owl");

    if (this.viewerId != null)
        props.setProperty("viewer.id", this.viewerId);
    if (this.userId != null)
        props.setProperty("user.id", this.userId);

    return props;
}

From source file:org.apache.maven.archetype.creator.FilesetArchetypeCreator.java

public void createArchetype(ArchetypeCreationRequest request, ArchetypeCreationResult result) {
    MavenProject project = request.getProject();
    List<String> languages = request.getLanguages();
    List<String> filtereds = request.getFiltereds();
    String defaultEncoding = request.getDefaultEncoding();
    boolean preserveCData = request.isPreserveCData();
    boolean keepParent = request.isKeepParent();
    boolean partialArchetype = request.isPartialArchetype();
    ArtifactRepository localRepository = request.getLocalRepository();
    File outputDirectory = request.getOutputDirectory();
    File basedir = project.getBasedir();

    Properties properties = new Properties();
    Properties configurationProperties = new Properties();
    if (request.getProperties() != null) {
        properties.putAll(request.getProperties());
        configurationProperties.putAll(request.getProperties());
    }/*  w w  w  .  ja  va  2  s  . com*/

    extractPropertiesFromProject(project, properties, configurationProperties, request.getPackageName());

    if (outputDirectory == null) {
        getLogger().debug("No output directory defined, using default: " + DEFAULT_OUTPUT_DIRECTORY);
        outputDirectory = FileUtils.resolveFile(basedir, DEFAULT_OUTPUT_DIRECTORY);
    }
    outputDirectory.mkdirs();

    getLogger().debug("Creating archetype in " + outputDirectory);

    try {
        File archetypePomFile = createArchetypeProjectPom(project, localRepository, configurationProperties,
                outputDirectory);

        File archetypeResourcesDirectory = new File(outputDirectory, getTemplateOutputDirectory());

        File archetypeFilesDirectory = new File(archetypeResourcesDirectory, Constants.ARCHETYPE_RESOURCES);
        getLogger().debug("Archetype's files output directory " + archetypeFilesDirectory);

        File archetypeDescriptorFile = new File(archetypeResourcesDirectory, Constants.ARCHETYPE_DESCRIPTOR);
        archetypeDescriptorFile.getParentFile().mkdirs();

        File archetypePostGenerationScript = new File(archetypeResourcesDirectory,
                Constants.ARCHETYPE_POST_GENERATION_SCRIPT);
        archetypePostGenerationScript.getParentFile().mkdirs();

        if (request.getProject().getBuild() != null
                && CollectionUtils.isNotEmpty(request.getProject().getBuild().getResources())) {
            for (Resource resource : request.getProject().getBuild().getResources()) {
                File inputFile = new File(
                        resource.getDirectory() + File.separator + Constants.ARCHETYPE_POST_GENERATION_SCRIPT);
                if (inputFile.exists()) {
                    FileUtils.copyFile(inputFile, archetypePostGenerationScript);
                }
            }
        }

        getLogger().debug("Starting archetype's descriptor " + project.getArtifactId());
        ArchetypeDescriptor archetypeDescriptor = new ArchetypeDescriptor();

        archetypeDescriptor.setName(project.getArtifactId());
        archetypeDescriptor.setPartial(partialArchetype);

        addRequiredProperties(archetypeDescriptor, properties);

        // TODO ensure reverseProperties contains NO dotted properties
        Properties reverseProperties = getReversedProperties(archetypeDescriptor, properties);
        // reverseProperties.remove( Constants.GROUP_ID );

        // TODO ensure pomReversedProperties contains NO dotted properties
        Properties pomReversedProperties = getReversedProperties(archetypeDescriptor, properties);
        // pomReversedProperties.remove( Constants.PACKAGE );

        String packageName = configurationProperties.getProperty(Constants.PACKAGE);

        Model pom = pomManager.readPom(FileUtils.resolveFile(basedir, Constants.ARCHETYPE_POM));

        List<String> excludePatterns = configurationProperties.getProperty(Constants.EXCLUDE_PATTERNS) != null
                ? Arrays.asList(
                        StringUtils.split(configurationProperties.getProperty(Constants.EXCLUDE_PATTERNS), ","))
                : Collections.<String>emptyList();

        List<String> fileNames = resolveFileNames(pom, basedir, excludePatterns);
        if (getLogger().isDebugEnabled()) {
            getLogger().debug("Scanned for files " + fileNames.size());

            for (String name : fileNames) {
                getLogger().debug("- " + name);
            }
        }

        List<FileSet> filesets = resolveFileSets(packageName, fileNames, languages, filtereds, defaultEncoding);
        getLogger().debug("Resolved filesets for " + archetypeDescriptor.getName());

        archetypeDescriptor.setFileSets(filesets);

        createArchetypeFiles(reverseProperties, filesets, packageName, basedir, archetypeFilesDirectory,
                defaultEncoding);
        getLogger().debug("Created files for " + archetypeDescriptor.getName());

        setParentArtifactId(reverseProperties, configurationProperties.getProperty(Constants.ARTIFACT_ID));

        for (Iterator<String> modules = pom.getModules().iterator(); modules.hasNext();) {
            String moduleId = (String) modules.next();
            String rootArtifactId = configurationProperties.getProperty(Constants.ARTIFACT_ID);
            String moduleIdDirectory = moduleId;

            if (moduleId.indexOf(rootArtifactId) >= 0) {
                moduleIdDirectory = StringUtils.replace(moduleId, rootArtifactId, "__rootArtifactId__");
            }

            getLogger().debug("Creating module " + moduleId);

            ModuleDescriptor moduleDescriptor = createModule(reverseProperties, rootArtifactId, moduleId,
                    packageName, FileUtils.resolveFile(basedir, moduleId),
                    new File(archetypeFilesDirectory, moduleIdDirectory), languages, filtereds, defaultEncoding,
                    preserveCData, keepParent);

            archetypeDescriptor.addModule(moduleDescriptor);

            getLogger().debug(
                    "Added module " + moduleDescriptor.getName() + " in " + archetypeDescriptor.getName());
        }

        restoreParentArtifactId(reverseProperties, null);
        restoreArtifactId(reverseProperties, configurationProperties.getProperty(Constants.ARTIFACT_ID));

        createPoms(pom, configurationProperties.getProperty(Constants.ARTIFACT_ID),
                configurationProperties.getProperty(Constants.ARTIFACT_ID), archetypeFilesDirectory, basedir,
                pomReversedProperties, preserveCData, keepParent);
        getLogger().debug("Created Archetype " + archetypeDescriptor.getName() + " template pom(s)");

        Writer out = null;
        try {
            out = WriterFactory.newXmlWriter(archetypeDescriptorFile);

            ArchetypeDescriptorXpp3Writer writer = new ArchetypeDescriptorXpp3Writer();

            writer.write(out, archetypeDescriptor);

            getLogger().debug("Archetype " + archetypeDescriptor.getName() + " descriptor written");
        } finally {
            IOUtil.close(out);
        }

        createArchetypeBasicIt(archetypeDescriptor, outputDirectory);

        // Copy archetype integration tests.
        File archetypeIntegrationTestInputFolder = new File(basedir,
                Constants.SRC + File.separator + "it" + File.separator + "projects");
        File archetypeIntegrationTestOutputFolder = new File(outputDirectory, Constants.SRC + File.separator
                + Constants.TEST + File.separator + Constants.RESOURCES + File.separator + "projects");

        if (archetypeIntegrationTestInputFolder.exists()) {
            getLogger().info("Copying: " + archetypeIntegrationTestInputFolder.getAbsolutePath() + " into "
                    + archetypeIntegrationTestOutputFolder.getAbsolutePath());

            FileUtils.copyDirectoryStructure(archetypeIntegrationTestInputFolder,
                    archetypeIntegrationTestOutputFolder);

        }
        InvocationRequest internalRequest = new DefaultInvocationRequest();
        internalRequest.setPomFile(archetypePomFile);
        internalRequest.setGoals(Collections.singletonList(request.getPostPhase()));

        Invoker invoker = new DefaultInvoker();
        InvocationResult invokerResult = invoker.execute(internalRequest);
        if (invokerResult.getExitCode() != 0) {
            if (invokerResult.getExecutionException() != null) {
                throw invokerResult.getExecutionException();
            } else {
                throw new Exception("Invoker process ended with result different than 0!");
            }
        }

    } catch (Exception e) {
        result.setCause(e);
    }
}

From source file:org.apache.juddi.v3.client.config.UDDIClerk.java

/**
 * Registers a WSDL Definition onto the UDDI node referenced by the
 * clerk. Note, if registration fails, no exception is thrown
 *
 * @param wsdlDefinition - the WSDL Definition
 * @param keyDomain - the keyDomain which will be used to construct the
 * UDDI key IDs. If left null the keyDomain defined in the node's
 * properties will be used./*from  ww  w .java 2 s.co m*/
 * @param businessKey - the key of the business to which this service
 * belongs. If left null the businessKey defined in the node's
 * properties will be used.
 *
 */
public void registerWsdls(Definition wsdlDefinition, String keyDomain, String businessKey) {

    try {
        Properties properties = new Properties();
        properties.putAll(this.getUDDINode().getProperties());
        if (keyDomain != null) {
            properties.setProperty("keyDomain", keyDomain);
        }
        if (businessKey != null) {
            properties.setProperty("businessKey", businessKey);
        }

        WSDL2UDDI wsdl2UDDI = new WSDL2UDDI(this, new URLLocalizerDefaultImpl(), properties);
        wsdl2UDDI.registerBusinessServices(wsdlDefinition);
    } catch (Exception e) {
        log.error("Unable to register wsdl " + " ." + e.getMessage(), e);
    } catch (Throwable t) {
        log.error("Unable to register wsdl " + " ." + t.getMessage(), t);
    }
}

From source file:org.apache.juddi.v3.client.config.UDDIClerk.java

/**
 * Removes the UDDI data structures belonging to the WSDLs for this
 * clerk from the UDDI node. Note, if registration fails, no exception
 * is thrown/*from www .j av  a2 s.  c  o m*/
 */
public void unRegisterWsdls() {
    if (this.getWsdls() != null) {
        Properties properties = new Properties();
        properties.putAll(this.getUDDINode().getProperties());

        for (WSDL wsdl : this.getWsdls()) {
            try {
                URL wsdlUrl = this.getClass().getClassLoader().getResource(wsdl.getFileName());
                ReadWSDL rw = new ReadWSDL();
                Definition wsdlDefinition = rw.readWSDL(wsdlUrl);
                if (wsdl.keyDomain != null) {
                    properties.setProperty("keyDomain", wsdl.keyDomain);
                }
                if (wsdl.businessKey != null) {
                    properties.setProperty("businessKey", wsdl.getBusinessKey());
                }

                WSDL2UDDI wsdl2UDDI = new WSDL2UDDI(this, new URLLocalizerDefaultImpl(), properties);
                wsdl2UDDI.unRegisterBusinessServices(wsdlDefinition);
            } catch (Exception e) {
                log.error("Unable to register wsdl " + wsdl.getFileName() + " ." + e.getMessage(), e);
            } catch (Throwable t) {
                log.error("Unable to register wsdl " + wsdl.getFileName() + " ." + t.getMessage(), t);
            }
        }
    }
}

From source file:org.apache.juddi.v3.client.config.UDDIClerk.java

/**
 * Registers the WSDL files referenced in the clerk onto the UDDI node
 * referenced by the clerk. Note, if registration fails, no exception is
 * thrown//ww  w . j  a  va2 s  .  co m
 * <pre>
 * {@code
 * <clerks registerOnStartup="false">
 *     <clerk name="joe" node="default" publisher="joepublisher" password="joepublisher" isPasswordEncrypted="false" cryptoProvider="">
 *        <wsdl businessName="WSDL-Business">wsdl/helloworld.wsdl</wsdl>
 *     </clerk>
 *  </clerks>
 * }
 * </pre>
 *
 * @param localizerBaseUrl - The baseUrl part which will be used when
 * building the bindingTemplate.
 */
public void registerWsdls(URL localizerBaseUrl) {
    if (this.getWsdls() != null) {
        Properties properties = new Properties();
        properties.putAll(this.getUDDINode().getProperties());

        for (WSDL wsdl : this.getWsdls()) {
            try {
                URL wsdlUrl = this.getClass().getClassLoader().getResource(wsdl.getFileName());
                ReadWSDL rw = new ReadWSDL();
                Definition wsdlDefinition = rw.readWSDL(wsdlUrl);
                if (wsdl.keyDomain != null) {
                    properties.setProperty("keyDomain", wsdl.keyDomain);
                }
                if (wsdl.businessKey != null) {
                    properties.setProperty("businessKey", wsdl.getBusinessKey());
                }

                WSDL2UDDI wsdl2UDDI = new WSDL2UDDI(this, new URLLocalizerDefaultImpl(localizerBaseUrl),
                        properties);
                wsdl2UDDI.registerBusinessServices(wsdlDefinition);
            } catch (Exception e) {
                log.error("Unable to register wsdl " + wsdl.getFileName() + " ." + e.getMessage(), e);
            } catch (Throwable t) {
                log.error("Unable to register wsdl " + wsdl.getFileName() + " ." + t.getMessage(), t);
            }
        }
    }
}

From source file:cytoscape.CyMain.java

License:asdf

private Properties createProperties(String[] potentialProps) {
    // for ( String asdf: potentialProps)
    // logger.info("prop: '" + asdf + "'");
    Properties props = new Properties();
    Properties argProps = new Properties();

    Matcher propPattern = Pattern.compile("^((\\w+\\.*)+)\\=(.+)$").matcher("");

    for (int i = 0; i < potentialProps.length; i++) {
        propPattern.reset(potentialProps[i]);

        // check to see if the string is a key value pair
        if (propPattern.matches()) {
            argProps.setProperty(propPattern.group(1), propPattern.group(3));

            // otherwise assume it's a file/url
        } else {/*from w w w .j  av a  2 s .  c om*/
            try {
                InputStream in = null;

                try {
                    in = FileUtil.getInputStream(potentialProps[i]);
                    if (in != null)
                        props.load(in);
                    else
                        logger.info("Couldn't load property: " + potentialProps[i]);
                } finally {
                    if (in != null) {
                        in.close();
                    }
                }
            } catch (IOException e) {
                logger.warn("Couldn't load property '" + potentialProps[i] + "' from file: " + e.getMessage(),
                        e);
            }
        }
    }

    // Transfer argument properties into the full properties.
    // We do this so that anything specified on the command line
    // overrides anything specified in a file.
    props.putAll(argProps);

    addDefaultProps(props);

    return props;
}

From source file:org.opencastproject.capture.impl.SchedulerImpl.java

/**
 * A helper function to wrap the configuration of an event. This function writes the attached files to disk and
 * generates the initial {@code Mediapackage}.
 * //from   ww w  .ja va  2s .  c  o  m
 * @param attachments
 *          The {@code PropertyList} of the capture. This contains all of the attachments and such needed to setup the
 *          directory structure.
 * @param props
 *          The system {@code Properties} for the job. This can be overridden by the properties attached to the event.
 * @param job
 *          The {@code JobDetail} instance itself. This is what everything gets attached to so that Quartz can run
 *          properly.
 * @throws org.opencastproject.util.ConfigurationException
 * @throws MediaPackageException
 * @throws MalformedURLException
 * @throws ParseException
 */
@SuppressWarnings("unchecked")
private void setupEvent(PropertyList attachments, Properties props, JobDetail job)
        throws org.opencastproject.util.ConfigurationException, MediaPackageException, MalformedURLException,
        ParseException {
    MediaPackage pack = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder().createNew();
    pack.setIdentifier(new IdImpl(props.getProperty(CaptureParameters.RECORDING_ID)));

    // Create the directory we'll be capturing into
    File captureDir = new File(configService.getItem(CaptureParameters.CAPTURE_FILESYSTEM_CAPTURE_CACHE_URL),
            props.getProperty(CaptureParameters.RECORDING_ID));
    if (!captureDir.exists()) {
        try {
            FileUtils.forceMkdir(captureDir);
        } catch (IOException e) {
            log.error("IOException creating required directory {}, skipping capture.", captureDir.toString());
            return;
        }
    }

    ListIterator<Property> iter = (ListIterator<Property>) attachments.listIterator();
    // For each attachment
    while (iter.hasNext()) {
        Property p = iter.next();
        // TODO: Make this not hardcoded? Make this not depend on Apple's idea of rfc 2445?
        String filename = p.getParameter("X-APPLE-FILENAME").getValue();
        if (filename == null) {
            log.warn("No filename given for attachment, skipping.");
            continue;
        }
        // Get the contents of the attachment. Note that this assumes the attachment is a string of some sorts
        // This breaks with binary files (probably)
        String contents = propertyToString(p);

        // Handle any attachments
        try {
            // If the event has properties
            if (filename.equals(CaptureParameters.RECORDING_PROPERTIES)) {
                // Load the properties
                Properties jobProps = new Properties();
                StringReader s = new StringReader(contents);
                jobProps.load(s);
                s.close();
                // Merge them overtop of the system properties
                jobProps.putAll(props);
                // Attach the properties to the job itself
                job.getJobDataMap().put(JobParameters.CAPTURE_PROPS, jobProps);
                // And attach the properties file to the mediapackage
                pack.add(new URI(filename));
                // Handle the episode metadata
            } else if ("episode.xml".equals(filename)) {
                pack.add(new URI(filename), MediaPackageElement.Type.Catalog, MediaPackageElements.EPISODE);
                // Handle the series metadata
            } else if ("series.xml".equals(filename)) {
                pack.add(new URI(filename), MediaPackageElement.Type.Catalog, MediaPackageElements.SERIES);
            } else {
                pack.add(new URI(filename));
            }
        } catch (IOException e) {
            log.error("Unable to read properties file attached to event {}!",
                    props.getProperty(CaptureParameters.RECORDING_ID));
        } catch (URISyntaxException e) {
            log.error("Unable to add file {} to mediapackage: {}.", filename, e);
        }
        job.getJobDataMap().put(JobParameters.MEDIA_PACKAGE, pack);
        // Note that we overwrite any pre-existing files with this. In other words, if there is a file called foo.txt in
        // the
        // captureDir directory and there is an attachment called foo.txt then we will overwrite the one on disk with the
        // one from the ical
        URL u = new File(captureDir, filename).toURI().toURL();
        try {
            IoSupport.writeUTF8File(u, contents);
        } catch (IOException e) {
            log.error("Unable to write to {}, IOException occurred", u.toString());
        }
    }

    job.getJobDataMap().put(JobParameters.CAPTURE_AGENT, captureAgent);
    job.getJobDataMap().put(JobParameters.JOB_SCHEDULER, scheduler);
}