use of org.apache.struts2.convention.annotation.Actions in project onebusaway-application-modules by camsys.
the class TripAction method execute.
@Override
@Actions({ @Action(value = "/where/trip"), @Action(value = "/where/iphone/trip") })
public String execute() throws ServiceException {
if (_id == null)
return INPUT;
if (_time == null)
_time = new Date();
TripDetailsQueryBean query = new TripDetailsQueryBean();
query.setTripId(_id);
if (_serviceDate != null)
query.setServiceDate(_serviceDate.getTime());
query.setVehicleId(_vehicleId);
query.setTime(_time.getTime());
_tripDetails = _service.getSingleTripDetails(query);
if (_tripDetails == null)
throw new NoSuchTripServiceException(_id);
TripStopTimesBean stopTimes = _tripDetails.getSchedule();
_timeZone = TimeZone.getTimeZone(stopTimes.getTimeZone());
_actualServiceDate = getActualServiceDate();
return SUCCESS;
}
use of org.apache.struts2.convention.annotation.Actions in project onebusaway-application-modules by camsys.
the class AgenciesAction method execute.
@Override
@Actions({ @Action(value = "/where/iphone/agencies") })
public String execute() throws ServiceException {
_model = _transitDataService.getAgenciesWithCoverage();
Collections.sort(_model, new AgencyWithCoverageBeanComparator());
return SUCCESS;
}
use of org.apache.struts2.convention.annotation.Actions in project qi4j-sdk by Qi4j.
the class Qi4jCodebehindPackageProvider method processActionClass.
/**
* Create a default action mapping for a class instance.
*
* The namespace annotation is honored, if found, otherwise
* the Java package is converted into the namespace
* by changing the dots (".") to slashes ("/").
*
* @param cls Action or POJO instance to process
* @param pkgs List of packages that were scanned for Actions
*/
protected void processActionClass(Class<?> cls, String[] pkgs) {
String name = cls.getName();
String actionPackage = cls.getPackage().getName();
String actionNamespace = null;
String actionName = null;
org.apache.struts2.config.Action actionAnn = (org.apache.struts2.config.Action) cls.getAnnotation(org.apache.struts2.config.Action.class);
if (actionAnn != null) {
actionName = actionAnn.name();
if (actionAnn.namespace().equals(org.apache.struts2.config.Action.DEFAULT_NAMESPACE)) {
actionNamespace = "";
} else {
actionNamespace = actionAnn.namespace();
}
} else {
for (String pkg : pkgs) {
if (name.startsWith(pkg)) {
if (LOG.isDebugEnabled()) {
LOG.debug("ClasspathPackageProvider: Processing class " + name);
}
name = name.substring(pkg.length() + 1);
actionNamespace = "";
actionName = name;
int pos = name.lastIndexOf('.');
if (pos > -1) {
actionNamespace = "/" + name.substring(0, pos).replace('.', '/');
actionName = name.substring(pos + 1);
}
break;
}
}
// Truncate Action suffix if found
if (actionName.endsWith(getClassSuffix())) {
actionName = actionName.substring(0, actionName.length() - getClassSuffix().length());
}
// Force initial letter of action to lowercase, if desired
if ((forceLowerCase) && (actionName.length() > 1)) {
int lowerPos = actionName.lastIndexOf('/') + 1;
StringBuilder sb = new StringBuilder();
sb.append(actionName.substring(0, lowerPos));
sb.append(Character.toLowerCase(actionName.charAt(lowerPos)));
sb.append(actionName.substring(lowerPos + 1));
actionName = sb.toString();
}
}
PackageConfig.Builder pkgConfig = loadPackageConfig(actionNamespace, actionPackage, cls);
// In case the package changed due to namespace annotation processing
if (!actionPackage.equals(pkgConfig.getName())) {
actionPackage = pkgConfig.getName();
}
Annotation annotation = cls.getAnnotation(ParentPackage.class);
if (annotation != null) {
String parent = ((ParentPackage) annotation).value()[0];
PackageConfig parentPkg = configuration.getPackageConfig(parent);
if (parentPkg == null) {
throw new ConfigurationException("ClasspathPackageProvider: Unable to locate parent package " + parent, annotation);
}
pkgConfig.addParent(parentPkg);
if (!isNotEmpty(pkgConfig.getNamespace()) && isNotEmpty(parentPkg.getNamespace())) {
pkgConfig.namespace(parentPkg.getNamespace());
}
}
ResultTypeConfig defaultResultType = packageLoader.getDefaultResultType(pkgConfig);
ActionConfig actionConfig = new ActionConfig.Builder(actionPackage, actionName, cls.getName()).addResultConfigs(new ResultMap<String, ResultConfig>(cls, actionName, defaultResultType)).build();
pkgConfig.addActionConfig(actionName, actionConfig);
}
use of org.apache.struts2.convention.annotation.Actions in project onebusaway-application-modules by camsys.
the class BlockAction method execute.
@Override
@Actions({ @Action(value = "/where/block"), @Action(value = "/where/iphone/block") })
public String execute() throws ServiceException {
if (_id == null)
return INPUT;
_blockInstance = _service.getBlockInstance(_id, _serviceDate.getTime());
if (_blockInstance == null)
return ERROR;
BlockConfigurationBean blockConfig = _blockInstance.getBlockConfiguration();
_timeZone = TimeZone.getTimeZone(blockConfig.getTimeZone());
return SUCCESS;
}
Aggregations