Exemple #1
0
CUAGGroup* RetainParamGroup(CUAGDirectory* directory, VJSParms_callStaticFunction& ioParms, sLONG paramNum)
{
	CUAGGroup* result = nil;
	if (paramNum <= ioParms.CountParams())
	{
		if (ioParms.IsStringParam(paramNum))
		{
			StErrorContextInstaller errs(false);
			VString s;
			ioParms.GetStringParam(paramNum, s);
			result = directory->RetainGroup(s);
			if (result == nil)
			{
				VUUID xid;
				xid.FromString(s);
				result = directory->RetainGroup(xid);
			}
		}
		else
		{
			result = ioParms.GetParamObjectPrivateData<VJSGroup>(paramNum);
			if (result != nil)
				result->Retain();
		}
	}
	return result;
}
Exemple #2
0
VError removeGroupFromGroup(VJSParms_callStaticFunction& ioParms, CUAGGroup* inGroup, const VString& s)
{
	VError err = VE_OK;
	CUAGDirectory* dir = inGroup->GetDirectory();
	CUAGGroup* group;
	{
		StErrorContextInstaller errs(false);
		group = dir->RetainGroup(s);
		if (group == nil)
		{
			VUUID id;
			id.FromString(s);
			group = dir->RetainGroup(id);
		}
	}
	if (group != nil)
	{
		err = inGroup->RemoveFromGroup(group);
	}
	else
	{
		err = ThrowError(VE_UAG_GROUPNAME_DOES_NOT_EXIST, s);
	}
	QuickReleaseRefCountable(group);
	return err;
}
Exemple #3
0
void VJSSession::_getID( XBOX::VJSParms_getProperty& ioParms, CUAGSession* inSession)
{
	VString s;
	VUUID xid;
	inSession->GetID(xid);
	xid.GetString(s);
	ioParms.ReturnString(s);
}
XBOX::VError VRIAJSRuntimeContext::SetUAGSession(CUAGSession* inSession, bool addSession)
{
	VRIAServerProject *application = GetRootApplication();

	if (fCurrentUAGSession != NULL)
	{
		if (fCurrentUAGSession->IsDefault() && !fCurrentUAGSession->IsEmpty() && inSession != NULL)
		{
			inSession->SetStorageObject(fCurrentUAGSession->GetStorageObject());
		}
	}

	CopyRefCountable(&fCurrentUAGSession, inSession);
	if (addSession)
	{
		VRIAHTTPSessionManager* sessionMgr = fRootApplication->RetainSessionMgr();
		if (sessionMgr != NULL)
		{
			sessionMgr->AddSession(fCurrentUAGSession);
			sessionMgr->Release();
		}
	}

	VJSContext jscontext(fGlobalContext);
	VJSSessionStorageObject* storage = GetSessionStorageObject();
	if (storage == NULL)
	{
		VJSValue value( jscontext);
		value.SetNull();
		jscontext.GetGlobalObject().SetProperty( "sessionStorage", value);
	}
	else
		jscontext.GetGlobalObject().SetProperty( "sessionStorage", VJSStorageClass::CreateInstance(jscontext, storage));

	CDB4DContext* basecontext = RetainDB4DContext(application);
	if (basecontext != NULL)
	{
		VUUID userID;
		userID.SetNull(true);
		basecontext->SetCurrentUser(userID, inSession);
		basecontext->Release();
	}

	return VE_OK;
}
Boolean IPropertyCollector::GetUUID(VUUID& outID) const
{
	Boolean	succeed = GetVUUID(CVSTR("uuid"), outID);
	
	if (!succeed)
		outID.Clear();
	
	return succeed;
}
bool VBagLoader::GetUUID( const VValueBag& inBag, VUUID& outUUID)
{
	bool ok;
	if (fRegenerateUUIDs)
	{
		VUUID bag_uuid;
		ok = inBag.GetVUUID( BagLoaderKeys::uuid, bag_uuid);
		if (ok && !bag_uuid.IsNull())
		{
			try
			{
				MapVUUID::const_iterator i = fUUIDs.find( bag_uuid);
				if (i != fUUIDs.end())
				{
					outUUID = i->second;
				}
				else
				{
					outUUID.Regenerate();
					fUUIDs[bag_uuid] = outUUID;
				}
			}
			catch(...)
			{
				ok = false;
			}
		}
		else
		{
			outUUID.Regenerate();
		}
	}
	else
	{
		ok = inBag.GetVUUID( BagLoaderKeys::uuid, outUUID);
		if (!ok)
		{
			outUUID.Regenerate();
		}
	}
	
	return ok;
}
Exemple #7
0
void VJSDirectory::_getUser(VJSParms_callStaticFunction& ioParms, CUAGDirectory* inDirectory)
{
	StErrorContextInstaller errs(false, true);
	VString s;
	ioParms.GetStringParam(1, s);
	CUAGUser* user = inDirectory->RetainUser(s);
	if (user == nil)
	{
		VUUID id;
		id.FromString(s);
		user = inDirectory->RetainUser(id);
	}
	if (user == nil)
		ioParms.ReturnNullValue();
	else
	{
		ioParms.ReturnValue(VJSUser::CreateInstance(ioParms.GetContext(), user));
		user->Release();
	}
}
Exemple #8
0
void VJSDirectory::_getGroup(VJSParms_callStaticFunction& ioParms, CUAGDirectory* inDirectory)
{
	StErrorContextInstaller errs(false, true);
	VString s;
	ioParms.GetStringParam(1, s);
	CUAGGroup* group = inDirectory->RetainGroup(s);
	if (group == nil)
	{
		VUUID id;
		id.FromString(s);
		group = inDirectory->RetainGroup(id);
	}
	if (group == nil)
		ioParms.ReturnNullValue();
	else
	{
		ioParms.ReturnValue(VJSGroup::CreateInstance(ioParms.GetContext(), group));
		group->Release();
	}
}
VError removeGroupFromGroup(VJSParms_callStaticFunction& ioParms, CUAGGroup* inGroup, const VString& s)
{
	VError err = VE_OK;
	CUAGDirectory* dir = inGroup->GetDirectory();
	CUAGGroup* group = dir->RetainGroup(s);
	if (group == nil)
	{
		VUUID id;
		id.FromString(s);
		group = dir->RetainGroup(id);
	}
	if (group != nil)
	{
		err = inGroup->RemoveFromGroup(group);
	}
	else
	{
		err = ThrowError(VE_UAG_GROUPNAME_DOES_NOT_EXIST, s);
	}
	return err;
}
Exemple #10
0
void VJSDirectory::_setLoginListener(VJSParms_callStaticFunction& ioParms, CUAGDirectory* inDirectory)
{
	VError err;
	VString listenerRef;
	if (ioParms.IsStringParam(1))
	{
		ioParms.GetStringParam(1, listenerRef);
		VString groupRef;
		CUAGGroup* group = ioParms.GetParamObjectPrivateData<VJSGroup>(2);
		if (group == NULL)
			ioParms.GetStringParam(2, groupRef);
		else
		{
			VUUID xid;
			group->GetID(xid);
			xid.GetString(groupRef);
		}
		inDirectory->SetLoginListener(listenerRef, groupRef);
	}
	else
		XBOX::vThrowError(XBOX::VE_JVSC_WRONG_PARAMETER_TYPE_STRING, "1");
}
Exemple #11
0
void VUUID::GetVUUID(VUUID& outValue) const
{
	outValue.FromVUUID(*this);
}
Exemple #12
0
void VUUID::FromVUUID(const VUUID& inValue)
{
	fData = inValue.fData;
	_GotValue(inValue.IsNull());
}
Exemple #13
0
VUUID::VUUID(const VUUID& inUUID):VValueSingle(inUUID.IsNull())
{
	fCachedConvertedString = NULL;
	fData = inUUID.fData;
}
VError DB4DJournalParser::NextOperation( uLONG8 &outOperation, uLONG8 *outGlobalOperation, CDB4DJournalData **outJournalData )
{
	VError error = VE_OK;
	RecordHeader recHeader;
	
	if ( outJournalData )
		*outJournalData = NULL;

	outOperation = fCurrentOperation;
	sLONG8 globaloperation = 0;
	
	if ( fFileStream )
	{
		uLONG operationTag;
		error = fFileStream->GetLong(operationTag);
		if ( error == VE_OK )
		{
			if ( operationTag == kTagLogDB4D )
			{
				sLONG8 contextID;
				DB4D_LogAction logAction;
				sLONG len;
				sLONG8 curpos;
				error = fFileStream->GetLong8(globaloperation);

				if ( error == VE_OK )
				{
					error = fFileStream->GetLong(len);
				}

				if ( !outJournalData )
				{
					error = fFileStream->SetPosByOffset( len - 24 );//- 4 /*Tag*/ - 8 /*Operation#*/- 4 /*len*/ - 4 /*len at the end*/ - 4 /*tag at the end*/
				}
				else
				{

				if ( error == VE_OK )
					error = fFileStream->GetLong((uLONG&)logAction);

				if ( error == VE_OK )
					error = fFileStream->GetLong8(contextID);

				uLONG8 timeStamp;
				if (error == VE_OK)
					error = fFileStream->GetLong8(timeStamp);


				if (error == VE_OK)
				{
					switch (logAction)
					{
						case DB4D_Log_OpenData:
						case DB4D_Log_CloseData:
						case DB4D_Log_StartBackup:
						case DB4D_Log_StartTrans:
						case DB4D_Log_Commit:
						case DB4D_Log_RollBack:
							{
								*outJournalData = new VDB4DJournalData(globaloperation, logAction,contextID, GetContextExtraData( contextID),timeStamp);
							}
							break;

						case DB4D_Log_CloseContext:
							{
								*outJournalData = new VDB4DJournalData(globaloperation, logAction,contextID, GetContextExtraData( contextID),timeStamp);
								fContextExtraByID.erase(contextID);
							}
							break;

						case DB4D_Log_CreateRecord:
						case DB4D_Log_ModifyRecord:
							{
								VUUID xTableID;
								if ( error == VE_OK )
									error = recHeader.ReadFromStream(fFileStream);
								
								if ( error == VE_OK )
									if ( !recHeader.Match(DBOH_Record) )
										error = VE_DB4D_WRONGRECORDHEADER;
								
								if ( error == VE_OK )
									error = xTableID.ReadFromStream(fFileStream);

								curpos = fFileStream->GetPos();
								if ( error == VE_OK )
								{
									sLONG dataSize = recHeader.GetLen() + sizeof(ChampHeader)*(recHeader.GetNbFields());
									error = fFileStream->SetPosByOffset(dataSize);
								}
								if ( error == VE_OK )
									*outJournalData = new VDB4DJournalData(globaloperation, logAction,contextID, GetContextExtraData( contextID),&recHeader,timeStamp, curpos, fFileStream, xTableID);
							}
							break;

						case DB4D_Log_DeleteBlob:
							{
								VString path;
								sLONG blobnumber;
								if ( error == VE_OK )
									error = fFileStream->GetLong(blobnumber);

								if (blobnumber == -2)
								{
									sLONG lenpath = 0;
									error = fFileStream->GetLong(lenpath);
									if (lenpath > 0)
									{
										tempBuffer<256> buff(len);
										error = fFileStream->GetWords((sWORD*)buff.GetPtr(), &lenpath);
										path.FromBlock(buff.GetPtr(), lenpath * sizeof(UniChar), VTC_UTF_16);
									}
								}
								
								VUUID xTableID;
								if ( error == VE_OK )
									error = xTableID.ReadFromStream(fFileStream);

								if ( error == VE_OK )
								{
									VDB4DJournalData* jdata = new VDB4DJournalData(globaloperation, logAction,contextID, GetContextExtraData( contextID),timeStamp, blobnumber ,xTableID);
									*outJournalData = jdata;
									if (!path.IsEmpty())
									{
										jdata->SetPath(path);
									}
								}
							}
							break;

						case DB4D_Log_DeleteRecord:
						case DB4D_Log_TruncateTable:
							{
								sLONG recordNumber;
								if ( error == VE_OK )
									error = fFileStream->GetLong(recordNumber);
								/*
								sLONG tableIndex;
								if ( error == VE_OK )
									error = fFileStream->GetLong(tableIndex);
								*/
								VUUID xTableID;
								if ( error == VE_OK )
									error = xTableID.ReadFromStream(fFileStream);

								if ( error == VE_OK )
									*outJournalData = new VDB4DJournalData(globaloperation, logAction,contextID, GetContextExtraData( contextID),timeStamp,recordNumber,xTableID);
							}
							break;

						case DB4D_Log_CreateContextWithUserUUID:
							{
								VUUID userID;
								error = userID.ReadFromStream(fFileStream);
								if (error == VE_OK)
									*outJournalData = new VDB4DJournalData(globaloperation, logAction,contextID, GetContextExtraData( contextID),timeStamp,userID);
							}
							break;
						
						case DB4D_Log_CreateContextWithExtra:
							{
								VValueBag *bag = new VValueBag;
								if (bag != NULL)
								{
									// the extra data is always stored in little endian
									Boolean oldNeedSwap = fFileStream->NeedSwap();
									fFileStream->SetLittleEndian();
									error = bag->ReadFromStream(fFileStream);
									fFileStream->SetNeedSwap( oldNeedSwap);
									
									if (error == VE_OK)
									{
										try
										{
											fContextExtraByID[contextID] = bag;
										}
										catch(...)
										{
										}
										*outJournalData = new VDB4DJournalData(globaloperation, logAction,contextID, GetContextExtraData( contextID),timeStamp);
									}
								}
								else
								{
									error = memfull;
								}
								ReleaseRefCountable( &bag);
							}
							break;

						case DB4D_Log_CreateBlob:
						case DB4D_Log_ModifyBlob:
							{
								VString path;

								sLONG lenblob = 0;
								sLONG blobNumber;
								if ( error == VE_OK )
									error = fFileStream->GetLong(blobNumber);

								if (blobNumber == -2)
								{
									sLONG lenpath = 0;
									error = fFileStream->GetLong(lenpath);
									if (lenpath > 0)
									{
										tempBuffer<256> buff(len);
										error = fFileStream->GetWords((sWORD*)buff.GetPtr(), &lenpath);
										path.FromBlock(buff.GetPtr(), lenpath * sizeof(UniChar), VTC_UTF_16);
									}
								}


								VUUID xTableID;
								if ( error == VE_OK )
									error = xTableID.ReadFromStream(fFileStream);

								curpos = fFileStream->GetPos();
								if ( error == VE_OK )
								{
									error = fFileStream->GetLong(lenblob);
									error = fFileStream->SetPosByOffset(lenblob);
								}
								if ( error == VE_OK )
								{
									VDB4DJournalData* jdata = new VDB4DJournalData(globaloperation, logAction,contextID, GetContextExtraData( contextID),timeStamp, blobNumber, lenblob, xTableID, curpos, fFileStream);
									*outJournalData = jdata;
									if (!path.IsEmpty())
									{
										jdata->SetPath(path);
									}
								}
							}
							break;

						case DB4D_Log_SaveSeqNum:
							{
								sLONG8 seqnum;
								if ( error == VE_OK )
									error = fFileStream->GetLong8(seqnum);
								/*
								sLONG tableIndex;
								if ( error == VE_OK )
								error = fFileStream->GetLong(tableIndex);
								*/
								VUUID xTableID;
								if ( error == VE_OK )
									error = xTableID.ReadFromStream(fFileStream);

								if ( error == VE_OK )
									*outJournalData = new VDB4DJournalData(globaloperation, logAction,contextID, GetContextExtraData( contextID), timeStamp, seqnum, xTableID, true);
							}
							break;

						default:
							assert(false);
							break;
					}
				}
				}
				sLONG lenEnd;
				if ( error == VE_OK )
				{
					error = fFileStream->GetLong(lenEnd);
					if (len != lenEnd)
						error = VE_UNIMPLEMENTED;
				}

				uLONG operationTagEnd;
				if (error == VE_OK)
				{
					error = fFileStream->GetLong((uLONG&)operationTagEnd);
					if (operationTagEnd != kTagLogDB4DEnd)
						error = VE_UNIMPLEMENTED;
				}
			}
			else
			{
				error = VE_UNIMPLEMENTED; // bad file
			}

			if ( error != VE_OK )
			{
				if ( outJournalData && *outJournalData )
				{
					(*outJournalData)->Release();
					*outJournalData = NULL;
				}
			}
			else
			{
				outOperation = ++fCurrentOperation;
				if ( outJournalData && *outJournalData )
				{
					if ( fCurrentData )
						fCurrentData->Release();
					fCurrentData = *outJournalData;
					fCurrentData->Retain();
				}
			}
		}
	}
	else
	{
		error = VE_UNIMPLEMENTED; // not initialized
	}

	if (outGlobalOperation != NULL)
		*outGlobalOperation = globaloperation;
	
	return error;
}