本文整理汇总了Java中org.springframework.extensions.webscripts.connector.Connector类的典型用法代码示例。如果您正苦于以下问题:Java Connector类的具体用法?Java Connector怎么用?Java Connector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Connector类属于org.springframework.extensions.webscripts.connector包,在下文中一共展示了Connector类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: remoteCall
import org.springframework.extensions.webscripts.connector.Connector; //导入依赖的package包/类
private void remoteCall(HttpServletRequest request, JSONObject auditSample) throws JSONException, URIException,
UnsupportedEncodingException {
Connector connector;
try {
connector = FrameworkUtil.getConnector(request.getSession(true), auditSample.getString(AUDIT_USER_ID),
AlfrescoUserFactory.ALFRESCO_ENDPOINT_ID);
ConnectorContext postContext = new ConnectorContext(null, buildDefaultHeaders());
postContext.setMethod(HttpMethod.POST);
postContext.setContentType("text/plain;charset=UTF-8");
InputStream in = new ByteArrayInputStream(auditSample.toString().getBytes("UTF-8"));
// Webscript call
connector.call("/share-stats/insert-audit", postContext, in);
} catch (ConnectorServiceException e) {
if (logger.isDebugEnabled()) {
logger.debug(e.getMessage(), e);
}
}
}
开发者ID:atolcd,项目名称:alfresco-audit-share,代码行数:22,代码来源:ProxyAuditFilter.java
示例2: remoteCall
import org.springframework.extensions.webscripts.connector.Connector; //导入依赖的package包/类
private void remoteCall(HttpServletRequest request, JSONObject auditSample) throws JSONException, URIException,
UnsupportedEncodingException {
Connector connector;
try {
connector = FrameworkUtil.getConnector(request.getSession(true), auditSample.getString(AUDIT_USER_ID),
AlfrescoUserFactory.ALFRESCO_ENDPOINT_ID);
// if (parameters == null), we use the 'inputstream'
// The webscript is called with the audit converted into JSON.
ConnectorContext postContext = new ConnectorContext(null, buildDefaultHeaders());
postContext.setMethod(HttpMethod.POST);
postContext.setContentType("text/plain;charset=UTF-8");
InputStream in = new ByteArrayInputStream(auditSample.toString().getBytes("UTF-8"));
// Webscript call
connector.call("/share-stats/insert-audit", postContext, in);
} catch (ConnectorServiceException e) {
if (logger.isDebugEnabled()) {
logger.debug(e.getMessage(), e);
}
}
}
开发者ID:atolcd,项目名称:alfresco-audit-share,代码行数:22,代码来源:AuditFilter.java
示例3: retrieveFormDefinition
import org.springframework.extensions.webscripts.connector.Connector; //导入依赖的package包/类
/**
* Retrieves the form definition from the repository FormService for the
* given item.
*
* @param itemKind The form item kind
* @param itemId The form item id
* @param visibleFields The list of field names to return or null
* to return all fields
* @param formConfig The form configuration
* @return Response object from the remote call
*/
protected Response retrieveFormDefinition(String itemKind, String itemId,
List<String> visibleFields, FormConfigElement formConfig)
{
Response response = null;
try
{
// setup the connection
ConnectorService connService = FrameworkUtil.getConnectorService();
RequestContext requestContext = ThreadLocalRequestContext.getRequestContext();
String currentUserId = requestContext.getUserId();
HttpSession currentSession = ServletUtil.getSession(true);
Connector connector = connService.getConnector(ENDPOINT_ID, currentUserId, currentSession);
ConnectorContext context = new ConnectorContext(HttpMethod.POST, null, buildDefaultHeaders());
context.setContentType("application/json");
// call the form service
response = connector.call("/api/formdefinitions", context, generateFormDefPostBody(itemKind,
itemId, visibleFields, formConfig));
if (logger.isDebugEnabled())
logger.debug("Response status: " + response.getStatus().getCode());
}
catch (Exception e)
{
if (logger.isErrorEnabled())
logger.error("Failed to get form definition: ", e);
}
return response;
}
开发者ID:ecm4u,项目名称:ecm4u-alfresco-bugpatches,代码行数:43,代码来源:FormUIGet.java
示例4: processFieldContent
import org.springframework.extensions.webscripts.connector.Connector; //导入依赖的package包/类
/**
* Processes the field for content. This method is used when a content field
* is being used in a form where JavaScript is disabled and thus AJAX is
* unavailable to retrieve the content, it must therefore be done server side.
*
* @param context The context
* @param field The field to be processed
* @param fieldDefinition The definition of the field to be processed
* @param fieldConfig The configuration of the field to be processed
* @throws JSONException
*/
protected void processFieldContent(ModelContext context, Field field,
JSONObject fieldDefinition, FormField fieldConfig) throws JSONException
{
// if the field is a content field and JavaScript is disabled
// we need to retrieve the content here and store in model
if (context.getFormUIModel().get(MODEL_CAPABILITIES) != null && "content".equals(field.getDataType()))
{
// NOTE: In the future when other capabilties are added the 'javascript'
// flag will need to be checked, for now it's the only reason
// the capabilities object will be present so a check is redundant
if (logger.isDebugEnabled())
logger.debug("Retrieving content for \"" + field.getConfigName() + "\" as JavaScript is disabled");
// get the nodeRef of the content and then the content itself
String nodeRef = getParameter(context.getRequest(), "itemId");
try
{
ConnectorService connService = FrameworkUtil.getConnectorService();
RequestContext requestContext = ThreadLocalRequestContext.getRequestContext();
String currentUserId = requestContext.getUserId();
HttpSession currentSession = ServletUtil.getSession(true);
Connector connector = connService.getConnector(ENDPOINT_ID, currentUserId, currentSession);
// call the form service
Response response = connector.call("/api/node/content/" + nodeRef.replace("://", "/"));
if (response.getStatus().getCode() == Status.STATUS_OK)
{
field.setContent(response.getText());
}
}
catch (Exception e)
{
if (logger.isErrorEnabled())
logger.error("Failed to get field content: ", e);
}
}
}
开发者ID:ecm4u,项目名称:ecm4u-alfresco-bugpatches,代码行数:51,代码来源:FormUIGet.java
示例5: isTicketValid
import org.springframework.extensions.webscripts.connector.Connector; //导入依赖的package包/类
private boolean isTicketValid(ConnectorSession connectorSession, String ticket) {
if (StringUtils.isBlank(ticket)) {
return false;
}
if (StringUtils.isNotBlank(connectorSession.getParameter("ALWAYS_VALID"))) {
return true;
}
try {
Connector connector = FrameworkUtil.getConnector("alfresco");
ConnectorSession fakeSession = clone(connectorSession);
fakeSession.setParameter(CS_PARAM_ALF_TICKET, ticket);
fakeSession.setParameter("ALWAYS_VALID", "true");
connector.setConnectorSession(fakeSession);
Map<String, String> parameters = new HashMap<String, String>();
parameters.put("alf_ticket", ticket);
Map<String, String> headers = Collections.emptyMap();
ConnectorContext context = new ConnectorContext(parameters, headers);
Response response = connector.call("/api/metadata", context);
return response.getStatus().getCode() == Status.STATUS_OK;
} catch (Exception ex) {
return false;
}
}
开发者ID:Redpill-Linpro,项目名称:share-ticket-login,代码行数:32,代码来源:AlfrescoTicketAuthenticator.java
示例6: evaluate
import org.springframework.extensions.webscripts.connector.Connector; //导入依赖的package包/类
@Override
public boolean evaluate(JSONObject jsonObject) {
try
{
String username = getUserId();
JSONObject modifier =(JSONObject) getProperty(jsonObject,"cm:modifier");
if (username.equalsIgnoreCase((String)modifier.get("userName")))
{
return true;
}
String siteName = getSiteId(jsonObject);
if (siteName == null)
{
// It's not a site, so we have no opinion on access
return true;
}
// Fetch the membership information for the site
RequestContext rc = ThreadLocalRequestContext.getRequestContext();
Connector conn = rc.getServiceRegistry().getConnectorService().getConnector(
"alfresco", username, ServletUtil.getSession());
Response response = conn.call("/api/sites/"+siteName+"/memberships/"+username);
if (response.getStatus().getCode() == Status.STATUS_OK)
{
// Convert the response text to jsonobject
JSONObject responsetext = (JSONObject)new JSONParser().parse(response.getResponse());
// Get the user role and compare with required role
return requiredRole.equalsIgnoreCase(this.getUserRole(responsetext));
}
else if (response.getStatus().getCode() == Status.STATUS_NOT_FOUND)
{
// Not a member of the site / site not found / etc
// Shouldn't be showing in this case
return false;
}
else
{
logger.warn("Invalid response fetching memberships for " + username + " in " + siteName + " - " + response);
return false;
}
}
catch (Exception err)
{
throw new AlfrescoRuntimeException("Failed to run UI evaluator: " + err.getMessage());
}
}
开发者ID:muralidharand,项目名称:alfresco-disable-enable-download-action,代码行数:54,代码来源:DownloadActionEvaluator.java
示例7: getProbeSettings
import org.springframework.extensions.webscripts.connector.Connector; //导入依赖的package包/类
@Override
protected Settings getProbeSettings(final WebScriptRequest req) {
try {
Pair<String, String> parseRequestedTransformation = parseRequestedTransformation(req);
final RequestContext requestContext = ThreadLocalRequestContext.getRequestContext();
final ConnectorService connService = requestContext.getServiceRegistry().getConnectorService();
final String currentUserId = requestContext.getUserId();
final HttpSession currentSession = ServletUtil.getSession(true);
final Connector connector = connService.getConnector(ENDPOINT_ID, currentUserId, currentSession);
final String alfrescoURL = "/org/redpill/alfresco/clusterprobe/probe/transform/" + parseRequestedTransformation.getFirst() + "/" + parseRequestedTransformation.getSecond();
final Response response = connector.call(alfrescoURL);
return new Settings(response.getResponse(), response.getStatus().getCode());
} catch (final Exception ex) {
LOG.error(ex.getMessage(), ex);
final StringBuilder sb = new StringBuilder();
StackTraceUtil.buildStackTrace(ex.getMessage(), ex.getStackTrace(), sb, 0);
return new Settings("Couldn't get settings from repo server.\n" + sb.toString(), 500);
}
}
开发者ID:Redpill-Linpro,项目名称:alfresco-cluster-probe,代码行数:29,代码来源:ProbeTransform.java
示例8: getProbeSettings
import org.springframework.extensions.webscripts.connector.Connector; //导入依赖的package包/类
@Override
protected Settings getProbeSettings(final WebScriptRequest req) {
try {
final RequestContext requestContext = ThreadLocalRequestContext.getRequestContext();
final ConnectorService connService = requestContext.getServiceRegistry().getConnectorService();
final String currentUserId = requestContext.getUserId();
final HttpSession currentSession = ServletUtil.getSession(true);
final Connector connector = connService.getConnector(ENDPOINT_ID, currentUserId, currentSession);
final String alfrescoURL = "/org/redpill/alfresco/clusterprobe/probe/search";
final Response response = connector.call(alfrescoURL);
return new Settings(response.getResponse(), response.getStatus().getCode());
} catch (final Exception ex) {
LOG.error(ex.getMessage(), ex);
final StringBuilder sb = new StringBuilder();
StackTraceUtil.buildStackTrace(ex.getMessage(), ex.getStackTrace(), sb, 0);
return new Settings("Couldn't get settings from repo server.\n" + sb.toString(), 500);
}
}
开发者ID:Redpill-Linpro,项目名称:alfresco-cluster-probe,代码行数:29,代码来源:ProbeSearch.java
示例9: getProbeSettings
import org.springframework.extensions.webscripts.connector.Connector; //导入依赖的package包/类
@Override
protected Settings getProbeSettings(final WebScriptRequest req) {
try {
final String server = getServer();
final RequestContext requestContext = ThreadLocalRequestContext.getRequestContext();
final ConnectorService connService = requestContext.getServiceRegistry().getConnectorService();
final String currentUserId = requestContext.getUserId();
final HttpSession currentSession = ServletUtil.getSession(true);
final Connector connector = connService.getConnector(ENDPOINT_ID, currentUserId, currentSession);
final String alfrescoURL = "/org/redpill/alfresco/clusterprobe/settings?server=" + server;
final Response response = connector.call(alfrescoURL);
final String jsonResponse = response.getResponse();
final JSONObject json = new JSONObject(new JSONTokener(jsonResponse));
return new Settings(json.getString("text"), json.getInt("code"));
} catch (final Exception ex) {
LOG.error(ex.getMessage(), ex);
final StringBuilder sb = new StringBuilder();
StackTraceUtil.buildStackTrace(ex.getMessage(), ex.getStackTrace(), sb, 0);
return new Settings("Couldn't get settings from repo server.\n" + sb.toString(), 500);
}
}
开发者ID:Redpill-Linpro,项目名称:alfresco-cluster-probe,代码行数:34,代码来源:ProbeGet.java
示例10: getProbeSettings
import org.springframework.extensions.webscripts.connector.Connector; //导入依赖的package包/类
@Override
protected Settings getProbeSettings(final WebScriptRequest req) {
try {
final RequestContext requestContext = ThreadLocalRequestContext.getRequestContext();
final ConnectorService connService = requestContext.getServiceRegistry().getConnectorService();
final String currentUserId = requestContext.getUserId();
final HttpSession currentSession = ServletUtil.getSession(true);
final Connector connector = connService.getConnector(ENDPOINT_ID, currentUserId, currentSession);
final String alfrescoURL = "/org/redpill/alfresco/clusterprobe/probe";
final Response response = connector.call(alfrescoURL);
return new Settings(response.getResponse(), response.getStatus().getCode());
} catch (final Exception ex) {
LOG.error(ex.getMessage(), ex);
final StringBuilder sb = new StringBuilder();
StackTraceUtil.buildStackTrace(ex.getMessage(), ex.getStackTrace(), sb, 0);
return new Settings("Couldn't get settings from repo server.\n" + sb.toString(), 500);
}
}
开发者ID:Redpill-Linpro,项目名称:alfresco-cluster-probe,代码行数:29,代码来源:ProbeRepoGet.java
注:本文中的org.springframework.extensions.webscripts.connector.Connector类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论