public static String getConnectorName(String beanClassName) { final String[] splits = StringUtils.split(beanClassName, "."); return splits[splits.length-2]; }
@POST @Path("/{dashboardId}/widgets/reorder") @ApiOperation(value = "Change the order of widgets in a dashboard", response = DashboardModel.class, responseContainer = "Array") @Produces({ MediaType.APPLICATION_JSON }) public Response setWidgetsOrder(@PathParam("dashboardId") long dashboardId, @FormParam("widgetNames") String widgetNames) throws UnsupportedEncodingException { long guestId = AuthHelper.getGuestId(); try { final String[] wNames = StringUtils.split(widgetNames, ","); dashboardsService.setWidgetsOrder(guestId, dashboardId, wNames); return getDashboards(); } catch (Exception e) { StringBuilder sb = new StringBuilder("module=API component=dashboardStore action=setWidgetOrder") .append(" guestId=").append(guestId) .append(" stackTrace=<![CDATA[").append(Utils.stackTrace(e)).append("]]>"); logger.warn(sb.toString()); return Response.serverError().entity("Failed to set widget order: " + e.getMessage()).build(); } }
@GET @Path("/{dashboardId}/availableWidgets") @ApiOperation(value = "List available widgets", response = DashboardWidget.class, responseContainer = "Array") @Produces({ MediaType.APPLICATION_JSON }) public Response getAvailableWidgets(@PathParam("dashboardId") long dashboardId) { long guestId = AuthHelper.getGuestId(); try { final List<DashboardWidget> widgetsNotYetInDashboard = new ArrayList<DashboardWidget>(); final List<DashboardWidget> availableWidgetsList = widgetsService.getAvailableWidgetsList(guestId); final Dashboard dashboard = dashboardsService.getDashboard(guestId, dashboardId); final String[] dashboardWidgets = StringUtils.split(dashboard.widgetNames, ","); outerloop: for (DashboardWidget availableWidget : availableWidgetsList) { for (String dashboardWidgetName : dashboardWidgets) { if (availableWidget.WidgetName.equals(dashboardWidgetName)) continue outerloop; } widgetsNotYetInDashboard.add(availableWidget); } return Response.ok(widgetsNotYetInDashboard).build(); } catch (Exception e) { StringBuilder sb = new StringBuilder("module=API component=dashboardStore action=getAvailableWidgets") .append(" guestId=").append(guestId) .append(" stackTrace=<![CDATA[").append(Utils.stackTrace(e)).append("]]>"); logger.warn(sb.toString()); return Response.serverError().entity("Failed to get availableWidgets: " + e.getMessage()).build(); } }
@POST @Path("/reorder") @ApiOperation(value = "Change the order of dashboards", response = DashboardModel.class, responseContainer = "Array") @Produces({ MediaType.APPLICATION_JSON }) public Response setDashboardsOrder(@FormParam("dashboardIds") String dashboardIds) throws UnsupportedEncodingException { long guestId = AuthHelper.getGuestId(); try { //dashboardIds = URLDecoder.decode(dashboardIds, "UTF-8"); final String[] dNames = StringUtils.split(dashboardIds, ","); long[] ids = new long[dNames.length]; int i=0; for (String dName : dNames) { ids[i++] = Long.valueOf(dName); } dashboardsService.setDashboardsOrder(guestId, ids); return getDashboards(); } catch (Exception e) { StringBuilder sb = new StringBuilder("module=API component=dashboardStore action=setDashboardsOrder") .append(" guestId=").append(guestId) .append(" stackTrace=<![CDATA[").append(Utils.stackTrace(e)).append("]]>"); logger.warn(sb.toString()); return Response.serverError().entity("Failed to set dashboard order: " + e.getMessage()).build(); } }
private DashboardModel toDashboardModel(final Dashboard dashboard, long guestId) { DashboardModel dashboardModel = new DashboardModel(); dashboardModel.id = dashboard.getId(); dashboardModel.name = dashboard.name; dashboardModel.active = dashboard.active; final List<DashboardWidget> availableWidgetsList = widgetsService.getAvailableWidgetsList(guestId); final String[] widgetNames = StringUtils.split(dashboard.widgetNames, ","); List<DashboardWidgetModel> widgetModels = new ArrayList<DashboardWidgetModel>(); there: for (String widgetName : widgetNames) { for (DashboardWidget dashboardWidget : availableWidgetsList) { if (dashboardWidget.WidgetName.equals(widgetName)) { widgetModels.add(toDashboardWidgetModel(dashboardWidget, dashboard, guestId)); continue there; } } } dashboardModel.widgets = widgetModels; return dashboardModel; }
String[] sources = StringUtils.split(file,","); contextProperties = new ExtendedProperties();
String[] sources = StringUtils.split(file,","); contextProperties = new ExtendedProperties();
String[] sources = StringUtils.split(file,","); contextProperties = new ExtendedProperties();