nucm-logo

NUCM-2.0 Documentation
Interface: Removal: nc_destroyversion


[Attribute | Removal | Distribution]

[nc_destroyversion]

Signature

int  nc_destroyversion(const char*  path,
		       const char*  p_cwd,
		       const char*  version)

Functionality

Physically removes a single version of the NUCM artifact determined by the interpretation of the parameters path and p_cwd from a NUCM logical repository. The version that is removed is determined by the parameter version, and is only removed if it is not referenced by any collections.

Return Values

0: everything went ok
-1: an error occurred

NdbErrno Codes

NdbOk :everything went ok
NdbUnknown :the path does not represent a NUCM artifact
NdbNotOpen :the NUCM artifact has not been opened in the workspace
NdbRefcount:the version of the artifact can not be removed because it is still referenced by one or more collections
NdbConnect :the server is down or not reachable
NdbComm :a communication error occurred
NdbProtocol:a failure occurred in the NUCM protocol
NdbNotAvail:service is not available

Example

Assuming a repository is filled with project, and in particular contains a project "my_project" that has members "1", "2", "3", "4", and "5". Artifact "4" has many versions, and some of these versions are members of other projects. To remove all versions of "4" that are not members of any project, the following code fragment can be used:
   #include "nc.h"

   char  lastversion[MAX_VERSION_LENGTH + 1];
   char  version[MAX_VERSION_LENGTH + 1];
   int  i;

   nc_lastversion("//serl.cs.colorado.edu:1234/nucm_root/my_project/4",
		  "",
		  lastversion);
   for (i = 1 ; i <= atoi(lastversion) ; i++) {
      sprintf(version, "%d", i);
      result = nc_destroyversion("//serl.cs.colorado.edu:1234/nucm_root/my_project/4",
				 "",
				 version);
      if (result == -1) {
	 if (NdbErrno == NdbRefCount) {
	    printf("Version %d is a member of a project\n", i);
	 } else {
	    printf("Error during removal of version %d", i);
	 }
      } else {
	 printf("Version %d was removed\n", i);
      }
   }

[Top | Quick Index] [Concepts | Interface]

SERL <serl.cs.colorado.edu>