public static void main(String[] args) { ObjGenApp app = new ObjGenApp(); try { app.processCmdLine(args); } catch (CmisBaseException ce) { System.out.println("Error: Could not process command. " + ce); System.out.println("Extended error: " + ce.getErrorContent()); ce.printStackTrace(); } catch (Exception e) { System.out.println("Could not fill repository " + e); e.printStackTrace(); } }
} else if (ex instanceof CmisBaseException) { statusCode = getErrorCode((CmisBaseException) ex); exceptionName = ((CmisBaseException) ex).getExceptionName(); Map<String, String> additionalData = ((CmisBaseException) ex).getAdditionalData(); if (additionalData != null && !additionalData.isEmpty()) { for (Map.Entry<String, String> e : additionalData.entrySet()) {
fault.setCode(((CmisBaseException) ex).getCode()); fault.setMessage(ex.getMessage()); Map<String, String> additionalData = ((CmisBaseException) ex).getAdditionalData(); if (additionalData != null && !additionalData.isEmpty()) { try {
private void testTrailingSpace(Session session, Folder testFolder) { String name = "trailing.txt"; try { Document doc = createDocumentWithoutChecks(testFolder, name + " "); if (doc.getName().equals(name + " ")) { addResult(createInfoResult("Repository does supports document names with a trailing space.")); } else { if (doc.getName().equals(name)) { addResult(createInfoResult("Repository removes trailing space from document name.")); } else { addResult(createInfoResult("Repository renames documents with a trailing space.")); } } } catch (CmisBaseException e) { addResult(createInfoResult("Repository does not support document names with a trailing space. Exception: " + e.toString())); } }
if (cbe.getErrorContent() != null) { writer.write("<br/>\n<b>Error content:</b><br/><br/><pre>\n"); writer.write(escape(cbe.getErrorContent()) + "</pre>\n");
/** * Creates a test folder. */ protected Folder createTestFolder(Session session) { String testFolderParentPath = getParameters().get(TestParameters.DEFAULT_TEST_FOLDER_PARENT); if (testFolderParentPath == null) { testFolderParentPath = TestParameters.DEFAULT_TEST_FOLDER_PARENT_VALUE; } String name = "cmistck" + System.currentTimeMillis() + session.getRepositoryInfo().hashCode(); Folder parent = null; try { CmisObject parentObject = session.getObjectByPath(testFolderParentPath, SELECT_ALL_NO_CACHE_OC); if (!(parentObject instanceof Folder)) { addResult(createResult(FAILURE, "Parent folder of the test folder is actually not a folder! Path: " + testFolderParentPath, true)); } parent = (Folder) parentObject; } catch (CmisBaseException e) { addResult(createResult(UNEXPECTED_EXCEPTION, "Test folder could not be created! Exception: " + e.getMessage(), e, true)); } if (parent != null) { testFolder = createFolder(session, parent, name); } return testFolder; }
@Override public ErrorInfo extractError(Exception ex) { int statusCode = SC_INTERNAL_SERVER_ERROR; // 500 String exceptionName = "runtime"; if (ex instanceof CmisRuntimeException) { Throwable cause = ex.getCause(); if (cause instanceof RecoverableClientException) { // don't log something harsh in that case statusCode = getHttpStatus((RecoverableClientException) cause); } else { LOG.error(ex.getMessage(), ex); } } else if (ex instanceof CmisStorageException) { LOG.error(ex.getMessage(), ex); statusCode = getErrorCode((CmisStorageException) ex); exceptionName = ((CmisStorageException) ex).getExceptionName(); } else if (ex instanceof CmisBaseException) { statusCode = getErrorCode((CmisBaseException) ex); exceptionName = ((CmisBaseException) ex).getExceptionName(); } else if (ex instanceof IOException) { LOG.warn(ex.getMessage(), ex); } else { LOG.error(ex.getMessage(), ex); } String message = ex.getMessage(); if (!(ex instanceof CmisBaseException)) { message = "An error occurred!"; } return new ErrorInfo(statusCode, exceptionName, message); }
Map<String, String> additionalData = ((CmisBaseException) t).getAdditionalData(); if (additionalData != null && !additionalData.isEmpty()) { pw.print("<hr noshade='noshade'/>Additional data:<br><br>");
private void testLeadingSpace(Session session, Folder testFolder) { String name = "leading.txt"; try { Document doc = createDocumentWithoutChecks(testFolder, " " + name); if (doc.getName().equals(" " + name)) { addResult(createInfoResult("Repository does supports document names with a leading space.")); } else { if (doc.getName().equals(name)) { addResult(createInfoResult("Repository removes leading space from document name.")); } else { addResult(createInfoResult("Repository renames documents with a leading space.")); } } } catch (CmisBaseException e) { addResult(createInfoResult("Repository does not support document names with a leading space. Exception: " + e.toString())); } }
if (cbe.getErrorContent() != null) { writer.write(NL + "Error Content:" + NL + NL); writer.write(cbe.getErrorContent());
/** * Deletes an object and checks if it is deleted. */ protected void deleteObject(CmisObject object) { if (object != null) { if (object instanceof Folder) { try { ((Folder) object).deleteTree(true, null, true); } catch (CmisBaseException e) { addResult(createResult(UNEXPECTED_EXCEPTION, "Folder could not be deleted! Exception: " + e.getMessage(), e, true)); } } else { try { object.delete(true); } catch (CmisBaseException e) { addResult(createResult(UNEXPECTED_EXCEPTION, "Object could not be deleted! Exception: " + e.getMessage(), e, true)); } } CmisTestResult f = createResult(FAILURE, "Object should not exist anymore but it is still there! ID: " + object.getId(), true); addResult(assertIsFalse(exists(object), null, f)); } }
} else if (ex instanceof CmisBaseException) { statusCode = getErrorCode((CmisBaseException) ex); exceptionName = ((CmisBaseException) ex).getExceptionName();
private void testCenterSpaceSpace(Session session, Folder testFolder) { String name = "center space.txt"; try { Document doc = createDocumentWithoutChecks(testFolder, name); if (doc.getName().equals(name)) { addResult(createInfoResult("Repository does supports document names with a space.")); } else { if (doc.getName().equals("centerspace.txt")) { addResult(createInfoResult("Repository removes spaces from document name.")); } else { addResult(createInfoResult("Repository renames documents with a space.")); } } } catch (CmisBaseException e) { addResult(createInfoResult("Repository does not support document names with a space. Exception: " + e.toString())); } }
if (cbe.getErrorContent() != null) { jsonResult.put("errorcontent", cbe.getErrorContent());
} catch (CmisBaseException e) { addResult(createResult(UNEXPECTED_EXCEPTION, "Newly created document is invalid! Exception: " + e.getMessage(), e, true));
private void testMultipleCenterSpaceSpace(Session session, Folder testFolder) { String name = "twocenter spaces.txt"; try { Document doc = createDocumentWithoutChecks(testFolder, name); if (doc.getName().equals(name)) { addResult(createInfoResult("Repository does supports document names with more than one successive spaces.")); } else { if (doc.getName().equals("twocenterspaces.txt")) { addResult(createInfoResult("Repository removes spaces from document name.")); } else if (doc.getName().equals("twocenter spaces.txt")) { addResult(createInfoResult("Repository combines multiple spaces into one in document names.")); } else { addResult(createInfoResult("Repository renames documents with a space.")); } } } catch (CmisBaseException e) { addResult(createInfoResult("Repository does not support document names with a space. Exception: " + e.toString())); } }
addResult(createResult(UNEXPECTED_EXCEPTION, "Item could not be created! Exception: " + e.getMessage(), e, true)); return null; addResult(createResult(UNEXPECTED_EXCEPTION, "Newly created item is invalid! Exception: " + e.getMessage(), e, true));
throw new CmisRuntimeException("Could not determine the name of the PWC: " + e.toString(), e);
addResult(createResult(UNEXPECTED_EXCEPTION, "Policy could not be created! Exception: " + e.getMessage(), e, true)); return null; } catch (CmisBaseException e) { addResult(createResult(UNEXPECTED_EXCEPTION, "Newly created policy is invalid! Exception: " + e.getMessage(), e, true));
addResult(createResult(UNEXPECTED_EXCEPTION, "Folder could not be created! Exception: " + e.getMessage(), e, true)); return null; "Newly created folder is invalid! Exception: " + e.getMessage(), e, true));