/** * Will be invoked to load the credentials from the request. * * @param \AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface $servletRequest The servlet request instance * @param \AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface $servletResponse The servlet response instance * * @return void */ protected function onCredentials(HttpServletRequestInterface $servletRequest, HttpServletResponseInterface $servletResponse) { // try to load username and password from the request instead if ($servletRequest->hasParameter(FormKeys::USERNAME) && $servletRequest->hasParameter(FormKeys::PASSWORD)) { // load username/password from the request $this->username = new String($servletRequest->getParameter(FormKeys::USERNAME)); $this->password = new String($servletRequest->getParameter(FormKeys::PASSWORD)); } }
/** * Creates a new app. * * @param \AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface $servletRequest The request instance * @param \AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface $servletResponse The response instance * * @return void * @see \AppserverIo\Psr\Servlet\Http\HttpServlet::doPost() * * @SWG\Post( * path="/applications.do", * tags={"applications"}, * summary="Create's a new application", * consumes={"multipart/form-data"}, * @SWG\Parameter( * name="containerId", * in="formData", * description="The ID of the container to deploy the PHAR archive to", * required=true, * type="string" * ), * @SWG\Parameter( * name="file", * in="formData", * description="The PHAR archive containing the application", * required=true, * type="file" * ), * @SWG\Response( * response=200, * description="a ""success"" message" * ), * @SWG\Response( * response=500, * description="Internal Server Error" * ) * ) */ public function doPost(HttpServletRequestInterface $servletRequest, HttpServletResponseInterface $servletResponse) { // query whether we've found an container ID and the PHAR archive if ($servletRequest->hasParameter(RequestKeys::CONTAINER_ID) && ($pharArchive = $servletRequest->getPart(ApplicationServlet::UPLOADED_PHAR_FILE))) { // save file to appserver's upload tmp folder with a temporary name $pharArchive->init(); $pharArchive->write($pharArchive->getFilename()); // upload the file $this->getApplicationProcessor()->upload($servletRequest->getParameter(RequestKeys::CONTAINER_ID), $pharArchive->getFilename()); } else { $this->addError(ErrorOverviewData::factoryForPointer(500, 'Missing container ID or corrupt PHAR archive')); } }