Ejemplo n.º 1
0
int
rsDataObjPut( rsComm_t *rsComm, dataObjInp_t *dataObjInp,
              bytesBuf_t *dataObjInpBBuf, portalOprOut_t **portalOprOut ) {
    int status;
    int status2;
    int remoteFlag;
    rodsServerHost_t *rodsServerHost;
    specCollCache_t *specCollCache = NULL;

    resolveLinkedPath( rsComm, dataObjInp->objPath, &specCollCache,
                       &dataObjInp->condInput );
    remoteFlag = getAndConnRemoteZone( rsComm, dataObjInp, &rodsServerHost,
                                       REMOTE_CREATE );

    if ( const char* acl_string = getValByKey( &dataObjInp->condInput, ACL_INCLUDED_KW ) ) {
        try {
            irods::deserialize_acl( acl_string );
        }
        catch ( const irods::exception& e ) {
            rodsLog( LOG_ERROR, "%s", e.what() );
            return e.code();
        }
    }
    if ( const char* metadata_string = getValByKey( &dataObjInp->condInput, METADATA_INCLUDED_KW ) ) {
        try {
            irods::deserialize_metadata( metadata_string );
        }
        catch ( const irods::exception& e ) {
            rodsLog( LOG_ERROR, "%s", e.what() );
            return e.code();
        }
    }

    if ( remoteFlag < 0 ) {
        return remoteFlag;
    }
    else if ( remoteFlag == LOCAL_HOST ) {
        // =-=-=-=-=-=-=-
        // working on the "home zone", determine if we need to redirect to a different
        // server in this zone for this operation.  if there is a RESC_HIER_STR_KW then
        // we know that the redirection decision has already been made
        std::string       hier;
        if ( getValByKey( &dataObjInp->condInput, RESC_HIER_STR_KW ) == NULL ) {
            irods::error ret = irods::resolve_resource_hierarchy(
                                   irods::CREATE_OPERATION, rsComm,
                                   dataObjInp, hier );
            if ( !ret.ok() ) {
                std::stringstream msg;
                msg << __FUNCTION__;
                msg << " :: failed in irods::irods::resolve_resource_hierarchy for [";
                msg << dataObjInp->objPath << "]";
                irods::log( PASSMSG( msg.str(), ret ) );
                return ret.code();
            }
            // =-=-=-=-=-=-=-
            // we resolved the redirect and have a host, set the hier str for subsequent
            // api calls, etc.
            addKeyVal( &dataObjInp->condInput, RESC_HIER_STR_KW, hier.c_str() );

        } // if keyword

        status2 = applyRuleForPostProcForWrite( rsComm, dataObjInpBBuf,
                                                dataObjInp->objPath );
        if ( status2 < 0 ) {
            return ( status2 );
        }

        dataObjInp->openFlags = O_RDWR;
        status = _rsDataObjPut( rsComm, dataObjInp, dataObjInpBBuf,
                                portalOprOut );
    }
    else {
        int l1descInx;
        status = _rcDataObjPut( rodsServerHost->conn, dataObjInp,
                                dataObjInpBBuf, portalOprOut );
        if ( status < 0 ||
                getValByKey( &dataObjInp->condInput, DATA_INCLUDED_KW ) != NULL ) {
            return status;
        }
        else {
            /* have to allocate a local l1descInx to keep track of things
             * since the file is in remote zone. It sets remoteL1descInx,
             * oprType = REMOTE_ZONE_OPR and remoteZoneHost so that
             * rsComplete knows what to do */
            l1descInx = allocAndSetL1descForZoneOpr(
                            ( *portalOprOut )->l1descInx, dataObjInp, rodsServerHost, NULL );
            if ( l1descInx < 0 ) {
                return l1descInx;
            }
            ( *portalOprOut )->l1descInx = l1descInx;
            return status;
        }
    }

    return status;
}
Ejemplo n.º 2
0
int
rsDataObjPut (rsComm_t *rsComm, dataObjInp_t *dataObjInp,
bytesBuf_t *dataObjInpBBuf, portalOprOut_t **portalOprOut)
{
    int status;
    int status2;
    int remoteFlag;
    rodsServerHost_t *rodsServerHost;
    specCollCache_t *specCollCache = NULL;

    resolveLinkedPath (rsComm, dataObjInp->objPath, &specCollCache,
      &dataObjInp->condInput);
#if 0
    status = resolvePathInSpecColl (rsComm, dataObjInp->objPath,
          READ_COLL_PERM, 0, &dataObjInfo);

    if (dataObjInfo != NULL) {
        if (dataObjInfo->specColl != NULL && 
	  dataObjInfo->specColl->collClass == LINKED_COLL) {
            rstrcpy (dataObjInp->objPath, dataObjInfo->objPath,
              MAX_NAME_LEN);
	}
        freeAllDataObjInfo (dataObjInfo);
    }
#endif

    remoteFlag = getAndConnRemoteZone (rsComm, dataObjInp, &rodsServerHost,
      REMOTE_CREATE);

    if (remoteFlag < 0) {
        return (remoteFlag);
    } else if (remoteFlag == LOCAL_HOST) {
	/** since the object is written here, we apply pre procesing RAJA 
         * Dec 2 2010 **/
      status2 = applyRuleForPostProcForWrite(rsComm, dataObjInpBBuf, 
       dataObjInp->objPath);
	 if (status2 < 0) 
	   return(status2); /* need to dealloc anything??? */
	/** since the object is written here, we apply pre procesing RAJA 
         * Dec 2 2010 **/

	dataObjInp->openFlags = O_RDWR;
        status = _rsDataObjPut (rsComm, dataObjInp, dataObjInpBBuf,
          portalOprOut, BRANCH_MSG);
    } else {
	int l1descInx;
        status = _rcDataObjPut (rodsServerHost->conn, dataObjInp, 
	  dataObjInpBBuf, portalOprOut);
        if (status < 0 || 
          getValByKey (&dataObjInp->condInput, DATA_INCLUDED_KW) != NULL) {
            return (status);
        } else {
            /* have to allocate a local l1descInx to keep track of things
             * since the file is in remote zone. It sets remoteL1descInx,
             * oprType = REMOTE_ZONE_OPR and remoteZoneHost so that  
             * rsComplete knows what to do */
            l1descInx = allocAndSetL1descForZoneOpr (
              (*portalOprOut)->l1descInx, dataObjInp, rodsServerHost, NULL);
            if (l1descInx < 0) return l1descInx;
            (*portalOprOut)->l1descInx = l1descInx;
            return status;
        }
    }

    return (status);
}