File Upload IdentityIQ 8.4

Which IIQ version are you inquiring about?

8.4

Hi Experts,

I’m trying to develop a file upload utility by referring to the link below:

Upload file QuickLink - Compass

However, I’m a bit confused. Do I need to build a plugin for this, or can I directly create the XHTML file and place it in the SailPoint folder?

Also, for Step 2, once I create the Java class, where should I place it?

@Bernardc you can directly create XHTML and java.

Java file should be here : WEB-INF/classes- > sailpoint → services → standard → fileUpload

check this link : Solved: Uploading a Local File from IIQ to SFTP server - Compass

You can add xhtml to WEB-INF directory

Hi @vishal_kejriwal1

I have created the xhtml, java class, and updated the faces-config accordingly. But having below error when submit.

<EventMessage>javax.servlet.ServletException: /workitem/fileUpload.xhtml @15,67 value="#{fileUploadClass.serverField}": Target Unreachable, identifier [fileUploadClass] resolved to null</EventMessage>
<Stacktrace>javax.servlet.ServletException: javax.servlet.ServletException: /workitem/fileUpload.xhtml @15,67 value="#{fileUploadClass.serverField}": Target Unreachable, identifier [fileUploadClass] resolved to null

Not sure the root cause, but checked my face-config, I think it is fine? Can you help me out to check where is the error? Much appreciated it!

  1. xhtml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui">

<h:head>
    <title>File Upload</title>
</h:head>
<h:body>
    <h:form enctype="multipart/form-data">
        <h:panelGrid columns="2">

            <h:outputLabel value="Server:" />
            <h:inputText value="#{fileUploadClass.serverField}" />

            <h:outputLabel value="User:" />
            <h:inputText value="#{fileUploadClass.userField}" />

            <h:outputLabel value="Password:" />
            <h:inputSecret value="#{fileUploadClass.passwordField}" />

            <h:outputLabel value="Target Path:" />
            <h:inputText value="#{fileUploadClass.targetFilePathField}" />

            <h:outputLabel value="File:" />
            <p:fileUpload fileUploadListener="#{fileUploadClass.handleFileUpload}" 
                          mode="advanced" 
                          dragDropSupport="true" 
                          update="messages" />

            <h:commandButton value="Submit" action="#{fileUploadClass.uploadFile}" />

        </h:panelGrid>

        <h:messages id="messages" />

    </h:form>
</h:body>
</html>

  1. javaclass
package sailpoint.services.standard.fileUpload;

import org.primefaces.model.file.UploadedFile;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import java.io.*;

@ManagedBean(name="fileUploadClass")
@SessionScoped
public class FileUploadClass {

    private String serverField;
    private String userField;
    private String passwordField;
    private UploadedFile uploadFile;
    private String targetFilePathField;

    // Getter and Setter methods
    public String getServerField() {
        return serverField;
    }

    public void setServerField(String serverField) {
        this.serverField = serverField;
    }

    public String getUserField() {
        return userField;
    }

    public void setUserField(String userField) {
        this.userField = userField;
    }

    public String getPasswordField() {
        return passwordField;
    }

    public void setPasswordField(String passwordField) {
        this.passwordField = passwordField;
    }

    public UploadedFile getUploadFile() {
        return uploadFile;
    }

    public void setUploadFile(UploadedFile uploadFile) {
        this.uploadFile = uploadFile;
    }

    public String getTargetFilePathField() {
        return targetFilePathField;
    }

    public void setTargetFilePathField(String targetFilePathField) {
        this.targetFilePathField = targetFilePathField;
    }

    // Handle File Upload
    public void handleFileUpload() {
        if (uploadFile != null) {
            try (InputStream stream = uploadFile.getInputStream()) {

                String destination = targetFilePathField + "/" + uploadFile.getFileName();
                System.out.println("Destination of the target file is : " + destination);

                try (OutputStream writeOutput = new FileOutputStream(destination)) {
                    int sizeOfFile = (int) uploadFile.getSize();
                    byte[] buffer = new byte[sizeOfFile];
                    int readBytes;

                    while ((readBytes = stream.read(buffer, 0, sizeOfFile)) != -1) {
                        writeOutput.write(buffer, 0, readBytes);
                        writeOutput.flush();
                    }
                }

                // Set file permissions
                File targetFileSetPermission = new File(destination);
                targetFileSetPermission.setWritable(true, false);
                targetFileSetPermission.setReadable(true, false);
                targetFileSetPermission.setExecutable(true, false);

                System.out.println("File uploaded successfully!");

            } catch (IOException e) {
                System.out.println("File upload failed: " + e.getMessage());
            }
        }
    }

    public String uploadFile() {
        handleFileUpload();
        return "success";
    }
}

  1. face-config
  <managed-bean>
    <description>fileUpload</description>
    <managed-bean-name>fileUploadClass</managed-bean-name>
    <managed-bean-class>sailpoint.services.standard.fileUpload.FileUploadClass</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
  </managed-bean>

  <navigation-rule>
    <description>fileUpload</description>
    <from-view-id>*</from-view-id>
    <navigation-case>
        <from-outcome>success</from-outcome>
        <to-view-id>/workitem/fileUpload.xhtml</to-view-id>
        <redirect />
    </navigation-case>
  </navigation-rule>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.