int
lsDataObjUtil (rcComm_t *conn, rodsPath_t *srcPath, 
rodsEnv *myRodsEnv, rodsArguments_t *rodsArgs, 
genQueryInp_t *genQueryInp)
{
    int status = 0;
 

    if (rodsArgs->longOption == True) {
	if (srcPath->rodsObjStat != NULL &&
	  srcPath->rodsObjStat->specColl != NULL) {
	    if (srcPath->rodsObjStat->specColl->collClass == LINKED_COLL) {
                lsDataObjUtilLong (conn, 
		  srcPath->rodsObjStat->specColl->objPath, myRodsEnv, rodsArgs,
                  genQueryInp);
	    } else {
	        lsSpecDataObjUtilLong (conn, srcPath,
	          myRodsEnv, rodsArgs);
	    }
	} else {
            lsDataObjUtilLong (conn, srcPath->outPath, myRodsEnv, rodsArgs, 
	      genQueryInp);
	}
    } else if (rodsArgs->bundle == True) {
	lsSubfilesInBundle (conn, srcPath->outPath, myRodsEnv, rodsArgs);
    } else {
	printLsStrShort (srcPath->outPath);
        if (rodsArgs->accessControl == True) {
            printDataAcl (conn, srcPath->dataId);
        }
    }

    if (srcPath == NULL) {
       rodsLog (LOG_ERROR,
          "lsDataObjUtil: NULL srcPath input");
        return (USER__NULL_INPUT_ERR);
    }

    return (status);
}
int
printLsShort (rcComm_t *conn,  rodsArguments_t *rodsArgs, 
genQueryOut_t *genQueryOut)
{
    int i;

    sqlResult_t *dataName, *dataId;
    char *tmpDataName, *tmpDataId;

   if (genQueryOut == NULL) {
        return (USER__NULL_INPUT_ERR);
    }

    if ((dataId = getSqlResultByInx (genQueryOut, COL_D_DATA_ID)) == NULL) {
        rodsLog (LOG_ERROR,
          "printLsShort: getSqlResultByInx for COL_D_DATA_ID failed");
        return (UNMATCHED_KEY_OR_INDEX);
    }

    if ((dataName = getSqlResultByInx (genQueryOut, COL_DATA_NAME)) == NULL) {
        rodsLog (LOG_ERROR,
          "printLsShort: getSqlResultByInx for COL_DATA_NAME failed");
        return (UNMATCHED_KEY_OR_INDEX);
    }

    for (i = 0;i < genQueryOut->rowCnt; i++) {
        tmpDataName = &dataName->value[dataName->len * i];
	printLsStrShort (tmpDataName);

        if (rodsArgs->accessControl == True) {
            tmpDataId = &dataId->value[dataId->len * i];
            printDataAcl (conn, tmpDataId);
        }
    }

    return (0);
}
int
lsCollUtil (rcComm_t *conn, rodsPath_t *srcPath, rodsEnv *myRodsEnv, 
rodsArguments_t *rodsArgs)
{
    int savedStatus = 0;
    char *srcColl;
    int status;
    int queryFlags;
    collHandle_t collHandle;
    collEnt_t collEnt;

    if (srcPath == NULL) {
       rodsLog (LOG_ERROR,
          "lsCollUtil: NULL srcPath input");
        return (USER__NULL_INPUT_ERR);
    }

    srcColl = srcPath->outPath;

    /* print this collection */
    printf ("%s:\n", srcColl);

    if (rodsArgs->accessControl == True) {
       printCollAcl (conn, srcColl);
       printCollInheritance (conn, srcColl);
    }

    queryFlags = DATA_QUERY_FIRST_FG;
    if (rodsArgs->veryLongOption == True) {
	/* need to check veryLongOption first since it will have both
	 * veryLongOption and longOption flags on. */
	queryFlags = queryFlags | VERY_LONG_METADATA_FG | NO_TRIM_REPL_FG;
    } else if (rodsArgs->longOption == True) { 
	queryFlags |= LONG_METADATA_FG | NO_TRIM_REPL_FG;;
    }

    status = rclOpenCollection (conn, srcColl, queryFlags,
      &collHandle);

    if (status < 0) {
        rodsLog (LOG_ERROR,
          "lsCollUtil: rclOpenCollection of %s error. status = %d",
          srcColl, status);
        return status;
    }
    while ((status = rclReadCollection (conn, &collHandle, &collEnt)) >= 0) {
	if (collEnt.objType == DATA_OBJ_T) {
            if (rodsArgs->bundle == True) {
		char myPath[MAX_NAME_LEN];
		snprintf (myPath, MAX_NAME_LEN, "%s/%s", collEnt.collName,
		  collEnt.dataName);
                lsSubfilesInBundle (conn, myPath, myRodsEnv, rodsArgs);
	    } else {
	        printDataCollEnt (&collEnt, queryFlags);
	        if (rodsArgs->accessControl == True) {
		    printDataAcl (conn, collEnt.dataId);
	        }
	    }
	} else {
	    printCollCollEnt (&collEnt, queryFlags);
	    /* need to drill down */
            if (rodsArgs->recursive == True && 
	      strcmp (collEnt.collName, "/") != 0) {
                rodsPath_t tmpPath;
                memset (&tmpPath, 0, sizeof (tmpPath));
                rstrcpy (tmpPath.outPath, collEnt.collName, MAX_NAME_LEN);
                status = lsCollUtil (conn, &tmpPath, myRodsEnv, rodsArgs);
	        if (status < 0) savedStatus = status;
	    }
	}
    }
    rclCloseCollection (&collHandle);
    if (savedStatus < 0 && savedStatus != CAT_NO_ROWS_FOUND) {
        return (savedStatus);
    } else {
        return (0);
    }
}
int
printLsLong (rcComm_t *conn, rodsArguments_t *rodsArgs, 
genQueryOut_t *genQueryOut)
{
    int i;
    sqlResult_t *dataName, *replNum, *dataSize, *rescName, 
      *replStatus, *dataModify, *dataOwnerName, *dataId;
    sqlResult_t *chksumStr, *dataPath, *rescGrp, *dataType;
    char *tmpDataId;
    int queryFlags;

   if (genQueryOut == NULL) {
        return (USER__NULL_INPUT_ERR);
    }

    queryFlags = setQueryFlag (rodsArgs);

    if (rodsArgs->veryLongOption == True) {
        if ((chksumStr = getSqlResultByInx (genQueryOut, COL_D_DATA_CHECKSUM)) 
	  == NULL) {
            rodsLog (LOG_ERROR,
              "printLsLong: getSqlResultByInx for COL_D_DATA_CHECKSUM failed");
            return (UNMATCHED_KEY_OR_INDEX);
        }

        if ((dataPath = getSqlResultByInx (genQueryOut, COL_D_DATA_PATH)) 
          == NULL) {
            rodsLog (LOG_ERROR,
              "printLsLong: getSqlResultByInx for COL_D_DATA_PATH failed");
            return (UNMATCHED_KEY_OR_INDEX);
        }

        if ((rescGrp = getSqlResultByInx (genQueryOut, COL_D_RESC_GROUP_NAME))
          == NULL) {
            rodsLog (LOG_ERROR,
             "printLsLong: getSqlResultByInx for COL_D_RESC_GROUP_NAME failed");
            return (UNMATCHED_KEY_OR_INDEX);
        }

        if ((dataType = getSqlResultByInx (genQueryOut, COL_DATA_TYPE_NAME))
          == NULL) {
            rodsLog (LOG_ERROR,
             "printLsLong: getSqlResultByInx for COL_DATA_TYPE_NAME failed");
            return (UNMATCHED_KEY_OR_INDEX);
        }
    }

    if ((dataId = getSqlResultByInx (genQueryOut, COL_D_DATA_ID)) == NULL) {
        rodsLog (LOG_ERROR,
          "printLsLong: getSqlResultByInx for COL_D_DATA_ID failed");
        return (UNMATCHED_KEY_OR_INDEX);
    }

    if ((dataName = getSqlResultByInx (genQueryOut, COL_DATA_NAME)) == NULL) {
        rodsLog (LOG_ERROR,
          "printLsLong: getSqlResultByInx for COL_DATA_NAME failed");
        return (UNMATCHED_KEY_OR_INDEX);
    }

    if ((replNum = getSqlResultByInx (genQueryOut, COL_DATA_REPL_NUM)) == 
      NULL) {
        rodsLog (LOG_ERROR,
          "printLsLong: getSqlResultByInx for COL_DATA_REPL_NUM failed");
        return (UNMATCHED_KEY_OR_INDEX);
    }

    if ((dataSize = getSqlResultByInx (genQueryOut, COL_DATA_SIZE)) == NULL) {
        rodsLog (LOG_ERROR,
          "printLsLong: getSqlResultByInx for COL_DATA_SIZE failed");
        return (UNMATCHED_KEY_OR_INDEX);
    }

    if ((rescName = getSqlResultByInx (genQueryOut, COL_D_RESC_NAME)) == NULL) {
        rodsLog (LOG_ERROR,
          "printLsLong: getSqlResultByInx for COL_D_RESC_NAME failed");
        return (UNMATCHED_KEY_OR_INDEX);
    }

    if ((replStatus = getSqlResultByInx (genQueryOut, COL_D_REPL_STATUS)) == 
     NULL) {
        rodsLog (LOG_ERROR,
          "printLsLong: getSqlResultByInx for COL_D_REPL_STATUS failed");
        return (UNMATCHED_KEY_OR_INDEX);
    }

    if ((dataModify = getSqlResultByInx (genQueryOut, COL_D_MODIFY_TIME)) ==
     NULL) {
        rodsLog (LOG_ERROR,
          "printLsLong: getSqlResultByInx for COL_D_MODIFY_TIME failed");
        return (UNMATCHED_KEY_OR_INDEX);
    }

    if ((dataOwnerName = getSqlResultByInx (genQueryOut, COL_D_OWNER_NAME)) ==
     NULL) {
        rodsLog (LOG_ERROR,
          "printLsLong: getSqlResultByInx for COL_D_OWNER_NAME failed");
        return (UNMATCHED_KEY_OR_INDEX);
    }

   for (i = 0;i < genQueryOut->rowCnt; i++) {
	collEnt_t collEnt;

	bzero (&collEnt, sizeof (collEnt));

	collEnt.dataName = &dataName->value[dataName->len * i];
	collEnt.replNum = atoi (&replNum->value[replNum->len * i]);
	collEnt.dataSize = strtoll (&dataSize->value[dataSize->len * i], 0, 0);
	collEnt.resource = &rescName->value[rescName->len * i];
	collEnt.ownerName = &dataOwnerName->value[dataOwnerName->len * i];
	collEnt.replStatus = atoi (&replStatus->value[replStatus->len * i]);
	collEnt.modifyTime = &dataModify->value[dataModify->len * i];
        if (rodsArgs->veryLongOption == True) {
	    collEnt.chksum = &chksumStr->value[chksumStr->len * i];
	    collEnt.phyPath = &dataPath->value[dataPath->len * i];
	    collEnt.rescGrp = &rescGrp->value[rescGrp->len * i];
	    collEnt.dataType = &dataType->value[dataType->len * i];
	}

	printDataCollEntLong (&collEnt, queryFlags);

	if (rodsArgs->accessControl == True) {
            tmpDataId = &dataId->value[dataId->len * i];
	    printDataAcl (conn, tmpDataId);
	}
    }

    return (0);
}
Exemplo n.º 5
0
int
printLsLong( rcComm_t *conn, rodsArguments_t *rodsArgs,
             genQueryOut_t *genQueryOut ) {
    int i = 0;
    sqlResult_t *dataName = 0, *replNum = 0, *dataSize = 0, *rescName = 0, *rescHier = 0,
                 *replStatus = 0, *dataModify = 0, *dataOwnerName = 0, *dataId = 0;
    sqlResult_t *chksumStr = 0, *dataPath = 0, *dataType = 0; // JMC - backport 4636
    char *tmpDataId = 0;
    int queryFlags = 0;

    if ( genQueryOut == NULL ) {
        return USER__NULL_INPUT_ERR;
    }

    queryFlags = setQueryFlag( rodsArgs );

    if ( rodsArgs->veryLongOption == True ) {
        if ( ( chksumStr = getSqlResultByInx( genQueryOut, COL_D_DATA_CHECKSUM ) )
                == NULL ) {
            rodsLog( LOG_ERROR,
                     "printLsLong: getSqlResultByInx for COL_D_DATA_CHECKSUM failed" );
            return UNMATCHED_KEY_OR_INDEX;
        }

        if ( ( dataPath = getSqlResultByInx( genQueryOut, COL_D_DATA_PATH ) )
                == NULL ) {
            rodsLog( LOG_ERROR,
                     "printLsLong: getSqlResultByInx for COL_D_DATA_PATH failed" );
            return UNMATCHED_KEY_OR_INDEX;
        }

        if ( ( dataType = getSqlResultByInx( genQueryOut, COL_DATA_TYPE_NAME ) ) == NULL ) { // JMC - backport 4636

            rodsLog( LOG_ERROR,
                     "printLsLong: getSqlResultByInx for COL_DATA_TYPE_NAME failed" );
            return UNMATCHED_KEY_OR_INDEX;
        }
    }

    if ( ( dataId = getSqlResultByInx( genQueryOut, COL_D_DATA_ID ) ) == NULL ) {
        rodsLog( LOG_ERROR,
                 "printLsLong: getSqlResultByInx for COL_D_DATA_ID failed" );
        return UNMATCHED_KEY_OR_INDEX;
    }

    if ( ( dataName = getSqlResultByInx( genQueryOut, COL_DATA_NAME ) ) == NULL ) {
        rodsLog( LOG_ERROR,
                 "printLsLong: getSqlResultByInx for COL_DATA_NAME failed" );
        return UNMATCHED_KEY_OR_INDEX;
    }

    if ( ( replNum = getSqlResultByInx( genQueryOut, COL_DATA_REPL_NUM ) ) ==
            NULL ) {
        rodsLog( LOG_ERROR,
                 "printLsLong: getSqlResultByInx for COL_DATA_REPL_NUM failed" );
        return UNMATCHED_KEY_OR_INDEX;
    }

    if ( ( dataSize = getSqlResultByInx( genQueryOut, COL_DATA_SIZE ) ) == NULL ) {
        rodsLog( LOG_ERROR,
                 "printLsLong: getSqlResultByInx for COL_DATA_SIZE failed" );
        return UNMATCHED_KEY_OR_INDEX;
    }

    if ( ( rescName = getSqlResultByInx( genQueryOut, COL_D_RESC_NAME ) ) == NULL ) {
        rodsLog( LOG_ERROR,
                 "printLsLong: getSqlResultByInx for COL_D_RESC_NAME failed" );
        return UNMATCHED_KEY_OR_INDEX;
    }

    if ( ( rescHier = getSqlResultByInx( genQueryOut, COL_D_RESC_HIER ) ) == NULL ) {
        // If the index is not found then COL_D_RESC_HIER was most likely stripped
        // from the query input to talk to an older zone.
        // use resource name instead
        rescHier = rescName;
    }

    if ( ( replStatus = getSqlResultByInx( genQueryOut, COL_D_REPL_STATUS ) ) ==
            NULL ) {
        rodsLog( LOG_ERROR,
                 "printLsLong: getSqlResultByInx for COL_D_REPL_STATUS failed" );
        return UNMATCHED_KEY_OR_INDEX;
    }

    if ( ( dataModify = getSqlResultByInx( genQueryOut, COL_D_MODIFY_TIME ) ) ==
            NULL ) {
        rodsLog( LOG_ERROR,
                 "printLsLong: getSqlResultByInx for COL_D_MODIFY_TIME failed" );
        return UNMATCHED_KEY_OR_INDEX;
    }

    if ( ( dataOwnerName = getSqlResultByInx( genQueryOut, COL_D_OWNER_NAME ) ) ==
            NULL ) {
        rodsLog( LOG_ERROR,
                 "printLsLong: getSqlResultByInx for COL_D_OWNER_NAME failed" );
        return UNMATCHED_KEY_OR_INDEX;
    }

    for ( i = 0; i < genQueryOut->rowCnt; i++ ) {
        collEnt_t collEnt;

        bzero( &collEnt, sizeof( collEnt ) );

        collEnt.dataName = &dataName->value[dataName->len * i];
        collEnt.replNum = atoi( &replNum->value[replNum->len * i] );
        collEnt.dataSize = strtoll( &dataSize->value[dataSize->len * i], 0, 0 );
        collEnt.resource = &rescName->value[rescName->len * i];
        collEnt.resc_hier = &rescHier->value[rescHier->len * i];
        collEnt.ownerName = &dataOwnerName->value[dataOwnerName->len * i];
        collEnt.replStatus = atoi( &replStatus->value[replStatus->len * i] );
        collEnt.modifyTime = &dataModify->value[dataModify->len * i];
        if ( rodsArgs->veryLongOption == True ) {
            collEnt.chksum = &chksumStr->value[chksumStr->len * i];
            collEnt.phyPath = &dataPath->value[dataPath->len * i];
            collEnt.dataType = &dataType->value[dataType->len * i];  // JMC - backport 4636
        }

        printDataCollEntLong( &collEnt, queryFlags );

        if ( rodsArgs->accessControl == True ) {
            tmpDataId = &dataId->value[dataId->len * i];
            printDataAcl( conn, tmpDataId );
        }
    }

    return 0;
}