Here are the examples of the java api org.springframework.extensions.webscripts.WebScriptRequest taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
492 Examples
19
View Source File : WorkspacesGet.java
License : Apache License 2.0
Project Creator : Open-MBEE
License : Apache License 2.0
Project Creator : Open-MBEE
/**
* Entry point
*/
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {
WorkspacesGet instance = new WorkspacesGet(repository, getServices());
return instance.executeImplImpl(req, status, cache);
}
19
View Source File : WorkspacesGet.java
License : Apache License 2.0
Project Creator : Open-MBEE
License : Apache License 2.0
Project Creator : Open-MBEE
/**
* Validate the request and check some permissions
*/
@Override
protected boolean validateRequest(WebScriptRequest req, Status status) {
return checkRequestContent(req);
}
19
View Source File : WorkspaceHistoryGet.java
License : Apache License 2.0
Project Creator : Open-MBEE
License : Apache License 2.0
Project Creator : Open-MBEE
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {
WorkspaceHistoryGet instance = new WorkspaceHistoryGet(repository, getServices());
return instance.executeImplImpl(req, status, cache);
}
19
View Source File : WorkspaceDelete.java
License : Apache License 2.0
Project Creator : Open-MBEE
License : Apache License 2.0
Project Creator : Open-MBEE
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {
WorkspaceDelete instance = new WorkspaceDelete(repository, getServices());
return instance.executeImplImpl(req, status, cache);
}
19
View Source File : UserPreferencesPost.java
License : Apache License 2.0
Project Creator : Open-MBEE
License : Apache License 2.0
Project Creator : Open-MBEE
/**
* Webscript entry point
*/
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {
UserPreferencesPost instance = new UserPreferencesPost(repository, getServices());
return instance.executeImplImpl(req, status, cache);
}
19
View Source File : UserPreferencesGet.java
License : Apache License 2.0
Project Creator : Open-MBEE
License : Apache License 2.0
Project Creator : Open-MBEE
/**
* Webscript entry point
*/
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {
UserPreferencesGet instance = new UserPreferencesGet(repository, getServices());
return instance.executeImplImpl(req, status, cache);
}
19
View Source File : OrgDelete.java
License : Apache License 2.0
Project Creator : Open-MBEE
License : Apache License 2.0
Project Creator : Open-MBEE
/**
* Webscript entry point
*/
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {
OrgDelete instance = new OrgDelete(repository, getServices());
return instance.executeImplImpl(req, status, cache);
}
19
View Source File : ModelsGet.java
License : Apache License 2.0
Project Creator : Open-MBEE
License : Apache License 2.0
Project Creator : Open-MBEE
/**
* Entry point
*/
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {
ModelsGet instance = new ModelsGet(repository, getServices());
return instance.executeImplImpl(req, status, cache);
}
19
View Source File : ModelIdsGet.java
License : Apache License 2.0
Project Creator : Open-MBEE
License : Apache License 2.0
Project Creator : Open-MBEE
/**
* Entry point
*/
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {
ModelIdsGet instance = new ModelIdsGet(repository, getServices());
return instance.executeImplImpl(req, status, cache);
}
19
View Source File : ModelGet.java
License : Apache License 2.0
Project Creator : Open-MBEE
License : Apache License 2.0
Project Creator : Open-MBEE
/**
* Get the depth to recurse to from the request parameter.
*
* @param req WebScriptRequest object
* @return Depth < 0 is infinite recurse, depth = 0 is just the element (if no request
* parameter)
*/
Long getDepthFromRequest(WebScriptRequest req) {
long depth = 0L;
String depthParam = req.getParameter("depth");
if (depthParam != null) {
depth = parseDepth(depthParam);
}
return getBooleanArg(req, "recurse", false) ? 100000L : depth;
}
19
View Source File : MmsVersion.java
License : Apache License 2.0
Project Creator : Open-MBEE
License : Apache License 2.0
Project Creator : Open-MBEE
/**
* Webscript entry point
*/
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {
MmsVersion instance = new MmsVersion(repository, getServices());
return instance.executeImplImpl(req, status, cache);
}
19
View Source File : MigrateGet.java
License : Apache License 2.0
Project Creator : Open-MBEE
License : Apache License 2.0
Project Creator : Open-MBEE
/**
* Webscript entry point
*/
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {
MigrateGet instance = new MigrateGet(repository, getServices());
return instance.executeImplImpl(req, status, cache);
}
19
View Source File : HostnameGet.java
License : Apache License 2.0
Project Creator : Open-MBEE
License : Apache License 2.0
Project Creator : Open-MBEE
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {
HostnameGet instance = new HostnameGet(repository, getServices());
return instance.executeImplImpl(req, status, cache);
}
19
View Source File : DocumentsGet.java
License : Apache License 2.0
Project Creator : Open-MBEE
License : Apache License 2.0
Project Creator : Open-MBEE
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {
DoreplacedentsGet instance = new DoreplacedentsGet(repository, getServices());
return instance.executeImplImpl(req, status, cache);
}
19
View Source File : CommitsGet.java
License : Apache License 2.0
Project Creator : Open-MBEE
License : Apache License 2.0
Project Creator : Open-MBEE
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {
CommitsGet instance = new CommitsGet(repository, getServices());
return instance.executeImplImpl(req, status, cache);
}
19
View Source File : CommitsGet.java
License : Apache License 2.0
Project Creator : Open-MBEE
License : Apache License 2.0
Project Creator : Open-MBEE
/**
* Validate the request and check some permissions
*/
@Override
protected boolean validateRequest(WebScriptRequest req, Status status) {
return true;
}
19
View Source File : ArtifactsGet.java
License : Apache License 2.0
Project Creator : Open-MBEE
License : Apache License 2.0
Project Creator : Open-MBEE
@Override
protected Map<String, Object> getModel(WebScriptRequest req) throws IOException {
JsonObject result = handleRequest(req, 0L, Sjm.ARTIFACTS);
return finish(req, result, false, Sjm.ARTIFACTS);
}
19
View Source File : ArtifactsGet.java
License : Apache License 2.0
Project Creator : Open-MBEE
License : Apache License 2.0
Project Creator : Open-MBEE
/**
* Entry point
*/
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {
ArtifactsGet instance = new ArtifactsGet(repository, getServices());
return instance.executeImplImpl(req, status, cache);
}
19
View Source File : ArtifactGet.java
License : Apache License 2.0
Project Creator : Open-MBEE
License : Apache License 2.0
Project Creator : Open-MBEE
/**
* Entry point
*/
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {
ArtifactGet instance = new ArtifactGet(repository, getServices());
return instance.executeImplImpl(req, status, cache);
}
19
View Source File : ArtifactGet.java
License : Apache License 2.0
Project Creator : Open-MBEE
License : Apache License 2.0
Project Creator : Open-MBEE
@Override
protected Map<String, Object> getModel(WebScriptRequest req) throws IOException {
JsonObject result = handleRequest(req, 0L, Sjm.ARTIFACTS);
return finish(req, result, true, Sjm.ARTIFACTS);
}
19
View Source File : ScriptPagingDetails.java
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
/**
* Creates a new {@link PagingRequest} object, based on the standard URL
* parameters for webscript paging.
*
* @param req The request object to extract parameters from
* @param maxResultCount The maximum results count if none is specified
*/
public static PagingRequest buildPagingRequest(WebScriptRequest req, int maxResultCount) throws WebScriptException {
int pageSize = maxResultCount;
int startIndex = 0;
String queryId = req.getParameter("queryId");
String pageSizeS = req.getParameter("pageSize");
if (pageSizeS != null) {
try {
pageSize = Integer.parseInt(pageSizeS);
} catch (NumberFormatException e) {
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Paging size parameters invalid");
}
}
String startIndexS = req.getParameter("startIndex");
if (startIndexS != null) {
try {
startIndex = Integer.parseInt(startIndexS);
} catch (NumberFormatException e) {
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Paging size parameters invalid");
}
} else {
// No Start Index given, did they supply a Page Number?
String pageNumberS = req.getParameter("page");
if (pageNumberS != null) {
try {
int pageNumber = Integer.parseInt(pageNumberS);
startIndex = (pageNumber - 1) * pageSize;
} catch (NumberFormatException e) {
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Paging size parameters invalid");
}
}
}
PagingRequest paging = new PagingRequest(startIndex, pageSize, queryId);
// The default total count is the higher of page 10, or 2 pages further
paging.setRequestTotalCountMax(Math.max(10 * pageSize, startIndex + 2 * pageSize));
// All done
return paging;
}
19
View Source File : SerializerTestHelper.java
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
public Object searchSQLQueryFromJson(String query, Clreplaced<?> clreplacedz) throws IOException {
Content content = mock(Content.clreplaced);
when(content.getReader()).thenReturn(new StringReader(query));
WebScriptRequest request = mock(WebScriptRequest.clreplaced);
when(request.getContent()).thenReturn(content);
return extractJsonContent(request, jsonHelper, clreplacedz);
}
19
View Source File : SerializerTestHelper.java
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
public SearchQuery extractFromJson(String json) throws IOException {
Content content = mock(Content.clreplaced);
when(content.getReader()).thenReturn(new StringReader(json));
WebScriptRequest request = mock(WebScriptRequest.clreplaced);
when(request.getContent()).thenReturn(content);
return extractJsonContent(request, jsonHelper, SearchQuery.clreplaced);
}
19
View Source File : TestDeclarativeSpreadsheetWebScriptGet.java
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
@Override
protected Object identifyResource(String format, WebScriptRequest req) {
return null;
}
19
View Source File : Params.java
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
/**
* Parameters preplaceded in from a Rest client for use in calls to the rest api.
*
* @author Gethin James
*/
public clreplaced Params implements Parameters {
// Note: isCollectionResource maps to "readAll". It can apply to these levels, eg ...
// /enreplacedies,
// /enreplacedies/{enreplacedyAId}/relationship1,
// /enreplacedies/{enreplacedyAId}/relationship1/{enreplacedyBId}/relationship2
private final boolean isCollectionResource;
private final String enreplacedyId;
private final String relationshipId;
private final String relationship2Id;
private final Object preplacededIn;
private final InputStream stream;
private final RecognizedParams recognizedParams;
private final String addressedProperty;
private final BasicContentInfo contentInfo;
private final WebScriptRequest request;
// Constants
private static final RecognizedParams NULL_PARAMS = new RecognizedParams(null, null, null, null, null, null, null, null, false);
private static final BasicContentInfo DEFAULT_CONTENT_INFO = new ContentInfoImpl(MimetypeMap.MIMETYPE_BINARY, "UTF-8", -1, null);
protected Params(Boolean isCollectionResource, String enreplacedyId, String relationshipId, String relationship2Id, Object preplacededIn, InputStream stream, String addressedProperty, RecognizedParams recognizedParams, BasicContentInfo contentInfo, WebScriptRequest request) {
super();
this.isCollectionResource = (isCollectionResource != null ? isCollectionResource : (enreplacedyId == null));
this.enreplacedyId = enreplacedyId;
this.relationshipId = relationshipId;
this.relationship2Id = relationship2Id;
this.preplacededIn = preplacededIn;
this.stream = stream;
this.recognizedParams = recognizedParams;
this.addressedProperty = addressedProperty;
this.request = request;
this.contentInfo = contentInfo == null ? DEFAULT_CONTENT_INFO : contentInfo;
}
public static Params valueOf(BeanPropertiesFilter paramFilter, String enreplacedyId, WebScriptRequest request) {
return new Params(null, enreplacedyId, null, null, null, null, null, new RecognizedParams(null, null, paramFilter, null, null, null, null, null, false), null, request);
}
public static Params valueOf(String enreplacedyId, String relationshipId, WebScriptRequest request) {
return new Params(null, enreplacedyId, relationshipId, null, null, null, null, NULL_PARAMS, null, request);
}
public static Params valueOf(RecognizedParams recognizedParams, String enreplacedyId, String relationshipId, WebScriptRequest request) {
return new Params(null, enreplacedyId, relationshipId, null, null, null, null, recognizedParams, null, request);
}
public static Params valueOf(String enreplacedyId, RecognizedParams recognizedParams, Object preplacededIn, WebScriptRequest request) {
return new Params(null, enreplacedyId, null, null, preplacededIn, null, null, recognizedParams, null, request);
}
public static Params valueOf(String enreplacedyId, String relationshipId, RecognizedParams recognizedParams, Object preplacededIn, WebScriptRequest request) {
return new Params(null, enreplacedyId, relationshipId, null, preplacededIn, null, null, recognizedParams, null, request);
}
public static Params valueOf(String enreplacedyId, String relationshipId, Object preplacededIn, InputStream stream, String addressedProperty, RecognizedParams recognizedParams, BasicContentInfo contentInfo, WebScriptRequest request) {
return new Params(null, enreplacedyId, relationshipId, null, preplacededIn, stream, addressedProperty, recognizedParams, contentInfo, request);
}
public static Params valueOf(boolean isCollectionResource, String enreplacedyId, String relationshipId, String relationship2Id, Object preplacededIn, InputStream stream, String addressedProperty, RecognizedParams recognizedParams, BasicContentInfo contentInfo, WebScriptRequest request) {
return new Params(isCollectionResource, enreplacedyId, relationshipId, relationship2Id, preplacededIn, stream, addressedProperty, recognizedParams, contentInfo, request);
}
public String getEnreplacedyId() {
return this.enreplacedyId;
}
public Object getPreplacededIn() {
return this.preplacededIn;
}
public String getRelationshipId() {
return this.relationshipId;
}
public String getRelationship2Id() {
return this.relationship2Id;
}
public boolean isCollectionResource() {
return this.isCollectionResource;
}
public Query getQuery() {
return this.recognizedParams.query;
}
public Paging getPaging() {
return this.recognizedParams.paging;
}
public BeanPropertiesFilter getFilter() {
return this.recognizedParams.filter;
}
@Override
public boolean includeSource() {
return this.recognizedParams.includeSource;
}
public Map<String, BeanPropertiesFilter> getRelationsFilter() {
return this.recognizedParams.relationshipFilter;
}
public InputStream getStream() {
return this.stream;
}
/*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("Params [enreplacedyId=");
builder.append(this.enreplacedyId);
builder.append(", relationshipId=");
builder.append(this.relationshipId);
builder.append(", preplacededIn=");
builder.append(this.preplacededIn);
builder.append(", paging=");
builder.append(this.recognizedParams.paging);
builder.append(", query=");
builder.append(this.recognizedParams.query);
builder.append(", sorting=");
builder.append(this.recognizedParams.sorting);
builder.append(", include=");
builder.append(this.recognizedParams.include);
builder.append(", select=");
builder.append(this.recognizedParams.select);
builder.append(", filter=");
builder.append(this.recognizedParams.filter);
builder.append(", relationshipFilter=");
builder.append(this.recognizedParams.relationshipFilter);
builder.append(", includeSource=");
builder.append(this.recognizedParams.includeSource);
builder.append(", addressedProperty=");
builder.append(this.addressedProperty);
builder.append("]");
return builder.toString();
}
@Override
public /**
* Similar to the standard HTTPRequest method. Just returns the first parameter value or NULL.
*/
String getParameter(String parameterName) {
if (recognizedParams.requestParameters != null && !recognizedParams.requestParameters.isEmpty()) {
String[] vals = recognizedParams.requestParameters.get(parameterName);
if (vals != null && vals.length > 0) {
// Just return the first element.
return vals[0];
}
}
return null;
}
@Override
public T getParameter(String parameterName, Clreplaced<T> clazz) throws InvalidArgumentException {
String param = getParameter(parameterName);
if (param == null)
return null;
Object obj = ConvertUtils.convert(param, clazz);
if (obj != null && obj.getClreplaced().equals(clazz)) {
return (T) obj;
}
throw new InvalidArgumentException(InvalidArgumentException.DEFAULT_MESSAGE_ID, new Object[] { parameterName });
}
@Override
public boolean hasBinaryProperty(String propertyName) {
return (addressedProperty != null && addressedProperty.equals(propertyName));
}
@Override
public List<SortColumn> getSorting() {
return recognizedParams.sorting;
}
@Override
public String getBinaryProperty() {
return addressedProperty;
}
@Override
public List<String> getSelectedProperties() {
return recognizedParams.select;
}
@Override
public List<String> getInclude() {
return recognizedParams.include;
}
@Override
public BasicContentInfo getContentInfo() {
return contentInfo;
}
@Override
public WebScriptRequest getRequest() {
return request;
}
/**
* A formal set of params that any rest service could potentially have preplaceded in as request params
*/
public static clreplaced RecognizedParams {
final Paging paging;
private final BeanPropertiesFilter filter;
private final Map<String, BeanPropertiesFilter> relationshipFilter;
private final Map<String, String[]> requestParameters;
private final Query query;
private final List<String> include;
@Deprecated
private final List<String> // see include
select;
private final List<SortColumn> sorting;
private final boolean includeSource;
@SuppressWarnings("unchecked")
public RecognizedParams(Map<String, String[]> requestParameters, Paging paging, BeanPropertiesFilter filter, Map<String, BeanPropertiesFilter> relationshipFilter, List<String> include, List<String> select, Query query, List<SortColumn> sorting, boolean includeSource) {
super();
this.requestParameters = requestParameters;
this.paging = paging == null ? Paging.DEFAULT : paging;
this.filter = filter == null ? BeanPropertiesFilter.ALLOW_ALL : filter;
this.query = query == null ? QueryImpl.EMPTY : query;
this.relationshipFilter = (Map<String, BeanPropertiesFilter>) (relationshipFilter == null ? Collections.emptyMap() : relationshipFilter);
this.include = (List<String>) (include == null ? Collections.emptyList() : include);
this.select = (List<String>) (select == null ? Collections.emptyList() : select);
this.sorting = (List<SortColumn>) (sorting == null ? Collections.emptyList() : sorting);
this.includeSource = includeSource;
}
}
}
19
View Source File : Params.java
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
public static Params valueOf(String enreplacedyId, String relationshipId, Object preplacededIn, InputStream stream, String addressedProperty, RecognizedParams recognizedParams, BasicContentInfo contentInfo, WebScriptRequest request) {
return new Params(null, enreplacedyId, relationshipId, null, preplacededIn, stream, addressedProperty, recognizedParams, contentInfo, request);
}
19
View Source File : Params.java
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
public static Params valueOf(String enreplacedyId, String relationshipId, WebScriptRequest request) {
return new Params(null, enreplacedyId, relationshipId, null, null, null, null, NULL_PARAMS, null, request);
}
19
View Source File : Params.java
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
public static Params valueOf(RecognizedParams recognizedParams, String enreplacedyId, String relationshipId, WebScriptRequest request) {
return new Params(null, enreplacedyId, relationshipId, null, null, null, null, recognizedParams, null, request);
}
19
View Source File : Params.java
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
public static Params valueOf(boolean isCollectionResource, String enreplacedyId, String relationshipId, String relationship2Id, Object preplacededIn, InputStream stream, String addressedProperty, RecognizedParams recognizedParams, BasicContentInfo contentInfo, WebScriptRequest request) {
return new Params(isCollectionResource, enreplacedyId, relationshipId, relationship2Id, preplacededIn, stream, addressedProperty, recognizedParams, contentInfo, request);
}
19
View Source File : Params.java
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
public static Params valueOf(String enreplacedyId, String relationshipId, RecognizedParams recognizedParams, Object preplacededIn, WebScriptRequest request) {
return new Params(null, enreplacedyId, relationshipId, null, preplacededIn, null, null, recognizedParams, null, request);
}
19
View Source File : Params.java
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
public static Params valueOf(BeanPropertiesFilter paramFilter, String enreplacedyId, WebScriptRequest request) {
return new Params(null, enreplacedyId, null, null, null, null, null, new RecognizedParams(null, null, paramFilter, null, null, null, null, null, false), null, request);
}
19
View Source File : Params.java
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
public static Params valueOf(String enreplacedyId, RecognizedParams recognizedParams, Object preplacededIn, WebScriptRequest request) {
return new Params(null, enreplacedyId, null, null, preplacededIn, null, null, recognizedParams, null, request);
}
19
View Source File : NetworkWebScriptGet.java
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
@Override
public void execute(final Api api, final WebScriptRequest req, final WebScriptResponse res) throws IOException {
try {
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>() {
@Override
public Void execute() throws Throwable {
// apply content type
res.setContentType(Format.JSON.mimetype() + ";charset=UTF-8");
replacedistant.getJsonHelper().withWriter(res.getOutputStream(), new Writer() {
@Override
public void writeContents(JsonGenerator generator, ObjectMapper objectMapper) throws JsonGenerationException, JsonMappingException, IOException {
String personId = AuthenticationUtil.getFullyAuthenticatedUser();
String networkId = TenantUtil.getCurrentDomain();
PersonNetwork networkMembership = networks.getNetwork(personId, networkId);
if (networkMembership != null) {
// TODO this is not ideal, but the only way to populate the embedded network enreplacedies (this would normally be
// done automatically by the api framework).
Object wrapped = helper.processAdditionsToTheResponse(res, Api.ALFRESCO_PUBLIC, NetworksEnreplacedyResource.NAME, Params.valueOf(personId, null, req), networkMembership);
objectMapper.writeValue(generator, wrapped);
} else {
throw new EnreplacedyNotFoundException(networkId);
}
}
});
return null;
}
}, true, true);
} catch (ApiException | WebScriptException apiException) {
renderException(apiException, res, replacedistant);
} catch (RuntimeException runtimeException) {
renderException(runtimeException, res, replacedistant);
}
}
19
View Source File : NetworksWebScriptGet.java
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
@Override
public void execute(final Api api, final WebScriptRequest req, final WebScriptResponse res) throws IOException {
try {
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>() {
@Override
public Void execute() throws Throwable {
final Paging paging = findPaging(req);
// apply content type
res.setContentType(Format.JSON.mimetype() + ";charset=UTF-8");
replacedistant.getJsonHelper().withWriter(res.getOutputStream(), new Writer() {
@Override
public void writeContents(JsonGenerator generator, ObjectMapper objectMapper) throws JsonGenerationException, JsonMappingException, IOException {
List<Object> enreplacedies = new ArrayList<Object>();
String personId = AuthenticationUtil.getFullyAuthenticatedUser();
CollectionWithPagingInfo<PersonNetwork> networkMemberships = networks.getNetworks(personId, paging);
for (PersonNetwork networkMember : networkMemberships.getCollection()) {
// TODO this is not ideal, but the only way to populate the embedded network enreplacedies (this would normally be
// done automatically by the api framework).
Object wrapped = helper.processAdditionsToTheResponse(res, Api.ALFRESCO_PUBLIC, NetworksEnreplacedyResource.NAME, Params.valueOf(personId, null, req), networkMember);
enreplacedies.add(wrapped);
}
objectMapper.writeValue(generator, CollectionWithPagingInfo.asPaged(paging, enreplacedies));
}
});
return null;
}
}, true, true);
} catch (ApiException | WebScriptException apiException) {
renderException(apiException, res, replacedistant);
} catch (RuntimeException runtimeException) {
renderException(runtimeException, res, replacedistant);
}
}
19
View Source File : WorkflowInstancesGet.java
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
private Date getDateFromRequest(WebScriptRequest req, String paramName) {
String dateParam = req.getParameter(paramName);
if (dateParam != null) {
if (!EMPTY.equals(dateParam) && !NULL.equals(dateParam)) {
return getDateParameter(req, paramName);
}
}
return null;
}
19
View Source File : WorkflowInstancesGet.java
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
/**
* Gets the specified {@link WorkflowState}, null if not requested.
*
* @param req The WebScript request
* @return The workflow state or null if not requested
*/
private WorkflowState getState(WebScriptRequest req) {
String stateName = req.getParameter(PARAM_STATE);
if (stateName != null) {
try {
return WorkflowState.valueOf(stateName.toUpperCase());
} catch (IllegalArgumentException e) {
String msg = "Unrecognised State parameter: " + stateName;
throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, msg);
}
}
return null;
}
19
View Source File : WorkflowInstanceGet.java
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
private boolean getIncludeTasks(WebScriptRequest req) {
String includeTasks = req.getParameter(PARAM_INCLUDE_TASKS);
if (includeTasks != null) {
try {
return Boolean.valueOf(includeTasks);
} catch (Exception e) {
// do nothing, false will be returned
}
}
// Defaults to false.
return false;
}
19
View Source File : WorkflowInstanceDelete.java
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
private boolean getForced(WebScriptRequest req) {
String forced = req.getParameter(PARAM_FORCED);
if (forced != null) {
try {
return Boolean.valueOf(forced);
} catch (Exception e) {
// do nothing, false will be returned
}
}
// Defaults to false.
return false;
}
19
View Source File : TaskInstancesGet.java
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
/**
* Retrieves the pooledTasks parameter.
*
* @param req The WebScript request
* @return null if not present, Boolean object otherwise
*/
private Boolean getPooledTasks(WebScriptRequest req) {
Boolean result = null;
String includePooledTasks = req.getParameter(PARAM_POOLED_TASKS);
if (includePooledTasks != null) {
result = Boolean.valueOf(includePooledTasks);
}
return result;
}
19
View Source File : TaskInstancesGet.java
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
/**
* Returns the specified authority. If no authority is specified then returns the current Fully Authenticated user.
* @param req WebScriptRequest
* @return String
*/
private String getAuthority(WebScriptRequest req) {
String authority = req.getParameter(PARAM_AUTHORITY);
if (authority == null || authority.length() == 0) {
authority = null;
}
return authority;
}
19
View Source File : AbstractWorkflowWebscript.java
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
/**
* Processes the given date filter parameter from the provided webscript request.
*
* If the parameter is present but set to an empty string or to "null" the
* date is added to the given filters Map as "", if the parameter
* contains an ISO8601 date it's added as a Date object to the filters.
*
* @param req The WebScript request
* @param paramName The name of the parameter to look for
* @param filters Map of filters to add the date to
*/
protected void processDateFilter(WebScriptRequest req, String paramName, Map<String, Object> filters) {
// TODO: support other keywords i.e. today, tomorrow
String dateParam = req.getParameter(paramName);
if (dateParam != null) {
Object date = EMPTY;
if (!EMPTY.equals(dateParam) && !NULL.equals(dateParam)) {
date = getDateParameter(req, paramName);
}
filters.put(paramName, date);
}
}
19
View Source File : AbstractWorkflowWebscript.java
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
/**
* Retrieves the named parameter as an integer, if the parameter is not present the default value is returned
*
* @param req The WebScript request
* @param paramName The name of parameter to look for
* @param defaultValue The default value that should be returned if parameter is not present in request or if it is not positive
* @return The request parameter or default value
*/
protected int getIntParameter(WebScriptRequest req, String paramName, int defaultValue) {
String paramString = req.getParameter(paramName);
if (paramString != null) {
try {
int param = Integer.valueOf(paramString);
if (param > 0) {
return param;
}
} catch (NumberFormatException e) {
throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, e.getMessage());
}
}
return defaultValue;
}
19
View Source File : AbstractWorkflowWebscript.java
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {
WorkflowModelBuilder modelBuilder = new WorkflowModelBuilder(namespaceService, nodeService, authenticationService, personService, workflowService, dictionaryService);
return buildModel(modelBuilder, req, status, cache);
}
19
View Source File : TestCredentialsCommandProcessor.java
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
/* (non-Javadoc)
* @see org.alfresco.repo.web.scripts.transfer.CommandProcessor#process(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.WebScriptResponse)
*/
public int process(WebScriptRequest req, WebScriptResponse resp) {
// Since all the checks that are needed are actually carried out by the transfer web script, this processor
// effectively becomes a no-op.
int result = Status.STATUS_OK;
resp.setStatus(result);
return result;
}
19
View Source File : SubscriptionServiceUnfollowPost.java
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
public JSONObject executeImpl(String userId, WebScriptRequest req, WebScriptResponse res) throws IOException, ParseException {
JSONArray jsonUsers = (JSONArray) JSONValue.parseWithException(req.getContent().getContent());
for (Object o : jsonUsers) {
String user = (o == null ? null : o.toString());
if (user != null) {
subscriptionService.unfollow(userId, user);
}
}
return null;
}
19
View Source File : SubscriptionServiceFollowPost.java
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
public JSONObject executeImpl(String userId, WebScriptRequest req, WebScriptResponse res) throws IOException, ParseException {
JSONArray jsonUsers = (JSONArray) JSONValue.parseWithException(req.getContent().getContent());
for (Object o : jsonUsers) {
String user = (o == null ? null : o.toString());
if (user != null) {
subscriptionService.follow(userId, user);
}
}
return null;
}
19
View Source File : AlfrescoModelGet.java
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
public void execute(WebScriptRequest req, WebScriptResponse res) {
try {
handle(req, res);
} catch (IOException e) {
throw new WebScriptException("IO exception parsing request", e);
} catch (JSONException e) {
throw new WebScriptException("Invalid JSON", e);
}
}
19
View Source File : SiteAdminSitesGet.java
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
private int getIntParameter(WebScriptRequest req, String paramName, int defaultValue) {
String paramString = req.getParameter(paramName);
if (paramString != null) {
try {
int param = Integer.valueOf(paramString);
if (param >= 0) {
return param;
}
} catch (NumberFormatException e) {
throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, e.getMessage());
}
}
return defaultValue;
}
19
View Source File : AbstractLinksWebScript.java
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
/**
* Builds up a listing Paging request, based on the arguments
* specified in the URL
*/
protected PagingRequest buildPagingRequest(WebScriptRequest req) {
if (req.getParameter("page") == null || req.getParameter("pageSize") == null) {
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Paging size parameters missing");
}
return new ScriptPagingDetails(req, 100);
}
19
View Source File : SolrFacetConfigAdminGet.java
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
@Override
protected Map<String, Object> executeImpl(final WebScriptRequest req, final Status status, final Cache cache) {
// Allow all authenticated users view the filters
return unprotectedExecuteImpl(req, status, cache);
}
See More Examples