use of javax.jws.WebMethod in project ats-framework by Axway.
the class AgentWsImpl method scheduleActionsInMultipleThreads.
/**
* Schedule a set of actions (queue) in multiple threads. The actions
* will not be executed until a call to startQueue is made
*
* @param queueName the name of the action queue
* @param actions the actions in that queue
* @param serializedThreadingPattern the serialized threading pattern to be used
* @param testCaseState the test case state
* @throws AgentException on error
* @throws InternalComponentException if an exception is thrown while the actions are executed
*/
@WebMethod
public void scheduleActionsInMultipleThreads(@WebParam(name = "name") String queueName, @WebParam(name = "queueId") int queueId, @WebParam(name = "actions") ActionWrapper[] actions, @WebParam(name = "serializedThreadingPattern") byte[] serializedThreadingPattern, @WebParam(name = "serializedLoaderDataConfig") byte[] serializedLoaderDataConfig, boolean isUseSynchronizedIterations) throws AgentException, InternalComponentException {
final String caller = getCaller();
ThreadsPerCaller.registerThread(caller);
try {
ArrayList<ActionRequest> actionRequests = new ArrayList<ActionRequest>();
for (ActionWrapper actionWrapper : actions) {
List<ArgumentWrapper> args = actionWrapper.getArgs();
int numArguments = args.size();
Object[] arguments = new Object[numArguments];
// unwrap the action arguments
for (int i = 0; i < numArguments; i++) {
ArgumentWrapper argWrapper = args.get(i);
ByteArrayInputStream byteInStream = new ByteArrayInputStream(argWrapper.getArgumentValue());
ObjectInputStream objectInStream = new ObjectInputStream(byteInStream);
arguments[i] = objectInStream.readObject();
}
// construct the action request
ActionRequest actionRequest = new ActionRequest(actionWrapper.getComponentName(), actionWrapper.getActionName(), arguments);
actionRequests.add(actionRequest);
}
ByteArrayInputStream byteInStream;
ObjectInputStream objectInStream;
// de-serialize the threading configuration
byteInStream = new ByteArrayInputStream(serializedThreadingPattern);
objectInStream = new ObjectInputStream(byteInStream);
ThreadingPattern threadingPattern = (ThreadingPattern) objectInStream.readObject();
// de-serialize the loader data configuration
byteInStream = new ByteArrayInputStream(serializedLoaderDataConfig);
objectInStream = new ObjectInputStream(byteInStream);
LoaderDataConfig loaderDataConfig = (LoaderDataConfig) objectInStream.readObject();
MultiThreadedActionHandler.getInstance(caller).scheduleActions(caller, queueName, queueId, actionRequests, threadingPattern, loaderDataConfig, isUseSynchronizedIterations);
} catch (Exception e) {
handleExceptions(e);
} finally {
ThreadsPerCaller.unregisterThread();
}
}
use of javax.jws.WebMethod in project ats-framework by Axway.
the class AgentWsImpl method pushConfiguration.
/**
* Apply client configuration to the server
*
* @param configurators the serialized configurators to be applied
* @return the agent version
* @throws AgentException on error
*/
@SuppressWarnings("unchecked")
@WebMethod
public String pushConfiguration(@WebParam(name = "configurators") byte[] serializedConfigurators) throws AgentException {
final String caller = getCaller();
ThreadsPerCaller.registerThread(caller);
ByteArrayInputStream byteInStream = new ByteArrayInputStream(serializedConfigurators);
ObjectInputStream objectInStream;
try {
objectInStream = new ObjectInputStream(byteInStream);
List<Configurator> configurators = (List<Configurator>) objectInStream.readObject();
// Check if AgentConfigurator is set. In such case we will need to reload the
// Agent components as this configuration defines the way Agent components are loaded.
boolean needToReloadComponents = false;
for (Configurator configurator : configurators) {
if (configurator instanceof AgentConfigurator) {
needToReloadComponents = true;
break;
}
}
if (needToReloadComponents) {
// the already loaded Agent components are first unloaded
MainComponentLoader.getInstance().destroy();
// the initialization procedure will implicitly apply the new configurations
// and then will load up again the Agent components
MainComponentLoader.getInstance().initialize(configurators);
} else {
// just apply the configurations
ConfigurationManager.getInstance().apply(configurators);
}
} catch (IOException ioe) {
final String msg = "IO error while serializing configurators";
// log on the monitored machine
log.error(msg, ioe);
throw new AgentException(msg, ioe);
} catch (ClassNotFoundException cnfe) {
final String msg = "Could not deserialize configurators";
// log on the monitored machine
log.error(msg, cnfe);
throw new AgentException(msg, cnfe);
} catch (Exception e) {
final String msg = "Error applying configurators";
// log on the monitored machine
log.error(msg, e);
throw new AgentException(msg, e);
} finally {
ThreadsPerCaller.unregisterThread();
}
return AtsVersion.getAtsVersion();
}
use of javax.jws.WebMethod in project openmeetings by apache.
the class CalendarWebService method save.
/**
* Save an appointment
*
* @param sid
* The SID of the User. This SID must be marked as Loggedin
* @param appointment
* calendar event
*
* @return - appointment saved
*/
@WebMethod
@POST
@Path("/")
public AppointmentDTO save(@QueryParam("sid") @WebParam(name = "sid") String sid, @FormParam("appointment") @WebParam(name = "appointment") AppointmentDTO appointment) {
// Seems to be create
log.debug("save SID: {}", sid);
return performCall(sid, sd -> {
User u = userDao.get(sd.getUserId());
if (!AuthLevelUtil.hasUserLevel(u.getRights())) {
log.error("save: not authorized");
return false;
}
return AuthLevelUtil.hasWebServiceLevel(u.getRights()) || appointment.getOwner() == null || appointment.getOwner().getId().equals(u.getId());
}, sd -> {
User u = userDao.get(sd.getUserId());
Appointment a = appointment.get(userDao, fileDao, dao, u);
if (a.getRoom().getId() != null) {
if (a.getRoom().isAppointment()) {
a.getRoom().setIspublic(false);
} else {
a.setRoom(roomDao.get(a.getRoom().getId()));
}
}
return new AppointmentDTO(dao.update(a, u.getId()));
});
}
use of javax.jws.WebMethod in project openmeetings by apache.
the class FileWebService method getRoom.
/**
* Get a File Explorer Object by a given Room
*
* @param sid
* The SID of the User. This SID must be marked as logged in
* @param roomId
* Room Id
* @return - File Explorer Object by a given Room
*/
@WebMethod
@GET
@Path("/room/{id}")
public FileExplorerObject getRoom(@WebParam(name = "sid") @QueryParam("sid") String sid, @WebParam(name = "id") @PathParam("id") long roomId) {
log.debug("getRoom::roomId {}", roomId);
return performCall(sid, User.Right.Room, sd -> {
FileExplorerObject fileExplorerObject = new FileExplorerObject();
// Home File List
List<FileItem> fList = fileDao.getByOwner(sd.getUserId());
fileExplorerObject.setUser(fList, fileDao.getSize(fList));
// Public File List
List<FileItem> rList = fileDao.getByRoom(roomId);
fileExplorerObject.setRoom(rList, fileDao.getSize(rList));
return fileExplorerObject;
});
}
use of javax.jws.WebMethod in project openmeetings by apache.
the class RoomWebService method hash.
/**
* Method to get invitation hash with given parameters
*
* @param sid - The SID of the User. This SID must be marked as Loggedin
* @param invite - parameters of the invitation
* @param sendmail - flag to determine if email should be sent or not
* @return - serviceResult object with the result
*/
@WebMethod
@POST
@Path("/hash")
public ServiceResult hash(@WebParam(name = "sid") @QueryParam("sid") String sid, @WebParam(name = "invite") @QueryParam("invite") InvitationDTO invite, @WebParam(name = "sendmail") @QueryParam("sendmail") boolean sendmail) {
log.debug("[hash] invite {}", invite);
return performCall(sid, User.Right.Soap, sd -> {
Invitation i = invite.get(sd.getUserId(), userDao, roomDao);
i = inviteDao.update(i);
if (i != null) {
if (sendmail) {
try {
inviteManager.sendInvitationLink(i, MessageType.Create, invite.getSubject(), invite.getMessage(), false);
} catch (Exception e) {
throw new ServiceException(e.getMessage());
}
}
return new ServiceResult(i.getHash(), Type.SUCCESS);
} else {
return new ServiceResult("error.unknown", Type.ERROR);
}
});
}
Aggregations