Search in sources :

Example 91 with WebMethod

use of javax.jws.WebMethod in project openmeetings by apache.

the class RoomWebService method close.

/**
 * Method to remotely close rooms. If a room is closed all users
 * inside the room and all users that try to enter it will be redirected to
 * the redirectURL that is defined in the Room-Object.
 *
 * Returns positive value if authentication was successful.
 *
 * @param sid
 *            The SID of the User. This SID must be marked as Loggedin
 * @param id
 *            the room id
 *
 * @return - 1 in case of success, -2 otherwise
 */
@WebMethod
@GET
@Path("/close/{id}")
public ServiceResult close(@WebParam(name = "sid") @QueryParam("sid") String sid, @WebParam(name = "id") @PathParam("id") long id) {
    return performCall(sid, User.Right.Soap, sd -> {
        Long userId = sd.getUserId();
        Room room = roomDao.get(id);
        room.setClosed(true);
        roomDao.update(room, userId);
        WebSocketHelper.sendRoom(new RoomMessage(room.getId(), userDao.get(userId), RoomMessage.Type.roomClosed));
        return new ServiceResult("Closed", Type.SUCCESS);
    });
}
Also used : ServiceResult(org.apache.openmeetings.db.dto.basic.ServiceResult) RoomMessage(org.apache.openmeetings.db.util.ws.RoomMessage) Room(org.apache.openmeetings.db.entity.room.Room) WebMethod(javax.jws.WebMethod) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 92 with WebMethod

use of javax.jws.WebMethod in project openmeetings by apache.

the class UserWebService method login.

/**
 * @param user - login or email of Openmeetings user with admin or SOAP-rights
 * @param pass - password
 *
 * @return - {@link ServiceResult} with error code or SID and userId
 */
@WebMethod
@GET
@Path("/login")
public ServiceResult login(@WebParam(name = "user") @QueryParam("user") String user, @WebParam(name = "pass") @QueryParam("pass") String pass) {
    try {
        log.debug("Login user");
        User u = userDao.login(user, pass);
        if (u == null) {
            return new ServiceResult("error.bad.credentials", Type.ERROR);
        }
        Sessiondata sd = sessionDao.create(u.getId(), u.getLanguageId());
        log.debug("Login user: {}", u.getId());
        return new ServiceResult(sd.getSessionId(), Type.SUCCESS);
    } catch (OmException oe) {
        return oe.getKey() == null ? UNKNOWN : new ServiceResult(oe.getKey(), Type.ERROR);
    } catch (Exception err) {
        log.error("[login]", err);
        return UNKNOWN;
    }
}
Also used : User(org.apache.openmeetings.db.entity.user.User) ServiceResult(org.apache.openmeetings.db.dto.basic.ServiceResult) Sessiondata(org.apache.openmeetings.db.entity.server.Sessiondata) OmException(org.apache.openmeetings.util.OmException) OmException(org.apache.openmeetings.util.OmException) ServiceException(org.apache.openmeetings.webservice.error.ServiceException) WebMethod(javax.jws.WebMethod) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 93 with WebMethod

use of javax.jws.WebMethod in project openmeetings by apache.

the class UserWebService method getRoomHash.

/**
 * Description: sets the SessionObject for a certain SID, after setting this
 * Session-Object you can use the SID + a RoomId to enter any Room. ...
 * Session-Hashs are deleted 15 minutes after the creation if not used.
 *
 * @param sid
 *            The SID from getSession
 * @param user
 *            user details to set
 * @param options
 *            room options to set
 *
 * @return - secure hash or error code
 */
@WebMethod
@POST
@Path("/hash")
public ServiceResult getRoomHash(@WebParam(name = "sid") @QueryParam("sid") String sid, @WebParam(name = "user") @FormParam("user") ExternalUserDTO user, @WebParam(name = "options") @FormParam("options") RoomOptionsDTO options) {
    return performCall(sid, User.Right.Soap, sd -> {
        RemoteSessionObject remoteSessionObject = new RemoteSessionObject(user.getLogin(), user.getFirstname(), user.getLastname(), user.getProfilePictureUrl(), user.getEmail(), user.getExternalId(), user.getExternalType());
        log.debug(remoteSessionObject.toString());
        String xmlString = remoteSessionObject.toXml();
        log.debug("xmlString " + xmlString);
        String hash = soapDao.addSOAPLogin(sid, options.getRoomId(), options.isModerator(), options.isShowAudioVideoTest(), options.isAllowSameURLMultipleTimes(), options.getRecordingId(), options.isAllowRecording());
        if (hash != null) {
            if (options.isAllowSameURLMultipleTimes()) {
                sd.setPermanent(true);
            }
            sd.setXml(xmlString);
            sessionDao.update(sd);
            return new ServiceResult(hash, Type.SUCCESS);
        }
        return UNKNOWN;
    });
}
Also used : ServiceResult(org.apache.openmeetings.db.dto.basic.ServiceResult) RemoteSessionObject(org.apache.openmeetings.db.entity.server.RemoteSessionObject) WebMethod(javax.jws.WebMethod) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Example 94 with WebMethod

use of javax.jws.WebMethod in project quickstarts by jboss-switchyard.

the class AirportService method order.

/**
 * Order flight ticket defined by fltid for a user identified by name.
 * @param name username
 * @param fltid flight identifier
 */
@WebMethod
public void order(@WebParam(name = "name") String name, @WebParam(name = "fltid") String fltid) {
    log.info("AirportService:order");
    UserBusinessActivity uba = UserBusinessActivity.getUserBusinessActivity();
    if (uba != null) {
        log.info("Transaction ID = " + uba.toString());
        if (uba.toString().compareTo("Unknown") == 0) {
            log.info("JBoss AS is badly configured. (Enable XTS)");
            return;
        }
        // Create order participant (fly ticket)
        OrderParticipant op = new OrderParticipant(uba.toString(), fltid);
        try {
            // Enlist order participant to the transaction
            BusinessActivityManager.getBusinessActivityManager().enlistForBusinessAgreementWithCoordinatorCompletion(op, "org.switchyard.quickstarts.bpel.xts.wsba.ws:AirportService:" + name + ":" + fltid);
        } catch (Exception e) {
            log.log(Level.SEVERE, e.getMessage());
            e.printStackTrace();
        }
    }
}
Also used : UserBusinessActivity(com.arjuna.mw.wst11.UserBusinessActivity) WebMethod(javax.jws.WebMethod)

Example 95 with WebMethod

use of javax.jws.WebMethod in project quickstarts by jboss-switchyard.

the class AirportService method getFLTID.

/**
 * Get flight identifier for the parameters.
 * @param from place (city)
 * @param to place (city)
 * @param date of flight
 * @return format [from/to/month/day]
 */
@WebMethod
@WebResult(name = "fltid")
public String getFLTID(@WebParam(name = "from") String from, @WebParam(name = "to") String to, @WebParam(name = "date") Date date) {
    Calendar c = Calendar.getInstance();
    c.setTime(date);
    return from + "/" + to + "/" + String.valueOf(c.get(Calendar.MONTH) + 1) + "/" + String.valueOf(c.get(Calendar.DAY_OF_MONTH));
}
Also used : Calendar(java.util.Calendar) WebMethod(javax.jws.WebMethod) WebResult(javax.jws.WebResult)

Aggregations

WebMethod (javax.jws.WebMethod)107 Method (java.lang.reflect.Method)18 Path (javax.ws.rs.Path)17 IOException (java.io.IOException)16 WebResult (javax.jws.WebResult)13 MessageContext (javax.xml.ws.handler.MessageContext)12 WebServiceException (javax.xml.ws.WebServiceException)11 Test (org.junit.Test)10 DataHandler (javax.activation.DataHandler)9 GET (javax.ws.rs.GET)9 Action (javax.xml.ws.Action)9 ArrayList (java.util.ArrayList)8 Oneway (javax.jws.Oneway)8 POST (javax.ws.rs.POST)8 File (java.io.File)7 InputStream (java.io.InputStream)6 HttpServletRequest (javax.servlet.http.HttpServletRequest)6 QName (javax.xml.namespace.QName)6 RequestWrapper (javax.xml.ws.RequestWrapper)6 AbstractCodeGenTest (org.apache.cxf.tools.wsdlto.AbstractCodeGenTest)6