public PutTriplet ( TripleName subjectName, TripleName predicateName, TripleName objectName ) : bool | ||
subjectName | TripleName | |
predicateName | TripleName | |
objectName | TripleName | |
return | bool |
public void PutTriplet(SingleTriple triple) { try { var subjectName = TripleName.Parse(triple.Subject); var predicateName = TripleName.Parse(triple.Predicate); var objectName = TripleName.Parse(triple.Object); #if RELEASE ApiOperation(delegate(User user, Storage storage) { if (user == null) { SetStatusCode(HttpStatusCode.Unauthorized, "Anonymous users cannot modify triple"); } else { objectName = storage.EnsurePrefix(objectName); if (objectName.Prefix == "_") { var tripleOwner = storage.GetSubjectOwner(objectName); if (tripleOwner != null && tripleOwner != user.Id.ToString()) SetStatusCode(HttpStatusCode.BadRequest, "Object bNode belongs to another user"); } if (storage.GetSubjectOwner(subjectName) == user.Id.ToString()) { #else using(var storage = new Storage()) #endif { SetStatusCode(storage.PutTriplet(subjectName, predicateName, objectName) ? HttpStatusCode.OK : HttpStatusCode.NotModified, ""); } #if RELEASE } else { SetStatusCode(HttpStatusCode.Unauthorized, "Only subject owners can modify triple"); } } }); #endif } catch (ArgumentException exc) { SetStatusCode(HttpStatusCode.BadRequest, exc.Message); } }
public void PutTriplet(SingleTriple triple) { #if RELEASE ApiOperation(delegate(User user, Storage storage) { if (user == null) { SetStatusCode(HttpStatusCode.Unauthorized, "Anonymous users cannot modify triple"); } else { if (GetSubjectOwner(storage, triple.Subject) == user.Id.ToString()) { #else using(var storage = new Storage()) #endif try { SetStatusCode(storage.PutTriplet(triple.Subject, triple.Predicate, triple.Object) ? HttpStatusCode.OK : HttpStatusCode.NotModified, ""); } catch (ArgumentException exc) { SetStatusCode(HttpStatusCode.BadRequest, exc.Message); } #if RELEASE } else { SetStatusCode(HttpStatusCode.Unauthorized, "Only subject owners can modify triple"); } } }); #endif }