Skip to content

Commit

Permalink
ViewsRepository: improve logging
Browse files Browse the repository at this point in the history
  • Loading branch information
teosarca committed Jul 22, 2017
1 parent 00b525c commit 50c30f5
Showing 1 changed file with 30 additions and 7 deletions.
37 changes: 30 additions & 7 deletions src/main/java/de/metas/ui/web/view/ViewsRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ private void truncateTempTablesIfAllowed()
truncateTable(I_T_WEBUI_ViewSelection.Table_Name);
truncateTable(I_T_WEBUI_ViewSelectionLine.Table_Name);
}
else
{
logger.info("Skip truncating selection tables on startup because not configured");
}
}

private static void truncateTable(final String tableName)
Expand Down Expand Up @@ -138,7 +142,6 @@ private void registerAnnotatedFactories(final Collection<IViewFactory> viewFacto
logger.info("Registered {} for windowId={}, viewType={}", factory, windowId, viewTypes);
}
}

}

private final IViewFactory getFactory(final WindowId windowId, final JSONViewDataType viewType)
Expand All @@ -163,6 +166,9 @@ private static final ArrayKey mkFactoryKey(final WindowId windowId, final JSONVi
return ArrayKey.of(windowId, viewType);
}

/**
* @param viewsIndexStorages view index storages discovered in spring context
*/
@Autowired
private void registerViewsIndexStorages(final Collection<IViewsIndexStorage> viewsIndexStorages)
{
Expand Down Expand Up @@ -210,7 +216,8 @@ private Stream<IView> streamAllViews()
@Override
public ViewLayout getViewLayout(final WindowId windowId, final JSONViewDataType viewDataType)
{
DocumentPermissionsHelper.assertWindowAccess(windowId, null, UserSession.getCurrentPermissions());
final String viewId = null; // N/A
DocumentPermissionsHelper.assertViewAccess(windowId, viewId, UserSession.getCurrentPermissions());

final IViewFactory factory = getFactory(windowId, viewDataType);
return factory.getViewLayout(windowId, viewDataType)
Expand All @@ -229,6 +236,8 @@ public List<IView> getViews()
@Override
public IView createView(final CreateViewRequest request)
{
logger.trace("Creating new view from {}", request);

final WindowId windowId = request.getWindowId();
final JSONViewDataType viewType = request.getViewType();
final IViewFactory factory = getFactory(windowId, viewType);
Expand All @@ -241,13 +250,16 @@ public IView createView(final CreateViewRequest request)
}

getViewsStorageFor(view.getViewId()).put(view);
logger.trace("Created view {}", view);

return view;
}

@Override
public IView filterView(final ViewId viewId, final JSONFilterViewRequest jsonRequest)
{
logger.trace("Creating filtered view from {} using {}", viewId, jsonRequest);

// Get current view
final IView view = getView(viewId);

Expand All @@ -269,6 +281,11 @@ public IView filterView(final ViewId viewId, final JSONFilterViewRequest jsonReq
if (view != newView)
{
getViewsStorageFor(newView.getViewId()).put(newView);
logger.trace("Created filtered view {}", newView);
}
else
{
logger.trace("Filtered view is the same as the ordiginal. Returning the original {}", view);
}

// Return the newly created view
Expand All @@ -278,6 +295,8 @@ public IView filterView(final ViewId viewId, final JSONFilterViewRequest jsonReq
@Override
public IView deleteStickyFilter(final ViewId viewId, final String filterId)
{
logger.trace("Deleting sticky filter {} from {}", filterId, viewId);

// Get current view
final IView view = getView(viewId);

Expand All @@ -299,6 +318,11 @@ public IView deleteStickyFilter(final ViewId viewId, final String filterId)
if (view != newView)
{
getViewsStorageFor(newView.getViewId()).put(newView);
logger.trace("Sticky filter deleted. Returning new view {}", newView);
}
else
{
logger.trace("Sticky filter NOT deleted. Returning current view {}", view);
}

// Return the newly created view
Expand Down Expand Up @@ -336,12 +360,14 @@ public IView getViewIfExists(final ViewId viewId)
public void deleteView(final ViewId viewId)
{
getViewsStorageFor(viewId).removeById(viewId);
logger.trace("Removed view {}", viewId);
}

@Override
public void invalidateView(final ViewId viewId)
{
getViewsStorageFor(viewId).invalidateView(viewId);
logger.trace("Invalided view {}", viewId);
}

@Override
Expand All @@ -350,6 +376,7 @@ public void notifyRecordsChanged(final Set<TableRecordReference> recordRefs)
{
if (recordRefs.isEmpty())
{
logger.trace("No changed records provided. Skip notifying views.");
return;
}

Expand All @@ -360,10 +387,6 @@ public void notifyRecordsChanged(final Set<TableRecordReference> recordRefs)
notifiedCount.incrementAndGet();
});

if (logger.isDebugEnabled())
{
logger.debug("Notified {} views about changed records: {}", notifiedCount, recordRefs);
}

logger.debug("Notified {} views about changed records: {}", notifiedCount, recordRefs);
}
}

0 comments on commit 50c30f5

Please sign in to comment.