Search in sources :

Example 61 with FacesMessage

use of javax.faces.application.FacesMessage in project dataverse by IQSS.

the class HarvestingClientsPage method init.

public String init() {
    if (!isSessionUserAuthenticated()) {
        return "/loginpage.xhtml" + navigationWrapper.getRedirectPage();
    } else if (!isSuperUser()) {
        return navigationWrapper.notAuthorized();
    }
    if (dataverseId != null) {
        setDataverse(dataverseService.find(getDataverseId()));
        if (getDataverse() == null) {
            return navigationWrapper.notFound();
        }
    } else {
        setDataverse(dataverseService.findRootDataverse());
    }
    configuredHarvestingClients = harvestingClientService.getAllHarvestingClients();
    pageMode = PageMode.VIEW;
    FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, JH.localize("harvestclients.title"), JH.localize("harvestclients.toptip")));
    return null;
}
Also used : FacesMessage(javax.faces.application.FacesMessage)

Example 62 with FacesMessage

use of javax.faces.application.FacesMessage in project dataverse by IQSS.

the class EditDatafilesPage method handleLabelsFileUpload.

public void handleLabelsFileUpload(FileUploadEvent event) {
    logger.fine("entering handleUpload method.");
    UploadedFile file = event.getFile();
    if (file != null) {
        InputStream uploadStream = null;
        try {
            uploadStream = file.getInputstream();
        } catch (IOException ioex) {
            logger.info("the file " + file.getFileName() + " failed to upload!");
            FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_WARN, "upload failure", "the file " + file.getFileName() + " failed to upload!");
            FacesContext.getCurrentInstance().addMessage(null, message);
            return;
        }
        savedLabelsTempFile = saveTempFile(uploadStream);
        logger.fine(file.getFileName() + " is successfully uploaded.");
        FacesMessage message = new FacesMessage("Succesful", file.getFileName() + " is uploaded.");
        FacesContext.getCurrentInstance().addMessage(null, message);
    }
// process file (i.e., just save it in a temp location; for now):
}
Also used : UploadedFile(org.primefaces.model.UploadedFile) InputStream(java.io.InputStream) IOException(java.io.IOException) FacesMessage(javax.faces.application.FacesMessage)

Example 63 with FacesMessage

use of javax.faces.application.FacesMessage in project dataverse by IQSS.

the class EditDatafilesPage method handleFileUpload.

/**
 * Handle native file replace
 * @param event
 * @throws java.io.IOException
 */
public void handleFileUpload(FileUploadEvent event) throws IOException {
    if (!uploadInProgress) {
        uploadInProgress = true;
    }
    if (event == null) {
        throw new NullPointerException("event cannot be null");
    }
    UploadedFile uFile = event.getFile();
    if (uFile == null) {
        throw new NullPointerException("uFile cannot be null");
    }
    /**
     * For File Replace, take a different code path
     */
    if (isFileReplaceOperation()) {
        handleReplaceFileUpload(event, uFile.getInputstream(), uFile.getFileName(), uFile.getContentType(), event, null);
        if (fileReplacePageHelper.hasContentTypeWarning()) {
            RequestContext context = RequestContext.getCurrentInstance();
            RequestContext.getCurrentInstance().update("datasetForm:fileTypeDifferentPopup");
            context.execute("PF('fileTypeDifferentPopup').show();");
        }
        return;
    }
    List<DataFile> dFileList = null;
    try {
        // Note: A single uploaded file may produce multiple datafiles -
        // for example, multiple files can be extracted from an uncompressed
        // zip file.
        dFileList = FileUtil.createDataFiles(workingVersion, uFile.getInputstream(), uFile.getFileName(), uFile.getContentType(), systemConfig);
    } catch (IOException ioex) {
        logger.warning("Failed to process and/or save the file " + uFile.getFileName() + "; " + ioex.getMessage());
        return;
    }
    /*catch (FileExceedsMaxSizeException ex) {
            logger.warning("Failed to process and/or save the file " + uFile.getFileName() + "; " + ex.getMessage());
            return;
        }*/
    // -----------------------------------------------------------
    // These raw datafiles are then post-processed, in order to drop any files
    // already in the dataset/already uploaded, and to correct duplicate file names, etc.
    // -----------------------------------------------------------
    String warningMessage = processUploadedFileList(dFileList);
    if (warningMessage != null) {
        uploadWarningMessage = warningMessage;
        FacesContext.getCurrentInstance().addMessage(event.getComponent().getClientId(), new FacesMessage(FacesMessage.SEVERITY_ERROR, "upload warning", warningMessage));
        // save the component id of the p:upload widget, so that we could
        // send an info message there, from elsewhere in the code:
        uploadComponentId = event.getComponent().getClientId();
    }
}
Also used : UploadedFile(org.primefaces.model.UploadedFile) RequestContext(org.primefaces.context.RequestContext) IOException(java.io.IOException) FacesMessage(javax.faces.application.FacesMessage)

Example 64 with FacesMessage

use of javax.faces.application.FacesMessage in project trainning by fernandotomasio.

the class PessoasBean method atualizar.

public void atualizar() {
    System.out.println("Sobre: " + this.sobre);
    FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Perfil atualizado!"));
}
Also used : FacesMessage(javax.faces.application.FacesMessage)

Example 65 with FacesMessage

use of javax.faces.application.FacesMessage in project oxAuth by GluuFederation.

the class LogoutAction method logoutFailed.

public void logoutFailed() {
    String message = languageBean.getMessage("logout.failedToProceed");
    facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, message, message));
    facesService.redirect("/error.xhtml");
}
Also used : FacesMessage(javax.faces.application.FacesMessage)

Aggregations

FacesMessage (javax.faces.application.FacesMessage)370 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)43 SQLException (java.sql.SQLException)40 Connection (java.sql.Connection)34 FacesContext (javax.faces.context.FacesContext)25 ArrayList (java.util.ArrayList)24 UIInput (javax.faces.component.UIInput)24 ValidatorException (javax.faces.validator.ValidatorException)24 GroupHelper (mom.trd.opentheso.bdd.helper.GroupHelper)22 NodeAutoCompletion (mom.trd.opentheso.bdd.helper.nodes.NodeAutoCompletion)22 CandidateHelper (mom.trd.opentheso.bdd.helper.CandidateHelper)19 UserHelper2 (mom.trd.opentheso.bdd.helper.UserHelper2)19 IOException (java.io.IOException)16 NoteHelper (mom.trd.opentheso.bdd.helper.NoteHelper)15 Test (org.junit.Test)13 TermHelper (mom.trd.opentheso.bdd.helper.TermHelper)12 Term (mom.trd.opentheso.bdd.datas.Term)11 UploadedFile (org.primefaces.model.UploadedFile)11 HikariDataSource (com.zaxxer.hikari.HikariDataSource)10 Date (java.util.Date)10