Exemplo n.º 1
0
/*----------------------------------------------------------------------------*/
void XmlServer :: methodRegister(XmlRequest& request, XmlResponse& response)
{
  if(database->isKsefError() || database->ksefDatabase() == NULL)
  {
    response.setStatus(XmlResponse::InternalError, database->ksefMessage());
    return;
  }

  User user = database->userStorage()->user(request.userName(), request.password());
  if(!user.ksef.write)
  {
    response.setStatus(XmlResponse::accessDenied, QString("Access denied for user '%1'").arg(user.name));
    return;
  }

  KsefDocument doc;

  QDomElement data = request.data();
  QDomElement e = data.firstChildElement("RQ");
  e = e.firstChildElement("DAT");

  if(e.isNull() || !doc.assign(e))
  {
    response.setStatus(XmlResponse::InvalidQuery, "Invalid query");
    return;
  }



  if(!database->ksefDatabase()->cashRegister(doc, response))
    response.setStatus(XmlResponse::InternalError, database->ksefDatabase()->message());
}
Exemplo n.º 2
0
/*----------------------------------------------------------------------------*/
void XmlServer :: methodUpdate(XmlRequest& request, XmlResponse& response)
{
  if(database->isStoreError() || database->storeDatabase() == NULL)
  {
    response.setStatus(XmlResponse::InternalError, database->storeMessage());
    return;
  }

  User user = database->userStorage()->user(request.userName(), request.password());
  if(!user.store.write)
  {
    response.setStatus(XmlResponse::accessDenied, QString("Access denied for user '%1'").arg(user.name));
    return;
  }
  if(!database->storeDatabase()->update(request, response))
    response.setStatus(XmlResponse::InternalError, database->storeDatabase()->message());
}
Exemplo n.º 3
0
/*----------------------------------------------------------------------------*/
void XmlServer :: methodKsefGet(XmlRequest& request, XmlResponse& response)
{
  if(database->isKsefError() || database->ksefDatabase() == NULL)
  {
    response.setStatus(XmlResponse::InternalError, database->ksefMessage());
    return;
  }

  User user = database->userStorage()->user(request.userName(), request.password());
  if(!user.ksef.read)
  {
    response.setStatus(XmlResponse::accessDenied, QString("Access denied for user '%1'").arg(user.name));
    return;
  }

  if(!database->ksefDatabase()->query(request, response))
    response.setStatus(XmlResponse::InternalError, database->ksefDatabase()->message());
}