Ejemplo n.º 1
0
	def query(self, params):
		q = Structs.getQueryFromXmlRpc(params[0])
		ptype = Structs.getProductTypeFromXmlRpc(params[1])
		ids = self.catalog.query(q, ptype)
		if ids is not None and len(ids) > 0:
			return Result(None, [self.catalog.getProductById(i) for i in ids])
		return Result(None, Vector())
Ejemplo n.º 2
0
	def transferFile(self, params):
		outFile, data, offset, numBytes = params
		if os.path.exists(outFile):
			out = file(outFile, 'ab')
		else:
			dirPath = os.dirname(outFile)
			os.makedirs(dirPath)
			out = file(outFile, 'wb')
		out.seek(offset)
		out.write(data)
		out.close()
		return Result(Boolean, 'true')
Ejemplo n.º 3
0
	def removePermissionFromGroup(self, params):
		permName = params[1]
		group = self.userDB.groups[params[0]]
		indexes = []
		index = 0
		for perm in group.perms:
			if perm == permName:
				indexes.append(index)
		indexes.reverse()
		for index in indexes:
			del group.perms[index]
		self.userDB.save()
		return Result(Boolean, 'true')
Ejemplo n.º 4
0
	def removeUserFromGroup(self, params):
		groupID = params[1]
		user = self.userDB.users[params[0]]
		indexes = []
		index = 0
		for group in user.group:
			if group.groupID == groupID:
				indexes.append(index)
			index += 1
		indexes.reverse()
		for index in indexes:
			del user.groups[index]
		self.userDB.save()
		return Result(Boolean, 'true')
Ejemplo n.º 5
0
	def removeGroup(self, params):
		groupID = params[0]
		del self.userDB.groups[groupID]
		for user in self.userDB.users.itervalues():
			indexes = []
			index = 0
			for group in user.groups:
				if group.groupID == groupID:
					indexes.append(index)
				index += 1
			indexes.reverse()
			for index in indexes:
				del user.groups[index]
		self.userDB.save()
		return Result(Boolean, 'true')
Ejemplo n.º 6
0
	def ingestProduct(self, params):
		productHash, metadata, clientXfer = params
		p = Structs.getProductFromXmlRpc(productHash)
		p.setTransferStatus(Product.STATUS_TRANSFER)
		self.catalog.addProduct(p)
		
		m = Metadata()
		m.addMetadata(metadata)
		self.catalog.addMetadata(m, p)
		
		if not clientXfer:
	                versioner = GenericFileManagerObjectFactory.getVersionerFromClassName(p.getProductType().getVersioner())
			versioner.createDataStoreReferences(p, m)
			self.catalog.addProductReferences(p)
			self.xfer.transferProduct(p)
			p.setTransferStatus(Product.STATUS_RECEIVED)
			self.catalog.setProductTranfserStatus(p)
		return Result(None, p.getProductId())
Ejemplo n.º 7
0
	def removeFile(self, params):
		os.remove(params[0])
		return Result(Boolean, 'true')
Ejemplo n.º 8
0
	def addMetadata(self, params):
		p = Structs.getProductFromXmlRpc(params[0])
		m = Metadata()
		m.addMetadata(params[1])
		self.catalog.addMetadata(m, p)
		return Result(Boolean, 'true')
Ejemplo n.º 9
0
	def isTransferComplete(self, params):
		return Result(Boolean, _toJavaBoolean(self.tracker.isTransferComplete(Structs.getProductFromXmlRpc(params[0]))))
Ejemplo n.º 10
0
	def addPermissionToGroup(self, params):
		self.userDB.groups[params[0]].perms.append(params[1])
		self.userDB.save()
		return Result(Boolean, 'true')
Ejemplo n.º 11
0
	def addProductType(self, params):
		ptype = Structs.getProductTypeFromXmlRpc(params[0])
		self.repo.addProductType(ptype)
		return Result(None, ptype.getProductTypeId())
Ejemplo n.º 12
0
	def addGroup(self, params):
		groupID = params[0]
		group = Group(groupID, params[1], params[2])
		self.userDB.groups[groupID] = group
		self.userDB.save()
		return Result(Boolean, 'true')
Ejemplo n.º 13
0
	def addUserToGroup(self, params):
		self.userDB.users[params[0]].groups.append(self.userDB.groups[params[1]])
		return Result(Boolean, 'true')
Ejemplo n.º 14
0
	def getProductReferences(self, params):
		p = Structs.getProductFromXmlRpc(params[0])
		return Result(None, Structs.getXmlRpcReferences(self.catalog.getProductReferences(p)))
Ejemplo n.º 15
0
	def getProductByName(self, params):
		return Result(None, Structs.getXmlRpcProduct(self.catalog.getProductByName(params[0])))
Ejemplo n.º 16
0
	def getMetadata(self, params):
		return Result(None, self.catalog.getMetadata(Structs.getProductFromXmlRpc(params[0])).getHashtable())
Ejemplo n.º 17
0
	def getProductTypes(self, params):
		return Result(None, Structs.getXmlRpcProductList(self.repo.getProductTypes()))
Ejemplo n.º 18
0
	def hasProduct(self, params):
		p = self.catalog.getProductByName(params[0])
		return Result(Boolean, _toJavaBoolean(p is not None and p.transferStatus == Product.STATUS_RECEIVED))
Ejemplo n.º 19
0
	def getTopNProducts(self, params):
		if len(params) == 1:
			return Result(None, Structs.getXmlRpcProductList(self.catalog.getTopNProducts(params[0])))
		ptype = Structs.getProductTypeFromXmlRpc(params[1])
		return Result(None, Structs.getXmlRpcProductList(self.catalog.getTopNProducts(params[0], ptype)))
Ejemplo n.º 20
0
	def getNumProducts(self, params):
		ptype = Structs.getProductTypeFromXmlRpc(params[0])
		return Result(Integer, str(self.catalog.getNumProducts(ptype)))
Ejemplo n.º 21
0
	def addUser(self, params):
		userID = params[0]
		user = User(userID, params[1], params[2], _encodePassword(params[3]), [])
		self.userDB.users[userID] = user
		self.userDB.save()
		return Result(Boolean, 'true')
Ejemplo n.º 22
0
	def getCurrentFileTransfers(self, params):
		xfers = self.tracker.getCurrentFileTransfers()
		if xfers is not None and len(xfers) > 0:
			return Result(None, Structs.getXmlRpcFileTransferStatuses(xfers))
		else:
			return Result(None, Vector())
Ejemplo n.º 23
0
	def removeUser(self, params):
		del self.userDB.users[params[0]]
		return Result(Boolean, 'true')
Ejemplo n.º 24
0
	def pagedQuery(self, params):
		ptype = Structs.getProductTypeFromXmlRpc(params[1])
		query = Structs.getQueryFromXmlRpc(params[0])
		return Result(None, Structs.getXmlRpcProductPage(self.catalog.pagedQuery(query, ptype, params[2])))
Ejemplo n.º 25
0
	def getRefPctTransferred(self, params):
		pct = self.tracker.getPctTransferred(Structs.getReferenceFromXmlRpc(params[0]))
		return Result(Double, str(pct))
Ejemplo n.º 26
0
	def getProductTypeById(self, params):
		ptype = self.repo.getProductTypeById(params[0])
		return Result(None, Structs.getXmlRpcProductType(ptype))
Ejemplo n.º 27
0
	def getProductPctTransferred(self, params):
		return Result(Double, str(self.tracker.getPctTransferred((Structs.getProductFromXmlRpc(params[0])))))
Ejemplo n.º 28
0
	def catalogProduct(self, params):
		p = Structs.getProductFromXmlRpc(params[0])
		return Result(None, self.catalog.addProduct(p))
Ejemplo n.º 29
0
	def getProductsByProductType(self, params):
		ptype = Structs.getProductTypeFromXmlRpc(params[0])
		return Result(None, Structs.getXmlRpcProductList(self.catalog.getProductsByProductType(ptype)))
Ejemplo n.º 30
0
	def getPrevPage(self, params):
		ptype = Structs.getProductTypeFromXmlRpc(params[0])
		page = Structs.getProductPageFromXmlRpc(params[1])
		return Result(None, Structs.getXmlRpcProductPage(self.catalog.getPrevPage(ptype, page)))