Example usage for java.net URI resolve

List of usage examples for java.net URI resolve

Introduction

In this page you can find the example usage for java.net URI resolve.

Prototype

public URI resolve(String str) 

Source Link

Document

Constructs a new URI by parsing the given string and then resolving it against this URI.

Usage

From source file:edu.mayo.informatics.lexgrid.convert.directConversions.UMLSHistoryFileToSQL.java

/**
 * Private method, reads MRCONSO.RRF file and loads the concept descriptions
 * in a Map.//from   www  . j a  v a2 s  . co  m
 * 
 * @param metaFolderPath
 * @throws Exception
 */
private void readMrConso(URI metaFolderPath) throws Exception {

    if (metaFolderPath == null) {
        if (failOnAllErrors_) {
            message_.fatalAndThrowException("URI unspecified for 'MRCONSO.RRF' file.");
        }
    }

    Snapshot snap1 = SimpleMemUsageReporter.snapshot();
    message_.info("Reading 'MRCONSO.RRF'...");

    BufferedReader mrconsoFile = null;

    try {
        mrconsoFile = getReader(metaFolderPath.resolve("MRCONSO.RRF"));

        String line = mrconsoFile.readLine();

        int lineNo = 0;
        while (line != null) {

            ++lineNo;

            if (line.startsWith("#") || line.length() == 0) {
                line = mrconsoFile.readLine();
                continue;
            }

            List<String> elements = deTokenizeString(line, token_);
            if (elements.size() > 14 && "y".equalsIgnoreCase(elements.get(6))) {

                if (!mrconsoConceptName_.keySet().contains(elements.get(0))) {
                    mrconsoConceptName_.put(elements.get(0), elements.get(14));
                }
            }
            line = mrconsoFile.readLine();
        }

    } catch (MalformedURLException e) {
        message_.error("Exceptions while reading MRCONSO.RRF: " + e.getMessage());
    } catch (IOException e) {
        message_.error("Exceptions while reading MRCONSO.RRF: " + e.getMessage());
    } finally {
        mrconsoFile.close();
    }

    Snapshot snap2 = SimpleMemUsageReporter.snapshot();
    message_.info("Done reading 'MRCONSO.RRF': Time taken: "
            + SimpleMemUsageReporter.formatTimeDiff(snap2.getTimeDelta(snap1)));

}

From source file:org.kitodo.services.file.FileServiceTest.java

@Test
public void testMoveDirectoryWithExistingTarget() throws IOException {
    URI directory = fileService.createDirectory(URI.create("fileServiceTest"), "movingDirectoryTargetMissing");
    fileService.createResource(directory, "test.xml");
    URI target = fileService.createDirectory(URI.create("fileServiceTest"), "movingTargetMissing");
    fileService.createResource(target, "testTarget.xml");

    Assert.assertTrue(fileService.fileExist(directory));
    Assert.assertTrue(fileService.fileExist(directory.resolve("test.xml")));
    Assert.assertTrue(fileService.fileExist(target));
    Assert.assertTrue(fileService.fileExist(target.resolve("testTarget.xml")));

    fileService.moveDirectory(directory, target);

    Assert.assertFalse(fileService.fileExist(directory));
    Assert.assertFalse(fileService.fileExist(directory.resolve("test.xml")));
    Assert.assertTrue(fileService.fileExist(target));
    Assert.assertTrue(fileService.fileExist(target.resolve("test.xml")));
    Assert.assertTrue(fileService.fileExist(target.resolve("testTarget.xml")));

}

From source file:org.kitodo.export.ExportDms.java

/**
 * Download image./*from  www.  j av a 2 s .c  o m*/
 *
 * @param process
 *            object
 * @param userHome
 *            File
 * @param atsPpnBand
 *            String
 * @param ordnerEndung
 *            String
 */
public void imageDownload(Process process, URI userHome, String atsPpnBand, final String ordnerEndung)
        throws IOException {
    // determine the source folder
    URI tifOrdner = ServiceManager.getProcessService().getImagesTifDirectory(true, process.getId(),
            process.getTitle(), process.getProcessBaseUri());

    // copy the source folder to the destination folder
    if (fileService.fileExist(tifOrdner) && !fileService.getSubUris(tifOrdner).isEmpty()) {
        URI zielTif = userHome.resolve(atsPpnBand + ordnerEndung + "/");

        /* bei Agora-Import einfach den Ordner anlegen */
        if (process.getProject().isUseDmsImport()) {
            if (!fileService.fileExist(zielTif)) {
                fileService.createDirectory(userHome, atsPpnBand + ordnerEndung);
            }
        } else {
            // if no async import, then create the folder with user
            // authorization again
            User user = ServiceManager.getUserService().getAuthenticatedUser();
            try {
                fileService.createDirectoryForUser(zielTif, user.getLogin());
            } catch (IOException e) {
                handleException(e, process.getTitle());
                throw e;
            } catch (RuntimeException e) {
                handleException(e, process.getTitle());
            }
        }

        if (Objects.nonNull(exportDmsTask)) {
            exportDmsTask.setWorkDetail(null);
        }
    }
}

From source file:org.opencb.opencga.storage.app.cli.client.executors.VariantCommandExecutor.java

private void annotation()
        throws StorageEngineException, IOException, URISyntaxException, VariantAnnotatorException {
    StorageVariantCommandOptions.VariantAnnotateCommandOptions annotateVariantsCommandOptions = variantCommandOptions.annotateVariantsCommandOptions;

    VariantDBAdaptor dbAdaptor = variantStorageEngine.getDBAdaptor(annotateVariantsCommandOptions.dbName);

    /*/*from   www  .  j  a  v  a  2  s .com*/
     * Create Annotator
     */
    ObjectMap options = configuration.getStorageEngine(storageEngine).getVariant().getOptions();
    if (annotateVariantsCommandOptions.annotator != null) {
        options.put(VariantAnnotationManager.ANNOTATION_SOURCE, annotateVariantsCommandOptions.annotator);
    }
    if (annotateVariantsCommandOptions.customAnnotationKey != null) {
        options.put(VariantAnnotationManager.CUSTOM_ANNOTATION_KEY,
                annotateVariantsCommandOptions.customAnnotationKey);
    }
    if (annotateVariantsCommandOptions.species != null) {
        options.put(VariantAnnotationManager.SPECIES, annotateVariantsCommandOptions.species);
    }
    if (annotateVariantsCommandOptions.assembly != null) {
        options.put(VariantAnnotationManager.ASSEMBLY, annotateVariantsCommandOptions.assembly);
    }
    options.putAll(annotateVariantsCommandOptions.commonOptions.params);

    VariantAnnotator annotator = VariantAnnotatorFactory.buildVariantAnnotator(configuration, storageEngine,
            options);
    //            VariantAnnotator annotator = VariantAnnotationManager.buildVariantAnnotator(annotatorSource, annotatorProperties,
    // annotateVariantsCommandOptions.species, annotateVariantsCommandOptions.assembly);
    DefaultVariantAnnotationManager variantAnnotationManager = new DefaultVariantAnnotationManager(annotator,
            dbAdaptor);

    /*
     * Annotation options
     */
    Query query = new Query();
    if (annotateVariantsCommandOptions.filterRegion != null) {
        query.put(VariantDBAdaptor.VariantQueryParams.REGION.key(),
                annotateVariantsCommandOptions.filterRegion);
    }
    if (annotateVariantsCommandOptions.filterChromosome != null) {
        query.put(VariantDBAdaptor.VariantQueryParams.CHROMOSOME.key(),
                annotateVariantsCommandOptions.filterChromosome);
    }
    if (annotateVariantsCommandOptions.filterGene != null) {
        query.put(VariantDBAdaptor.VariantQueryParams.GENE.key(), annotateVariantsCommandOptions.filterGene);
    }
    if (annotateVariantsCommandOptions.filterAnnotConsequenceType != null) {
        query.put(VariantDBAdaptor.VariantQueryParams.ANNOT_CONSEQUENCE_TYPE.key(),
                annotateVariantsCommandOptions.filterAnnotConsequenceType);
    }
    if (!annotateVariantsCommandOptions.overwriteAnnotations) {
        query.put(VariantDBAdaptor.VariantQueryParams.ANNOTATION_EXISTS.key(), false);
    }
    URI outputUri = UriUtils.createUri(
            annotateVariantsCommandOptions.outdir == null ? "." : annotateVariantsCommandOptions.outdir);
    Path outDir = Paths.get(outputUri.resolve(".").getPath());

    /*
     * Create and load annotations
     */
    boolean doCreate = annotateVariantsCommandOptions.create,
            doLoad = annotateVariantsCommandOptions.load != null;
    if (!annotateVariantsCommandOptions.create && annotateVariantsCommandOptions.load == null) {
        doCreate = true;
        doLoad = true;
    }

    URI annotationFile = null;
    if (doCreate) {
        long start = System.currentTimeMillis();
        logger.info("Starting annotation creation ");
        annotationFile = variantAnnotationManager.createAnnotation(outDir,
                annotateVariantsCommandOptions.fileName == null ? annotateVariantsCommandOptions.dbName
                        : annotateVariantsCommandOptions.fileName,
                query, new QueryOptions(options));
        logger.info("Finished annotation creation {}ms", System.currentTimeMillis() - start);
    }

    if (doLoad) {
        long start = System.currentTimeMillis();
        logger.info("Starting annotation load");
        if (annotationFile == null) {
            //                annotationFile = new URI(null, c.load, null);
            annotationFile = Paths.get(annotateVariantsCommandOptions.load).toUri();
        }
        variantAnnotationManager.loadAnnotation(annotationFile, new QueryOptions(options));

        logger.info("Finished annotation load {}ms", System.currentTimeMillis() - start);
    }
}

From source file:org.opencb.opencga.storage.app.cli.client.executors.VariantCommandExecutor.java

private void stats() throws IOException, URISyntaxException, StorageEngineException, IllegalAccessException,
        InstantiationException, ClassNotFoundException {
    StorageVariantCommandOptions.VariantStatsCommandOptions statsVariantsCommandOptions = variantCommandOptions.statsVariantsCommandOptions;

    ObjectMap options = storageConfiguration.getVariant().getOptions();
    if (statsVariantsCommandOptions.dbName != null && !statsVariantsCommandOptions.dbName.isEmpty()) {
        options.put(VariantStorageEngine.Options.DB_NAME.key(), statsVariantsCommandOptions.dbName);
    }//w ww .  ja  v  a  2s  .  com
    options.put(VariantStorageEngine.Options.OVERWRITE_STATS.key(), statsVariantsCommandOptions.overwriteStats);
    options.put(VariantStorageEngine.Options.UPDATE_STATS.key(), statsVariantsCommandOptions.updateStats);
    options.putIfNotEmpty(VariantStorageEngine.Options.FILE_ID.key(), statsVariantsCommandOptions.fileId);
    options.put(VariantStorageEngine.Options.STUDY_ID.key(), statsVariantsCommandOptions.studyId);
    if (statsVariantsCommandOptions.studyConfigurationFile != null
            && !statsVariantsCommandOptions.studyConfigurationFile.isEmpty()) {
        options.put(FileStudyConfigurationManager.STUDY_CONFIGURATION_PATH,
                statsVariantsCommandOptions.studyConfigurationFile);
    }
    options.put(VariantStorageEngine.Options.RESUME.key(), statsVariantsCommandOptions.resume);

    if (statsVariantsCommandOptions.commonOptions.params != null) {
        options.putAll(statsVariantsCommandOptions.commonOptions.params);
    }

    Map<String, Set<String>> cohorts = null;
    if (statsVariantsCommandOptions.cohort != null && !statsVariantsCommandOptions.cohort.isEmpty()) {
        cohorts = new LinkedHashMap<>(statsVariantsCommandOptions.cohort.size());
        for (Map.Entry<String, String> entry : statsVariantsCommandOptions.cohort.entrySet()) {
            List<String> samples = Arrays.asList(entry.getValue().split(","));
            if (samples.size() == 1 && samples.get(0).isEmpty()) {
                samples = new ArrayList<>();
            }
            cohorts.put(entry.getKey(), new HashSet<>(samples));
        }
    }

    options.put(VariantStorageEngine.Options.AGGREGATED_TYPE.key(), statsVariantsCommandOptions.aggregated);

    if (statsVariantsCommandOptions.aggregationMappingFile != null) {
        Properties aggregationMappingProperties = new Properties();
        try {
            aggregationMappingProperties
                    .load(new FileInputStream(statsVariantsCommandOptions.aggregationMappingFile));
            options.put(VariantStorageEngine.Options.AGGREGATION_MAPPING_PROPERTIES.key(),
                    aggregationMappingProperties);
        } catch (FileNotFoundException e) {
            logger.error("Aggregation mapping file {} not found. Population stats won't be parsed.",
                    statsVariantsCommandOptions.aggregationMappingFile);
        }
    }

    /**
     * Create DBAdaptor
     */
    VariantDBAdaptor dbAdaptor = variantStorageEngine
            .getDBAdaptor(options.getString(VariantStorageEngine.Options.DB_NAME.key()));
    //        dbAdaptor.setConstantSamples(Integer.toString(statsVariantsCommandOptions.fileId));    // TODO jmmut: change to studyId when we
    // remove fileId
    StudyConfiguration studyConfiguration = dbAdaptor.getStudyConfigurationManager()
            .getStudyConfiguration(statsVariantsCommandOptions.studyId, new QueryOptions(options)).first();
    if (studyConfiguration == null) {
        studyConfiguration = new StudyConfiguration(Integer.parseInt(statsVariantsCommandOptions.studyId),
                statsVariantsCommandOptions.dbName);
    }
    /**
     * Create and load stats
     */
    URI outputUri = UriUtils.createUri(
            statsVariantsCommandOptions.fileName == null ? "" : statsVariantsCommandOptions.fileName);
    URI directoryUri = outputUri.resolve(".");
    String filename = outputUri.equals(directoryUri)
            ? VariantStorageEngine.buildFilename(studyConfiguration.getStudyName(),
                    Integer.parseInt(statsVariantsCommandOptions.fileId))
            : Paths.get(outputUri.getPath()).getFileName().toString();
    //        assertDirectoryExists(directoryUri);
    DefaultVariantStatisticsManager variantStatisticsManager = new DefaultVariantStatisticsManager(dbAdaptor);

    boolean doCreate = true;
    boolean doLoad = true;
    //        doCreate = statsVariantsCommandOptions.create;
    //        doLoad = statsVariantsCommandOptions.load != null;
    //        if (!statsVariantsCommandOptions.create && statsVariantsCommandOptions.load == null) {
    //            doCreate = doLoad = true;
    //        } else if (statsVariantsCommandOptions.load != null) {
    //            filename = statsVariantsCommandOptions.load;
    //        }

    try {

        Map<String, Integer> cohortIds = statsVariantsCommandOptions.cohortIds.entrySet().stream()
                .collect(Collectors.toMap(Map.Entry::getKey, e -> Integer.parseInt(e.getValue())));

        QueryOptions queryOptions = new QueryOptions(options);
        if (doCreate) {
            filename += "." + TimeUtils.getTime();
            outputUri = outputUri.resolve(filename);
            outputUri = variantStatisticsManager.createStats(dbAdaptor, outputUri, cohorts, cohortIds,
                    studyConfiguration, queryOptions);
        }

        if (doLoad) {
            outputUri = outputUri.resolve(filename);
            variantStatisticsManager.loadStats(dbAdaptor, outputUri, studyConfiguration, queryOptions);
        }
    } catch (Exception e) { // file not found? wrong file id or study id? bad parameters to ParallelTaskRunner?
        e.printStackTrace();
        logger.error(e.getMessage());
    }
}

From source file:org.kitodo.production.services.file.FileServiceTest.java

@Test
public void testCopyDirectoryWithExistingTarget() throws IOException {
    URI fromDirectory = fileService.createDirectory(URI.create("fileServiceTest"),
            "copyDirectoryExistingTarget");
    fileService.createResource(fromDirectory, "testToCopy.pdf");

    URI toDirectory = fileService.createDirectory(URI.create("fileServiceTest"),
            "copyDirectoryNotExistingTarget");
    fileService.createResource(toDirectory, "testExisting.pdf");

    assertTrue(fileService.fileExist(fromDirectory));
    assertTrue(fileService.fileExist(toDirectory));

    fileService.copyDirectory(fromDirectory, toDirectory);

    assertTrue(fileService.fileExist(toDirectory));
    assertTrue(fileService.fileExist(toDirectory.resolve("testToCopy.pdf")));
    assertTrue(fileService.fileExist(toDirectory.resolve("testExisting.pdf")));
    assertTrue(fileService.fileExist(fromDirectory));
    assertTrue(fileService.fileExist(fromDirectory.resolve("testToCopy.pdf")));
    assertFalse(fileService.fileExist(fromDirectory.resolve("testExisting.pdf")));

}

From source file:org.kitodo.services.file.FileServiceTest.java

@Test
public void testCopyDirectoryWithExistingTarget() throws IOException {
    URI fromDirectory = fileService.createDirectory(URI.create("fileServiceTest"),
            "copyDirectoryExistingTarget");
    fileService.createResource(fromDirectory, "testToCopy.pdf");

    URI toDirectory = fileService.createDirectory(URI.create("fileServiceTest"),
            "copyDirectoryNotExistingTarget");
    fileService.createResource(toDirectory, "testExisting.pdf");

    Assert.assertTrue(fileService.fileExist(fromDirectory));
    Assert.assertTrue(fileService.fileExist(toDirectory));

    fileService.copyDirectory(fromDirectory, toDirectory);

    Assert.assertTrue(fileService.fileExist(toDirectory));
    Assert.assertTrue(fileService.fileExist(toDirectory.resolve("testToCopy.pdf")));
    Assert.assertTrue(fileService.fileExist(toDirectory.resolve("testExisting.pdf")));
    Assert.assertTrue(fileService.fileExist(fromDirectory));
    Assert.assertTrue(fileService.fileExist(fromDirectory.resolve("testToCopy.pdf")));
    Assert.assertFalse(fileService.fileExist(fromDirectory.resolve("testExisting.pdf")));

}

From source file:org.opencb.opencga.app.cli.analysis.VariantCommandExecutor.java

@Deprecated
private void annotate(Job job) throws StorageManagerException, IOException, VariantAnnotatorException,
        CatalogException, IllegalAccessException, ClassNotFoundException, InstantiationException {
    AnalysisCliOptionsParser.AnnotateVariantCommandOptions cliOptions = variantCommandOptions.annotateVariantCommandOptions;

    //        long inputFileId = catalogManager.getFileId(cliOptions.fileId);

    // 1) Initialize VariantStorageManager
    long studyId = catalogManager.getStudyId(cliOptions.studyId, sessionId);
    Study study = catalogManager.getStudy(studyId, sessionId).first();

    /*//from   w w w  .ja va  2 s.c  om
     * Getting VariantStorageManager
     * We need to find out the Storage Engine Id to be used from Catalog
     */
    DataStore dataStore = AbstractFileIndexer.getDataStore(catalogManager, studyId, File.Bioformat.VARIANT,
            sessionId);
    initVariantStorageManager(dataStore);

    /*
     * Create DBAdaptor
     */
    VariantDBAdaptor dbAdaptor = variantStorageManager.getDBAdaptor(dataStore.getDbName());
    StudyConfigurationManager studyConfigurationManager = dbAdaptor.getStudyConfigurationManager();
    StudyConfiguration studyConfiguration = studyConfigurationManager.getStudyConfiguration((int) studyId, null)
            .first();

    /*
     * Create Annotator
     */
    ObjectMap options = storageConfiguration.getStorageEngine(dataStore.getStorageEngine()).getVariant()
            .getOptions();
    if (cliOptions.annotator != null) {
        options.put(VariantAnnotationManager.ANNOTATION_SOURCE, cliOptions.annotator);
    }
    if (cliOptions.species != null) {
        options.put(VariantAnnotationManager.SPECIES, cliOptions.species);
    }
    if (cliOptions.assembly != null) {
        options.put(VariantAnnotationManager.ASSEMBLY, cliOptions.assembly);
    }
    if (cliOptions.customAnnotationKey != null) {
        options.put(VariantAnnotationManager.CUSTOM_ANNOTATION_KEY, cliOptions.customAnnotationKey);
    }

    VariantAnnotator annotator = VariantAnnotationManager.buildVariantAnnotator(storageConfiguration,
            dataStore.getStorageEngine(), options);
    //            VariantAnnotator annotator = VariantAnnotationManager.buildVariantAnnotator(annotatorSource, annotatorProperties,
    // cliOptions.species, cliOptions.assembly);
    VariantAnnotationManager variantAnnotationManager = new VariantAnnotationManager(annotator, dbAdaptor);

    /*
     * Annotation options
     */
    Query query = new Query();
    if (cliOptions.filterRegion != null) {
        query.put(VariantDBAdaptor.VariantQueryParams.REGION.key(), cliOptions.filterRegion);
    }
    if (cliOptions.filterChromosome != null) {
        query.put(VariantDBAdaptor.VariantQueryParams.CHROMOSOME.key(), cliOptions.filterChromosome);
    }
    if (cliOptions.filterGene != null) {
        query.put(VariantDBAdaptor.VariantQueryParams.GENE.key(), cliOptions.filterGene);
    }
    if (cliOptions.filterAnnotConsequenceType != null) {
        query.put(VariantDBAdaptor.VariantQueryParams.ANNOT_CONSEQUENCE_TYPE.key(),
                cliOptions.filterAnnotConsequenceType);
    }
    if (!cliOptions.overwriteAnnotations) {
        query.put(VariantDBAdaptor.VariantQueryParams.ANNOTATION_EXISTS.key(), false);
    }
    //        URI outputUri = job.getTmpOutDirUri();
    URI outputUri = IndexDaemon.getJobTemporaryFolder(job.getId(), catalogConfiguration.getTempJobsDir())
            .toUri();
    Path outDir = Paths.get(outputUri.resolve(".").getPath());

    /*
     * Create and load annotations
     */
    boolean doCreate = cliOptions.create, doLoad = cliOptions.load != null;
    if (!cliOptions.create && cliOptions.load == null) {
        doCreate = true;
        doLoad = true;
    }

    URI annotationFile = null;
    if (doCreate) {
        long start = System.currentTimeMillis();
        logger.info("Starting annotation creation ");
        annotationFile = variantAnnotationManager.createAnnotation(outDir,
                cliOptions.fileName == null ? dataStore.getDbName() : cliOptions.fileName, query,
                new QueryOptions(options));
        logger.info("Finished annotation creation {}ms", System.currentTimeMillis() - start);
    }

    if (doLoad) {
        long start = System.currentTimeMillis();
        logger.info("Starting annotation load");
        if (annotationFile == null) {
            long fileId = catalogManager.getFileId(cliOptions.load, sessionId);
            annotationFile = catalogManager.getFileUri(catalogManager.getFile(fileId, sessionId).first());
        }
        variantAnnotationManager.loadAnnotation(annotationFile, new QueryOptions(options));
        logger.info("Finished annotation load {}ms", System.currentTimeMillis() - start);
    }
}

From source file:se.vgregion.portal.iframe.controller.CSViewController.java

/**
 * Prepare proxyLoginForm.jsp for form-based authentication.
 * /*  ww  w . j  ava  2 s.  c  o  m*/
 * @param model
 *            model
 * @param req
 *            request
 * @param prefs
 *            portlet preferences
 * @param postLogin
 *            postLogin url
 * @return proxyLoginForm
 * @throws URISyntaxException
 */
@ResourceMapping
public String showProxyForm(PortletPreferences prefs, ResourceRequest req, ModelMap model,
        @ModelAttribute("postLogin") String postLogin) {

    PortletConfig portletConfig = PortletConfig.getInstance(prefs);
    model.addAttribute("portletConfig", portletConfig);
    if (!portletConfig.isAuth()) {
        return "view";
    }

    String userId = lookupUid(req);

    if (portletConfig.isInotesUltralight()) {
        // We happen to know that we are going to need to make a call to get the user's mail server from ldap
        // later
        // in this method or rather in a method called by this method. We also know that the LdapService is an
        // AsyncCachingLdapServiceWrapper. Making a call now will speed up the experience for the user.
        ldapService.getLdapUserByUid(userId);
    }

    // 1: Credentials
    SiteKey siteKey = credentialService.getSiteKey(portletConfig.getSiteKey());
    model.addAttribute("siteKey", siteKey);

    UserSiteCredential siteCredential = new UserSiteCredential();
    credentialsAvailable(req, model, portletConfig, siteCredential, siteKey);

    // 2: postLogin
    if (postLogin != null && postLogin.length() > 0) {
        model.addAttribute("postLoginLink", true);
    }

    // 3: Dynamic Field
    if (StringUtils.isNotBlank(portletConfig.getDynamicField())) {
        Map<String, String> dynamicFieldValues = lookupDynamicValue(portletConfig);
        model.addAttribute("dynamicFieldValues", dynamicFieldValues);
    }

    // 4: RD encode
    if (portletConfig.isRdEncode()) {
        model.addAttribute("rdPass", encodeRaindancePassword(userId, portletConfig));
    }

    if (portletConfig.isInotesUltralight()) {
        // Then we place a dynamic url (including the userId) in the hiddenVariablesMap.
        Map<String, String> hiddenVariablesMap = new HashMap<String, String>();
        hiddenVariablesMap.put("RedirectTo", String.format(INOTES_ULTRALIGHT_REDIRECT_TO_URL,
                credentialService.getUserSiteCredential(userId, portletConfig.getSiteKey()).getSiteUser()));
        model.addAttribute("hiddenVariablesMap", hiddenVariablesMap);
    } else {
        model.addAttribute("hiddenVariablesMap", portletConfig.getHiddenVariablesMap());
    }

    URI src = null;
    try {
        String srcUrl = portletConfig.getSrc();
        srcUrl = replacePlaceholders(userId, srcUrl);
        src = new URI(srcUrl);

        String proxyAction;
        if (portletConfig.getFormAction() == null || portletConfig.getFormAction().length() < 1) {
            proxyAction = src.toString();
        } else {
            proxyAction = src.resolve(portletConfig.getFormAction()).toString();
        }

        if ("basic".equals(portletConfig.getAuthType())) {
            proxyAction = prepareBasicAuthAction(siteCredential, proxyAction);
        }

        model.addAttribute("proxyAction", proxyAction);
        debug(req, proxyAction);

        return "proxyLoginForm";
    } catch (URISyntaxException e) {
        e.printStackTrace(); // To change body of catch statement use File | Settings | File Templates.
        return "help";
    }

}

From source file:de.sub.goobi.export.dms.ExportDms.java

/**
 * Download image./*from  w ww . j a va 2  s  .  c  o  m*/
 *
 * @param process
 *            object
 * @param userHome
 *            File
 * @param atsPpnBand
 *            String
 * @param ordnerEndung
 *            String
 */
public void imageDownload(Process process, URI userHome, String atsPpnBand, final String ordnerEndung)
        throws IOException, InterruptedException {

    /*
     * dann den Ausgangspfad ermitteln
     */
    URI tifOrdner = serviceManager.getProcessService().getImagesTifDirectory(true, process);

    /*
     * jetzt die Ausgangsordner in die Zielordner kopieren
     */
    if (fileService.fileExist(tifOrdner) && fileService.getSubUris(tifOrdner).size() > 0) {
        URI zielTif = userHome.resolve(File.separator + atsPpnBand + ordnerEndung);

        /* bei Agora-Import einfach den Ordner anlegen */
        if (process.getProject().isUseDmsImport()) {
            if (!fileService.fileExist(zielTif)) {
                fileService.createDirectory(userHome, atsPpnBand + ordnerEndung);
            }
        } else {
            /*
             * wenn kein Agora-Import, dann den Ordner mit
             * Benutzerberechtigung neu anlegen
             */
            User myUser = (User) Helper.getManagedBeanValue("#{LoginForm.myBenutzer}");
            try {
                fileService.createDirectoryForUser(zielTif, myUser.getLogin());
            } catch (Exception e) {
                if (exportDmsTask != null) {
                    exportDmsTask.setException(e);
                } else {
                    Helper.setFehlerMeldung("Export canceled, error", "could not create destination directory");
                }
                logger.error("could not create destination directory", e);
                if (e instanceof IOException) {
                    throw (IOException) e;
                } else if (e instanceof InterruptedException) {
                    throw (InterruptedException) e;
                } else if (e instanceof RuntimeException) {
                    throw (RuntimeException) e;
                } else {
                    throw new UndeclaredThrowableException(e);
                }
            }
        }

        /* jetzt den eigentlichen Kopiervorgang */

        ArrayList<URI> dateien = fileService.getSubUris(Helper.dataFilter, tifOrdner);
        for (int i = 0; i < dateien.size(); i++) {
            if (exportDmsTask != null) {
                exportDmsTask.setWorkDetail(fileService.getFileName(dateien.get(i)));
            }
            URI meinZiel = zielTif.resolve(File.separator + fileService.getFileName(dateien.get(i)));
            fileService.copyFile(dateien.get(i), meinZiel);
            if (exportDmsTask != null) {
                exportDmsTask.setProgress((int) ((i + 1) * 98d / dateien.size() + 1));
                if (exportDmsTask.isInterrupted()) {
                    throw new InterruptedException();
                }
            }
        }
        if (exportDmsTask != null) {
            exportDmsTask.setWorkDetail(null);
        }
    }
}