use of org.orcid.jaxb.model.record_rc3.Preferences in project ORCID-Source by ORCID.
the class ValidateV2RC4SamplesTest method testMarshallPreferences.
@Test
public void testMarshallPreferences() throws JAXBException, SAXException, URISyntaxException {
Preferences object = (Preferences) unmarshallFromPath("/record_2.0_rc4/samples/preferences-2.0_rc4.xml", Preferences.class);
marshall(object, "/record_2.0_rc4/preferences-2.0_rc4.xsd");
}
use of org.orcid.jaxb.model.record_rc3.Preferences in project ORCID-Source by ORCID.
the class ValidateV2_1SamplesTest method testMarshallPreferences.
@Test
public void testMarshallPreferences() throws JAXBException, SAXException, URISyntaxException {
Preferences object = (Preferences) unmarshallFromPath("/record_2.1/samples/read_samples/preferences-2.1.xml", Preferences.class);
marshall(object, "/record_2.1/preferences-2.1.xsd");
}
use of org.orcid.jaxb.model.record_rc3.Preferences in project uPortal by Jasig.
the class PreferencesHeaderProvider method createHeader.
@Override
public Header createHeader(RenderRequest renderRequest, RenderResponse renderResponse) {
// Username
final String username = getUsername(renderRequest);
// PreferencesMap
final Map<String, List<String>> preferencesMap = new HashMap<>();
final PortletPreferences prefs = renderRequest.getPreferences();
for (Map.Entry<String, String[]> y : prefs.getMap().entrySet()) {
final String name = y.getKey();
/*
* We ignore (skip) preferences that exist for the benefit of the
* SoffitConnectorController.
*/
if (name.startsWith(SoffitConnectorController.CONNECTOR_PREFERENCE_PREFIX)) {
continue;
}
List<String> values = Arrays.asList(prefs.getValues(name, new String[0]));
if (!values.isEmpty()) {
preferencesMap.put(name, values);
}
}
// Preferences header
final Preferences preferences = preferencesService.createPreferences(preferencesMap, username, getExpiration(renderRequest));
final Header rslt = new BasicHeader(Headers.PREFERECES.getName(), preferences.getEncryptedToken());
logger.debug("Produced the following Preferences header for username='{}': {}", username, rslt);
return rslt;
}
use of org.orcid.jaxb.model.record_rc3.Preferences in project uPortal by Jasig.
the class SoffitRendererController method render.
@RequestMapping(value = "/{module}", method = RequestMethod.GET)
public ModelAndView render(final HttpServletRequest req, final HttpServletResponse res, @PathVariable final String module) {
logger.debug("Rendering for request URI '{}'", req.getRequestURI());
// Soffit Object Model
final PortalRequest portalRequest = getPortalRequest(req);
final Bearer bearer = getBearer(req);
final Preferences preferences = getPreferences(req);
final Definition definition = getDefinition(req);
// Select a view
final String viewName = selectView(req, module, portalRequest);
final Map<String, Object> model = modelAttributeService.gatherModelAttributes(viewName, req, res, portalRequest, bearer, preferences, definition);
model.put(PORTAL_REQUEST_MODEL_NAME, portalRequest);
model.put(BEARER_MODEL_NAME, bearer);
model.put(PREFERENCES_MODEL_NAME, preferences);
model.put(DEFINITION_MODEL_NAME, definition);
// Set up cache headers appropriately
configureCacheHeaders(res, module);
return new ModelAndView(viewName, model);
}
use of org.orcid.jaxb.model.record_rc3.Preferences in project uPortal by Jasig.
the class ModelAttributeServiceTest method testGetModelAttributeFromMethod.
@Test
public void testGetModelAttributeFromMethod() {
final ModelAttributeService modelAttributeService = new ModelAttributeService();
final Class[] parameterClasses = new Class[] { HttpServletRequest.class, PortalRequest.class, Bearer.class };
final Method method;
try {
method = getClass().getMethod("soffitModelAttributeMethod", parameterClasses);
} catch (NoSuchMethodException e) {
throw new RuntimeException(e);
}
// Object Model
final HttpServletRequest req = Mockito.mock(HttpServletRequest.class);
final HttpServletResponse res = Mockito.mock(HttpServletResponse.class);
final PortalRequest portalRequest = Mockito.mock(PortalRequest.class);
final Bearer bearer = Mockito.mock(Bearer.class);
final Preferences preferences = Mockito.mock(Preferences.class);
final Definition definition = Mockito.mock(Definition.class);
final Object modelAttribute = modelAttributeService.getModelAttributeFromMethod(this, method, req, res, portalRequest, bearer, preferences, definition);
assertEquals("Incorrect modelAttribute", modelAttribute, returnValue);
final Method brokenMethod;
try {
brokenMethod = getClass().getMethod("brokenSoffitModelAttributeMethod", parameterClasses);
} catch (NoSuchMethodException e) {
throw new RuntimeException(e);
}
try {
modelAttributeService.getModelAttributeFromMethod(this, brokenMethod, req, res, portalRequest, bearer, preferences, definition);
fail("Expected IllegalStateException for void-declaring method");
} catch (IllegalStateException e) {
// Expected; fall through...
}
}
Aggregations