Mostrando entradas con la etiqueta ucm. Mostrar todas las entradas
Mostrando entradas con la etiqueta ucm. Mostrar todas las entradas

19 feb 2013

Using CMIS query with boolean metadata

Often we create boolean type metadata on WebCenter Content. This type of metadata in fact is an integer type metadata, but uses a system internal view called "YesNoView".

Check screenshots above to see the default configuration of this kind of metadata.



If we check the standard "Check-in" page, the metadata is represented with a "combo-box" input.





You can use this metatada to perform searchs over UCM and retrive the contents that are checked as "hidden" (in this example).


Since WebCenter PS3 was released, you can show content on WebCenter Portal/Spaces with "Content-Presenter (CP)" taskflow. This component shows contents stored at content server (UCM).

CP allows the user to define a query that searchs on content-server the items that matches your query. This is done over CMIS standard instead UCM query syntax.

Now, we try to add a content-presenter on a page, and query filtering with the new metadata (Hidden content). This is the CP wizard screenshot.


Remember to check that the new metadata is in "Filters" section. And save/close the wizard...

The system will show some error stacktrace, this is a summary

Caused by: oracle.webcenter.content.integration.RepositoryException: 19-feb-2013 17:00:46 oracle.webcenter.content.integration.spi.ucm.search.SearchService search
GRAVE: Se ha producido un error al buscar el repositorio ucm. Se ha recibido el código de estado -1 al llamar al servicio GET_SEARCH_RESULTS, como usuario weblogic y registro de hora 19/02/13 17:00. La búsqueda es Search[repositoryId=ucm, max to return=5, useFullTextSearch=true, useCache=true, sort="toProperty('dDocTitle') ASC", fullText="
 Metadata criteria((cm_contentType equals IDC:GlobalProfile)AND(xHiddenContent [any] equals true))
 isOr=false"] y la asignación de parámetros es {ResultCount=5, FolderPathInSearchResults=1, SortField=dDocTitle, IdcService=GET_SEARCH_RESULTS, SortOrder=ASC, vcrAppendObjectClassInfo=1, StartRow=1, QueryText=(xHiddenContent  `true`), vcrContentType=IDC:GlobalProfile}.


If you have installed WebCenter Spaces, we can try the Web-interface to test the CMIS queries. In my case I tried the following URLs:
  • http://owc:8888/rest/api/cmis/query/q/ucm?q=SELECT * FROM ora:t:IDC:GlobalProfile WHERE ora:p:xTuiHiddenContent = TRUE
  • http://owc:8888/rest/api/cmis/query/q/ucm?q=SELECT * FROM ora:t:IDC:GlobalProfile WHERE ora:p:xTuiHiddenContent = 1

And the following errors were launched

oracle.webcenter.content.integration.cmis.query.ParseException: Feb 19, 2013 5:19:27 PM oracle.webcenter.content.integration.cmis.query.VcrExpressionSearchDelegate fixLiteral
SEVERE: Comparing boolean property [xHiddenContent] to non-Boolean literal [1]


oracle.webcenter.content.integration.RepositoryException: Feb 19, 2013 5:19:33 PM oracle.webcenter.content.integration.spi.ucm.search.SearchService search
SEVERE: An error occurred when searching repository ucm.  When calling service GET_SEARCH_RESULTS, as user anonymous, at timestamp 2/19/13 5:19 PM, received status code -1.   The search was Search[repositoryId=ucm, max to return=26, useFullTextSearch=false, useCache=true, expr="(toProperty('xHiddenContent') == true && toProperty('cm_contentType') == 'IDC:GlobalProfile')"] and the parameter map was {ResultCount=26, FolderPathInSearchResults=1, SortField=dInDate, IdcService=GET_SEARCH_RESULTS, SortOrder=Desc, vcrAppendObjectClassInfo=1, StartRow=1, QueryText=(xHiddenContent  `1`), vcrContentType=IDC:GlobalProfile}.

To solve this, there is a workaround that we can do, without affecting the content already stored at UCM.

First create a table in UCM (using ConfigurationManager Applet), this table should have a structure similar to this one:



After that, we create a view that uses that table, similar to this one:



Next you should add the values for true/false.


And finally, attach the new view created to the metadata, replacing the system "YesNoView" with the "YesNoCustomView" just created.


Now, restart WebCenter Spaces and try with this URL:

  • http://owc:8888/rest/api/cmis/query/q/ucm?q=SELECT * FROM ora:t:IDC:GlobalProfile WHERE ora:p:xHiddenContent = 1
Now the query is correctly performed over CMIS standard. And if you try CP Wizard now also works without problems.

I hope this information helps on your project.

Related Information 



12 feb 2013

java.net.socketpermission on WebCenter Content (UCM) Applets

After the one of the last updates of my local JRE I couln't connect to the UCM Applets of the client throught the proxy connection.

This error appears:


To solve this issue, go to your "java.policy" file, mine is under this path:

C:\Program Files (x86)\Java\jre7\lib\security\java.policy

Modify your file and add this line at the end of the file:


permission java.net.SocketPermission "*", "connect,accept,resolve"; 

After that modification, close all your browsers and retry to open the Applet.



26 oct 2012

Validate check-in form fields with Javascript

At one of my current projects we faced the problem that the dDocName field was filled with no common characters by the user.

For example they insert spaces and letters (like áéíóú). This kind of contentID was breaking the indexer process of UCM.

Most of you will tell me to use the AUTO_NUMBER property of content server, but on some type of content, the user have to insert a specified dDocName for our SSXA Web project.

To prevent contentID like "BIOGRAFÍA CATALÁN", we developed a custom component that performs a JS validation before check-in process.

For the validation I've created a REGEX expresion that allows only letters, numbers and underscore.

This is the code inserted in the custom-component. As you see, this will "include" all system validations with the <$include super.custom_schema_validation_script_post$> sentence.
After that, starts our custom validation, we only have to return "false" if we want to cancel the check-in process.

<@dynamichtml custom_schema_validation_script_post@>
<$include super.custom_schema_validation_script_post$>
<$if ((dpAction like "CheckinSel" or dpAction like "CheckinNew" or dpAction like "Update"))$>
if (document.Checkin != null && document.Checkin.dDocName != null)
{
var name = document.Checkin.dDocName.value;
if(name != null && name != '' && name.length > 0)
{
 var rgx_docname = /^[A-Za-z0-9_]{1,30}$/;
 
 if (rgx_docname.test(name))
 {
  vstatus = "Ok";
 }
 else
 {
  vstatus = "Error";
  alert("Error: You cannot use non-ASCII characters for ContentID");
  return false;
 }
}
}
<$endif$>   
<@end@>

Download here the custom-component for your customization and use.

14 mar 2012

Add SecurityGroup from parent folder in a profile check-in

Using folders component in WebCenter Content, let you to add default or inherit metadata to the contents that are under the parent folder.

Imagine that you have 3 different folders for a "news" content, two of them with "Public" SecurityGroup but the last one with "Secure" SecurityGroup.

Usually you will create only one profile, so users will select the folder during check-in process (if they can see them) and depending of the folder, the metadata dSecurityGroup will be filled.


Here are the steps to achieve this:

Modify "Folders" View

  1. Log into Configuration Manager Applet

  2. Go to "Tables" tab, and select "Collections" table.

  3. Click on "Edit Table", if you cannot see the columns, click on "syncrhonize definition" close again the windows and try again (sometimes it tooks a while until the columns information appears)

  4. Now move to "View" Tab and Edit the "Folders" View.

  5. Edit it and select the "Change Columns" to include the dSecurityGroup



  6. Move to the "Security" Tab and check the option "Publish view data".


Creating the Rule

  1. Create a new rule and check it as "global"

  2. Go to fields, and add "Security Group"



  3. Edit "Derived field information" and in custom tab add this code:




<$nuevoValor=getViewValue("Folders",#active.xCollectionID,"dSecurityGroup")$>
<$if nuevoValor$>
<$dpPromote("dSecurityGroup",nuevoValor)$>
<$endif$>


Few things to remember

If the metadata from the parent that you want to "derive" is custom (like xDepartment) you should create a view from table "COLMETA" with the columns dCollectionID and xDepartment, for more info check on metalink this note: 780979.1

5 sept 2011

Get metadata values from external service in a Custom Element Form

At my actual UCM project we are using some tables to store values of a metadata field.


We have already a custom service that performs a Query to the table to obtain that values, with this service we can show values of the DB table in our JSPX. (For more info on how to build this kind of components check Brian Bex Huff Book)


This is how our service returns the data:





Our customer ask us about the possibility of adding inside a Site Studio Contribution Form a custom element that shows in a combo the values of the table. After searching a bit I found Kyle's post really good and very similar to what I triying to do.


After modifying a bit the code, finally I have success, and my custom element performs this steps:
1- Executes a custom service
2- Obtain the data from XML Request via AJAX
3- Prints a combo with the data obtained.


There is the source code. (link)


For your purposes you will have to modify the next lines 36-41

var httpCgiPath = "http://" + document.location.hostname + "/cs/idcplg"; 
var myRset = "QueryResult";
var myIDField = "CT2_ID";
var myDescField = "CT2_DESC_EN";
var myFieldName = "custom-content-type-level-2";

Also should be modified the line 295 where is the URL of the service execution:



var requestUrl = httpCgiPath + "?IdcService=CUSTOM_CTN2&idN1=15&IsSoap=1";
loadXMLDoc(requestUrl, loadComboValues);



This is how it looks like:






22 ago 2011

SSXA + RIDC en un Servlet

Durante un desarrollo de un sitio web en tecnología SiteStudio for external applications (SSXA en adelante) me vi con la necesidad de utilizar el pool de conexiones RIDC que automáticamente cada aplicación Web SSXA tiene definida. 
En concreto no fuimos capaces de descargar un fichero en su formato "original" ya que la tecnología SSXA sólo parece contemplar la descarga de ficheros en su formato web desde UCM (web rendition). Por ello desarrollamos este servlet que es capaz de conectarse a UCM a través de RIDC y realizar una descarga de un fichero dado su identificador (dDocName).


Os dejo un ejemplo de como se realiza una llamada RIDC desde un servlet aprovechando su configuración de conexiones con UCM.




Ejemplo de RIDC usando un Servlet y SSXA:

private void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
{
if(request.getParameter("file")!=null && request.getParameter("file")!= ""){
try
{
 ClientApplication client = getWcmApplication(this.getServletContext());
 IdcClientFactory idcClientFact = new IdcClientFactory(client.getConfigLoader().getConfiguration().getSystemConfig().getIdcConfig());
 IdcClient m_client = idcClientFact.getClientManager().createClient(idcClientFact.getIdcConfig().getConnectionUrl());
 IdcContext m_userContext = idcClientFact.getGuestContext();

//Ejecución del servicio
DataBinder dataBinder = m_client.createBinder();

dataBinder.putLocal("IdcService", "GET_FILE");
dataBinder.putLocal("dDocName", request.getParameter("file"));
dataBinder.putLocal("RevisionSelectionMethod","LatestReleased");
dataBinder.putLocal("Rendition", "Primary");

 // Ejecuto la petición
 ServiceResponse sRes = m_client.sendRequest(m_userContext, dataBinder);
 String startSplit = "filename=";
 String content = sRes.getHeader(HEADER_CONTENT);
 String fileName = content.substring(content.indexOf(startSplit) + startSplit.length() + 1, content.length() - 1);

 response.setContentType( (sRes.getHeader(HEADER_MIME) != null) ? sRes.getHeader(HEADER_MIME) : "application/octet-stream" );
 response.setContentLength(Integer.parseInt(sRes.getHeader(HEADER_LENGTH)));
 response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"" );


 //
 //  Stream to the requester.
 //
 byte[] bbuf = new byte[512];
 DataInputStream in = new DataInputStream(sRes.getResponseStream());
 int length   = 0;
 while ((in != null) && ((length = in.read(bbuf)) != -1))
 {
 response.getOutputStream().write(bbuf,0,length);
 }


 in.close();
 response.getOutputStream().flush();
 response.getOutputStream().close(); 
}
catch (ApplicationException e) {
logger.error("Error en descarga de contenido",e);
}
catch (Exception e) {
 logger.error("Error en descarga de contenido",e);
}
}
}


public ClientApplication getWcmApplication(ServletContext sc) throws Exception
{ 
  return ServletApplicationFactory.createInstance(sc);
}