Topic
4 replies Latest Post - ‏2013-10-30T13:14:18Z by NKatic
IvanSaavedra
IvanSaavedra
30 Posts
ACCEPTED ANSWER

Pinned topic Import - Documment Whit The Same name Of a Existing Documment

‏2013-10-17T19:14:04Z |

Hi All!

 

Is there any way to restrict the user to import a documment with the same name and properties of a documment that already exist in the ICN repository?

 

Tks a lot!

  • BJOwings
    BJOwings
    185 Posts
    ACCEPTED ANSWER

    Re: Import - Documment Whit The Same name Of a Existing Documment

    ‏2013-10-18T18:42:28Z  in response to IvanSaavedra

    Are you working with CM or P8?   If this is CM then you can use the unique setting on the attribute of the item type.   I don't see a similar setting for a P8 property.  ICN doesn't have any feature to enforce uniqueness outside of the repository's.  It would be possible to add this through a programming customization, either a server-side event or ICN plugin, but it would have performance implications.  A search on document title would need to be performed on every import.

  • nicolas.leralle
    nicolas.leralle
    100 Posts
    ACCEPTED ANSWER

    Re: Import - Documment Whit The Same name Of a Existing Documment

    ‏2013-10-22T11:37:25Z  in response to IvanSaavedra

    Hi Ivan,

     

    I had to implement this behavior with IBM FileNet P8.

     

    We used a synchronous subscription to handle this point.

    Here are the consideration you have to be aware of:

    • Versionning
      • Can two version of the same document have the same DocumentTitle?
      • Have I to test the unicity on current version of document, or all version
    • Security rights (How can I notify the user that a document with the same Title exists, if he has no access to it?)

     

    We choose to implement following rules:

    • DocumentTitle has to be unique against all documents versions
    • If an existing value is found, if it is the same document, but an other version, the DocumentTitle is allowed, else, even if the user can't see the document, an exception is thrown, blocking the document add.

     

    The sample code looks like:

     

    private void checkDocTitleUnicity(Document docToCheck) {
    String documentTitle = docToCheck.get_Name();
    String documentId = docToCheck.get_Id().toString();
    String documentVersionSeriesId = docToCheck.get_VersionSeries().get_Id().toString();
    SearchScope searchScope = new SearchScope(objectStore);
    // Instantiate an SQL object to hold our search criteria
    SearchSQL search = new SearchSQL();
    // When searching, retrieve certain property
    search.setSelectList("Id");
    // From certain class
    search.setFromClauseInitialValue("Document", "D", true);
    documentTitle = documentTitle.replaceAll("'", "''");
    // with certain restrictions
    search.setWhereClause("DocumentTitle='"+documentTitle+"'");
    try{
    RepositoryRowSet rowSet = searchScope.fetchRows(search, null, null, new Boolean(true));
    Iterator<RepositoryRow> iter = rowSet.iterator();
    while (iter.hasNext()) {
    RepositoryRow row = (RepositoryRow) iter.next();
    Document docResult = Factory.Document.fetchInstance(objectStore, row.getProperties().get("Id").getIdValue(), null);
    if(!docResult.get_VersionSeries().get_Id().toString().equalsIgnoreCase(documentVersionSeriesId)){
    throw new EngineRuntimeException(ExceptionCode.E_NOT_UNIQUE);
    }
    }
    }catch (EngineRuntimeException ere) {
    if(!ere.getExceptionCode().equals(ExceptionCode.E_NOT_UNIQUE)){
    logger.error("Unmanaged exception occured during search : "+ere.getMessage());
    ErrorRecord er[] = { new ErrorRecord(ere) };
    throw new EngineRuntimeException(ere, ExceptionCode.EVENT_HANDLER_THREW, er);
    }
    else
    throw ere;
    }catch (Exception e) {
    logger.error("Unmanaged exception occured during search : "+e.getMessage());
    ErrorRecord er[] = { new ErrorRecord(e) };
    throw new EngineRuntimeException(e, ExceptionCode.EVENT_HANDLER_THREW, er);
    }
    logger.info("The document title "+documentTitle+" for the document with ID {"+documentId+"} is unique");
    }

     

    Hope this helps.

    Best regards,

     

    Nicolas