cancel
Showing results for 
Search instead for 
Did you mean: 

Get filenames from KM folder

Former Member
0 Kudos

Hi,

I want to know all filenames of a folder in the KM repository of my sap portal.

The url to the folder is already known...I just need to read the folder and put all the filenames in an Array or list or something else where I can loop through.

Kind regards

Accepted Solutions (0)

Answers (1)

Answers (1)

govardan_raj
Contributor
0 Kudos

Hi Tim,

for getting file names under a  KM Folder you can find the below code and for more info go through this link.

try

    {

//  Get a Resouce Context from the Local Method

     IResourceContext resourceContext = buildResourceContext();

//  get a resource factory

  IResourceFactory resourceFactory = ResourceFactory.getInstance();

//  Get a RID from the current path to display the according content

  RID pathRID = RID.getRID(parent.getPath());

//  Get a Iresource object to work on

  IResource resource = resourceFactory.getResource(pathRID, resourceContext);

//  cast the object to a Collection

  ICollection collection = (ICollection) resource;

//  get the Collection's Children

    IResourceList resourceList = collection.getChildren();

//  Sort Resource List by Name (Local Method)

    sortResouceListByName(resourceList);

//  Finally get an iterator to walk through the set of Children

   IResourceListIterator resourceListIterator =   resourceList.listIterator();

  

 

  

//   Now read all elements

  while (resourceListIterator.hasNext())

   {

  

   IResource tempResource = resourceListIterator.next();

  

   if (tempResource.isCollection())

   {

    //wdComponentAPI.getMessageManager().reportSuccess("Temp is Collection and Resource Name is-->"+tempResource.getName());

  //   create a new Context element for each of them

   folderContentElement =

   folderContentNode.createFolderContentElement();

  //   Local Method

   addFolderToContextNode( folderContentElement, tempResource, pathRID);

   folderContentNode.addElement(folderContentElement);

   parent.setIsExpanded(true);

   hasChildren = true;

     }

  }

  if (!hasChildren) {

   parent.setHasChildren(false);

  }

    }catch(Exception e)

    {

    

    }

go through this link -->

http://scn.sap.com/docs/DOC-26207

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/958fcd90-0201-0010-38aa-d8272da59...

you will understand better ,

Regards

Govardan Raj

Former Member
0 Kudos

Hi Govardan,

I have defined a custom property in my km reposity, called "publish" of type boolean

Publish=true if my document is published.

I need to mofify this property by all km documents but my source code not working and I haven't any error.

I attached my source code in txt file because I can't paste in this post.

Can you help me please??

Thank you in advance.

Regards

Mónica

govardan_raj
Contributor
0 Kudos

hi Monica ,

Have gone through your code can u please put it under try catch block  i.e

try

{

IResourceContext c =
ResourceFactory.getInstance().getServiceContext("cmadmin_service");
       
      
IResourceFactory resourceFactory = ResourceFactory.getInstance();
IResource resourceEdition= resourceFactory.getResource(editRID,c);
      
ICollection edCol= (ICollection)resourceEdition;
      
       IResourceList edList = edCol.getChildren();
      
IResourceListIterator edListIterator =   edList.listIterator();
      
while (edListIterator.hasNext())

  {  IResource tempResource = edListIterator.next();
           
           

    
   if(!tempResource.isCollection())//is a doc
            {
        
    if(!tempResource.isCheckedOut()) {//if not checkout is the same is checkin??
      
             
             
      tempResource.checkOut();
      IProperty propBooleanPublicado;
            
             tempResource.setProperty(new Property(propNameBooleanPublicado,Boolean.TRUE)); 
      tempResource.checkIn(tempResource.getContent(), tempResource.getProperties(), true);
           
              
    }
                    }

           
  }

}

catch (Exception e) 

{

       StackTraceElement element[] = e.getStackTrace();

       StringBuffer buffer = new StringBuffer();

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

            {

             buffer.append(element[i]);

                 }

            wdComponentAPI.getMessageManager().reportException(buffer.toString(),true);

}

now after executing this above code please post  the exception that you are getting ,. we can trace the ...

Becuase im not able to trace the faults

here  editRID is the parameter being passed to this method i guess

and

 

IProperty propBooleanPublicado;

tempResource.setProperty(new Property(propNameBooleanPublicado,Boolean.TRUE));

here propNameBooleanPublicado  is not being initialized , is it parameter being passed ?

Regards

Govardan


Former Member
0 Kudos

Hi Govardan,

I'm modifying the next function, there is definided block try-catch.

In this function I have included the funcionality to modify the property "publicado" for one document, but a need modify this property to all documents already existed in the repository.

public IRenderingEvent execute(IResource sourcedocRES, Event event)

  throws WcmException {

  int nversion = 0;

  int lvl = 0;

  ICopyParameter copyParams = null; //Parameters for copy.

  IResource targetdocRES = null; //Target document resource.

  IResource targetfoldRES = null; //Target folder resource.

  IContent sourceDocCONT = null;

  InputStream sourceDocIS = null;

  RID publiRID = null, editRID = null; //Document areas RIDs

  RID sourcedocumentRID = null,

  targetfolderRID = null,

  targetdocumentRID = null;

  IVersionController sourcefolderVC = null;

  IVersionController targetfolderVC = null;

  //Folder and Document RIDs.

  ConfirmFormEvent confiFormEvent = null;

  String msg = "";

  Status msgStatus = null;

// propiedad publicado

   Name nameBooleanPublicado = null;

   nameBooleanPublicado=new Name(Hardcodedvalues.NAMESPACE,Hardcodedvalues.PROPPUBLICADOC);

   IPropertyName propNameBooleanPublicado =new PropertyName(nameBooleanPublicado);

  try {

  //If ConfirmEvent is thrown

  if (event instanceof ConfirmFormEvent) {

  confiFormEvent = (ConfirmFormEvent) event;

  //Getting ConfirmFormEvent choice.

  if (ConfirmFormEvent

  .CHOICE_YES

  .equals(confiFormEvent.getChoice())) {

  //Getting Level parameter from UICommand.

  String level = this.getParameters().get("Level").toString();

  level = level.replace('[', ' ');

  level = level.replace(']', ' ');

  level = level.substring(1, level.length() - 1);

  lvl = Integer.parseInt(level);

  //Getting Publicacion parameter from UICommand.

  String publication =

  this.getParameters().get("Publicacion").toString();

  publication = publication.replace('[', ' ');

  publication = publication.replace(']', ' ');

  publication =

  publication.substring(1, publication.length() - 1);

  //Getting Publicacion RID.

  publiRID = RID.getRID(RID.PATH_SEPARATOR + publication);

  //Getting Edicion parameter from UICommand.

  String edition =

  this.getParameters().get("Edicion").toString();

  edition = edition.replace('[', ' ');

  edition = edition.replace(']', ' ');

  edition = edition.substring(1, edition.length() - 1);

  //Gestting Edicion RID

  editRID = RID.getRID(RID.PATH_SEPARATOR + edition);

  //Getting RID from source document

  sourcedocumentRID = sourcedocRES.getRID();

  //Getting RID from target folder.

  targetfolderRID =

  this.FinalCollectionPath(sourcedocRES, publiRID, lvl);

  //Getting RID from target document.

  targetdocumentRID =

  this.FinalDocumentPath(sourcedocRES, publiRID, lvl);

  //Getting Resource from target document.

  targetdocRES = this.RecoverResource(targetdocumentRID);

  //Getting Resource from target folder.

  targetfoldRES = this.RecoverResource(targetfolderRID);

  sourcefolderVC =

  (IVersionController) this

  .RecoverResource(

  sourcedocRES.getParentCollection().getRID())

  .as(IVersionController.class);

  targetfolderVC =

  (IVersionController) this.RecoverResource(

  targetfolderRID).as(

  IVersionController.class);

  //Testing if targetfolder exist

  if (this.RecoverResource(targetfolderRID) != null) {

  // Target and source folders are in the same state (versioned or not)

  if (sourcefolderVC.isEnabled()

  == targetfolderVC.isEnabled()) {

  // Target document does not exist

  if (!ResourceFactory

  .getInstance()

  .checkExistence(targetdocumentRID, context)) {

  // If source folder (edicion) is versioned

  if (sourcefolderVC.isEnabled()) {

  //Getting the version number given by the user.

  nversion =

  Integer.parseInt(

  confiFormEvent.getVersion());

  //If version greater than 0.

  if (nversion > 0) {

  //Setting property prp_related_version.

  //Forcing Check out before editing documents properties.

  if (!sourcedocRES.isCheckedOut()) {

  sourcedocRES.checkOut();

  }

  //Setting releated version property in source document.

  sourcedocRES.setProperty(

  new Property(

  this.InitPropName(),

  new Integer(nversion)));

  //Forcing a check in of the resource befor copying it.

  sourcedocRES.checkIn(

  sourcedocRES.getContent(),

  sourcedocRES.getProperties(),

  true);

  //Setting copy parameters.

  copyParams = new CopyParameter();

  copyParams.setIgnorePropertyFailures(

  true);

  //Copying source document to target document.

  sourcedocRES.copy(

  targetdocumentRID,

  copyParams);

  //If version greater than 1.

  if (nversion > 1) {

  this.UpdateToActualVersion(

  sourcedocRES,

  nversion);

  this.UpdateToActualVersion(

  RecoverResource(targetdocumentRID),

  nversion);

  this.InversalDeleteVersions(

  sourcedocRES,

  1);

  this.InversalDeleteVersions(

  RecoverResource(targetdocumentRID),

  1);

  //If version less than 1.

  } else {

  this.InversalDeleteVersions(

  sourcedocRES,

  0);

  }

  //If version less than 0.

  } else {

  //Error, version number must be greater than 0.

  msgStatus = Status.ABORT;

  msg =

  "La versión introducida, ha de ser superior a 0";

  }

  // If source folder (edicion) is not versioned

  } else {

  //No version input has been done so we set version number to 0.

  nversion = 0;

  //Setting property to source doc, that holds related version number.

  sourcedocRES.setProperty(

  new Property(

  this.InitPropName(),

  new Integer(nversion)));

  //Setting copy parameters.

  copyParams = new CopyParameter();

  copyParams.setIgnorePropertyFailures(true);

  //Copying source document to target document.

  sourcedocRES.copy(

  targetdocumentRID,

  copyParams);

  }

  //Target document exists

  } else {

  // If source folder (edicion) is versioned

  if (sourcefolderVC.isEnabled()) {

  //Getting Sourcedocument content.

  sourceDocIS =

  sourcedocRES

  .getContent()

  .getInputStream();

  sourceDocCONT =

  new Content(

  sourceDocIS,

  sourcedocRES.getResourceType(),

  sourcedocRES

  .getContent()

  .getContentLength());

  //Setting property prp_related_version.

  //Forcing Check out before editing documents properties.

  if (!sourcedocRES.isCheckedOut()) {

  sourcedocRES.checkOut();

  }

  // Setting releated version property in source document.

  // AFEGIT GREGORI

  String nlastversion =

  sourcedocRES

  .getVersionHistory()

  .get(

  sourcedocRES

  .getVersionHistory()

  .size()-1)

  .getRevisionID();

  if (nlastversion != null) {

  sourcedocRES.setProperty(

  new Property(

  this.InitPropName(),

  new Integer(

  Integer

  .valueOf(nlastversion)

  .intValue()

  + 1)));

  /* IProperty nversionsource =

  sourcedocRES.getProperty(

  this.InitPropName());

  sourcedocRES.setProperty(

  new Property(

  this.InitPropName(),

  new Integer(

  nversionsource

  .getIntValue()

  + 1)));*/

  // Forcing a check in of the resource befor copying it.

  sourcedocRES.checkIn(

  sourcedocRES.getContent(),

  sourcedocRES.getProperties(),

  true);

  if (!targetdocRES.isCheckedOut()) {

  targetdocRES.checkOut();

  }

  targetdocRES.updateContent(

  sourceDocCONT);

  targetdocRES.checkIn(

  targetdocRES.getContent(),

  targetdocRES.getProperties(),

  true);

  this.DeleteVersions(sourcedocRES);

  } else {

  msgStatus = Status.ABORT;

  msg =

  "Error al leer el número de version.";

  }

  //AFEGIT GREGORI

  // if source folder (edicion) is not versioned

  } else {

  // Getting Sourcedocument content.

  sourceDocIS =

  sourcedocRES

  .getContent()

  .getInputStream();

  sourceDocCONT =

  new Content(

  sourceDocIS,

  sourcedocRES.getResourceType(),

  sourcedocRES

  .getContent()

  .getContentLength());

  //Setting property prp_related_version.

  // Setting releated version property in source document.

  IProperty nversionsource =

  sourcedocRES.getProperty(

  this.InitPropName());

  sourcedocRES.setProperty(

  new Property(

  this.InitPropName(),

  new Integer(

  nversionsource.getIntValue()

  + 1)));

  targetdocRES.updateContent(sourceDocCONT);

  } //End if folder versioned.

  } //End target document exists

//*********** UPDATE BY MÓNICA GONZALEZ JULIO 2014

  IProperty propBooleanPublicado =

  sourcedocRES.getProperties().get(propNameBooleanPublicado);

  if (sourcedocRES.isVersioned()) {

  if(!sourcedocRES.isCheckedOut()){

  sourcedocRES.checkOut();

  }

   

  //publicado=SI

  sourcedocRES.setProperty(new Property(propNameBooleanPublicado,Boolean.TRUE));

  sourcedocRES.checkIn(sourcedocRES.getContent(), sourcedocRES.getProperties(), true);

  }

  //else sourcedocRES.setProperty(new Property(propNameBooleanPublicado,Boolean.TRUE));

  this.copyACL(targetdocumentRID);

  msgStatus = Status.OK;

  msg =

  "Se ha Publicado el documento "

  + sourcedocRES.getName();

  // Folder state is diferent (one versioned the other not)

  } else {

  msgStatus = Status.ABORT;

  msg =

  "El area de edicion y la de publicacion deben tener la misma configuracion respecto al versionado";

  }

  //Target folder does not exist.

  } else {

  msgStatus = Status.ERROR;

  msg =

  "En el area de publicación no existe la carpeta destino "

  + targetfolderRID

  + ".";

  } //End target folder exist

  } else {

  msgStatus = Status.WARNING;

  msg = "La acción ha sido cancelada por el usuario.";

  }

  }

  } catch (NumberFormatException e) {

  msgStatus = Status.ABORT;

  msg =

  "La versión introducida, ha de ser un valor numérico: "

  + e.toString();

  } catch (NotSupportedException e) {

  msgStatus = Status.ABORT;

  msg =

  "Esta acción no se puede realizar sobre el documento: "

  + e.toString();

  } catch (AccessDeniedException e) {

  msgStatus = Status.ABORT;

  msg =

  "No tiene los permisos necesarios para realizar la publicación: "

  + e.toString();

  } catch (ResourceException e) {

  msgStatus = Status.ABORT;

  msg =

  "Se ha producido un error al acceder a los datos del Documento, vuelva a entrar en la carpeta e intentelo de nuevo, en caso de persistir, contacte con el administrador del sistema: "

  + e.toString();

  } catch (ContentException e) {

  msgStatus = Status.ABORT;

  msg =

  "Se ha producido un error al acceder a los datos del Documento, vuelva a entrar en la carpeta e intentelo de nuevo, en caso de persistir, contacte con el administrador del sistema: "

  + e.getMessage();

  } catch (NullPointerException e) {

  msgStatus = Status.ABORT;

  msg =

  "Se ha producido un error al acceder a los datos del Documento, vuelva a entrar en la carpeta e intentelo de nuevo, en caso de persistir, contacte con el administrador del sistema: "

  + e.toString();

  }

  return new InfoEvent(msgStatus, msg);

  }

//end function

********************************************************************************************************

In this function I want included the source code I send yesterday:

IResourceContext c =

  ResourceFactory.getInstance().getServiceContext("cmadmin_service");

  

  IResourceFactory resourceFactory = ResourceFactory.getInstance();

  IResource resourceEdition= resourceFactory.getResource(editRID,c);

   

  ICollection edCol= (ICollection)resourceEdition;

   

  IResourceList edList = edCol.getChildren();

   

  IResourceListIterator edListIterator =   edList.listIterator();

   

  while (edListIterator.hasNext())

  {  IResource tempResource = edListIterator.next();

  /*IRepositoryServiceFactory repositoryServiceFactory =

   ResourceFactory

   .getInstance()

   .getServiceFactory();

   statemanagementManager =

   (

   IStatemanagementManager) repositoryServiceFactory

   .getRepositoryService(

  tempResource,

   IWcmConst.STATEMANAGEMENT_SERVICE);

  

   sResource =

   statemanagementManager

   .getStatemangementResource(

  tempResource);*/

   

    if(!tempResource.isCollection())//es un doc

  {

  

   if(!tempResource.isCheckedOut()) {//si no esta en check out esta en checkin

      

  tempResource.checkOut();

  IProperty propBooleanPublicado;

  

  tempResource.setProperty(new Property(propNameBooleanPublicado,Boolean.TRUE)); 

  tempResource.checkIn(tempResource.getContent(), tempResource.getProperties(), true);

  }

          

  }

        

  }//while

   

When I execute this function with this source code included I have any error,

Is correct the way to access all elements of the repository "edicion"?

Thanks!

Regards

Mónica

govardan_raj
Contributor
0 Kudos

hi Monica ,

In this you have so many  catch blocks  predefining the exceptions , just keep one single catch block to catch exception e

i.e

try

{

}catch(Exception e)

{

print the stack trace ... as suggested in above thread.

}

Former Member
0 Kudos

Hi Govardan,

Thanks for your help!!

I changed the function, I created a UICommand  this button update the property "Publicado" in all documents.

1. I created the UICommand property

2. Create .java in NWDS

This is the source code:

package com.offilog.kmquality.uicommand;

import java.util.List;

import com.offilog.kmquality.hardcoded.Hardcodedvalues;

import com.sapportals.htmlb.TextView;

import com.sapportals.htmlb.event.Event;

import com.sapportals.wcm.WcmException;

import com.sapportals.wcm.rendering.base.IRenderingEvent;

import com.sapportals.wcm.rendering.base.IScreenflowData;

import com.sapportals.wcm.rendering.base.event.InfoEvent;

import com.sapportals.wcm.rendering.screenflow.os.ConfirmComponent;

import com.sapportals.wcm.rendering.screenflow.os.ConfirmEvent;

import com.sapportals.wcm.rendering.screenflow.os.OneStepScreenflow;

import com.sapportals.wcm.rendering.uicommand.AbstractCommand;

import com.sapportals.wcm.rendering.uicommand.ICommand;

import com.sapportals.wcm.rendering.uicommand.ISimpleExecution;

import com.sapportals.wcm.repository.AccessDeniedException;

import com.sapportals.wcm.repository.IProperty;

import com.sapportals.wcm.repository.IPropertyName;

import com.sapportals.wcm.repository.IResource;

import com.sapportals.wcm.repository.IResourceContext;

import com.sapportals.wcm.repository.NotSupportedException;

import com.sapportals.wcm.repository.Property;

import com.sapportals.wcm.repository.PropertyName;

import com.sapportals.wcm.repository.ResourceException;

import com.sapportals.wcm.repository.ResourceFactory;

import com.sapportals.wcm.util.controlstatus.Status;

import com.sapportals.wcm.util.name.Name;

import com.sapportals.wcm.util.uri.RID;

import com.sapportals.wcm.repository.IResourceList;

import com.sapportals.wcm.repository.ICollection;

import com.sapportals.wcm.repository.IResourceListIterator;

public class ActualizarPublicadoUI extends AbstractCommand

  implements ISimpleExecution {

  private List values;

  /**

  * Metthod used to get a new instance of this command.

  *

  * @return a valid ICommand

  */

  public ICommand getNewInstance() {

  return this.initNewInstance(new ActualizarPublicadoUI());

  }

  /**

  * This methods executes the screenflow. It is triggered by the Flexible UI

  * framework.

  *

  * @return a valid IRenderingEvent object.

  */

  public IRenderingEvent execute(IScreenflowData sfd) throws WcmException {

  TextView tv = new TextView("Actualizar");

  ConfirmComponent cc =

  new ConfirmComponent(

  ConfirmComponent.OK_CANCEL,

  this.context.getLocale(),

  tv);

  String sRid = (String) this.values.get(0);

  RID rid = RID.getRID(sRid, null);

  IResource t = ResourceFactory.getInstance().getResource(rid, context);

  tv.setText(

  "¿Actualizar estado Publicado de todos los documentos ");

  OneStepScreenflow oscf =

  new OneStepScreenflow(sfd, this.getAlias(), rid, cc);

  return oscf.execute();

  }

  /**

  * This method gets the Command parameters

  */

  public String[] getTargetParameters() throws WcmException {

  return new String[] { this.getResource().getRID().getPath()};

  }

  /**

  * Target parameters.

  */

  public void setTargetParameters(List list, IResourceContext ctxt)

  throws WcmException {

  this.context = ctxt;

  this.values = list;

  }

  /* (non-Javadoc)

  * @see com.sapportals.wcm.rendering.uicommand.AbstractCommand#isExecutable()

  */

  public boolean isExecutable() {

  // TODO Auto-generated method stub

  return true;

  }

  /**

  * This method executes the command.

  *

  * @return a InfoEvent with a Status and a Message.

  */

public IRenderingEvent execute(IResource res,Event event)throws WcmException{

  String msg = null;

  Status msgstatus = null;

  try{

            // With the ConfirmEvent we can see if the user accept or canceled the process.

   if (event instanceof ConfirmEvent) {

                  //Getting the confirmEvent.

  ConfirmEvent confirmE = (ConfirmEvent) event;

  

  if (ConfirmEvent.CHOICE_YES.equals(confirmE.getChoice())){

  //Get value of parameter level of a UIcommand property.

  String level = this.getParameters().get("Level").toString();

  level = level.replace('[', ' ');

  level = level.replace(']', ' ');

  level = level.substring(1, level.length() - 1);

  int lvl = 0;

  lvl = Integer.parseInt(level);

  // Getting the value of the parameter Edicion of uICommand property.

  String edition = this.getParameters().get("Edicion").toString();

        edition = edition.replace('[', ' ');

    edition = edition.replace(']', ' ');

    edition = edition.substring(1, edition.length() - 1);

   //Get RID from String

    RID editRID =RID.getRID(RID.PATH_SEPARATOR + edition);

  //Trying to get the Resource from the RID above. If null return an error message.

  if (ResourceFactory.getInstance().getResource(editRID, context)!= null){

  ICollection KMFolders=

    (ICollection)ResourceFactory.getInstance().getResource(editRID, context);

  IResourceList resourceList = KMFolders.getChildren();

  //Recursive method

    if (resourceList.size() > 0) this.readCollection(KMFolders,editRID,lvl);

  }//if (ResourceFactory.getInstance().getResource(editRID, context)!= null)

  }//if (ConfirmEvent.CHOICE_YES.equals(confirmE.getChoice()))

  else if (confirmE.getChoice().equals(ConfirmEvent.CHOICE_NO)) {

  msgstatus = Status.ABORT;

  msg = "Cancelado.";

   }

  

  

   }//if (event instanceof ConfirmEvent)

         

          else {

  msgstatus = Status.ERROR;

  msg =

  "Evento no esperado, el evento no es del tipo ConfirmEvent";

    }

  }//try

  catch (NotSupportedException e) {

  e.fillInStackTrace();

  msgstatus = Status.ABORT;

  msg = "Esta Accion no se puede realizar sobre el documento";

  }

  catch (AccessDeniedException e) {

  e.fillInStackTrace();

  msgstatus = Status.ABORT;

  msg ="No tiene los permisos necesarios sobre el documento";

  }

  catch (ResourceException e) {

  e.fillInStackTrace();

  msgstatus = Status.ABORT;

  msg =

  "Se ha producido un error al acceder a los datos del Documento, vuelva a entrar en la carpeta e intentelo de nuevo, en caso de persistir, contacte con el administrador del sistema: "

  + e.getMessage();

  }

  catch (NullPointerException e) {

  e.fillInStackTrace();

  msgstatus = Status.ABORT;

  msg =

  "Se ha producido un error al acceder a los datos del Documento, vuelva a entrar en la carpeta e intentelo de nuevo, en caso de persistir, contacte con el administrador del sistema: "

  + e.getMessage();

  }

  return new InfoEvent(msgstatus, msg);

}

public void readCollection(ICollection editCollection, RID areaRID, int level )

  {

  //@@begin readCollection()

  try {

   IResourceList resourceList = editCollection.getChildren();

  

   IResourceListIterator resourceListIterator =

   resourceList.listIterator();

  

  while (resourceListIterator.hasNext()) {

  IResource tempResource = resourceListIterator.next();

   if (tempResource.isCollection() == true) {

  ICollection temp_collcn = (ICollection) tempResource;

  this.readCollection(temp_collcn,areaRID,level);

   } else if (

  tempResource.isCollection() == false) {

  //Storing the resource reference //

  this.changePublicadoResource(tempResource,areaRID,level);

   } // end of isCollection IF             

  } //end of while loop                         

        

  } catch (Exception ex) {

  

          }//catch

  } //@@end

private void changePublicadoResource(IResource res, RID areaRID, int level)

   throws ResourceException {

   //Get the resource to modify its properties.

   IResource resource = this.getResource(res, areaRID, level);

   //Change resource properties

   if (resource != null) {

   this.setPublicadoProperty(resource);

   }

  }//end  function

  private IResource getResource(IResource res, RID rid, int level)

  throws ResourceException {

  //"/xxx/xxx/yyy/xxx.txt"

  RID origen = res.getRID();

  List pathSeparado = origen.split();

  for (int i = 0; i < level; i++){

  pathSeparado.remove(0);

  }

  // "/yyy/xxx.txt

  pathSeparado.add(0, rid.toString());

  // "zzz/zzz/yyy/xxx.txt

  String temp = (String) pathSeparado.get(0);

  for (int i = 1; i < pathSeparado.size(); i++){

  temp = temp + RID.PATH_SEPARATOR + (String) pathSeparado.get(i);

  }

  RID path = RID.getRID(temp);

  IResource edit =

  ResourceFactory.getInstance().getResource(path, context);

  return edit;

  }

private void setPublicadoProperty(IResource res)

  throws ResourceException {

  //Get Property Publicado Name

  Name nameBooleanPublicado =

  new Name(Hardcodedvalues.NAMESPACE, Hardcodedvalues.PROPPUBLICADOC);

  IPropertyName propNameBooleanPublicado =

  new PropertyName(nameBooleanPublicado);

  //Get Property Deactivated

  IProperty propBooleanDelete =

  res.getProperties().get(propNameBooleanPublicado);

  if (res.isVersioned()) {

  if (!res.isCheckedOut()) {

  res.checkOut();

  }

  res.setProperty(new Property(propNameBooleanPublicado, Boolean.TRUE));

  res.checkIn(res.getContent(), res.getProperties(), true);

  } else {

  res.setProperty(new Property(propNameBooleanPublicado, Boolean.FALSE));

  }

  }

}//public class ActualizarPublicadoUI

Regards!!

govardan_raj
Contributor
0 Kudos

hi monica ,

Nice to hear that you solved the problem yourself

cheers

Govardan

Former Member
0 Kudos

Hi,

The problem is not solved...I can´t see in the menu the new option "Actualizar", this option have

This option must appear together "Publicar" and "Desactivar", I can't test my new .java still

Regards

govardan_raj
Contributor
0 Kudos

hi monica ,

In the above code where is "Publicar" and "Desactivar" is added to the options ?

Regards

Govardan

Former Member
0 Kudos

Hi Govardan,

I can see the new option =Activar" in the menu. The funcion working but  the execution is very slow.

Finally I have to do two new methods:

1. Is necessary to update all old documents.

2. A portal services to capture the event of a resource when the user modify a document and does check-In,  the value the property "publicado" should be False.

Thanks for your help, update this new property is being complicated... 🙂

Regards

Mónica