當前位置: 首頁>>代碼示例>>Java>>正文


Java ServiceException類代碼示例

本文整理匯總了Java中com.ibm.domino.services.ServiceException的典型用法代碼示例。如果您正苦於以下問題:Java ServiceException類的具體用法?Java ServiceException怎麽用?Java ServiceException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ServiceException類屬於com.ibm.domino.services包,在下文中一共展示了ServiceException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: evaluate

import com.ibm.domino.services.ServiceException; //導入依賴的package包/類
public Object evaluate(RestViewService service, RestViewEntry entry) throws ServiceException {
	// TODO: How can we cache the column name so we do not reevaluate it all the time?
	String columnName = getColumnName();
	if(StringUtil.isNotEmpty(columnName)) {
		return entry.getColumnValue(columnName);
	}
	String var = service.getParameters().getVar();
	if(StringUtil.isNotEmpty(var)) {
		// TODO: Do that on a per row basis only...
		Object old = service.getHttpRequest().getAttribute(var); 
		try {
			service.getHttpRequest().setAttribute(var,entry);
			return getValue();
		} finally {
			service.getHttpRequest().setAttribute(var,old);
		}
	} else {
		return getValue();
	}
}
 
開發者ID:OpenNTF,項目名稱:XPagesExtensionLibrary,代碼行數:21,代碼來源:DominoViewColumn.java

示例2: evaluate

import com.ibm.domino.services.ServiceException; //導入依賴的package包/類
public Object evaluate(RestDocumentService service, Document document) throws ServiceException {
	// TODO: How can we cache the item name so we do not reevaluate it all the time?
	String itemName = getItemName();
	try {
		if(StringUtil.isNotEmpty(itemName) && document.hasItem(itemName)) {
				return document.getItemValue(itemName);
		}
	} catch (NotesException e) {
		throw new ServiceException(e);
	}
	String var = service.getParameters().getVar();
	if(StringUtil.isNotEmpty(var)) {
		// TODO: Do that on a per item basis only...
		Object old = service.getHttpRequest().getAttribute(var); 
		try {
			service.getHttpRequest().setAttribute(var,document);
			return getValue();
		} finally {
			service.getHttpRequest().setAttribute(var,old);
		}
	} else {
		return getValue();
	}
}
 
開發者ID:OpenNTF,項目名稱:XPagesExtensionLibrary,代碼行數:25,代碼來源:DominoDocumentItem.java

示例3: writeEntry

import com.ibm.domino.services.ServiceException; //導入依賴的package包/類
protected void writeEntry(JsonWriter jwriter, String flags, String vname,
		String unid, DateTime lastModified) throws IOException, ServiceException {
	
	boolean folder = flags.indexOf( DESIGN_FLAG_FOLDER_VIEW ) >= 0;	
	boolean privateInDb = flags.indexOf( DESIGN_FLAG_PRIVATE_IN_DB ) >= 0;
	
	jwriter.startObject();
	
	try {
		writeProperty(jwriter, RestServiceConstants.ATTR_TITLE, vname);
		writeProperty(jwriter, ATTR_FOLDER, folder);
		writeProperty(jwriter, ATTR_PRIVATE, privateInDb);
		if (lastModified != null)
			writeDominoProperty(jwriter, RestServiceConstants.ATTR_MODIFIED,lastModified);
		writeProperty(jwriter, RestServiceConstants.ATTR_UNID, unid);
		String adddelim = (_uri.endsWith(RESOURCE_PATH_DELIM)) ? "" : RESOURCE_PATH_DELIM;
		String link = _uri + adddelim + VIEW_RESOURCE_PATH + unid;
		writeProperty(jwriter, RestServiceConstants.ATTR_HREF, link);
	} finally {
		jwriter.endObject();
	}		
}
 
開發者ID:OpenNTF,項目名稱:XPagesExtensionLibrary,代碼行數:23,代碼來源:JsonViewCollectionContent.java

示例4: getColumnValue

import com.ibm.domino.services.ServiceException; //導入依賴的package包/類
@Override
public Object getColumnValue(int index) throws ServiceException {
    try {
        if(index>=0) {
            if(columnValues==null) {
                columnValues = entry.getColumnValues();
            }
            ViewColumn c = columns.get(index);
            int idx = c.getColumnValuesIndex();
            if(idx!=DominoViewEntry.VC_NOT_PRESENT) {
                //Looks like the vector is smaller when the entry is a category                     
                if(idx<columnValues.size()) {
                    return columnValues.get(idx);
                }
            }
        }
        return null; // No values...
    } catch(NotesException ex) {
        throw new ServiceException(ex,""); // $NON-NLS-1$
    }
}
 
開發者ID:OpenNTF,項目名稱:XPagesExtensionLibrary,代碼行數:22,代碼來源:RestViewNavigatorFactory.java

示例5: renderServiceGet

import com.ibm.domino.services.ServiceException; //導入依賴的package包/類
private void renderServiceGet() throws ServiceException {
    try {
        DatabaseCollectionParameters parameters = getParameters();
        String contentType = "";
        if(StringUtil.isEmpty(contentType)) {
            contentType = HttpServiceConstants.CONTENTTYPE_APPLICATION_JSON;
        }
        getHttpResponse().setContentType(contentType);
        getHttpResponse().setCharacterEncoding(HttpServiceConstants.ENCODING_UTF8);
        
        Writer writer = new OutputStreamWriter(getOutputStream(),HttpServiceConstants.ENCODING_UTF8);
        boolean compact = parameters.isCompact();
        JsonWriter jwriter = new JsonWriter(writer,compact);
        
        JsonDatabaseCollectionContent content = factory.createDatabaseCollectionContent(this.defaultSession, "", RESOURCE_PATH); // $NON-NLS-1$
        content.writeDatabaseCollection(jwriter);

    } catch (UnsupportedEncodingException e) {
            throw new ServiceException(e,"");
    }
}
 
開發者ID:OpenNTF,項目名稱:XPagesExtensionLibrary,代碼行數:22,代碼來源:RestDatabaseCollectionJsonService.java

示例6: openDocument

import com.ibm.domino.services.ServiceException; //導入依賴的package包/類
@Override
public void openDocument(String id) throws ServiceException {
    checkNoDocument();
    try {
        // Should use both UNID and ID....
        this.doc = database.getDocumentByUNID(id);
        initDocument(doc);

        if( Loggers.SERVICES_LOGGER.isTraceDebugEnabled() ){
            Loggers.SERVICES_LOGGER.traceDebugp(this, "openDocument", // $NON-NLS-1$
                    "Document #{0} opened",id); // $NON-NLS-1$
        }
    } catch(NotesException ex) {
        throw new ServiceException(ex,"Error while loading document with id {0}",id);  // $NLX-RestDocumentNavigatorFactory.Errorwhilecreatingaloadingdocumen-1$
    }
}
 
開發者ID:OpenNTF,項目名稱:XPagesExtensionLibrary,代碼行數:17,代碼來源:RestDocumentNavigatorFactory.java

示例7: updateDocument

import com.ibm.domino.services.ServiceException; //導入依賴的package包/類
protected void updateDocument(RestViewNavigator viewNav, RestDocumentNavigator docNav, String id, JsonJavaObject items) throws ServiceException, JsonException, IOException {
    if(!queryOpenDocument(id)) {
        throw new ServiceException(null, msgErrorUpdatingData());
    }
    docNav.openDocument(id);
    Document doc = docNav.getDocument();
    postOpenDocument(doc);
    try {
        updateFields(viewNav, docNav, items);
        if (getParameters().isComputeWithForm()) {
            docNav.computeWithForm();
        }           
        if(!querySaveDocument(doc)) {
            throw new ServiceException(null, msgErrorUpdatingData());
        }
        docNav.save();
        postSaveDocument(doc);
    } finally {
        docNav.recycle();
    }
}
 
開發者ID:OpenNTF,項目名稱:XPagesExtensionLibrary,代碼行數:22,代碼來源:RestViewItemFileService.java

示例8: first

import com.ibm.domino.services.ServiceException; //導入依賴的package包/類
@Override
public boolean first(int start, int count) throws ServiceException {
    if (bFirst)
        return bFirst;
    try {
        navigator = createNavigator();
        int maxLevels = getParameters().getExpandLevel();
        if(maxLevels!=Integer.MAX_VALUE) {
            navigator.setMaxLevel(maxLevels);
        }
        if(!navigator.gotoFirst()) {
            return false;
        }
        navigator.setBufferMaxEntries(count);
        if(start>0) {
            int skipped = navigator.skip(start);
            if(skipped<start) {
                return false;
            }
        }
        bFirst = initEntry(navigator.getCurrent());
        return bFirst;
    } catch(NotesException ex) {
        throw new ServiceException(ex,""); // $NON-NLS-1$
    }
}
 
開發者ID:OpenNTF,項目名稱:XPagesExtensionLibrary,代碼行數:27,代碼來源:RestViewNavigatorFactory.java

示例9: deleteDocument

import com.ibm.domino.services.ServiceException; //導入依賴的package包/類
@Override
public void deleteDocument(String id) throws ServiceException {
    checkNoDocument();
    try {
        // Should use both UNID and ID....
        Document ddoc = database.getDocumentByUNID(id);
        if(ddoc!=null) {
            try { 
                ddoc.remove(true);
                
                if( Loggers.SERVICES_LOGGER.isTraceDebugEnabled() ){
                    Loggers.SERVICES_LOGGER.traceDebugp(this, "deleteDocument", // $NON-NLS-1$
                            "Document #{0} deleted",id); // $NON-NLS-1$
                }
            } finally {
                ddoc.recycle();
            }
        } else {
            throw new ServiceException(null,"The document with id {0} cannot be found",id);  // $NLX-RestDocumentNavigatorFactory.Errorwhilecreatingaloadingdocumen.1-1$
        }
    } catch(NotesException ex) {
        throw new ServiceException(ex,"An error occurred while deleting document with id {0}",id);  // $NLX-RestDocumentNavigatorFactory.Errorwhilecreatingadeletingdocume-1$
    }
}
 
開發者ID:OpenNTF,項目名稱:XPagesExtensionLibrary,代碼行數:25,代碼來源:RestDocumentNavigatorFactory.java

示例10: renderService

import com.ibm.domino.services.ServiceException; //導入依賴的package包/類
@Override
public void renderService() throws ServiceException {
    String method = getHttpRequest().getMethod();
    if (HTTP_GET.equalsIgnoreCase(method)) {
        renderServiceJSONGet();
    } else if (HTTP_POST.equalsIgnoreCase(method)) {
        String override = getHttpRequest().getHeader(HEADER_X_HTTP_METHOD_OVERRIDE);
        if (HTTP_PUT.equalsIgnoreCase(override)) {
            renderServiceJSONUpdate(PUT);
        } else if (HTTP_DELETE.equalsIgnoreCase(override)) {
            renderServiceJSONUpdate(DELETE);
        } else {
            renderServiceJSONUpdate(POST);
        }
    } else if (HTTP_PUT.equalsIgnoreCase(method)) {
        renderServiceJSONUpdate(PUT);
    } else if (HTTP_DELETE.equalsIgnoreCase(method)) {
        renderServiceJSONUpdate(DELETE);
    } else {
        throw new ServiceException(null, ResponseCode.METHOD_NOT_ALLOWED, "Method {0} is not allowed with JSON Rest Service", method); // $NLX-RestViewJsonService.Method0isnotallowedwithJSONRestSe-1$
    }
}
 
開發者ID:OpenNTF,項目名稱:XPagesExtensionLibrary,代碼行數:23,代碼來源:RestViewJsonService.java

示例11: renderService

import com.ibm.domino.services.ServiceException; //導入依賴的package包/類
@Override
public void renderService() throws ServiceException {
    String method = getHttpRequest().getMethod();
    if (Method.isMethod(Method.GET, method )) {
        renderServiceJSONGet();
    } else if (Method.isMethod(Method.POST, method)) {
        String override = getHttpRequest().getHeader(HEADER_X_HTTP_METHOD_OVERRIDE);
        if (Method.isMethod(Method.PUT, override)) {
            renderServiceJSONUpdate(Method.PUT);
        } else if (Method.isMethod(Method.DELETE, override)) {
            renderServiceJSONUpdate(Method.DELETE);
        } else if (Method.isMethod(Method.PATCH, override)) {
            renderServiceJSONUpdate(Method.PATCH);
        }else {
            renderServiceJSONUpdate(Method.POST);
        }
    } else if (Method.isMethod(Method.PUT, method)) {
        renderServiceJSONUpdate(Method.PUT);
    } else if (Method.isMethod(Method.PATCH, method)) {
        renderServiceJSONUpdate(Method.PATCH);
    } else if (HTTP_DELETE.equalsIgnoreCase(method)) {
        renderServiceJSONUpdate(Method.DELETE);
    } else {
        throw new ServiceException(null, ResponseCode.METHOD_NOT_ALLOWED, "Method {0} is not allowed with JSON Rest Service", method); // $NLX-RestDocumentJsonService.Method0isnotallowedwithJSONRestSe-1$
    }
}
 
開發者ID:OpenNTF,項目名稱:XPagesExtensionLibrary,代碼行數:27,代碼來源:RestDocumentJsonService.java

示例12: renderService

import com.ibm.domino.services.ServiceException; //導入依賴的package包/類
@Override
public void renderService() throws ServiceException {
    if ("GET".equalsIgnoreCase(getHttpRequest().getMethod())) { // $NON-NLS-1$
        renderServiceJSONGet();
        // Use a different status for an error?
        //HttpServletResponse.SC_METHOD_NOT_ALLOWED;
        throw new ServiceException(null,"Method {0} is not allowed with JSON Rest Service",getHttpRequest().getMethod()); // $NLX-RestTreeItemService.Method0isnotallowedwithJSONRestSe-1$
    }
}
 
開發者ID:OpenNTF,項目名稱:XPagesExtensionLibrary,代碼行數:10,代碼來源:RestTreeItemService.java

示例13: writeEntryAsJson

import com.ibm.domino.services.ServiceException; //導入依賴的package包/類
protected void writeEntryAsJson(JsonWriter g, IPickerEntry e) throws IOException, ServiceException {
    g.startObject();

    // Write the value
    Object value = e.getValue();
    g.startProperty("@value"); // $NON-NLS-1$
    outLiteralValue(g,value);
    g.endProperty();

    // Write the Label
    Object label = e.getLabel();
    if(label!=null) {
        g.startProperty("@label"); // $NON-NLS-1$
        outLiteralValue(g,label);
        g.endProperty();
    }
    
    // Then add the different attributes
    int ac = e.getAttributeCount();
    for(int i=0; i<ac; i++) {
        String name = e.getAttributeName(i);
        Object val = e.getAttributeValue(i);
        g.startProperty(name);
        outLiteralValue(g,val);
        g.endProperty();
    }
    
    g.endObject();
}
 
開發者ID:OpenNTF,項目名稱:XPagesExtensionLibrary,代碼行數:30,代碼來源:RestValuePickerService.java

示例14: findMethod

import com.ibm.domino.services.ServiceException; //導入依賴的package包/類
@Override
protected RpcMethod findMethod(String methodName) throws ServiceException {
	// NTF changed this so it calls the outer classes getter, so it can be overridden
	if (getMethods() != null) {
		for (int i = 0; i < getMethods().size(); i++) {
			RpcMethod m = getMethods().get(i);
			if (StringUtil.equals(methodName, m.getName())) {
				return m;
			}
		}
	}
	return null;
}
 
開發者ID:OpenNTF,項目名稱:XPagesExtensionLibrary,代碼行數:14,代碼來源:UIJsonRpcService.java

示例15: createFactory

import com.ibm.domino.services.ServiceException; //導入依賴的package包/類
private static ServiceFactory createFactory() {
	DefaultServiceFactory factory = new DefaultServiceFactory();
	
	// All Contacts View
	final List<RestViewColumn> allContactsColumns = Arrays.asList( (RestViewColumn)
			new DefaultViewColumn("ComputedColumn") {
				@Override
				public Object evaluate(RestViewService service, RestViewEntry entry) throws ServiceException {
					String v = entry.getColumnValue("EMail").toString();
					return v.toUpperCase();
				}
			}
		);
	factory.addFactory("AllContacts", new ServiceFactory() {
		public ServiceEngine createEngine(HttpServletRequest httpRequest, HttpServletResponse httpResponse) throws ServletException {
			DefaultViewParameters p = new DefaultViewParameters();
			p.setViewName("AllContacts");
			p.setGlobalValues(DefaultViewParameters.GLOBAL_ALL);
			p.setSystemColumns(DefaultViewParameters.SYSCOL_ALL);
			p.setDefaultColumns(true);
			p.setColumns(allContactsColumns);
			// Set the default parameters
			p.setStart(0);
			p.setCount(4);
			return new RestViewXmlLegacyService(httpRequest,httpResponse,p);
		}
	});
	
	return factory;
}
 
開發者ID:OpenNTF,項目名稱:XPagesExtensionLibrary,代碼行數:31,代碼來源:ServletFactory.java


注:本文中的com.ibm.domino.services.ServiceException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。