org.alfresco.error.AlfrescoRuntimeException Java Examples
The following examples show how to use
org.alfresco.error.AlfrescoRuntimeException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NameChecker.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 6 votes |
/** * Loads filename constraint from dictionary */ @Override public void afterPropertiesSet() throws Exception { PropertyCheck.mandatory(this, "dictionaryService", dictionaryService); QName qNameConstraint = QName.createQName(namespaceURI, constraintLocalName); ConstraintDefinition constraintDef = dictionaryService.getConstraint(qNameConstraint); if (constraintDef == null) { throw new AlfrescoRuntimeException("Constraint definition does not exist: " + qNameConstraint); } nameConstraint = constraintDef.getConstraint(); if (nameConstraint == null) { throw new AlfrescoRuntimeException("Constraint does not exist: " + qNameConstraint); } }
Example #2
Source File: AlfrescoSSLSocketFactoryTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void testConfiguration() throws Exception { KeyStore ks = KeyStore.getInstance(KEYSTORE_TYPE); // try to use the factory without initialization try { AlfrescoSSLSocketFactory.getDefault(); fail("An AlfrescoRuntimeException should be thrown as the factory is not initialized."); } catch (AlfrescoRuntimeException are) { // Expected } // initialize and get an instance of AlfrescoSSLSocketFactory AlfrescoSSLSocketFactory.initTrustedSSLSocketFactory(ks); AlfrescoSSLSocketFactory.getDefault(); }
Example #3
Source File: MultiTServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void checkDomain(String name) { if (name == null) { return; } String nameDomain = null; int idx1 = name.indexOf(SEPARATOR); if (idx1 == 0) { int idx2 = name.indexOf(SEPARATOR, 1); nameDomain = name.substring(1, idx2); } String tenantDomain = getCurrentUserDomain(); if (((nameDomain == null) && (!tenantDomain.equals(DEFAULT_DOMAIN))) || ((nameDomain != null) && (!nameDomain.equals(tenantDomain)))) { throw new AlfrescoRuntimeException("domain mismatch: expected = " + tenantDomain + ", actual = " + nameDomain); } }
Example #4
Source File: FileFolderLoaderTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void testFolderMissing() throws Exception { try { AuthenticationUtil.pushAuthentication(); AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser(); fileFolderLoader.createFiles( sharedHomePath + "/Missing", 0, 256, 1024L, 1024L, Long.MAX_VALUE, false, 10, 256L); fail("Folder does not exist"); } catch (AlfrescoRuntimeException e) { // Expected assertTrue(e.getCause() instanceof FileNotFoundException); } finally { AuthenticationUtil.popAuthentication(); } }
Example #5
Source File: ScriptThumbnail.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * Updates the thumbnails content */ public void update() { List<ChildAssociationRef> parentRefs = services.getNodeService().getParentAssocs(nodeRef, RenditionModel.ASSOC_RENDITION, RegexQNamePattern.MATCH_ALL); // There should in fact only ever be one parent association of type rendition on any rendition node. if (parentRefs.size() != 1) { StringBuilder msg = new StringBuilder(); msg.append("Node ") .append(nodeRef) .append(" has ") .append(parentRefs.size()) .append(" rendition parents. Unable to update."); if (logger.isWarnEnabled()) { logger.warn(msg.toString()); } throw new AlfrescoRuntimeException(msg.toString()); } String name = parentRefs.get(0).getQName().getLocalName(); ThumbnailDefinition def = services.getThumbnailService().getThumbnailRegistry().getThumbnailDefinition(name); services.getThumbnailService().updateThumbnail(this.nodeRef, def.getTransformationOptions()); }
Example #6
Source File: ScriptInvitationFactory.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
public ScriptInvitation<?> toScriptInvitation(Invitation invitation) { if(invitation instanceof NominatedInvitation) { return new ScriptNominatedInvitation((NominatedInvitation) invitation, invitationService); } if(invitation instanceof ModeratedInvitation) { String userName = invitation.getInviteeUserName(); NodeRef person = personService.getPerson(userName); Map<QName, Serializable> properties = nodeService.getProperties(person); String firstName = (String) properties.get(ContentModel.PROP_FIRSTNAME); String lastName = (String) properties.get(ContentModel.PROP_LASTNAME); String email = (String) properties.get(ContentModel.PROP_EMAIL); return new ScriptModeratedInvitation( (ModeratedInvitation) invitation, invitationService, email, firstName, lastName); } throw new AlfrescoRuntimeException("Unknown invitation type."); }
Example #7
Source File: RepositoryManagedSignatureProvider.java From CounterSign with GNU Affero General Public License v3.0 | 6 votes |
/** * Get the certificate chain for the CA certificate * * @param trustedKs * @return */ private Certificate[] getCaCertChain(KeyStore trustedKs) { Certificate[] caCertChain = null; String certAlias = config.getProperty(RepositoryManagedSignatureProviderFactory.TRUSTED_CERT_ALIAS); try { caCertChain = trustedKs.getCertificateChain(certAlias); } catch(KeyStoreException kse) { throw new AlfrescoRuntimeException(kse.getMessage()); } return caCertChain; }
Example #8
Source File: AuthorityBridgeTableAsynchronouslyRefreshedCache.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
private void checkCyclic(List<AuthorityBridgeLink> links) { Map<String, Set<String>> parentsToChildren = new HashMap<String, Set<String>>(); for (AuthorityBridgeLink link : links) { addToMap(parentsToChildren, link.getParentName(), link.getChildName()); } Map<String, Set<String>> removed = new HashMap<String, Set<String>>(); for (String parent : parentsToChildren.keySet()) { if (logger.isDebugEnabled()) { logger.debug("Start checking from '" + parent + "'"); } Set<String> authorities = new HashSet<String>(); authorities.add(parent); doCheck(parent, parentsToChildren, authorities, removed); } if (!removed.isEmpty()) { fixCyclic(removed); throw new AlfrescoRuntimeException("Cyclic links were detected and removed."); } }
Example #9
Source File: LocalWebScriptConnectorServiceImpl.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 6 votes |
/** * Builds a new Request object, using HttpClient method descriptions */ public RemoteConnectorRequest buildRequest(String url, Class<? extends HttpMethodBase> method) { // Get the method name String methodName; try { HttpMethodBase httpMethod = method.getConstructor(String.class).newInstance(url); methodName = httpMethod.getName(); } catch(Exception e) { throw new AlfrescoRuntimeException("Error identifying method name", e); } // Build and return return buildRequest(url, methodName); }
Example #10
Source File: ImapServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * This method is run as System within a single transaction on startup. */ public void startup() { bindBehaviour(); // Get NodeRefs for folders to ignore this.ignoreExtractionFolders = new HashSet<NodeRef>(ignoreExtractionFoldersBeans.length * 2); for (RepositoryFolderConfigBean ignoreExtractionFoldersBean : ignoreExtractionFoldersBeans) { NodeRef nodeRef = ignoreExtractionFoldersBean.getFolderPath(namespaceService, nodeService, searchService, fileFolderService); if (!ignoreExtractionFolders.add(nodeRef)) { // It was already in the set throw new AlfrescoRuntimeException("The folder extraction path has been referenced already: \n" + " Folder: " + ignoreExtractionFoldersBean); } } // Locate or create IMAP home imapHomeNodeRef = imapHomeConfigBean.getOrCreateFolderPath(namespaceService, nodeService, searchService, fileFolderService); }
Example #11
Source File: StripingBulkFilesystemImporter.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * Method that does the work of importing a filesystem using the BatchProcessor. * * @param bulkImportParameters The bulk import parameters to apply to this bulk import. * @param nodeImporter The node importer implementation that will import each node. * @param lockToken The lock token to use during the bulk import. */ @Override protected void bulkImportImpl(final BulkImportParameters bulkImportParameters, final NodeImporter nodeImporter, final String lockToken) { super.bulkImportImpl(bulkImportParameters, nodeImporter, lockToken); final File sourceFolder = nodeImporter.getSourceFolder(); final int batchSize = getBatchSize(bulkImportParameters); final int loggingInterval = getLoggingInterval(bulkImportParameters); final StripingFilesystemTracker tracker = new StripingFilesystemTracker(directoryAnalyser, bulkImportParameters.getTarget(), sourceFolder, batchSize); final BatchProcessor<ImportableItem> batchProcessor = getBatchProcessor(bulkImportParameters, tracker.getWorkProvider(), loggingInterval); final BatchProcessor.BatchProcessWorker<ImportableItem> worker = getWorker(bulkImportParameters, lockToken, nodeImporter, tracker); do { batchProcessor.process(worker, true); if(batchProcessor.getLastError() != null) { throw new AlfrescoRuntimeException(batchProcessor.getLastError()); } } while(tracker.moreLevels()); }
Example #12
Source File: KeyStoreKeyProviderTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
public void testAliasWithIncorrectPassword_One() throws Exception { try { getTestKeyStoreProvider(FILE_ONE, Collections.singletonMap(ALIAS_ONE, "password_fail")); // new KeystoreKeyProvider( // FILE_ONE, // getKeyStoreLoader(), // "SunJCE", // "JCEKS", // Collections.singletonMap(ALIAS_ONE, "password_fail")); fail("Expect to fail because password is incorrect"); } catch (AlfrescoRuntimeException e) { // Expected assertTrue(e.getCause() instanceof UnrecoverableKeyException); } }
Example #13
Source File: JodConverterSharedInstance.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
public void setTemplateProfileDir(String templateProfileDir) { if (templateProfileDir == null || templateProfileDir.trim().length() == 0) { this.templateProfileDir = null; } else { File tmp = new File(templateProfileDir); if (!tmp.isDirectory()) { throw new AlfrescoRuntimeException("OpenOffice template profile directory "+templateProfileDir+" does not exist."); } this.templateProfileDir = tmp; } }
Example #14
Source File: AbstractModuleComponent.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * {@inheritDoc} * * @see #executeInternal() the abstract method to be implemented by subclasses */ public final synchronized void execute() { // ensure that this has not been executed already String tenantDomain = tenantAdminService.getCurrentUserDomain(); if (! executed.containsKey(tenantDomain)) { executed.put(tenantDomain, false); } if (executed.get(tenantDomain)) { throw AlfrescoRuntimeException.create(ERR_ALREADY_EXECUTED, moduleId, name); } // Ensure properties have been set checkProperties(); // Execute try { executeInternal(); } catch (Throwable e) { throw AlfrescoRuntimeException.create(e, ERR_EXECUTION_FAILED, name, e.getMessage()); } finally { // There are no second chances executed.put(tenantDomain, true); } }
Example #15
Source File: HiddenAspectTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
private boolean checkMailbox(AlfrescoImapUser user, String mailboxName) { try { imapService.getOrCreateMailbox(user, mailboxName, true, false); } catch (AlfrescoRuntimeException e) { return false; } return true; }
Example #16
Source File: ActionsImpl.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
private Map<String, Serializable> extractActionParams(org.alfresco.service.cmr.action.ActionDefinition actionDefinition, Map<String, String> params) { Map<String, Serializable> parameterValues = new HashMap<>(); try { for (Map.Entry<String, String> entry : params.entrySet()) { String propertyName = entry.getKey(); Object propertyValue = entry.getValue(); // Get the parameter definition we care about ParameterDefinition paramDef = actionDefinition.getParameterDefintion(propertyName); if (paramDef == null && !actionDefinition.getAdhocPropertiesAllowed()) { throw new AlfrescoRuntimeException("Invalid parameter " + propertyName + " for action/condition " + actionDefinition.getName()); } if (paramDef != null) { QName typeQName = paramDef.getType(); // Convert the property value Serializable value = convertValue(typeQName, propertyValue); parameterValues.put(propertyName, value); } else { // If there is no parameter definition we can only rely on the .toString() // representation of the ad-hoc property parameterValues.put(propertyName, propertyValue.toString()); } } } catch (JSONException je) { throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not parse JSON from req.", je); } return parameterValues; }
Example #17
Source File: FavouritesServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
private PersonFavourite getFavouriteSite(String userName, SiteInfo siteInfo) { PersonFavourite favourite = null; String siteFavouritedKey = siteFavouritedKey(siteInfo); String siteCreatedAtKey = siteCreatedAtKey(siteInfo); Boolean isFavourited = false; Serializable s = preferenceService.getPreference(userName, siteFavouritedKey); if(s != null) { if(s instanceof String) { isFavourited = Boolean.valueOf((String)s); } else if(s instanceof Boolean) { isFavourited = (Boolean)s; } else { throw new AlfrescoRuntimeException("Unexpected favourites preference value"); } } if(isFavourited) { String createdAtStr = (String)preferenceService.getPreference(userName, siteCreatedAtKey); Date createdAt = (createdAtStr == null ? null : ISO8601DateFormat.parse(createdAtStr)); favourite = new PersonFavourite(userName, siteInfo.getNodeRef(), Type.SITE, siteInfo.getTitle(), createdAt); } return favourite; }
Example #18
Source File: AlfrescoSSLSocketFactory.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
public static synchronized SocketFactory getDefault() { if (context == null) { throw new AlfrescoRuntimeException("The factory was not initialized."); } return new AlfrescoSSLSocketFactory(); }
Example #19
Source File: RemoteAlfrescoTicketServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
protected PasswordCredentialsInfo ensureCredentialsFound(String remoteSystemId, BaseCredentialsInfo credentails) { // Check they exist, and are of the right type if (credentails == null) { throw new NoCredentialsFoundException(remoteSystemId); } if (! (credentails instanceof PasswordCredentialsInfo)) { throw new AlfrescoRuntimeException("Credentials found, but of the wrong type, needed PasswordCredentialsInfo but got " + credentails); } return (PasswordCredentialsInfo)credentails; }
Example #20
Source File: RepoStore.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
public Reader getReader() { ContentReader reader = contentService.getReader(nodeRef, ContentModel.PROP_CONTENT); try { return new InputStreamReader(getInputStream(), reader.getEncoding()); } catch (UnsupportedEncodingException e) { throw new AlfrescoRuntimeException("Unsupported Encoding", e); } }
Example #21
Source File: DefaultEncryptor.java From alfresco-core with GNU Lesser General Public License v3.0 | 5 votes |
@Override public Cipher getCipher(String keyAlias, AlgorithmParameters params, int mode) { Cipher cipher = null; // Get the encryption key Key key = keyProvider.getKey(keyAlias); if(key == null) { // No encryption possible return null; } try { if(cacheCiphers) { cipher = getCachedCipher(keyAlias, mode, params, key); } else { cipher = createCipher(mode, cipherAlgorithm, cipherProvider, key, params); } } catch (Exception e) { throw new AlfrescoRuntimeException( "Failed to construct cipher: alias=" + keyAlias + "; mode=" + mode, e); } return cipher; }
Example #22
Source File: PropertyCheck.java From alfresco-core with GNU Lesser General Public License v3.0 | 5 votes |
/** * Checks that the property with the given name is not null. * * @param target the object on which the property must have been set * @param propertyName the name of the property * @param value of the property value */ public static void mandatory(Object target, String propertyName, Object value) { if (value == null) { throw new AlfrescoRuntimeException( ERR_PROPERTY_NOT_SET, new Object[] {propertyName, target, target.getClass()}); } }
Example #23
Source File: CompositePasswordEncoder.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Determines if its safe to encode the encoding chain. This applies particularly to double-hashing. * BCRYPT uses its own internal salt so its NOT safe to use it more than once in an encoding chain * (because the result will be different each time.) BCRYPT CAN BE USED successfully as the last element in * an encoding chain. * * Anything that implements springframework PasswordEncoder is considered "unsafe" * (because the method takes no salt param). * * @param encodingChain mandatory encoding chain * @return true if it is okay to encode this chain. */ public boolean isSafeToEncodeChain(List<String> encodingChain) { if (encodingChain!= null && encodingChain.size() > 0 ) { List<String> unsafeEncoders = new ArrayList<>(); for (String encoderKey : encodingChain) { Object encoder = encoders.get(encoderKey); if (encoder == null) throw new AlfrescoRuntimeException("Invalid encoder specified: "+encoderKey); if (encoder instanceof org.springframework.security.crypto.password.PasswordEncoder) { //BCRYPT uses its own internal salt so its NOT safe to use it more than once in an encoding chain. //the Spring PasswordEncoder class doesn't require a salt and BCRYPTEncoder implements this, so //we will count the instances of Spring PasswordEncoder unsafeEncoders.add(encoderKey); } } if (unsafeEncoders.isEmpty()) return true; if (unsafeEncoders.size() == 1 && unsafeEncoders.get(0).equals(encodingChain.get(encodingChain.size()-1))) { //The unsafe encoder is used at the end so that's ok. return true; } //, because there is already an unupgradable encoder at the end of the chain. if (logger.isDebugEnabled()) { logger.debug("Non-upgradable encoders in the encoding chain: "+Arrays.toString(unsafeEncoders.toArray()) +". Only 1 non-upgradable encoder is allowed at the end of the chain: "+Arrays.toString(encodingChain.toArray())); } } return false; }
Example #24
Source File: RhinoScriptProcessor.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * @see org.alfresco.service.cmr.repository.ScriptProcessor#execute(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName, java.util.Map) */ public Object execute(NodeRef nodeRef, QName contentProp, Map<String, Object> model) { try { if (this.services.getNodeService().exists(nodeRef) == false) { throw new AlfrescoRuntimeException("Script Node does not exist: " + nodeRef); } if (contentProp == null) { contentProp = ContentModel.PROP_CONTENT; } ContentReader cr = this.services.getContentService().getReader(nodeRef, contentProp); if (cr == null || cr.exists() == false) { throw new AlfrescoRuntimeException("Script Node content not found: " + nodeRef); } // compile the script based on the node content Script script; Context cx = Context.enter(); try { script = cx.compileString(resolveScriptImports(cr.getContentString()), nodeRef.toString(), 1, null); } finally { Context.exit(); } return executeScriptImpl(script, model, false, nodeRef.toString()); } catch (Throwable err) { throw new ScriptException("Failed to execute script '" + nodeRef.toString() + "': " + err.getMessage(), err); } }
Example #25
Source File: ProbeApiTest.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
@Before @Override public void setup() throws Exception { // super.setup(); -- Takes a very long time and we need no test networks, sites or users. setRequestContext(null, null, null); String beanName = ProbeEntityResource.class.getCanonicalName()+".get"; probe = applicationContext.getBean(beanName, ProbeEntityResource.class); when(badDiscovery.getRepositoryInfo()).thenThrow(AlfrescoRuntimeException.class); origDiscovery = probe.setDiscovery(badDiscovery); }
Example #26
Source File: MultiTServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override public String getBaseName(String name, boolean forceForNonTenant) { if (name == null) { return null; } String tenantDomain = getCurrentUserDomain(); int idx1 = name.indexOf(SEPARATOR); if (idx1 == 0) { int idx2 = name.indexOf(SEPARATOR, 1); String nameDomain = name.substring(1, idx2); if ((!tenantDomain.equals(DEFAULT_DOMAIN)) && (!tenantDomain.equals(nameDomain))) { throw new AlfrescoRuntimeException("domain mismatch: expected = " + tenantDomain + ", actual = " + nameDomain); } if ((!tenantDomain.equals(DEFAULT_DOMAIN)) || (forceForNonTenant)) { // remove tenant domain name = name.substring(idx2 + 1); } } return name; }
Example #27
Source File: FeedGeneratorJob.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Calls the feed generator to do its work */ public void execute(JobExecutionContext context) throws JobExecutionException { JobDataMap jobData = context.getJobDetail().getJobDataMap(); // extract the feed cleaner to use Object feedGeneratorObj = jobData.get("feedGenerator"); if (feedGeneratorObj == null || !(feedGeneratorObj instanceof FeedGenerator)) { throw new AlfrescoRuntimeException( "FeedGeneratorObj data must contain valid 'feedGenerator' reference"); } FeedGenerator feedGenerator = (FeedGenerator)feedGeneratorObj; feedGenerator.execute(); }
Example #28
Source File: AbstractAclCrudDAOImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
public Pair<Long, AuthorityEntity> findByValue(AuthorityEntity value) { if ((value == null) || (value.getAuthority() == null)) { throw new AlfrescoRuntimeException("Unexpected: AuthorityEntity / name must not be null"); } return convertEntityToPair(getAuthorityEntity(value.getAuthority())); }
Example #29
Source File: RepositoryFolderConfigBean.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
private NodeRef getNullOrThrowAlfrescoRuntimeExcpetion(String exceptionMessage, boolean throwException) { if (throwException) { throw new AlfrescoRuntimeException(exceptionMessage); } return null; }
Example #30
Source File: AlfrescoKeyStoreImpl.java From alfresco-core with GNU Lesser General Public License v3.0 | 5 votes |
protected void createKey(String keyAlias) { KeyInfoManager keyInfoManager = null; try { keyInfoManager = getKeyInfoManager(getKeyStoreParameters()); Key key = getSecretKey(keyInfoManager.getKeyInformation(keyAlias)); encryptionKeysRegistry.registerKey(keyAlias, key); keys.setKey(keyAlias, key); KeyStore ks = loadKeyStore(getKeyStoreParameters(), keyInfoManager); ks.setKeyEntry(keyAlias, key, keyInfoManager.getKeyInformation(keyAlias).getPassword().toCharArray(), null); OutputStream keyStoreOutStream = getKeyStoreOutStream(); ks.store(keyStoreOutStream, keyInfoManager.getKeyStorePassword().toCharArray()); // Workaround for MNT-15005 keyStoreOutStream.close(); logger.info("Created key: " + keyAlias + "\n in key store: \n" + " Location: " + getKeyStoreParameters().getLocation() + "\n" + " Provider: " + getKeyStoreParameters().getProvider() + "\n" + " Type: " + getKeyStoreParameters().getType()); } catch(Throwable e) { throw new AlfrescoRuntimeException( "Failed to create key: " + keyAlias + "\n in key store: \n" + " Location: " + getKeyStoreParameters().getLocation() + "\n" + " Provider: " + getKeyStoreParameters().getProvider() + "\n" + " Type: " + getKeyStoreParameters().getType(), e); } finally { if(keyInfoManager != null) { keyInfoManager.clear(); } } }