WPUMFactory.getUserFactory returning NullPointerException

Hi All,
I am trying to do an application for creating a folder in KM repository.
I have written as follows.
public class KMAbstractComp extends AbstractPortalComponent
    public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)
          try
     com.sapportals.portal.security.usermanagement.IUser user = WPUMFactory.getUserFactory().getEP5User(request.getUser());
          catch (Exception e)
     response.write(e.toString());
But this statement is returning NullPointerException can anyone help me in this regard to resolve this issue.
Thanks,
Bhavyasri.M.

Hi Marcel,
Thanks for the reply!!!! 
I have written my code like this.
import com.sap.security.api.*;
import com.sapportals.portal.prt.component.*;
import com.sapportals.wcm.repository.*;
import com.sapportals.wcm.util.uri.RID;
import com.sapportals.wcm.util.usermanagement.WPUMFactory;
public class KMAbstractComp extends AbstractPortalComponent
    public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)
          try
               IUserFactory iuf = UMFactory.getUserFactory();
               IUser u =iuf.getUserByUniqueName("user");
               com.sapportals.portal.security.usermanagement.IUser user = WPUMFactory.getUserFactory().getEP5User(u);
               ResourceContext ctxt = new ResourceContext(user);
               RID rid = RID.getRID("/documents");
               IResource resource = ResourceFactory.getInstance().getResource(rid,ctxt);
               ICollection collection = (ICollection)resource;
               IResourceList reslist = collection.getChildren();
          catch (Exception e) {
               response.write(e.toString()
But it is showing NullPointerException.
I tried to juz print the
WPUMFactory.getUserFactory()
. But actuall its is printing null. This might be the problem, i guess. Can u plz tell me the way to resolvve this??
Thanks,
Bhavyasri.M.

Similar Messages

  • WPUMFactory.getUserFactory() throws null pointer exception

    Hi,
    I am trying to use KM API's to read files from KM repository. I am using the below code as mentioned in the blog: How to download KM documents using Web Dynpro Java
    Below is my code:
    IWDClientUser wdClientUser = WDClientUser.getCurrentUser();
    com.sap.security.api.IUser sapUser = wdClientUser.getSAPUser();
    IUser epUser = WPUMFactory.getUserFactory().getEP5User(sapUser);
    However the line WPUMFactory.getUserFactory() throws null pointer exception. Can some one please help on why these happens as these seems to be the standard code to read a file from KM.
    Thanks.
    Regards,
    Ponraj M

    Hi Ponraj ,
    Instead of fetching the current logged on user , use the below line to set the resource context and see if it helps .
    com.sapportals.wcm.repository.IResourceContext resourceContext = ResourceFactory.getInstance().getServiceContext("cmadmin_service");
    cmadmin_service is a existing user that can be used to access KM resources .
    Regards
    Mayank

  • MSSQL datatypes that return NullPointerException

    Using XSQLServlet with BEA Systems type 4 jDriver for SQL Server 7.0 Version: 5.1.0, I get the following error:
    oracle.xml.sql.OracleXMLSQLException: java.lang.NullPointerException
    while trying to access the following MSSQL Server datatypes which have non null values:
    1. binary
    2. image
    3. sql_variant
    4. timestamp
    5. uniqueidentifier
    6. varbinary
    The problem is NOT with the jDriver for SQL Server because I've built a class that returns non null data for all datatypes. The problem must lie with XSQL Servlet.
    To test, I use the following:
    xsql file:
    <xsql:query null-indicator="yes"
    connection="{@connection}"
    max-rows="{@max-rows}"
    xmlns:xsql="urn:oracle-xsql"> {@sql}
    </xsql:query>
    url:
    http://aetius/xsql/demo/query.xsql?connection=bea&sql=select+a,c,d,e+from+TYPES
    I'll delete column names, eg column b which is a binary data type, from the above URL to eliminate the java.lang.NullPointerException error.
    I've created the TYPES table to contain every MSSQL datatype.
    CREATE TABLE [dbo].[TYPES] (
    [a] [bigint] NULL ,
    [binary] (10) NULL ,
    [c] [bit] NULL ,
    [d] [char] (10) NULL ,
    [e] [datetime] NULL ,
    [f] [decimal](18, 0) NULL ,
    [g] [float] NULL ,
    [h] [image] NULL ,
    [int] NULL ,
    [j] [money] NULL ,
    [k] [nchar] (10) NULL ,
    [l] [ntext] NULL ,
    [m] [numeric](18, 0) NULL ,
    [n] [nvarchar] (10) NULL ,
    [o] [real] NULL ,
    [p] [smalldatetime] NULL ,
    [q] [smallint] NULL ,
    [r] [smallmoney] NULL ,
    [s] [sql_variant] NULL ,
    [t] [text] NULL ,
    [timestamp] NULL ,
    [v] [tinyint] NULL ,
    [w] [uniqueidentifier] NULL ,
    [x] [varbinary] (50) NULL ,
    [y] [varchar] (50) NULL
    ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
    BTW the MSSQL Server datatypes that DO work with XSQL Servlet:
    1. bigint
    2. bit
    3. char
    4. datetime
    5. decimal
    6. float
    7. int
    8. money
    9. nchar
    10. ntext
    11. numeric
    12. varchar
    13. real
    14. smalldatetime
    15. smallint
    16. smallmoney
    17. text
    18. tinyint
    19. varchar
    Steve.

    Thanks for the quick response.
    The problem does NOT seem to be in the XML SQL Utility. In other words using an instance of OracleXMLQuery in my data type test Java program, I have a successful output including the data types in question.
    Here is the Java program:
    package examples.jdbc.mssqlserver4;
    import java.io.*;
    import java.sql.*;
    import java.util.Properties;
    import oracle.xml.sql.query.OracleXMLQuery;
    public class Steve
    public static void main(String [] args)
    Properties props = new Properties();
    props.put("user", "lemkau");
    props.put("password", "lemkau");
    props.put("server", "Northwind@Aetius:1433");
    Driver myDriver = null;
    try
    String driverName = "weblogic.jdbc.mssqlserver4.Driver";
    String url = "jdbc:weblogic:mssqlserver4";
    // String driverName = "com.inet.tds.TdsDriver";
    // String url = "jdbc:inetdae7:aetius:1433";
    myDriver = (Driver) Class.forName(driverName).newInstance();
    Connection conn = myDriver.connect(url, props);
    try
    Statement stmt = conn.createStatement();
    stmt.execute("select * from TYPES");
    ResultSet rs = stmt.getResultSet();
    if(rs!=null)
    OracleXMLQuery qry = new OracleXMLQuery(conn, rs);
    String xmlString = qry.getXMLString();
    System.out.println(" OUPUT IS:\n"+xmlString);
    while (rs.next()) {
    System.out.println("bigint" + " - " + rs.getString("a"));
    System.out.println("binary" + " - " + rs.getString("b"));
    System.out.println("bit" + " - " + rs.getString("c"));
    System.out.println("char" + " - " + rs.getString("d"));
    System.out.println("datetime" + " - " + rs.getString("e"));
    System.out.println("decimal" + " - " + rs.getString("f"));
    System.out.println("float" + " - " + rs.getString("g"));
    System.out.println("image" + " - " + rs.getString("h"));
    System.out.println("int" + " - " + rs.getString("i"));
    System.out.println("money" + " - " + rs.getString("j"));
    System.out.println("nchar" + " - " + rs.getString("k"));
    System.out.println("ntext" + " - " + rs.getString("l"));
    System.out.println("numeric" + " - " + rs.getString("m"));
    System.out.println("nvarchar" + " - " + rs.getString("n"));
    System.out.println("real" + " - " + rs.getString("o"));
    System.out.println("smalldatetime" + " - " + rs.getString("p"));
    System.out.println("smallint" + " - " + rs.getString("q"));
    System.out.println("smallmoney" + " - " + rs.getString("r"));
    System.out.println("sql_variant" + " - " + rs.getString("s"));
    System.out.println("text" + " - " + rs.getString("t"));
    System.out.println("timestamp" + " - " + rs.getString("u"));
    System.out.println("tinyint" + " - " + rs.getString("v"));
    System.out.println("uniqueidentifier" + " - " + rs.getString("w"));
    System.out.println("varbinary" + " - " + rs.getString("x"));
    System.out.println("varchar" + " - " + rs.getString("y"));
    ResultSetMetaData md = rs.getMetaData();
    // System.out.println("Number of columns: " + md.getColumnCount());
    for (int i = 1; i <= md.getColumnCount(); i++) {
    String name = md.getColumnName(i);
    // System.out.println("Column Name: " + name);
    // System.out.println("Column Length: " + md.getColumnDisplaySize(i));
    stmt.close();
    conn.close();
    catch(SQLException se)
    System.out.println("An exception was raised " + se);
    catch(Exception e)
    System.out.println("An exception was raised " + e);
    Here is the result:
    "C:\Program Files\Oracle\JDeveloper 3.1.1.2\java1.2\jre\bin\java" -XXdebug -mx50m -classpath "C:\Program Files\Oracle\JDeveloper 3.1.1.2\myclasses;C:\Program Files\Oracle\JDeveloper 3.1.1.2\lib\jdev-rt.zip;C:\Program Files\Oracle\JDeveloper 3.1.1.2\lib\connectionmanager.zip;C:\weblogic\mssqlserver4v70\classes;C:\weblogic\mssqlserver4v70\license;C:\xsql\lib\Sprinta2000.jar;C:\xsql\lib\oraclexsql.jar;C:\xsql\lib;C:\xsql \lib\xsu12.jar;C:\xsql\lib\oraclexmlsql.jar;C:\xsql\lib\classes12.zip;C:\xsql\lib\xmlparserv2.jar;C:\Program Files\Oracle\JDeveloper 3.1.1.2\java1.2\jre\lib\rt.jar" examples.jdbc.mssqlserver4.Steve
    System Output: OUPUT IS:
    System Output: <?xml versi on = '1.0'?>
    System Output: <ROWSET>
    System Output: <ROW num="1">
    System Output: <a>1234567890</a>
    System Output: <b>0904D000340000000000</b>
    System Output: <c>true</c>
    System Output: <d>abc </d>
    System Output: <e>2000-10-25 09:41:20.34</e>
    System Output: <f>9</f>
    System Output: <g>9.2</g>
    System Output: <h>0904D000340000000000</h>
    System Output: <i>9</i>
    System Output: <j>18.50000000</j>
    System Output: <k>ALFKI </k>
    System Output: <l>Soft drinks, coffees, teas, beers, and ales</l>
    System Output: <m>9</m>
    System Output: <n>hello</n>
    System Output: <o>9.199999809265137</o>
    System Output: <p>2000-10-25 09:41:00.0</p>
    System Output: <q>9</q>
    System Output: <r>9.20000000</r>
    System Output: <t>Soft drinks, coffees, teas, beers, and ales</t>
    System Output: <u>00000000000002B1</u>
    System Output: <v>1</v>
    System Output: <w>1AFFD361F32ED04996AA62054E954531</w>
    System Output: <x>0904D000340000000000</x>
    System Output: <y>abc</y>
    System Output: </ROW>
    System Output: </ROWSET>
    System Output:
    All previously questionable data types listed below using an URL in a browser are now OK using OracleXMLQuery in a Java program.
    data type column name
    1. binary b
    2. image h
    3. sql_variant s
    4. timestamp u
    5. uniqueidentifier w
    6. varbinary x
    Does this help pinpoint the problem?
    null

  • Get Session Object return NullPointerException

    Hi,
    i write my code this give me NullPointerException
                   ClientBean client = (ClientBean)FacesContext.getCurrentInstance().getExternalContext().
    getRequestMap().get("client");
    here is my faces-config.xml
    <managed-bean>
    <description>
    Client Bean
    </description>
    <managed-bean-name>client</managed-bean-name>
    <managed-bean-class>ClientBean</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
    </managed-bean>
    Anybody have an idea why ?
    thanks,
    piwi

    Your bean is defined with session scope and you use the method getRequestMap for request scope attributes.
    Try getSessionMap().

  • Ampassword returns NullPointerException

    I got error running /opt/SUNWam/bin/ampassword -e The exception isException in thread "main" java.lang.NullPointerException
            at com.iplanet.services.util.Base64.encode(Base64.java:55)
            at com.iplanet.services.util.Crypt.encode(Crypt.java:240)
            at com.iplanet.services.util.Crypt.encode(Crypt.java:262)
            at com.sun.identity.security.EncodeAction.run(EncodeAction.java:108)
            at java.security.AccessController.doPrivileged(Native Method)
            at com.iplanet.services.ldap.ServerConfigMgr.main(ServerConfigMgr.java:257)From the debug log file, I found something like: ERROR: Crypt: Initialize JSS
    java.lang.SecurityException: Unable to initialize security library
            at org.mozilla.jss.CryptoManager.initializeAllNative2(Native Method)
            at org.mozilla.jss.CryptoManager.initialize(CryptoManager.java:827)
            at com.iplanet.services.util.JSSEncryption.<clinit>(JSSEncryption.java:250)
            at java.lang.Class.forName0(Native Method)
            at java.lang.Class.forName(Class.java:164)
            at com.iplanet.services.util.Crypt.createInstance(Crypt.java:128)
            at com.iplanet.services.util.Crypt.<clinit>(Crypt.java:101)
            at com.sun.identity.security.EncodeAction.run(EncodeAction.java:108)
            at java.security.AccessController.doPrivileged(Native Method)
            at com.iplanet.services.ldap.ServerConfigMgr.main(ServerConfigMgr.java:257)I've already setenv LD_LIBRARY_PATH "/usr/lib/mps:/opt/SUNWam/lib"Does the error related to any privileges on the machine because I logged in as a normal user to run the ampassword command. Also I have problem running amadmin command too. The command outputs Info 112: Entering ldapAuthenticate method!
    Success 0: No Exceptions! LDAP Authentication success!
    Info 113: Calling SSO method!
    Error 9: Operation failed: null

    YES it is permissions related. You need to run it as
    root or follow the instructions for changing AM to
    run as a non root userThanks so much. :)

  • CachedRowSet returns NullPointerException

    <p>Hi folks,</p><p>I am passing a populated CachedRowSetImpl object to ReportClientDocument in run-time.</p><p>First time around I get the following error:</p><pre>java.lang.NullPointerException<br />     java.io.Reader.<init>(Reader.java:61)<br />     java.io.InputStreamReader.<init>(InputStreamReader.java:80)<br />     java.util.Properties.load(Properties.java:266)<br />     javax.sql.rowset.spi.SyncFactory.initMapIfNecessary(SyncFactory.java:371)<br />     javax.sql.rowset.spi.SyncFactory.getInstance(SyncFactory.java:557)<br />     com.sun.rowset.CachedRowSetImpl.<init>(CachedRowSetImpl.java:224)<br />     org.apache.jsp.Clob_002dviewer_jsp._jspService(Clob_002dviewer_jsp.java:112)<br />     org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)<br />     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)<br />     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)<br />     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)<br />     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)<br />     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)</pre><p> </p><p>The second time I run the same JSP, I don&#39;t get this error.</p><p> Any thoughts?</p><p> Tim <br /></p>

    <p> </p><p>Looking at the stack trace, it doesn&#39;t appear to be a JRC issue. I&#39;ve traced back the call in the Java sources, and it appears in the CachedRowSetImpl constructor.<br /></p><p>Googling, I found the issue to be common.  One link I found was this:</p><p>/message/2227591#2227591 [original link is broken] </p>

  • How to use an authenticated user for a proxy call

    Dear all,
    I am currently working on a JEE application where the user needs to authenticate (for this I have configured the web.xml).
    Now inside this application I need to do a proxy call to a PI webservice.
    I would like to use the user credentials of the already logged in user in order to call the proxy.
    What I don't want to do is to use a service user for the proxy call.
    The code I am trying to call looks something like this:
         private IntegratedConfigurationIn getPort() throws Exception{
              IntegratedConfigurationIn port = null;
              try {
                   IntegratedConfigurationInService service = null;
                   service = new IntegratedConfigurationInService();
                   port = (IntegratedConfigurationIn) service.getIntegratedConfigurationIn_Port();
                  BindingProvider bp = (BindingProvider)port;
                  bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, user);
                  bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password);
                  if (url.length() != 0)
                       bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url);
              catch (Exception ex){
                   ex.printStackTrace();
              return port;
    The examples I found to retrieve the userdata pointed to codes similar to this one:
    public HttpServletRequest getHttpRequest() throws Exception {
              // Get runtime context
              Properties props = new Properties();
              props.put("domain", "true");
              Context initialContext = new InitialContext(props);
              ApplicationWebServiceContext wsContext = (ApplicationWebServiceContext) initialContext
                        .lookup(" /wsContext/ApplicationWebServiceContext");
              HttpServletRequest req = wsContext.getHttpServletRequest();
              return req;
    com.sap.security.api.IUser sapUser = com.sap.security.api.UMFactory.getAuthenticator().getLoggedInUser(getHttpRequest(), null);
              IUser ep5User = com.sapportals.wcm.util.usermanagement.WPUMFactory.getUserFactory().getEP5User(sapUser);
    Now I don't know how to bring it togehter and how to use an authenticated user for the BindingProvider.
    I would appreciate any hints or ideas.

    Peter,
    from the first screenshot, what I understood is that, you are calling an inbound PI web service that is intended to create an integrated configuration object (this is used for whole lot of other reason completely) but not actually calling a development web service.
    For this, you would have to generate your client classes from the WSDL provided by the PI developer for that particular service. Once you get those client classes generated, you could used the method provided in the other screenshot to extract the user and password and call the intended web service.
    Vijay Konam

  • Problem acessing KM in Web dynpro for upload a file

    Hello all.
    I have a problem to put a file inside a KM repository. I create a context element like a binary - fileData - and like a String - fileName. and the both code then i will show, I give the same error!!
    please try to help me, in where is my error...
    Code 1:
      public void onActionsavePolitic(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
        //@@begin onActionsavePolitic(ServerEvent)
          IPrivatePoliticCreationView.IFilenodeElement fileelement= wdContext.createFilenodeElement();
          wdContext.nodeFilenode().bind(fileelement);
          IWDAttributeInfo attInfo = wdContext.nodeFilenode().getNodeInfo().getAttribute("fileData");
        ISimpleTypeModifiable type = attInfo.getModifiableSimpleType();
          IWDModifiableBinaryType binaryType =(IWDModifiableBinaryType) wdContext.nodeFilenode().getNodeInfo().getAttribute("fileData").getModifiableSimpleType();
          IWDNodeElement element = wdContext.getParentElement();
          String filename = element.getAttributeAsText("fileName");
          if (filename.trim().equals(""))
                return;
          try {
                /*Get an object of current Portal user */
                IWDClientUser wdClientUser = WDClientUser.getCurrentUser();
                com.sap.security.api.IUser sapUser = wdClientUser.getSAPUser();
                com.sapportals.portal.security.usermanagement.IUser ep5User =
                      WPUMFactory.getUserFactory().getEP5User(sapUser);
                       ResourceContext context = new ResourceContext(ep5User);
                /*Give the path to KM in the variable path */
                 String path="/documents/News/";
                 RID rid = RID.getRID(path);
                 IResourceFactory factory =
                 ResourceFactory.getInstance();
                 ICollection folder = (ICollection) factory.getResource(rid,context);
                 //Using the upload element we can upload the files to a location in the server drive
                /*temperory location for writing */
                 String location =      "d:\";
                 String fileName = location+ fileelement.getFileName();
                 File file = new File(fileName);
                /*Create an output stream for writing to the temperory location*/
                 FileOutputStream out = new FileOutputStream(file);
                 out.write(fileelement.getFileData());
                 out.close();
                /*From the temporary location read the file using an input stream*/
                 FileInputStream fin = new FileInputStream(fileName);
                 fin.read();
                /*Using this input stream we can write to the repository
                 Content content = new Content(fileelement.getFiledata(),fileelement.get) */
                 Content content = new Content(fin,"byte", -1);
                 IResource newResource = folder.createResource(fileelement.getFileName(),null, content);
                 fin.close();
                 file.delete();
          } catch (NotSupportedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
          } catch (AccessDeniedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
          } catch (WDUMException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
          } catch (ResourceException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
          } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
          } catch (UserManagementException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
          } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
          } catch (WDRuntimeException e) {
          wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess(""+e.getMessage());
          }catch (IllegalArgumentException e) {
                wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess(""+e.getMessage());
        //@@end
    Code 2:
      public void onActionsavePolitic(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
        //@@begin onActionsavePolitic(ServerEvent)
          IPrivatePoliticCreationView.IFilenodeElement fileelement= wdContext.createFilenodeElement();
          wdContext.nodeFilenode().bind(fileelement);
          IWDAttributeInfo attInfo = wdContext.nodeFilenode().getNodeInfo().getAttribute("fileData");
          ISimpleTypeModifiable type = attInfo.getModifiableSimpleType();
    IWDModifiableBinaryType binaryType =(IWDModifiableBinaryType) wdContext.nodeFilenode().getNodeInfo().getAttribute("fileData").getModifiableSimpleType();
          IWDNodeElement element = wdContext.getParentElement();
          String filename = element.getAttributeAsText("fileName");
          if (filename.trim().equals(""))
                return;
          try {
                //      Get an object of current Portal user
                IWDClientUser wdClientUser = WDClientUser.getCurrentUser();
                com.sap.security.api.IUser sapUser = wdClientUser.getSAPUser();
                com.sapportals.portal.security.usermanagement.IUser ep5User =
                                 WPUMFactory.getUserFactory().getEP5User(sapUser);
                //       create an ep5 user from the retrieved user
                ResourceContext context = new ResourceContext(ep5User);
                //      Give the path to KM in the variable path
                String repository = "//documents//News//";
                RID rid = RID.getRID(repository);
                IResourceFactory factory = ResourceFactory.getInstance();
                ICollection folder = (ICollection) factory.getResource(rid, context);
                byte[] byteArray =
                      (byte[]) wdContext.currentFilenodeElement().getFileData();
                //      From the temporary location read the file using an input stream
                ByteArrayInputStream fin = new ByteArrayInputStream(byteArray);
                //      Using this input stream we can write to the repository
                Content content =
                      new Content(fin, binaryType.getMimeType().getHtmlMime(), -1L);
                try {
                      IMutablePropertyMap propertyMap = new MutablePropertyMap();
                      IResource newResource =
                            folder.createResource(
                                 wdContext.currentFilenodeElement().getAttributeAsText(
                                 "fileData"),
                                 propertyMap,
                                 content);
                } catch (NameAlreadyExistsException re2) {
                      try {
                            fin = new ByteArrayInputStream(byteArray);
                            content =
                                 new Content(
                                       fin,
                                       binaryType.getMimeType().getHtmlMime(),
                                       -1L);
                            RID fileRid = RID.getRID(repository + filename);
                            IResource fileResource = factory.getResource(fileRid, context);
                            fileResource.updateContent(content);
                      } catch (Exception e) {
                            wdComponentAPI.getMessageManager().reportSuccess(
                                 "File doesn't exist:" + e.getMessage());
                fin.close();
          } catch (Exception e) {
                wdComponentAPI.getMessageManager().reportException(
                      "File not found." + e.getMessage(),
                      true);
          } finally {
                element.setAttributeValue(wdContext.currentFilenodeElement().getFileName(), null);
        //@@end
    and the error then I have in same codes is:
      java.lang.IllegalArgumentException:
        at com.sap.tc.webdynpro.clientserver.data.DataContainer.createLocalPath(DataContainer.java:1347)
        at com.sap.tc.webdynpro.clientserver.data.DataContainer.updateAttribute(DataContainer.java:451)
        at com.sap.tc.webdynpro.clientserver.uielements.adaptbase.AbstractAdapter.updateAttribute(AbstractAdapter.java:644)
        at com.sap.tc.webdynpro.clientserver.uielib.standard.uradapter.FileUploadAdapter.onFILEUPLOADCHANGE(FileUploadAdapter.java:298)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    com.sap.tc.webdynpro.services.exceptions.WDRuntimeException
            at com.sap.tc.webdynpro.clientimpl.html.client.HtmlClient.handleUIElementEvent(HtmlClient.java:957)
            at com.sap.tc.webdynpro.clientimpl.html.client.HtmlClient.updateEventQueue(HtmlClient.java:372)
            at com.sap.tc.webdynpro.clientserver.cal.AbstractClient.prepareTasks(AbstractClient.java:93)
            at com.sap.tc.webdynpro.clientserver.session.ApplicationSession.doProcessing(ApplicationSession.java:294)
            at com.sap.tc.webdynpro.clientserver.session.ClientSession.doApplicationProcessingStandalone(ClientSession.java:707)
            at com.sap.tc.webdynpro.clientserver.session.ClientSession.doApplicationProcessing(ClientSession.java:661)
            at com.sap.tc.webdynpro.clientserver.session.ClientSession.doProcessing(ClientSession.java:229)
            at com.sap.tc.webdynpro.clientserver.session.RequestManager.doProcessing(RequestManager.java:152)
            at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:62)
            at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doPost(DispatcherServlet.java:53)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
            at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:390)
            at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:264)
            at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:347)
            at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:325)
            at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:887)
            at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:241)
            at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
            at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:148)
            at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
            at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
            at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
            at java.security.AccessController.doPrivileged(Native Method)
            at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
            at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)
    Caused by: java.lang.reflect.InvocationTargetException
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:324)
            at com.sap.tc.webdynpro.clientimpl.html.client.HtmlClient.handleUIElementEvent(HtmlClient.java:949)
            ... 25 more
    Caused by: java.lang.IllegalArgumentException:
            at com.sap.tc.webdynpro.clientserver.data.DataContainer.createLocalPath(DataContainer.java:1347)
            at com.sap.tc.webdynpro.clientserver.data.DataContainer.updateAttribute(DataContainer.java:451)
            at com.sap.tc.webdynpro.clientserver.uielements.adaptbase.AbstractAdapter.updateAttribute(AbstractAdapter.java:644)
            at com.sap.tc.webdynpro.clientserver.uielib.standard.uradapter.FileUploadAdapter.onFILEUPLOADCHANGE(FileUploadAdapter.java:298)
            ... 30 more

    Hello
    It looks that I have a similar problem - how could you solve your problem.
    Thanks in advance
    Sascha Fuchs

  • Creating a file in KM with attributes or metada

    Hi friends,
    I would like to create a document/file in KM but whith some attributes or metadata attached like time, date, contact person, telefon, department....
    I'm using the following code to upload a file, but I haven't found any Thread in this Forum about how to attach some metadata or context attributes.
         IPrivateRegistreEntradaView.IFileNodeElement fileelement = wdContext.currentFileNodeElement();
         wdContext.nodeFileNode().bind(fileelement);
         /*Make a simple type of that type*/
         IWDAttributeInfo attInfo = wdContext.nodeFileNode().getNodeInfo().getAttribute("filedata");
         ISimpleTypeModifiable type = attInfo.getModifiableSimpleType();
         /**Following is the code for uploading files**/
         /*Get an object of current Portal user */
         IWDClientUser wdClientUser = WDClientUser.getCurrentUser();
         com.sap.security.api.IUser sapUser = wdClientUser.getSAPUser();
         /*create an ep5 user from the retrieved user*/
          IUser ep5User = WPUMFactory.getUserFactory().getEP5User(sapUser);
          ResourceContext context = new ResourceContext(ep5User);
         /*Give the path to KM in the variable path */
         RID rid = RID.getRID("/documents");
         IResourceFactory factory = ResourceFactory.getInstance();
         ICollection folder = (ICollection) factory.getResource(rid,context);
          /***Using the upload element we can upload the files to a location in the server drive***/
         /*temperory location for writing */
          String location = "give the location here";
          String fileName = location + fileelement.getFilename();
          File file = new File(fileName);
         /*Create an output stream for writing to the temperory location*/
          FileOutputStream out = new FileOutputStream(file);
          out.write(fileelement.getFiledata());
          out.close();
         /*From the temporary location read the file using an input stream*/
          FileInputStream fin = new FileInputStream(fileName);
          fin.read();
         /*Using this input stream we can write to the repository*/
          //Content content = new Content(fileelement.getFiledata(),fileelement.get)
          Content content = new Content(fin,"byte", -1);
          IResource newResource = folder.createResource(fileelement.getFilename(), null, content);
    I think the solution could be by modifying the second argument of
    IResource newResource = folder.createResource(fileelement.getFilename(), null, content);
    This argument is a "IPropertyMap" type and now takes de value "null", but I'm not sure.
    Any ideas?
    Thanks very much in advance,

    Hello Lohitha,
    Thanks your interest but that link did not help a lot.
    Roberto,
    Thanks a lot for the links, the second one really gives a guide for setting up properties in the portal.
    But I found it quite more extended that my requirements, eventhought it helps a lot, since i just would like to attach some " attributes o some simple data" to the uploding file.
    I've found an option usint IPropertyMap
    Map myMap = new HashMap();
    String DEPARTAMENT = null;
    mapeo.put(DEPARTAMENTO, "HH.RR"); //this is just a example
    IPropertyMap myProperties = new PropertyMap(myMap) {
                   public int size() {
                        // TODO Auto-generated method stub
                        return 0;
                   public boolean isEmpty() {
                        // TODO Auto-generated method stub
                        return false;
    //Here we must implement all the metodes of the interface
    //then finally call
    IResource newResource = folder.createResource(fileelement.getFilename(), myProperties , content);
    But I'm not sure it could work, I'm having technical dificulties,
    Anybody could tell us any other simple option for creating a file in KM attaching some simple attributes??
    Thanks to all.
    Ivan,

  • Uploading a file in KM using KM API

    Hi,
    How to upload a file into KM using KM API.
    Regards
    MQ

    Hi,
    Pls go thru the below code.
    public static final String uptoKm(com.sap.tc.webdynpro.services.sal.datatransport.api.IWDResource resource){
                               try {
                                       ResourceContext  contex= new   ResourceContext(WPUMFactory.getUserFactory( ).getEP5User(req.getUser( )); );
                                       IResourceFactory factory = ResourceFactory.getInstance();
                                         RID rid = RID.getRID(PATH);
                                          ICollection folder = (ICollection)factory.getResource(rid,contex);
                                           Content content = new Content(resource.read(true),"byte",-1);
                                         folder.createResource(resource.getResourceName(),null,content);
                                       return resource.getResourceName();
                                  } catch (NotSupportedException e) {
                                       e.printStackTrace();
                                  } catch (AccessDeniedException e) {
                                       e.printStackTrace();
                                  } catch (ResourceException e) {
                                   e.printStackTrace();
                                   return null;
                                  } catch (IOException e) {
                                       e.printStackTrace();
                 return null;
    Above method accept parameter of resource and return file name on sucessfully uploaded.
    best regards
    Hari.

  • Accessing anonymous user in web dynpro application

    Hi All,
      I have created one web dynpro application for internet site (Anonymous user). While trying to retrieve the Iuser through web dynpro application, it is coming <b>null</b> coz user is Anonymous if i am not wrong.
    So I am not able to read the property file from the KM and based on the value coming from the property file i am setting in the drop down.
    Regards,
    Nelly
    Message was edited by: Nelly
            nelly khare

    hi,
    i did the same thing den code is working and values are coming from the property file but i m going to place this application in the Internet.
    There i can't ask user to enter User-Id and PWD.
    I tried to use IWDClient's object and through this i m accessing getSAPUser().
    here is the code that i m using:-
    <b>wdClientUser = WDClientUser.getCurrentUser();
    manager.reportSuccess("wdclientuser-"+wdClientUser);-value is coming for that
    sapUser = wdClientUser.getSAPUser();
    manager.reportSuccess("sapUser -"+sapUser );Null is coming for that
    //create an ep5 user from the retrieved user
    ep5User = WPUMFactory.getUserFactory().getEP5User(sapUser);
    resourseContext = new ResourceContext(ep5User);
    resourseFactory = ResourceFactory.getInstance();
    pathRID =RID.getRID(/documents/IDBDevelopments/Propertyfiles/JobOpportunity/DateofBirth.properties");
    resource =     (IResource) resourseFactory.getResource(pathRID,resourseContext);</b>
    In that point i m getting Null as value.coz it's description says that if user is Anopnymous this function will return Null.
    Coz of that i m not able to create Resource context for reading the property file.
    Regards,
    Deepak

  • Com.sapportals.portal.prt.service.soap.SOAPRuntimeContext

    Is there any class like com.sapportals.portal.prt.service.soap.SOAPRuntimeContext
    (which only works in the context of the portal) that can be used from an EJB environment?
    Basically, from inside an EJB, I want to get the authenticated IUser object that represents the user who called a secure web service.
    Of course, I can use code like this:
    String username = myContext.getCallerPrincipal().getName();
    IUser user = WPUMFactory.getUserFactory().getUser(username);
    The problem is the returned IUser object is not authenticated.  The call user.isAuthenticated() returns false.
    If I use the SOAPRuntimeContext object, I get an IUser object that is authenticated.  That means I can pass the IUser object to the knowledge managament APIs and preform functions as the user who logged into the web service.

    Dharmi,
    Please try this,
    Check the jar here
    New Reference for Portal APIs
    Or you can extract the parfile into your local computer and navigate to PORTAL-INF
    -> lib folder there you will find the required jar.
    Ramganesan Karuppaiyah

  • I need one helps  please

    I need one helps I am implementing a tree of navigation of km with java vestibule and have a problem, when I request to him to this that orders with respect to a metadata or reality with any criterion this always takes the folders and it orders them and later it takes the Links and you order them, and the truth that I need that it does not make that distinction single that orders by the metadata that does not take in whatever if it is Link or folder
    here the code goes that I am using to see if to somebody something is happened to him:
    import bean.NavigationTree;
    import com.sapportals.htmlb.TreeNode;
    import com.sapportals.htmlb.enum.ResourceType;
    import com.sapportals.htmlb.page.DynPage;
    import com.sapportals.htmlb.page.PageException;
    import com.sapportals.portal.htmlb.page.JSPDynPage;
    import com.sapportals.portal.htmlb.page.PageProcessorComponent;
    import com.sapportals.portal.prt.component.IPortalComponentContext;
    import com.sapportals.portal.prt.component.IPortalComponentProfile;
    import com.sapportals.portal.prt.component.IPortalComponentRequest;
    import com.sapportals.portal.prt.component.IPortalComponentResponse;
    import com.sapportals.portal.prt.component.IPortalComponentURI;
    import com.sapportals.portal.prt.session.IUserContext;
    import com.sapportals.portal.security.usermanagement.IUser;
    import com.sapportals.wcm.repository.ICollection;
    import com.sapportals.wcm.repository.IProperty;
    import com.sapportals.wcm.repository.IPropertyName;
    import com.sapportals.wcm.repository.IResource;
    import com.sapportals.wcm.repository.IResourceList;
    import com.sapportals.wcm.repository.PropertyName;
    import com.sapportals.wcm.repository.ResourceContext;
    import com.sapportals.wcm.repository.ResourceException;
    import com.sapportals.wcm.repository.ResourceFactory;
    import com.sapportals.wcm.repository.ResourcePropertyComparator;
    import com.sapportals.wcm.repository.enum.OrderType;
    import com.sapportals.wcm.util.uri.RID;
    //import com.sapportals.wcm.util.usermanagement.WPUMFactory;
    Title:        Navigation in KM repository with DynPage and JSP<br>
    Description:  Basic navigation.<br>
    Copyright:    Copyright (c) 2006<br>
    Company:      AGILE<br>
    @author Juan Solar
    public class Neo extends PageProcessorComponent {
         public DynPage getPage() {
              return new NeoDynPage();
         public class NeoDynPage extends JSPDynPage {
              public String pathInitial = "/documents/eo";
              public String pathDocument = "";
              private String kmNavigation = "";
              private String kmViewDoc = "";
              //          private String pictFolder = "/irj/portalapps/com.sap.portal.pcm.admin.plainfolder_converter/images/folder.gif";
              public IPortalComponentRequest request;
              public IPortalComponentResponse response;
              public IPortalComponentProfile profile;
              private NavigationTree treeBean;
              private IUser user;
              private IResourceList reslist;
              private int nodeCount;
              String TITLE = "TOrder";
              String NAMESPACE = "http://sapportals.com/xmlns/cm";
              String selectedTitle = "";
              public void doInitialization() throws PageException {
                   request = (IPortalComponentRequest) this.getRequest();
                   response = (IPortalComponentResponse) this.getResponse();
                   treeBean = new NavigationTree();
                   IPortalComponentContext myContext = request.getComponentContext();
                   profile = myContext.getProfile();
                   IPortalComponentURI componentURI =
                        request.createPortalComponentURI();
                   componentURI.setContextName("com.sap.km.cm.navigation");
                   kmNavigation = componentURI.toString();
                   componentURI.setContextName("com.sap.km.cm.docs");
                   selectedTitle = "";
                   kmViewDoc = componentURI.toString();
                   nodeCount = 0;
                   try {
                        //               pathInitial = profile.getProperty("pathInitial");
                        //                    user = WPUMFactory.getUserFactory().getEP5User(request.getUser());
                        user = getPortalUser(request);
                        ResourceContext ctxt = new ResourceContext(user);
                        RID rid = RID.getRID(pathInitial);
                        IResource resource =ResourceFactory.getInstance().getResource(rid, ctxt);
                        ICollection collection = (ICollection) resource;
                        reslist = collection.getChildren();
                   } catch (Exception e) {
                        response.write(e.getMessage());
              public void doProcessAfterInput() throws PageException {
              public void doProcessBeforeOutput() throws PageException {
                   TreeNode root = new TreeNode("rootNode", "root");
                   //               List tmp=(List)root;
                   //               Collections.sort(tmp);
                   root.setOpen(true);
                   try {
                        add_node(reslist, root);
                   } catch (ResourceException e) {
                        e.printStackTrace();
                   treeBean.setOutput("");
                   treeBean.setTree(root);
                   // set bean in servlet request - it will be used by the jsp afterwards
                   request.getServletRequest().setAttribute("neoTreeBean", treeBean);
                   this.setJspName("neotree.jsp");
              private String getSelectedTitle() {
                   return selectedTitle;
              //          public String getSelectedTitle(){
              //          Esta es una funcion alternativa para porder cambiar el criterio de ordenamiento del recurso lista
              private void sortResouceList(IResourceList resourceList,String orderBy)     throws Exception {
                   //create property names to index properties
                   IPropertyName iPropSort = new PropertyName("http://sapportals.com/xmlns/cm", orderBy);
                   //             create a comparator to order the resource list
                   ResourcePropertyComparator rRPC =new ResourcePropertyComparator(iPropSort, true);
                   //           order the resource list
                   resourceList.sort(rRPC);
              private String getPropertyValue(IPropertyName iname,IResource resource)throws ResourceException {
                   String value = "";
                   //               String namespace = "http://com.sap.netweaver.bc.rf.sample/xmlns/sample";
                   //               String name = "Order";
                   //               IPropertyName propertyName = new PropertyName(namespace, name);
                   IProperty property = resource.getProperty(iname); //propertyName
                   if (property != null) {
                        // property exists
                        value = property.getValueAsString();
                   } else {
                        // property is not set for this resource
                   return value;
    @param reslist      IResourceList
    @param root         TreeNode
              private void add_node(IResourceList list, TreeNode parentNode)
                   throws ResourceException {
                   //new add_node().doit();
                   String title;
                   String name;
                   String label;
                   String path;
                   IResourceList tmpreslist;
                   ICollection tmpcollection;
                   IPropertyName iProperty;
                   try {
                        sortResouceList(list,"displayname"); //, "Order"
                   } catch (Exception e) {
                        e.printStackTrace();
                   boolean first = true;
                   for (int i = 0; i < list.size(); i++) {
                        IResource tmpres = list.get(i);
                        String     rType= tmpres.getResourceType();
                        iProperty =     new PropertyName("http://sapportals.com/xmlns/cm", "displayname");//, "Order"
                        try {
                             name = tmpres.getName();
                             title = tmpres.getDisplayName();
                             title = (title.equals("") || title == null) ? name : title;
                             path = tmpres.getAccessRID().getPath();
                             if (tmpres.isCollection() && !tmpres.isHidden()) {
                                  tmpcollection = (ICollection) tmpres;
    //                              if (tmpcollection.getChildren().size() > 0) {
                                       TreeNode node =     new TreeNode(Integer.toString(nodeCount++),title,parentNode);
                                       node.setTooltip(name);     //
    //                                   if (order==null || (order!=null && order.equals(""))) {
    //                                        label = "<a class=urLnk href=\"javascript:nada();\" onclick=\"alert('";
    //                                        label ="Folder "node.getText()+" has not set the Order Metadata!! ";               // path;
    //                                        label += "');\">" + node.getText() + "</a>";
    //                                        node.setText(label);
    //                                   } else{
                                            tmpreslist = tmpcollection.getChildren();
                                            add_node(tmpreslist, node);
                             } else {
                                  if (first) {
                                       label =     "<a class=urLnk href=\"javascript:nada();\" onclick=\"goNavigate('";
                                       label += path;
                                       label += "');\">" + parentNode.getText() + "</a>";
                                       parentNode.setText(label);
                                       first = false;
                                  TreeNode node =     new TreeNode(Integer.toString(nodeCount++),title,parentNode);
                                  node.setTooltip(name);     //
                                  label ="<a class=urLnk href=\"javascript:nada();\" onclick=\"goNavigate('";
                                  label += path;
                                  label += "');\">" + node.getText() + "</a>";
                                  node.setText(label);
                        } catch (Exception ex) {
                             IPortalComponentResponse response = (IPortalComponentResponse) this.getResponse();
              //          href=\"javascript:void(0)          "<a target=\"itoptarget\"                     href=\""kmViewDocpath+"\"          
    Returns the IUser object.<br><     
    @param request
    @return user
              public IUser getPortalUser(IPortalComponentRequest request) {
                   //               user = WPUMFactory.getServiceUserFactory().getServiceUser("service_user_id");
                   IUserContext uc = request.getUser();
                   user = (IUser) uc.getUser();
                   return user;

    Click here for information. If you can't get the answers emailed to you for some reason(the email may take a few hours to arrive), contact the iTunes Store staff via the link in that article.
    (87419)

  • Problem in accessing images in the KM from Portal code.

    Hi All,
    I need to develop a portal application that accesses the KM and displays the images that are stored in the KM to the user. There are 8 images which are stored in the /documents/Images directory in the KM. The user should be able to see the next image in the KM by clicking on the 'Next' button of the JSP and the previous image in the KM by clicking on the 'Previous' button of the JSP.
    Below is the code which reads the KM and displays the images. However, the images that are displayed are not in a proper sequence. Also when the user clicks on the 'Next' button and arrives to the last image, although i disable the 'Next' button, when the user clicks on the 'Previous' button the user is not able to see the previous image. Infact the KM tries to display the next image which is not present and hence throws an IndexOutOfBoundsException. This happens vice versa for the 'Previous' button as well.
    Any help would be highly appreciated and rewarded.
    JSP Dynpage
    package com.ltitl.image;
    import com.ltitl.bean.ImageBean;
    import com.sap.security.api.IUser;
    import com.sapportals.htmlb.event.Event;
    import com.sapportals.htmlb.page.DynPage;
    import com.sapportals.htmlb.page.PageException;
    import com.sapportals.portal.htmlb.page.JSPDynPage;
    import com.sapportals.portal.htmlb.page.PageProcessorComponent;
    import com.sapportals.portal.prt.component.IPortalComponentProfile;
    import com.sapportals.portal.prt.component.IPortalComponentRequest;
    import com.sapportals.portal.prt.component.IPortalComponentSession;
    import com.sapportals.portal.security.usermanagement.UserManagementException;
    import com.sapportals.wcm.repository.ICollection;
    import com.sapportals.wcm.repository.IResource;
    import com.sapportals.wcm.repository.IResourceContext;
    import com.sapportals.wcm.repository.IResourceList;
    import com.sapportals.wcm.repository.ResourceContext;
    import com.sapportals.wcm.repository.ResourceException;
    import com.sapportals.wcm.repository.ResourceFactory;
    import com.sapportals.wcm.util.uri.RID;
    import com.sapportals.wcm.util.usermanagement.WPUMFactory;
    public class ImageControl extends PageProcessorComponent {
      public DynPage getPage(){
        return new ImageControlDynPage();
      public static class ImageControlDynPage extends JSPDynPage{
        public static ImageBean imageBean = null;
        public static IResource resource = null;
        public static IResourceContext resourceContext = null;
        public static IPortalComponentSession componentSession = null;
        public static IPortalComponentRequest request = null;
        public static IPortalComponentProfile profile = null;
        public static IUser user1 = null;
        public static RID rid = null;
        public static int count = 0;
        public static int total = 0;
        public static IResourceList children = null;
        public void doInitialization() throws PageException{
          request = (IPortalComponentRequest)this.getRequest();     
          componentSession = request.getComponentSession();
          profile = request.getComponentContext().getProfile();
          user1 = request.getUser();
          imageBean = new ImageBean();
           try
                   com.sapportals.portal.security.usermanagement.IUser user =  WPUMFactory.getUserFactory().getEP5User(user1);
         resourceContext = new ResourceContext(user);
         String imagepath = profile.getProperty("PathToFolder");     
         rid = RID.getRID(imagepath);
         resource = ResourceFactory.getInstance().getResource(rid,resourceContext);
         if(resource != null)
                 if(resource.isCollection())
                          ICollection collection = (ICollection)resource;
                          total = collection.getChildrenCount(true,false,false);
                          imageBean.setTotal(total);
                          children = collection.getChildren();
                          accessResource();
                     else
                          imageBean.setMsg_txt("resource " + resource.getName() + " is not a collection");
                else
                     imageBean.setMsg_txt("resource " + resource.getRID() + " does not exist");
              componentSession.putValue("imageBean",imageBean);
           } catch (UserManagementException ume) {
                imageBean.setMsg_txt("exception:" + ume.getLocalizedMessage());     
           catch(ResourceException ue) {
                imageBean.setMsg_txt("exception:" + ue.getLocalizedMessage());     
        public void doProcessAfterInput() throws PageException {
              IPortalComponentSession session = ((IPortalComponentRequest)this.getRequest()).getComponentSession();
              imageBean = (ImageBean)session.getValue("imageBean");
              if(null != imageBean) {
                   accessResource();
              else
                   imageBean.setMsg_txt("Image Bean null");
        public void doProcessBeforeOutput() throws PageException {
          this.setJspName("ImageOutput.jsp");
        public void onPrevious(Event event) throws PageException {
             --count;
         public void onNext(Event event) throws PageException {
              ++count;
    public void accessResource() throws PageException {
    try {
    if(count >= 0 && count < total)
    IResource resImg = children.get(count);
    imageBean.setCount(count);
    imageBean.setMsg_txt("count: " + count);
    imageBean.setInitialPath("/irj/go/km/docs");
    imageBean.setImageName("" + resImg.getRID());
    else
    imageBean.setMsg_txt("out of bounds count:" + count);
    } catch (ResourceException e) {
         imageBean.setMsg_txt("resource exception:" + e.getLocalizedMessage());

    ImageBean
    package com.ltitl.bean;
    import java.io.Serializable;
    public class ImageBean implements Serializable {
         public String imageName;
         public String msg_txt;
         public String initialPath;
         public int count;
         public int total;
          * @return
         public String getImageName() {
              return this.imageName;
          * @param string
         public void setImageName(String string) {
              imageName = string;
          * @return
         public String getMsg_txt() {
              return this.msg_txt;
          * @param string
         public void setMsg_txt(String string) {
              msg_txt = string;
          * @return
         public String getInitialPath() {
              return initialPath;
          * @param string
         public void setInitialPath(String string) {
              initialPath = string;
          * @return
         public int getCount() {
              return count;
          * @return
         public int getTotal() {
              return total;
          * @param i
         public void setCount(int i) {
              count = i;
          * @param i
         public void setTotal(int i) {
              total = i;
    Hope this helps.

  • Display KM image in JSP

    Hi All,
    I have image in KM folder. I want to display it in JSP as a html image. I am able to
    access the image using below code.
    <%
    try {
         IUser sapUser = componentRequest.getUser();
         com.sapportals.portal.security.usermanagement.IUser ep5User = WPUMFactory.getUserFactory().getEP5User(sapUser);
         IResourceContext resourceContext = new ResourceContext(ep5User);
         String path = "/documents/Images/sample.gif";
         RID imgRID = RID.getRID(path);
         IResource resource = ResourceFactory.getInstance().getResource(imgRID, resourceContext);
         BufferedInputStream bufIn = new BufferedInputStream(resource.getContent().getInputStream());
    byte[] imagebyte = new byte[bufIn.available()];
    bufIn.read(imagebyte);
    catch(Exception e ) { }
    %>
    <img border="0" width="147" height="66" src="">
    Using above code image is stored in a byte array. How to set this as html img tag source.
    Thanks
    Joe

    Hello Sreekanth,
    there are two approaches how to get an KM image into your JSP.
    <b>1) The easy one</b>
    Just put into SRC attribute of your IMG tag next link:
    <b>/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/</b>documents/Images/sample.gif
    Bold part is an access link to KM root. In this case - be aware, the users have to have access rights to given KM object (could be inherited from parent folder).
    <b>2) Through a stream</b>
    In this case you don't have to set access rights for a given resource for all users, you will read the image from Runtime (using ice_service context for example).
    And you can refer to that image as you refer your application. The only thing you need to do - is to write image byte stream to response in your application. Example:
              ByteArrayOutputStream PictureStream = ...;
              if (request.getParameter("Get_Image") != null) {
                        response.setContentType("image/gif");
                        ServletOutputStream sos = response.getOutputStream();
                        response.setHeader("Content-Disposition", "attachment; filename="image.gif"");
                        response.setHeader("Cache-Control", "no-cache");
                        PictureStream.writeTo(sos);
                        sos.close();
                   return;
    And then you address this image stream in your SRC attribute of IMG tag following:
    <u><i><your application url absolute or relative (relative is siggested)>?Get_Image=true</i></u>
    regards,
    mz

Maybe you are looking for

  • Macbook late 2009 mini DVI to HDMI not working

    I never had a problem using my external TV with my macbook untill now. I always connect it using a mini DVI cable to HDMI to TV. It worked pefectly for a while. But recently it stopped working, when i plug in my macbook to TV it shows a blue screen f

  • Hard Drive Full - Need to upgrade

    My Hard Drive is full on my Powerbook G4. I have dozens of external drives i use for storing backups but i want a larger hard drive that is internal so i can have easier mobility. what type of hard drive is compatible with this machine? Serial ATA or

  • "Recovered" CR2 files will not open in Photoshop CS6

    My son recently completed the National Three Peaks Challenge. Regrettably, having taken loads of pictures, he discovered that one of the CF cards was corrupt. He and his fellow climbers have now paid a company (a considerable sum) to recover these ph

  • My Firefox / Google start page has lost the buttons that allow me to "search the web" or "look at pages from UK". How can I get these back?

    These are the selection button just under the window where you enter what you are searching for and above the "Google Search" button. They used to be there but have disappeared!

  • Help with Media Encoder CS4

    I just purchased Flash CS4 and I am having problems viewing my video online. If you view:  http://lhswebdesign.com/~rkolinsky/rick/jfk/jfk.html you can see what happens.  The video never appears. I used a mov file, created a flv file.  Maybe my setti