Skip to Content
Enterprise workspaces provide several methods OOTB to integrate Portal content into workspaces –
OOTB module templates, create module template from Portal Content, importing KM snippets etc.

 

But many customers have been asking: “Do enterprise workspaces support integrating content from external sources?”

 

Well, the answer is positive! 😎

 

The next question of course is “Is it simple?”

Well, once again the answer is positive! 😎

 

You can use the Content API to integrate content from external sources into workspaces.

 

In a nutshell, you need to implement a content provider that represents the content from the external source in workspaces.

 

Through this provider, you can create workspace modules based on external content items and
control their appearance in the content galleries, such as the Module Gallery or Link Gallery.

Now that you’re acquainted with the basic concept, let’s get into details.

 

Step 0: Identify the Public API

First thing to do of course is to read the documentation of the Public API (we all do that, right?).

 

The Content API is contained in the com.sap.workspaces.content package

 

Step 1: Implementing an External Content Module

 

Enough with the reading! You’re eager to write some code.

 

Let’s start with extending the AbstractModule class to represent an external content item:

 

private class Module extends AbstractModule {

   private String url;

            public Module(String URL) {

           this.url= URL;

           }

     public String getID() {

                return “moduleID”;

     }

     public String getName(Locale locale) {

           return “moduleTitle”;

   }              

   //the type of content depends on the module’s isolation

   //mode:

  //if isolation return the URL

     //if embedded return HTML markup

     public String getContent(IPortalComponentRequest
request) throws WorkspacesRuntimeException {

       //Return the module’s URL

 

              return url;

 

              }

         public String getContentForIndexing()
throws WorkspacesRuntimeException {

        //Return the module’s title for indexing

 

              return “moduleTitle”;

 

              }

     }

 

Step 2: Implementing an External Content Provider

The next step is extending the AbstractContentProvider class to represent your content provider.

Note: You implement a content provider as a portal service.

public class ExternalContentProvider extends AbstractContentProvider implements IService {

       //remember this service key. You will use it in step 3!

     private static final String KEY = “tc~spaces~contentproviders.ExternalContentProvider”;

  

     private static final String SHARED_ID = “sharedModuleID”;

 

     private static final String PERSONAL_ID = “personalModuleID”;

 

     private static final String SHARED_URL = “/sharedURL”;

 

     private static final String PERSONAL_URL = “/personalURL”;

 

     ContentDescriptor[] sharedWSDescriptors = new ContentDescriptor[1];

 

     ContentDescriptor[] personalWSDescriptors = new ContentDescriptor[1];

  

     private String[] sharedCurCategories;

 

     private String[] personalCurCategories;

 

     private Date sharedCreationDate;

 

     private Date personalCreationDate;

  

     private void initDescriptors() {

 

            sharedWSDescriptors[0] = new
ContentDescriptor(“sharedTitle”, “sharedDesc”,
“sharedImageUrl”, SHARED_ID, this.sharedCurCategories, this.sharedCreationDate,
“sharedUrl”);

             personalWSDescriptors[0] = new
ContentDescriptor(“personalTitle”, “personalDesc”,
“personalImageUrl”, PERSONAL_ID, this.personalCurCategories,
this.personalCreationDate, “personalUrl”);

       }

        public String getID() {

             //Content Provider ID

             return “contentProviderSampleID”;

      }

        /**

       * In the content descriptor, define in which content galleries and types of workspaces

       * the content item should be available for the specified user and locale

       */     

      public ContentDescriptor getContentDescriptor(
String contentID, IUser user, Locale locale ) {

  

            ContentFilter filter = new
ContentFilter( new Availability[]{Availability.APPLICATION_LIST,
Availability.GALLERY, Availability.REPORT_LIST}, new Type[]{Type.PERSONAL,
Type.SHARED} );            

 

            ContentDescriptor[] descriptors =
getContentDescriptors( filter, user, locale );

  

            if (descriptors != null) {

                     for ( int i = 0; i < descriptors.length; i++ ) {

                             if (descriptors[i].getContentID().equals( contentID ) ) {

                                   return descriptors[i];

 

                            }

 

                    }

 

            }

  

            throw new
WorkspacesRuntimeException( “Descriptor not found for ID: ” +
contentID, null );

      }      

        // Define separate content descriptors for shared and personal workspaces

 

     public
ContentDescriptor[] getContentDescriptors( ContentFilter filter, IUser user,
Locale locale ) {

            if
( filter.getWorkspaceAvailability()[0].equals(Type.SHARED) ) {

                    return sharedWSDescriptors;

            }

              else
{

                      return personalWSDescriptors;

             }

      }

       //Create a module based on the content item using the Module class

     public AbstractModule getModule(String moduleID, IUser user) {

 

            if ( SHARED_ID.equals(moduleID) ) {

                   return new Module( SHARED_URL );

            }

             else {

                     return new Module( PERSONAL_URL );

 

            }

       }

 

Step 3: Integrating the External Content Provider

Simple, isn’t it?

Well, there is one more thing to do – integration!

To enable your content provider, you need to deploy and configure it, as follows:

  1. Finalize and deploy your service to the portal.
  2. Navigate to: Workspace Administration > Configuration> Content
  3. In the Content tab, choose: External Content > Add
  4. In the Content Provider field, enter prt_service:<your service key>.
  5. Navigate to Workspaces, open a workspace in which you are a manager, and choose Add Content. Check that your external content appears in the Module Gallery.
Is that it?

Yes! You can now enjoy your own content with enterprise workspaces! 🙂

Go back to: A Deep Dive into SAP NetWeaver Portal, Enterprise Workspaces (Main TOC blog)

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply