use of org.alfresco.error.AlfrescoRuntimeException in project alfresco-remote-api by Alfresco.
the class SearchMapper method fromScope.
/**
* SearchParameters from Scope object
* @param Scope scope
* @param sp SearchParameters
* @param searchRequestContext
*/
public void fromScope(SearchParameters sp, Scope scope, SearchRequestContext searchRequestContext) {
if (scope != null) {
List<String> stores = scope.getLocations();
if (stores != null && !stores.isEmpty()) {
// First reset the stores then add them.
sp.getStores().clear();
searchRequestContext.getStores().addAll(stores);
for (String aStore : stores) {
try {
sp.addStore(storeMapper.getStoreRef(aStore));
} catch (AlfrescoRuntimeException are) {
throw new InvalidArgumentException(InvalidArgumentException.DEFAULT_MESSAGE_ID, new Object[] { aStore });
}
}
if (stores.contains(StoreMapper.HISTORY) && (stores.size() > 1)) {
throw new InvalidArgumentException(InvalidArgumentException.DEFAULT_MESSAGE_ID, new Object[] { ": scope 'history' can only be used on its own" });
}
}
}
}
use of org.alfresco.error.AlfrescoRuntimeException in project alfresco-remote-api by Alfresco.
the class SOLRAuthenticationFilter method doFilter.
public void doFilter(ServletContext context, ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
HttpServletRequest httpRequest = (HttpServletRequest) request;
HttpServletResponse httpResponse = (HttpServletResponse) response;
/* if(secureComms == SecureCommsType.ALFRESCO)
{
// Need to get as a byte array because we need to read the request twice, once for authentication
// and again by the web service.
SOLRHttpServletRequestWrapper requestWrapper = new SOLRHttpServletRequestWrapper(httpRequest, encryptionUtils);
if(logger.isDebugEnabled())
{
logger.debug("Authenticating " + httpRequest.getRequestURI());
}
if(encryptionUtils.authenticate(httpRequest, requestWrapper.getDecryptedBody()))
{
try
{
OutputStream out = response.getOutputStream();
GenericResponseWrapper responseWrapper = new GenericResponseWrapper(httpResponse);
// TODO - do I need to chain to other authenticating filters - probably not?
// Could also remove sending of credentials with http request
chain.doFilter(requestWrapper, responseWrapper);
Pair<byte[], AlgorithmParameters> pair = encryptor.encrypt(KeyProvider.ALIAS_SOLR, null, responseWrapper.getData());
encryptionUtils.setResponseAuthentication(httpRequest, httpResponse, responseWrapper.getData(), pair.getSecond());
httpResponse.setHeader("Content-Length", Long.toString(pair.getFirst().length));
out.write(pair.getFirst());
out.close();
}
catch(Exception e)
{
throw new AlfrescoRuntimeException("", e);
}
}
else
{
httpResponse.setStatus(401);
}
}
else */
if (secureComms == SecureCommsType.HTTPS) {
if (httpRequest.isSecure()) {
// https authentication
chain.doFilter(request, response);
} else {
throw new AlfrescoRuntimeException("Expected a https request");
}
} else {
chain.doFilter(request, response);
}
}
use of org.alfresco.error.AlfrescoRuntimeException in project alfresco-remote-api by Alfresco.
the class PropFindMethod method generateFindPropertiesResponse.
/**
* Generates the XML response for a PROPFIND request that asks for a list of
* all known properties
*
* @param xml XMLWriter
* @param nodeInfo FileInfo
* @param isDir boolean
*/
protected void generateFindPropertiesResponse(XMLWriter xml, FileInfo nodeInfo, boolean isDir) {
try {
// Output the start of the properties element
Attributes nullAttr = getDAVHelper().getNullAttributes();
xml.startElement(WebDAV.DAV_NS, WebDAV.XML_PROPSTAT, WebDAV.XML_NS_PROPSTAT, nullAttr);
xml.startElement(WebDAV.DAV_NS, WebDAV.XML_PROP, WebDAV.XML_NS_PROP, nullAttr);
// Output the well-known properties
xml.write(DocumentHelper.createElement(WebDAV.XML_NS_LOCK_DISCOVERY));
xml.write(DocumentHelper.createElement(WebDAV.XML_NS_SUPPORTED_LOCK));
xml.write(DocumentHelper.createElement(WebDAV.XML_NS_RESOURCE_TYPE));
xml.write(DocumentHelper.createElement(WebDAV.XML_NS_DISPLAYNAME));
xml.write(DocumentHelper.createElement(WebDAV.XML_NS_GET_LAST_MODIFIED));
xml.write(DocumentHelper.createElement(WebDAV.XML_NS_GET_CONTENT_LENGTH));
xml.write(DocumentHelper.createElement(WebDAV.XML_NS_CREATION_DATE));
xml.write(DocumentHelper.createElement(WebDAV.XML_NS_GET_ETAG));
if (isDir) {
xml.write(DocumentHelper.createElement(WebDAV.XML_NS_GET_CONTENT_LANGUAGE));
xml.write(DocumentHelper.createElement(WebDAV.XML_NS_GET_CONTENT_TYPE));
}
// Output the custom properties
xml.write(DocumentHelper.createElement(WebDAV.XML_NS_ALF_AUTHTICKET));
// Close off the response
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_PROP, WebDAV.XML_NS_PROP);
xml.startElement(WebDAV.DAV_NS, WebDAV.XML_STATUS, WebDAV.XML_NS_STATUS, nullAttr);
xml.write(WebDAV.HTTP1_1 + " " + HttpServletResponse.SC_OK + " " + WebDAV.SC_OK_DESC);
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_STATUS, WebDAV.XML_NS_STATUS);
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_PROPSTAT, WebDAV.XML_NS_PROPSTAT);
} catch (Exception ex) {
throw new AlfrescoRuntimeException("XML processing error", ex);
}
}
use of org.alfresco.error.AlfrescoRuntimeException in project alfresco-remote-api by Alfresco.
the class PropPatchMethod method generatePropertyResponse.
/**
* Generates the XML response for a PROPFIND request that asks for a list of
* all known properties
*
* @param xml XMLWriter
* @param property WebDAVProperty
* @param status int
* @param description String
*/
protected void generatePropertyResponse(XMLWriter xml, WebDAVProperty property, int status, String description) {
try {
// Output the start of the properties element
Attributes nullAttr = getDAVHelper().getNullAttributes();
xml.startElement(WebDAV.DAV_NS, WebDAV.XML_PROPSTAT, WebDAV.XML_NS_PROPSTAT, nullAttr);
// Output property name
xml.startElement(WebDAV.DAV_NS, WebDAV.XML_PROP, WebDAV.XML_NS_PROP, nullAttr);
if (property.hasNamespaceName()) {
xml.write(DocumentHelper.createElement(property.getNamespaceName() + WebDAV.NAMESPACE_SEPARATOR + property.getName()));
} else {
xml.write(DocumentHelper.createElement(property.getName()));
}
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_PROP, WebDAV.XML_NS_PROP);
// Output action result status
xml.startElement(WebDAV.DAV_NS, WebDAV.XML_STATUS, WebDAV.XML_NS_STATUS, nullAttr);
xml.write(WebDAV.HTTP1_1 + " " + status + " " + description);
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_STATUS, WebDAV.XML_NS_STATUS);
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_PROPSTAT, WebDAV.XML_NS_PROPSTAT);
} catch (Exception ex) {
// Convert to a runtime exception
throw new AlfrescoRuntimeException("XML processing error", ex);
}
}
use of org.alfresco.error.AlfrescoRuntimeException in project alfresco-remote-api by Alfresco.
the class SiteMembershipRequestsImpl method getSiteInvitation.
private Invitation getSiteInvitation(String inviteeId, String siteId) {
// Is there an outstanding site invite request for the invitee?
InvitationSearchCriteriaImpl criteria = new InvitationSearchCriteriaImpl();
criteria.setInvitationType(InvitationType.MODERATED);
criteria.setInvitee(inviteeId);
criteria.setResourceName(siteId);
criteria.setResourceType(ResourceType.WEB_SITE);
List<Invitation> invitations = invitationService.searchInvitation(criteria);
if (invitations.size() > 1) {
// TODO exception
throw new AlfrescoRuntimeException("There should be only one outstanding site invitation");
}
return (invitations.size() == 0 ? null : invitations.get(0));
}
Aggregations